summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-04-26 17:47:25 +0200
committerHowaner <franzi.moos@googlemail.com>2014-04-26 17:47:25 +0200
commitd50f8f6f11f69e7e1e56be92fb2d72a5014a3e34 (patch)
treeb8386b26cd234380d840653119fc3205339b2413
parentWithers now use the new invulnerable. (diff)
downloadcuberite-d50f8f6f11f69e7e1e56be92fb2d72a5014a3e34.tar
cuberite-d50f8f6f11f69e7e1e56be92fb2d72a5014a3e34.tar.gz
cuberite-d50f8f6f11f69e7e1e56be92fb2d72a5014a3e34.tar.bz2
cuberite-d50f8f6f11f69e7e1e56be92fb2d72a5014a3e34.tar.lz
cuberite-d50f8f6f11f69e7e1e56be92fb2d72a5014a3e34.tar.xz
cuberite-d50f8f6f11f69e7e1e56be92fb2d72a5014a3e34.tar.zst
cuberite-d50f8f6f11f69e7e1e56be92fb2d72a5014a3e34.zip
-rw-r--r--src/Mobs/Wither.h3
-rw-r--r--src/Protocol/Protocol125.cpp9
-rw-r--r--src/Protocol/Protocol17x.cpp9
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp9
-rw-r--r--src/WorldStorage/WSSAnvil.cpp2
5 files changed, 28 insertions, 4 deletions
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index 81c9df1b1..fbea331d3 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -19,6 +19,9 @@ public:
/** Returns whether the wither is invulnerable to arrows. */
bool IsArmored(void) const;
+
+ /** Use the wither the invulnerable from the spawn? */
+ bool IsSpawnInvulnerable(void) const { return m_IsSpawnInvulnerable; }
// cEntity overrides
virtual bool Initialize(cWorld * a_World) override;
diff --git a/src/Protocol/Protocol125.cpp b/src/Protocol/Protocol125.cpp
index a23afb29a..3951eb3e4 100644
--- a/src/Protocol/Protocol125.cpp
+++ b/src/Protocol/Protocol125.cpp
@@ -2013,7 +2013,14 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
case cMonster::mtWither:
{
WriteByte(0x54); // Int at index 20
- WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks());
+ if (((const cWither &)a_Mob).IsSpawnInvulnerable())
+ {
+ WriteInt((Int32)((const cWither &)a_Mob).GetInvulnerableTicks());
+ }
+ else
+ {
+ WriteInt((Int32)0);
+ }
WriteByte(0x66); // Float at index 6
WriteFloat((float)(a_Mob.GetHealth()));
break;
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 80b161e3e..311e770f9 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -2820,7 +2820,14 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
case cMonster::mtWither:
{
WriteByte(0x54); // Int at index 20
- WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks());
+ if (((const cWither &)a_Mob).IsSpawnInvulnerable())
+ {
+ WriteInt(((const cWither &)a_Mob).GetInvulnerableTicks());
+ }
+ else
+ {
+ WriteInt(0);
+ }
WriteByte(0x66); // Float at index 6
WriteFloat((float)(a_Mob.GetHealth()));
break;
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 46c6b8e92..0c4a1a430 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -516,7 +516,14 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
}
case cMonster::mtWither:
{
- m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetWitherInvulnerableTicks());
+ if (((const cWither *)a_Monster)->IsSpawnInvulnerable())
+ {
+ m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetInvulnerableTicks());
+ }
+ else
+ {
+ m_Writer.AddInt("Invul", 0);
+ }
break;
}
case cMonster::mtWolf:
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 4532a925a..c21809270 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -2272,7 +2272,7 @@ void cWSSAnvil::LoadWitherFromNBT(cEntityList & a_Entities, const cParsedNBT & a
int CurrLine = a_NBT.FindChildByName(a_TagIdx, "Invul");
if (CurrLine > 0)
{
- Monster->SetWitherInvulnerableTicks(a_NBT.GetInt(CurrLine));
+ Monster->SetInvulnerableTicks(a_NBT.GetInt(CurrLine));
}
a_Entities.push_back(Monster.release());