1
0

Added splash potions to NBT serialization and retrieval

This commit is contained in:
archshift 2014-07-11 18:58:11 -07:00
parent 83c69134c0
commit 8cbd43e043
6 changed files with 50 additions and 1 deletions

View File

@ -312,7 +312,7 @@ AString cProjectileEntity::GetMCAClassName(void) const
case pkFireCharge: return "SmallFireball";
case pkEnderPearl: return "ThrownEnderpearl";
case pkExpBottle: return "ThrownExpBottle";
case pkSplashPotion: return "ThrownPotion";
case pkSplashPotion: return "SplashPotion";
case pkWitherSkull: return "WitherSkull";
case pkFirework: return "Firework";
case pkFishingFloat: return ""; // Unknown, perhaps MC doesn't save this?

View File

@ -27,6 +27,14 @@ public:
cSplashPotionEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed, cEntityEffect::eType a_EntityEffectType, cEntityEffect a_EntityEffect, int a_PotionName);
cEntityEffect::eType GetEntityEffectType() { return m_EntityEffectType; }
cEntityEffect GetEntityEffect() { return m_EntityEffect; }
int GetPotionName() { return m_PotionName; }
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
void SetPotionName(int a_PotionName) { m_PotionName = a_PotionName; }
protected:
// cProjectileEntity overrides:

View File

@ -29,6 +29,7 @@
#include "../Entities/Minecart.h"
#include "../Entities/Pickup.h"
#include "../Entities/ArrowEntity.h"
#include "../Entities/SplashPotionEntity.h"
#include "../Entities/TNTEntity.h"
#include "../Entities/ExpOrb.h"
#include "../Entities/HangingEntity.h"
@ -604,6 +605,16 @@ void cNBTChunkSerializer::AddProjectileEntity(cProjectileEntity * a_Projectile)
m_Writer.AddDouble("damage", Arrow->GetDamageCoeff());
break;
}
case cProjectileEntity::pkSplashPotion:
{
cSplashPotionEntity * Potion = (cSplashPotionEntity *)a_Projectile;
m_Writer.AddInt("EffectType", (Int16)Potion->GetEntityEffectType());
m_Writer.AddInt("EffectDuration", (Int16)Potion->GetEntityEffect().GetDuration());
m_Writer.AddShort("EffectIntensity", Potion->GetEntityEffect().GetIntensity());
m_Writer.AddDouble("EffectDistanceModifier", Potion->GetEntityEffect().GetDistanceModifier());
m_Writer.AddInt("PotionName", Potion->GetPotionName());
}
case cProjectileEntity::pkGhastFireball:
{
m_Writer.AddInt("ExplosionPower", 1);

View File

@ -46,6 +46,7 @@ class cTNTEntity;
class cExpOrb;
class cHangingEntity;
class cItemFrame;
class cEntityEffect;

View File

@ -36,6 +36,7 @@
#include "../Entities/Minecart.h"
#include "../Entities/Pickup.h"
#include "../Entities/ArrowEntity.h"
#include "../Entities/SplashPotionEntity.h"
#include "../Entities/ThrownEggEntity.h"
#include "../Entities/ThrownEnderPearlEntity.h"
#include "../Entities/ThrownSnowballEntity.h"
@ -1152,6 +1153,10 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a
{
LoadArrowFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
}
else if (strncmp(a_IDTag, "SplashPotion", a_IDTagLength) == 0)
{
LoadSplashPotionFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
}
else if (strncmp(a_IDTag, "Snowball", a_IDTagLength) == 0)
{
LoadSnowballFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
@ -1658,6 +1663,29 @@ void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
std::auto_ptr<cSplashPotionEntity> SplashPotion(new cSplashPotionEntity(NULL, 0, 0, 0, Vector3d(0, 0, 0), cEntityEffect::effNoEffect, cEntityEffect(), 0));
if (!LoadProjectileBaseFromNBT(*SplashPotion.get(), a_NBT, a_TagIdx))
{
return;
}
int EffectDuration = a_NBT.FindChildByName(a_TagIdx, "EffectDuration");
int EffectIntensity = a_NBT.FindChildByName(a_TagIdx, "EffectIntensity");
int EffectDistanceModifier = a_NBT.FindChildByName(a_TagIdx, "EffectDistanceModifier");
SplashPotion->SetEntityEffectType((cEntityEffect::eType) a_NBT.FindChildByName(a_TagIdx, "EffectType"));
SplashPotion->SetEntityEffect(cEntityEffect(EffectDuration, EffectIntensity, EffectDistanceModifier));
SplashPotion->SetPotionName(a_NBT.FindChildByName(a_TagIdx, "PotionName"));
// Store the new splash potion in the entities list:
a_Entities.push_back(SplashPotion.release());
}
void cWSSAnvil::LoadSnowballFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{

View File

@ -163,6 +163,7 @@ protected:
void LoadMinecartHFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadArrowFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadSplashPotionFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadSnowballFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadEggFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);
void LoadFireballFromNBT (cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx);