summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-11-04 22:53:37 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-11-04 22:53:37 +0100
commit3d00e52d42edc69eb777c90c6e6f479a5a473598 (patch)
tree9ed2245653c77b7de86678c345254fe70342126e
parentMore player speed/position overrides (diff)
downloadcuberite-fixesandfeatures.tar
cuberite-fixesandfeatures.tar.gz
cuberite-fixesandfeatures.tar.bz2
cuberite-fixesandfeatures.tar.lz
cuberite-fixesandfeatures.tar.xz
cuberite-fixesandfeatures.tar.zst
cuberite-fixesandfeatures.zip
-rw-r--r--src/Entities/ArrowEntity.cpp10
-rw-r--r--src/Entities/ArrowEntity.h2
-rw-r--r--src/Entities/Boat.cpp6
-rw-r--r--src/Entities/Boat.h2
-rw-r--r--src/Entities/EnderCrystal.cpp5
-rw-r--r--src/Entities/EnderCrystal.h2
-rw-r--r--src/Entities/Entity.cpp102
-rw-r--r--src/Entities/Entity.h33
-rw-r--r--src/Entities/ExpBottleEntity.cpp5
-rw-r--r--src/Entities/ExpBottleEntity.h2
-rw-r--r--src/Entities/ExpOrb.cpp27
-rw-r--r--src/Entities/ExpOrb.h12
-rw-r--r--src/Entities/FallingBlock.cpp7
-rw-r--r--src/Entities/FallingBlock.h3
-rw-r--r--src/Entities/FireChargeEntity.cpp5
-rw-r--r--src/Entities/FireChargeEntity.h2
-rw-r--r--src/Entities/GhastFireballEntity.cpp5
-rw-r--r--src/Entities/GhastFireballEntity.h2
-rw-r--r--src/Entities/HangingEntity.cpp4
-rw-r--r--src/Entities/HangingEntity.h2
-rw-r--r--src/Entities/ItemFrame.cpp4
-rw-r--r--src/Entities/ItemFrame.h2
-rw-r--r--src/Entities/Minecart.cpp28
-rw-r--r--src/Entities/Minecart.h12
-rw-r--r--src/Entities/Pawn.cpp6
-rw-r--r--src/Entities/Pawn.h2
-rw-r--r--src/Entities/Pickup.cpp44
-rw-r--r--src/Entities/Pickup.h11
-rw-r--r--src/Entities/Player.cpp66
-rw-r--r--src/Entities/Player.h14
-rw-r--r--src/Entities/ProjectileEntity.cpp17
-rw-r--r--src/Entities/ProjectileEntity.h3
-rw-r--r--src/Entities/SplashPotionEntity.cpp10
-rw-r--r--src/Entities/SplashPotionEntity.h7
-rw-r--r--src/Entities/TNTEntity.cpp14
-rw-r--r--src/Entities/TNTEntity.h3
-rw-r--r--src/Entities/ThrownEggEntity.cpp5
-rw-r--r--src/Entities/ThrownEggEntity.h2
-rw-r--r--src/Entities/ThrownEnderPearlEntity.cpp7
-rw-r--r--src/Entities/ThrownEnderPearlEntity.h2
-rw-r--r--src/Entities/ThrownSnowballEntity.cpp5
-rw-r--r--src/Entities/ThrownSnowballEntity.h2
-rw-r--r--src/Entities/WitherSkullEntity.cpp7
-rw-r--r--src/Entities/WitherSkullEntity.h2
-rw-r--r--src/Items/ItemLilypad.h2
-rw-r--r--src/Mobs/AggressiveMonster.cpp4
-rw-r--r--src/Mobs/AggressiveMonster.h2
-rw-r--r--src/Mobs/Bat.cpp4
-rw-r--r--src/Mobs/Bat.h2
-rw-r--r--src/Mobs/Blaze.cpp4
-rw-r--r--src/Mobs/Blaze.h2
-rw-r--r--src/Mobs/CaveSpider.cpp4
-rw-r--r--src/Mobs/CaveSpider.h2
-rw-r--r--src/Mobs/Chicken.cpp4
-rw-r--r--src/Mobs/Chicken.h2
-rw-r--r--src/Mobs/Cow.cpp4
-rw-r--r--src/Mobs/Cow.h2
-rw-r--r--src/Mobs/Creeper.cpp4
-rw-r--r--src/Mobs/Creeper.h2
-rw-r--r--src/Mobs/EnderDragon.cpp4
-rw-r--r--src/Mobs/EnderDragon.h2
-rw-r--r--src/Mobs/Enderman.cpp4
-rw-r--r--src/Mobs/Enderman.h2
-rw-r--r--src/Mobs/Ghast.cpp4
-rw-r--r--src/Mobs/Ghast.h2
-rw-r--r--src/Mobs/Giant.cpp4
-rw-r--r--src/Mobs/Giant.h2
-rw-r--r--src/Mobs/Horse.cpp4
-rw-r--r--src/Mobs/Horse.h2
-rw-r--r--src/Mobs/IronGolem.cpp4
-rw-r--r--src/Mobs/IronGolem.h2
-rw-r--r--src/Mobs/MagmaCube.cpp4
-rw-r--r--src/Mobs/MagmaCube.h2
-rw-r--r--src/Mobs/Monster.cpp69
-rw-r--r--src/Mobs/Monster.h32
-rw-r--r--src/Mobs/Mooshroom.cpp4
-rw-r--r--src/Mobs/Mooshroom.h2
-rw-r--r--src/Mobs/Ocelot.h2
-rw-r--r--src/Mobs/PassiveAggressiveMonster.cpp4
-rw-r--r--src/Mobs/PassiveAggressiveMonster.h2
-rw-r--r--src/Mobs/PassiveMonster.cpp4
-rw-r--r--src/Mobs/PassiveMonster.h2
-rw-r--r--src/Mobs/Pig.cpp4
-rw-r--r--src/Mobs/Pig.h2
-rw-r--r--src/Mobs/Sheep.cpp4
-rw-r--r--src/Mobs/Sheep.h2
-rw-r--r--src/Mobs/Silverfish.h2
-rw-r--r--src/Mobs/Skeleton.cpp4
-rw-r--r--src/Mobs/Skeleton.h2
-rw-r--r--src/Mobs/Slime.cpp5
-rw-r--r--src/Mobs/Slime.h2
-rw-r--r--src/Mobs/SnowGolem.cpp4
-rw-r--r--src/Mobs/SnowGolem.h2
-rw-r--r--src/Mobs/Spider.cpp4
-rw-r--r--src/Mobs/Spider.h2
-rw-r--r--src/Mobs/Squid.cpp4
-rw-r--r--src/Mobs/Squid.h2
-rw-r--r--src/Mobs/Villager.cpp4
-rw-r--r--src/Mobs/Villager.h2
-rw-r--r--src/Mobs/Witch.cpp4
-rw-r--r--src/Mobs/Witch.h2
-rw-r--r--src/Mobs/Wither.cpp4
-rw-r--r--src/Mobs/Wither.h2
-rw-r--r--src/Mobs/Wolf.cpp6
-rw-r--r--src/Mobs/Wolf.h2
-rw-r--r--src/Mobs/Zombie.cpp4
-rw-r--r--src/Mobs/Zombie.h2
-rw-r--r--src/Mobs/ZombiePigman.cpp4
-rw-r--r--src/Mobs/ZombiePigman.h2
-rw-r--r--src/MonsterConfig.cpp47
-rw-r--r--src/MonsterConfig.h31
-rw-r--r--src/Simulator/FireSimulator.cpp62
-rw-r--r--src/Simulator/FireSimulator.h4
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp4
-rw-r--r--src/WorldStorage/WSSAnvil.cpp302
-rw-r--r--src/WorldStorage/WSSAnvil.h6
116 files changed, 598 insertions, 661 deletions
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index c265c5043..005c0f44a 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -8,8 +8,8 @@
-cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkArrow, a_Creator, a_X, a_Y, a_Z, 0.5, 0.5),
+cArrowEntity::cArrowEntity(CreateEntityInfo Info, cEntity * a_Creator) :
+ super(Info, pkArrow, a_Creator, 0.5, 0.5),
m_PickupState(psNoPickup),
m_DamageCoeff(2),
m_IsCritical(false),
@@ -17,10 +17,8 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a
m_HitGroundTimer(0),
m_HasTeleported(false),
m_bIsCollected(false),
- m_HitBlockPos(Vector3i(0, 0, 0))
+ m_HitBlockPos(0, 0, 0)
{
- SetSpeed(a_Speed);
- SetMass(0.1);
SetYawFromSpeed();
SetPitchFromSpeed();
LOGD("Created arrow %d with speed {%.02f, %.02f, %.02f} and rot {%.02f, %.02f}",
@@ -34,7 +32,7 @@ cArrowEntity::cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a
cArrowEntity::cArrowEntity(cPlayer & a_Player, double a_Force) :
- super(pkArrow, &a_Player, a_Player.GetThrowStartPos(), a_Player.GetThrowSpeed(a_Force * 1.5 * 20), 0.5, 0.5),
+ super(CreateEntityInfo{ a_Player.GetThrowStartPos(), a_Player.GetThrowSpeed(a_Force * 1.5 * 20), Vector3d(0, 0, 0) }, pkArrow, &a_Player, 0.5, 0.5),
m_PickupState(psInSurvivalOrCreative),
m_DamageCoeff(2),
m_IsCritical((a_Force >= 1)),
diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h
index a1e7a17e7..4822ae690 100644
--- a/src/Entities/ArrowEntity.h
+++ b/src/Entities/ArrowEntity.h
@@ -32,7 +32,7 @@ public:
CLASS_PROTODEF(cArrowEntity)
/// Creates a new arrow with psNoPickup state and default damage modifier coeff
- cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+ cArrowEntity(CreateEntityInfo Info, cEntity * a_Creator);
/// Creates a new arrow as shot by a player, initializes it from the player object
cArrowEntity(cPlayer & a_Player, double a_Force);
diff --git a/src/Entities/Boat.cpp b/src/Entities/Boat.cpp
index 328a70846..a21e48e25 100644
--- a/src/Entities/Boat.cpp
+++ b/src/Entities/Boat.cpp
@@ -13,12 +13,10 @@
-cBoat::cBoat(double a_X, double a_Y, double a_Z) :
- super(etBoat, a_X, a_Y, a_Z, 0.98, 0.7)
+cBoat::cBoat(CreateEntityInfo a_Info) :
+ super(etBoat, a_Info, 0.98, 0.7, 6)
{
SetMass(20.f);
- SetMaxHealth(6);
- SetHealth(6);
}
diff --git a/src/Entities/Boat.h b/src/Entities/Boat.h
index 8de88d165..89dd63987 100644
--- a/src/Entities/Boat.h
+++ b/src/Entities/Boat.h
@@ -30,7 +30,7 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override;
- cBoat(double a_X, double a_Y, double a_Z);
+ cBoat(CreateEntityInfo a_Info);
} ;
diff --git a/src/Entities/EnderCrystal.cpp b/src/Entities/EnderCrystal.cpp
index 30df2c110..bf879373e 100644
--- a/src/Entities/EnderCrystal.cpp
+++ b/src/Entities/EnderCrystal.cpp
@@ -10,10 +10,9 @@
-cEnderCrystal::cEnderCrystal(double a_X, double a_Y, double a_Z)
- : cEntity(etEnderCrystal, a_X, a_Y, a_Z, 1.0, 1.0)
+cEnderCrystal::cEnderCrystal(CreateEntityInfo a_Info)
+ : cEntity(etEnderCrystal, a_Info, 1.0, 1.0, 5)
{
- SetMaxHealth(5);
}
diff --git a/src/Entities/EnderCrystal.h b/src/Entities/EnderCrystal.h
index c98c3b681..97f218967 100644
--- a/src/Entities/EnderCrystal.h
+++ b/src/Entities/EnderCrystal.h
@@ -17,7 +17,7 @@ class cEnderCrystal :
public:
CLASS_PROTODEF(cEnderCrystal)
- cEnderCrystal(double a_X, double a_Y, double a_Z);
+ cEnderCrystal(CreateEntityInfo a_Info);
private:
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 02fcd5f1b..3413dedcc 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -25,41 +25,41 @@ cCriticalSection cEntity::m_CSCount;
-cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height)
- : m_UniqueID(0)
- , m_Health(1)
- , m_MaxHealth(1)
- , m_AttachedTo(NULL)
- , m_Attachee(NULL)
- , m_bDirtyHead(true)
- , m_bDirtyOrientation(true)
- , m_bHasSentNoSpeed(true)
- , m_bOnGround(false)
- , m_Gravity(-9.81f)
- , m_LastPos(a_X, a_Y, a_Z)
- , m_IsInitialized(false)
- , m_WorldTravellingFrom(NULL)
- , m_EntityType(a_EntityType)
- , m_World(NULL)
- , m_IsFireproof(false)
- , m_TicksSinceLastBurnDamage(0)
- , m_TicksSinceLastLavaDamage(0)
- , m_TicksSinceLastFireDamage(0)
- , m_TicksLeftBurning(0)
- , m_TicksSinceLastVoidDamage(0)
- , m_IsSwimming(false)
- , m_IsSubmerged(false)
- , m_AirLevel(0)
- , m_AirTickTimer(0)
- , m_TicksAlive(0)
- , m_HeadYaw(0.0)
- , m_Rot(0.0, 0.0, 0.0)
- , m_Pos(a_X, a_Y, a_Z)
- , m_WaterSpeed(0, 0, 0)
- , m_Mass (0.001) // Default 1g
- , m_Width(a_Width)
- , m_Height(a_Height)
- , m_InvulnerableTicks(0)
+cEntity::cEntity(CreateEntityInfo a_Info, eEntityType a_EntityType, double a_Width, double a_Height, int a_MaxHealth) :
+ m_UniqueID(0),
+ m_Health(a_Info.Health),
+ m_MaxHealth(a_MaxHealth),
+ m_AttachedTo(NULL),
+ m_Attachee(NULL),
+ m_bDirtyHead(true),
+ m_bDirtyOrientation(true),
+ m_bHasSentNoSpeed(true),
+ m_bOnGround(false),
+ m_Gravity(-9.81f),
+ m_LastPos(a_Info.Position),
+ m_IsInitialized(false),
+ m_WorldTravellingFrom(NULL),
+ m_EntityType(a_EntityType),
+ m_World(NULL),
+ m_IsFireproof(false),
+ m_TicksSinceLastBurnDamage(0),
+ m_TicksSinceLastLavaDamage(0),
+ m_TicksSinceLastFireDamage(0),
+ m_TicksLeftBurning(0),
+ m_TicksSinceLastVoidDamage(0),
+ m_IsSwimming(false),
+ m_IsSubmerged(false),
+ m_AirLevel(0),
+ m_AirTickTimer(0),
+ m_TicksAlive(0),
+ m_HeadYaw(0.0),
+ m_Rot(a_Info.Rotation),
+ m_Pos(a_Info.Position),
+ m_WaterSpeed(0, 0, 0),
+ m_Mass (0.001), // Default 1g
+ m_Width(a_Width),
+ m_Height(a_Height),
+ m_InvulnerableTicks(0)
{
cCSLock Lock(m_CSCount);
m_EntityCount++;
@@ -1338,7 +1338,7 @@ bool cEntity::DetectPortal()
if (IsPlayer())
{
cPlayer * Player = (cPlayer *)this;
- Player->TeleportToCoords(Player->GetLastBedPos().x, Player->GetLastBedPos().y, Player->GetLastBedPos().z);
+ SetPosition(Player->GetLastBedPos());
Player->GetClientHandle()->SendRespawn(dimOverworld);
}
@@ -1598,25 +1598,6 @@ void cEntity::StopBurning(void)
-void cEntity::TeleportToEntity(cEntity & a_Entity)
-{
- TeleportToCoords(a_Entity.GetPosX(), a_Entity.GetPosY(), a_Entity.GetPosZ());
-}
-
-
-
-
-
-void cEntity::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
-{
- SetPosition(a_PosX, a_PosY, a_PosZ);
- m_World->BroadcastTeleportEntity(*this);
-}
-
-
-
-
-
void cEntity::BroadcastMovementUpdate(const cClientHandle * a_Exclude)
{
// Process packet sending every two ticks
@@ -1738,16 +1719,6 @@ bool cEntity::IsA(const char * a_ClassName) const
-void cEntity::SetRot(const Vector3f & a_Rot)
-{
- m_Rot = a_Rot;
- m_bDirtyOrientation = true;
-}
-
-
-
-
-
void cEntity::SetHeadYaw(double a_HeadYaw)
{
m_HeadYaw = a_HeadYaw;
@@ -1830,6 +1801,7 @@ void cEntity::SetPosition(const Vector3d & a_Pos)
+
void cEntity::AddPosition(const Vector3d & a_AddPos)
{
m_Pos += a_AddPos;
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 3d7177fd4..72546b1e5 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -63,6 +63,19 @@ struct TakeDamageInfo
+struct CreateEntityInfo
+{
+ Vector3d Position;
+ Vector3d Speed;
+ Vector3d Rotation;
+ int Health;
+ int MaxHealth;
+} ;
+
+
+
+
+
// tolua_begin
class cEntity
{
@@ -83,10 +96,7 @@ public:
etExpOrb,
etFloater,
etItemFrame,
- etPainting,
-
- // Common variations
- etMob = etMonster, // DEPRECATED, use etMonster instead!
+ etPainting
} ;
// tolua_end
@@ -143,7 +153,7 @@ public:
static const int VOID_BOUNDARY = -46; ///< Y position to begin applying void damage
static const int FALL_DAMAGE_HEIGHT = 4; ///< Y difference after which fall damage is applied
- cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
+ cEntity(CreateEntityInfo a_Info, eEntityType a_EntityType, double a_Width, double a_Height, int a_MaxHealth);
virtual ~cEntity();
/** Spawns the entity in the world; returns true if spawned, false if not (plugin disallowed).
@@ -190,7 +200,6 @@ public:
double GetPosX (void) const { return m_Pos.x; }
double GetPosY (void) const { return m_Pos.y; }
double GetPosZ (void) const { return m_Pos.z; }
- const Vector3d & GetRot (void) const { return m_Rot; } // OBSOLETE, use individual GetYaw(), GetPitch, GetRoll() components
double GetYaw (void) const { return m_Rot.x; } // In degrees, [-180, +180)
double GetPitch (void) const { return m_Rot.y; } // In degrees, [-180, +180), but normal client clips to [-90, +90]
double GetRoll (void) const { return m_Rot.z; } // In degrees, unused in current client
@@ -208,7 +217,6 @@ public:
void SetHeight (double a_Height) { m_Height = a_Height; }
void SetWidth (double a_Width) { m_Width = a_Width; }
void SetMass (double a_Mass);
- void SetRot (const Vector3f & a_Rot); // OBSOLETE, use individual SetYaw(), SetPitch(), SetRoll() components
void SetYaw (double a_Yaw); // In degrees, normalizes to [-180, +180)
void SetPitch (double a_Pitch); // In degrees, normalizes to [-180, +180)
void SetRoll (double a_Roll); // In degrees, normalizes to [-180, +180)
@@ -420,12 +428,6 @@ public:
virtual void SpawnOn(cClientHandle & a_Client) = 0;
// tolua_begin
-
- /// Teleports to the entity specified
- virtual void TeleportToEntity(cEntity & a_Entity);
-
- /// Teleports to the coordinates specified
- virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ);
/** Moves entity to specified world, taking a world pointer */
bool MoveToWorld(cWorld * a_World, bool a_ShouldSendRespawn = true) { return DoMoveToWorld(a_World, a_ShouldSendRespawn); }
@@ -479,7 +481,10 @@ public:
int GetAirLevel(void) const { return m_AirLevel; }
/** Gets number of ticks this entity has existed for */
- long int GetTicksAlive(void) const { return m_TicksAlive; }
+ long GetTicksAlive(void) const { return m_TicksAlive; }
+
+ /** Sets number of ticks this entity has existed for */
+ void SetTicksAlive(long a_TicksAlive) { m_TicksAlive = a_TicksAlive; }
/** Gets the invulnerable ticks from the entity */
int GetInvulnerableTicks(void) const { return m_InvulnerableTicks; }
diff --git a/src/Entities/ExpBottleEntity.cpp b/src/Entities/ExpBottleEntity.cpp
index ee142a5a2..851617788 100644
--- a/src/Entities/ExpBottleEntity.cpp
+++ b/src/Entities/ExpBottleEntity.cpp
@@ -7,10 +7,9 @@
-cExpBottleEntity::cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkExpBottle, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+cExpBottleEntity::cExpBottleEntity(CreateEntityInfo a_Info, cEntity * a_Creator) :
+ super(a_Info, pkExpBottle, a_Creator, 0.25, 0.25)
{
- SetSpeed(a_Speed);
}
diff --git a/src/Entities/ExpBottleEntity.h b/src/Entities/ExpBottleEntity.h
index d36110f97..5d9b328d0 100644
--- a/src/Entities/ExpBottleEntity.h
+++ b/src/Entities/ExpBottleEntity.h
@@ -23,7 +23,7 @@ public:
CLASS_PROTODEF(cExpBottleEntity)
- cExpBottleEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+ cExpBottleEntity(CreateEntityInfo a_Info, cEntity * a_Creator);
protected:
diff --git a/src/Entities/ExpOrb.cpp b/src/Entities/ExpOrb.cpp
index 73d5cbfed..65e7bcc2d 100644
--- a/src/Entities/ExpOrb.cpp
+++ b/src/Entities/ExpOrb.cpp
@@ -5,26 +5,10 @@
#include "../ClientHandle.h"
-cExpOrb::cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward)
- : cEntity(etExpOrb, a_X, a_Y, a_Z, 0.98, 0.98)
- , m_Reward(a_Reward)
- , m_Timer(0.f)
+cExpOrb::cExpOrb(CreateEntityInfo a_Info, int a_Reward)
+ : cEntity(a_Info, etExpOrb, 0.98, 0.98, 5),
+ m_Reward(a_Reward)
{
- SetMaxHealth(5);
- SetHealth(5);
-}
-
-
-
-
-
-cExpOrb::cExpOrb(const Vector3d & a_Pos, int a_Reward)
- : cEntity(etExpOrb, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98)
- , m_Reward(a_Reward)
- , m_Timer(0.f)
-{
- SetMaxHealth(5);
- SetHealth(5);
}
@@ -69,9 +53,8 @@ void cExpOrb::Tick(float a_Dt, cChunk & a_Chunk)
}
HandlePhysics(a_Dt, a_Chunk);
- m_Timer += a_Dt;
- if (m_Timer >= 1000 * 60 * 5) // 5 minutes
+ if (GetTicksAlive() >= 20 * 60 * 5) // 5 minutes
{
- Destroy(true);
+ Destroy();
}
}
diff --git a/src/Entities/ExpOrb.h b/src/Entities/ExpOrb.h
index bdb9a5b19..ae487b1ef 100644
--- a/src/Entities/ExpOrb.h
+++ b/src/Entities/ExpOrb.h
@@ -18,19 +18,12 @@ public:
CLASS_PROTODEF(cExpOrb)
- cExpOrb(double a_X, double a_Y, double a_Z, int a_Reward);
- cExpOrb(const Vector3d & a_Pos, int a_Reward);
+ cExpOrb(CreateEntityInfo a_Info, int a_Reward);
// Override functions
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void SpawnOn(cClientHandle & a_Client) override;
- /** Returns the number of ticks that this entity has existed */
- int GetAge(void) const { return (int)(m_Timer / 50); } // tolua_export
-
- /** Set the number of ticks that this entity has existed */
- void SetAge(int a_Age) { m_Timer = (float)(a_Age * 50); } // tolua_export
-
/** Get the exp amount */
int GetReward(void) const { return m_Reward; } // tolua_export
@@ -39,7 +32,4 @@ public:
protected:
int m_Reward;
-
- /** The number of ticks that the entity has existed / timer between collect and destroy; in msec */
- float m_Timer;
} ; // tolua_export
diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp
index 111c5fa84..14a12ba7f 100644
--- a/src/Entities/FallingBlock.cpp
+++ b/src/Entities/FallingBlock.cpp
@@ -10,11 +10,10 @@
-cFallingBlock::cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) :
- super(etFallingBlock, a_BlockPosition.x + 0.5f, a_BlockPosition.y + 0.5f, a_BlockPosition.z + 0.5f, 0.98, 0.98),
+cFallingBlock::cFallingBlock(CreateEntityInfo a_Info, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) :
+ super(a_Info, etFallingBlock, 0.98, 0.98, 1),
m_BlockType(a_BlockType),
- m_BlockMeta(a_BlockMeta),
- m_OriginalPosition(a_BlockPosition)
+ m_BlockMeta(a_BlockMeta)
{
}
diff --git a/src/Entities/FallingBlock.h b/src/Entities/FallingBlock.h
index c20fe8eb9..94d9e72e3 100644
--- a/src/Entities/FallingBlock.h
+++ b/src/Entities/FallingBlock.h
@@ -23,7 +23,7 @@ public:
CLASS_PROTODEF(cFallingBlock)
/// Creates a new falling block. a_BlockPosition is expected in world coords
- cFallingBlock(const Vector3i & a_BlockPosition, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
+ cFallingBlock(CreateEntityInfo a_Info, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
BLOCKTYPE GetBlockType(void) const { return m_BlockType; }
NIBBLETYPE GetBlockMeta(void) const { return m_BlockMeta; }
@@ -35,7 +35,6 @@ public:
private:
BLOCKTYPE m_BlockType;
NIBBLETYPE m_BlockMeta;
- Vector3i m_OriginalPosition; // Position where the falling block has started, in world coords
} ;
diff --git a/src/Entities/FireChargeEntity.cpp b/src/Entities/FireChargeEntity.cpp
index aba32602f..f9993f96f 100644
--- a/src/Entities/FireChargeEntity.cpp
+++ b/src/Entities/FireChargeEntity.cpp
@@ -7,10 +7,9 @@
-cFireChargeEntity::cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkFireCharge, a_Creator, a_X, a_Y, a_Z, 0.3125, 0.3125)
+cFireChargeEntity::cFireChargeEntity(CreateEntityInfo a_Info, cEntity * a_Creator) :
+ super(a_Info, pkFireCharge, a_Creator, 0.3125, 0.3125)
{
- SetSpeed(a_Speed);
SetGravity(0);
}
diff --git a/src/Entities/FireChargeEntity.h b/src/Entities/FireChargeEntity.h
index 5df55bec4..cbfd4beb6 100644
--- a/src/Entities/FireChargeEntity.h
+++ b/src/Entities/FireChargeEntity.h
@@ -23,7 +23,7 @@ public:
CLASS_PROTODEF(cFireChargeEntity)
- cFireChargeEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+ cFireChargeEntity(CreateEntityInfo a_Info, cEntity * a_Creator);
protected:
diff --git a/src/Entities/GhastFireballEntity.cpp b/src/Entities/GhastFireballEntity.cpp
index 9e4cb387e..b3456f6db 100644
--- a/src/Entities/GhastFireballEntity.cpp
+++ b/src/Entities/GhastFireballEntity.cpp
@@ -7,10 +7,9 @@
-cGhastFireballEntity::cGhastFireballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkGhastFireball, a_Creator, a_X, a_Y, a_Z, 1, 1)
+cGhastFireballEntity::cGhastFireballEntity(CreateEntityInfo a_Info, cEntity * a_Creator) :
+ super(a_Info, pkGhastFireball, a_Creator, 1, 1)
{
- SetSpeed(a_Speed);
SetGravity(0);
}
diff --git a/src/Entities/GhastFireballEntity.h b/src/Entities/GhastFireballEntity.h
index 3ed72d9ef..6c8a20b08 100644
--- a/src/Entities/GhastFireballEntity.h
+++ b/src/Entities/GhastFireballEntity.h
@@ -23,7 +23,7 @@ public:
CLASS_PROTODEF(cGhastFireballEntity)
- cGhastFireballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+ cGhastFireballEntity(CreateEntityInfo a_Info, cEntity * a_Creator);
protected:
diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp
index 3276bc4a0..5cc502548 100644
--- a/src/Entities/HangingEntity.cpp
+++ b/src/Entities/HangingEntity.cpp
@@ -9,8 +9,8 @@
-cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
- : cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8)
+cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, CreateEntityInfo a_Info)
+ : cEntity(a_Info, a_EntityType, 0.8, 0.8)
, m_BlockFace(a_BlockFace)
{
SetMaxHealth(1);
diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h
index 1cc0034e1..e071f7bed 100644
--- a/src/Entities/HangingEntity.h
+++ b/src/Entities/HangingEntity.h
@@ -18,7 +18,7 @@ public:
CLASS_PROTODEF(cHangingEntity)
- cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
+ cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, CreateEntityInfo a_Info);
/** Returns the orientation from the hanging entity */
eBlockFace GetDirection() const { return m_BlockFace; } // tolua_export
diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp
index f512324eb..38030c485 100644
--- a/src/Entities/ItemFrame.cpp
+++ b/src/Entities/ItemFrame.cpp
@@ -9,8 +9,8 @@
-cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
- : cHangingEntity(etItemFrame, a_BlockFace, a_X, a_Y, a_Z)
+cItemFrame::cItemFrame(eBlockFace a_BlockFace, CreateEntityInfo a_Info)
+ : cHangingEntity(etItemFrame, a_BlockFace, a_Info)
, m_Item(E_BLOCK_AIR)
, m_Rotation(0)
{
diff --git a/src/Entities/ItemFrame.h b/src/Entities/ItemFrame.h
index a63b78b70..6a375ab3d 100644
--- a/src/Entities/ItemFrame.h
+++ b/src/Entities/ItemFrame.h
@@ -18,7 +18,7 @@ public:
CLASS_PROTODEF(cItemFrame)
- cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
+ cItemFrame(eBlockFace a_BlockFace, CreateEntityInfo a_Info);
/** Returns the item in the frame */
const cItem & GetItem(void) { return m_Item; } // tolua_export
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index f45e7bb69..e733d9ee1 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -84,18 +84,14 @@ protected:
-cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) :
- super(etMinecart, a_X, a_Y, a_Z, 0.98, 0.7),
+cMinecart::cMinecart(ePayload a_Payload, CreateEntityInfo a_Info) :
+ super(a_Info, etMinecart, 0.98, 0.7, 6),
m_Payload(a_Payload),
m_LastDamage(0),
m_DetectorRailPosition(0, 0, 0),
m_bIsOnDetectorRail(false)
{
SetMass(20.f);
- SetMaxHealth(6);
- SetHealth(6);
- SetWidth(1);
- SetHeight(0.9);
}
@@ -1059,8 +1055,8 @@ void cMinecart::Destroyed()
////////////////////////////////////////////////////////////////////////////////
// cRideableMinecart:
-cRideableMinecart::cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height) :
- super(mpNone, a_X, a_Y, a_Z),
+cRideableMinecart::cRideableMinecart(CreateEntityInfo a_Info, const cItem & a_Content, int a_Height) :
+ super(mpNone, a_Info),
m_Content(a_Content),
m_Height(a_Height)
{
@@ -1104,8 +1100,8 @@ void cRideableMinecart::OnRightClicked(cPlayer & a_Player)
////////////////////////////////////////////////////////////////////////////////
// cMinecartWithChest:
-cMinecartWithChest::cMinecartWithChest(double a_X, double a_Y, double a_Z) :
- super(mpChest, a_X, a_Y, a_Z),
+cMinecartWithChest::cMinecartWithChest(CreateEntityInfo a_Info) :
+ super(mpChest, a_Info),
cEntityWindowOwner(this),
m_Contents(ContentsWidth, ContentsHeight)
{
@@ -1163,8 +1159,8 @@ void cMinecartWithChest::Destroyed()
////////////////////////////////////////////////////////////////////////////////
// cMinecartWithFurnace:
-cMinecartWithFurnace::cMinecartWithFurnace(double a_X, double a_Y, double a_Z) :
- super(mpFurnace, a_X, a_Y, a_Z),
+cMinecartWithFurnace::cMinecartWithFurnace(CreateEntityInfo a_Info) :
+ super(mpFurnace, a_Info),
m_FueledTimeLeft(-1),
m_IsFueled(false)
{
@@ -1225,8 +1221,8 @@ void cMinecartWithFurnace::Tick(float a_Dt, cChunk & a_Chunk)
////////////////////////////////////////////////////////////////////////////////
// cMinecartWithTNT:
-cMinecartWithTNT::cMinecartWithTNT(double a_X, double a_Y, double a_Z) :
- super(mpTNT, a_X, a_Y, a_Z)
+cMinecartWithTNT::cMinecartWithTNT(CreateEntityInfo a_Info) :
+ super(mpTNT, a_Info)
{
}
@@ -1239,8 +1235,8 @@ cMinecartWithTNT::cMinecartWithTNT(double a_X, double a_Y, double a_Z) :
////////////////////////////////////////////////////////////////////////////////
// cMinecartWithHopper:
-cMinecartWithHopper::cMinecartWithHopper(double a_X, double a_Y, double a_Z) :
- super(mpHopper, a_X, a_Y, a_Z)
+cMinecartWithHopper::cMinecartWithHopper(CreateEntityInfo a_Info) :
+ super(mpHopper, a_Info)
{
}
diff --git a/src/Entities/Minecart.h b/src/Entities/Minecart.h
index 6b6ad36b5..a542d5321 100644
--- a/src/Entities/Minecart.h
+++ b/src/Entities/Minecart.h
@@ -51,7 +51,7 @@ protected:
Vector3i m_DetectorRailPosition;
bool m_bIsOnDetectorRail;
- cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z);
+ cMinecart(ePayload a_Payload, CreateEntityInfo a_Info);
/** Handles physics on normal rails
For each tick, slow down on flat rails, speed up or slow down on ascending/descending rails (depending on direction), and turn on curved rails
@@ -93,7 +93,7 @@ class cRideableMinecart :
public:
CLASS_PROTODEF(cRideableMinecart)
- cRideableMinecart(double a_X, double a_Y, double a_Z, const cItem & a_Content, int a_Height);
+ cRideableMinecart(CreateEntityInfo a_Info, const cItem & a_Content, int a_Height);
const cItem & GetContent(void) const {return m_Content;}
int GetBlockHeight(void) const {return m_Height;}
@@ -119,7 +119,7 @@ class cMinecartWithChest :
public:
CLASS_PROTODEF(cMinecartWithChest)
- cMinecartWithChest(double a_X, double a_Y, double a_Z);
+ cMinecartWithChest(CreateEntityInfo a_Info);
enum
{
@@ -167,7 +167,7 @@ class cMinecartWithFurnace :
public:
CLASS_PROTODEF(cMinecartWithFurnace)
- cMinecartWithFurnace(double a_X, double a_Y, double a_Z);
+ cMinecartWithFurnace(CreateEntityInfo a_Info);
// cEntity overrides:
virtual void OnRightClicked(cPlayer & a_Player) override;
@@ -199,7 +199,7 @@ class cMinecartWithTNT :
public:
CLASS_PROTODEF(cMinecartWithTNT)
- cMinecartWithTNT(double a_X, double a_Y, double a_Z);
+ cMinecartWithTNT(CreateEntityInfo a_Info);
} ;
@@ -214,5 +214,5 @@ class cMinecartWithHopper :
public:
CLASS_PROTODEF(cMinecartWithHopper)
- cMinecartWithHopper(double a_X, double a_Y, double a_Z);
+ cMinecartWithHopper(CreateEntityInfo a_Info);
} ;
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index fc8ca3d47..9ae37370b 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -9,9 +9,9 @@
-cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height) :
- super(a_EntityType, 0, 0, 0, a_Width, a_Height)
- , m_EntityEffects(tEffectMap())
+cPawn::cPawn(CreateMonsterInfo a_Info, eEntityType a_EntityType, double a_Width, double a_Height) :
+ super(a_Info.EntityInfo, a_EntityType, a_Width, a_Height, a_Info.MonsterInfo.m_MaxHealth),
+ m_EntityEffects(tEffectMap())
{
}
diff --git a/src/Entities/Pawn.h b/src/Entities/Pawn.h
index d50bcd8af..5674d0562 100644
--- a/src/Entities/Pawn.h
+++ b/src/Entities/Pawn.h
@@ -18,7 +18,7 @@ class cPawn :
public:
CLASS_PROTODEF(cPawn)
- cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
+ cPawn(CreateMonsterInfo a_Info, eEntityType a_EntityType, double a_Width, double a_Height);
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index 87b5bed07..6917e4dad 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -84,17 +84,14 @@ protected:
-cPickup::cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX /* = 0.f */, float a_SpeedY /* = 0.f */, float a_SpeedZ /* = 0.f */)
- : cEntity(etPickup, a_PosX, a_PosY, a_PosZ, 0.2, 0.2)
- , m_Timer(0.f)
- , m_Item(a_Item)
- , m_bCollected(false)
- , m_bIsPlayerCreated(IsPlayerCreated)
+cPickup::cPickup(CreateEntityInfo a_Info, const cItem & a_Item, bool IsPlayerCreated)
+ : cEntity(etPickup, a_Info, 0.2, 0.2, 5),
+ m_DestroyTimer(0),
+ m_Item(a_Item),
+ m_bCollected(false),
+ m_bIsPlayerCreated(IsPlayerCreated)
{
SetGravity(-10.5f);
- SetMaxHealth(5);
- SetHealth(5);
- SetSpeed(a_SpeedX, a_SpeedY, a_SpeedZ);
}
@@ -112,10 +109,10 @@ void cPickup::SpawnOn(cClientHandle & a_Client)
void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
{
+ UNUSED(a_Dt);
+
super::Tick(a_Dt, a_Chunk);
BroadcastMovementUpdate(); // Notify clients of position
-
- m_Timer += a_Dt;
if (!m_bCollected)
{
@@ -141,13 +138,8 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
)
{
m_bCollected = true;
- m_Timer = 0; // We have to reset the timer.
- m_Timer += a_Dt; // In case we have to destroy the pickup in the same tick.
- if (m_Timer > 500.f)
- {
- Destroy(true);
- return;
- }
+ Destroy();
+ return;
}
// Try to combine the pickup with adjacent same-item pickups:
@@ -167,22 +159,25 @@ void cPickup::Tick(float a_Dt, cChunk & a_Chunk)
}
else
{
- if (m_Timer > 500.f) // 0.5 second
+ // Playing collect animation, wait until it's complete
+ m_DestroyTimer++;
+
+ if (m_DestroyTimer == 10) // Animation lasts around 0.5 seconds
{
- Destroy(true);
+ Destroy();
return;
}
}
- if (m_Timer > 1000 * 60 * 5) // 5 minutes
+ if (GetTicksAlive() >= 20 * 60 * 5) // 5 minutes
{
- Destroy(true);
+ Destroy();
return;
}
if (GetPosY() < VOID_BOUNDARY) // Out of this world and no more visible!
{
- Destroy(true);
+ Destroy();
return;
}
}
@@ -202,7 +197,7 @@ bool cPickup::CollectedBy(cPlayer * a_Dest)
}
// Two seconds if player created the pickup (vomiting), half a second if anything else
- if (m_Timer < (m_bIsPlayerCreated ? 2000.f : 500.f))
+ if (GetTicksAlive() < (m_bIsPlayerCreated ? 40 : 10))
{
// LOG("Pickup %d cannot be collected by \"%s\", because it is not old enough.", m_UniqueID, a_Dest->GetName().c_str());
return false; // Not old enough
@@ -236,7 +231,6 @@ bool cPickup::CollectedBy(cPlayer * a_Dest)
// All of the pickup has been collected, schedule the pickup for destroying
m_bCollected = true;
}
- m_Timer = 0;
return true;
}
diff --git a/src/Entities/Pickup.h b/src/Entities/Pickup.h
index 4d5250819..4fa430767 100644
--- a/src/Entities/Pickup.h
+++ b/src/Entities/Pickup.h
@@ -25,7 +25,7 @@ public:
CLASS_PROTODEF(cPickup)
- cPickup(double a_PosX, double a_PosY, double a_PosZ, const cItem & a_Item, bool IsPlayerCreated, float a_SpeedX = 0.f, float a_SpeedY = 0.f, float a_SpeedZ = 0.f);
+ cPickup(CreateEntityInfo a_Info, const cItem & a_Item, bool IsPlayerCreated);
cItem & GetItem(void) {return m_Item; } // tolua_export
const cItem & GetItem(void) const {return m_Item; }
@@ -36,12 +36,6 @@ public:
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
- /** Returns the number of ticks that this entity has existed */
- int GetAge(void) const { return (int)(m_Timer / 50); } // tolua_export
-
- /** Set the number of ticks that this entity has existed */
- void SetAge(int a_Age) { m_Timer = (float)(a_Age * 50); } // tolua_export
-
/** Returns true if the pickup has already been collected */
bool IsCollected(void) const { return m_bCollected; } // tolua_export
@@ -50,8 +44,7 @@ public:
private:
- /** The number of ticks that the entity has existed / timer between collect and destroy; in msec */
- float m_Timer;
+ int m_DestroyTimer;
cItem m_Item;
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 3a0d96e7d..2757c7518 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -226,14 +226,16 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
bool CanMove = true;
if (!GetPosition().EqualsEps(m_LastPos, 0.01)) // Non negligible change in position from last tick?
- {
- // Apply food exhaustion from movement:
- ApplyFoodExhaustionFromMovement();
-
+ {
if (cRoot::Get()->GetPluginManager()->CallHookPlayerMoving(*this, m_LastPos, GetPosition()))
{
CanMove = false;
- TeleportToCoords(m_LastPos.x, m_LastPos.y, m_LastPos.z);
+ SetPosition(m_LastPos, true);
+ }
+ else
+ {
+ // Apply food exhaustion from movement:
+ ApplyFoodExhaustionFromMovement();
}
m_ClientHandle->StreamChunks();
}
@@ -1007,17 +1009,16 @@ void cPlayer::Respawn(void)
m_FoodSaturationLevel = 5.0;
m_FoodExhaustionLevel = 0.0;
- // Reset Experience
+ // Reset experience
m_CurrentXp = 0;
m_LifetimeTotalXp = 0;
- // ToDo: send score to client? How?
m_ClientHandle->SendRespawn(GetWorld()->GetDimension(), true);
// Extinguish the fire:
StopBurning();
- TeleportToCoords(GetLastBedPos().x, GetLastBedPos().y, GetLastBedPos().z);
+ SetPosition(GetLastBedPos(), true);
SetVisible(true);
}
@@ -1269,21 +1270,6 @@ unsigned int cPlayer::AwardAchievement(const eStatistic a_Ach)
-void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
-{
- cEntity::SetPosition(a_PosX, a_PosY, a_PosZ);
- m_LastGroundHeight = (float)a_PosY;
- m_LastJumpHeight = (float)a_PosY;
- m_bIsTeleporting = true;
-
- m_World->BroadcastTeleportEntity(*this, GetClientHandle());
- m_ClientHandle->SendPlayerMoveLook();
-}
-
-
-
-
-
void cPlayer::SendRotation(double a_YawDegrees, double a_PitchDegrees)
{
SetYaw(a_YawDegrees);
@@ -1349,31 +1335,47 @@ void cPlayer::AddSpeed(const Vector3d & a_Speed)
-void cPlayer::SetPosition(const Vector3d & a_Position)
+void cPlayer::SetPosition(const Vector3d & a_Position, bool a_Teleport)
{
super::SetPosition(a_Position);
- // Teleport the client
- TeleportToCoords(a_Position.x, a_Position.y, a_Position.z);
+ if (a_Teleport)
+ {
+ // Teleport the client
+ m_LastGroundHeight = (float)a_Position.y;
+ m_LastJumpHeight = (float)a_Position.y;
+ m_bIsTeleporting = true;
+
+ m_World->BroadcastTeleportEntity(*this, GetClientHandle());
+ m_ClientHandle->SendPlayerMoveLook();
+ }
}
-void cPlayer::AddPosition(const Vector3d & a_Position)
+void cPlayer::AddPosition(const Vector3d & a_Position, bool a_Teleport)
{
super::AddPosition(a_Position);
- // Teleport the client
- TeleportToCoords(GetPosX(), GetPosY(), GetPosZ());
+ if (a_Teleport)
+ {
+ // Teleport the client
+ m_LastGroundHeight = (float)a_Position.y;
+ m_LastJumpHeight = (float)a_Position.y;
+ m_bIsTeleporting = true;
+
+ m_World->BroadcastTeleportEntity(*this, GetClientHandle());
+ m_ClientHandle->SendPlayerMoveLook();
+ }
}
-void cPlayer::MoveTo( const Vector3d & a_NewPos)
+void cPlayer::MoveTo(const Vector3d & a_NewPos)
{
if ((a_NewPos.y < -990) && (GetPosY() > -100))
{
@@ -1396,7 +1398,7 @@ void cPlayer::MoveTo( const Vector3d & a_NewPos)
Vector3d DeltaPos = a_NewPos - GetPosition();
UpdateMovementStats(DeltaPos);
- SetPosition( a_NewPos);
+ SetPosition(a_NewPos, false);
SetStance(a_NewPos.y + 1.62);
}
@@ -2206,7 +2208,7 @@ void cPlayer::Detach()
{
if (!cBlockInfo::IsSolid(m_World->GetBlock(x, y, z)) && cBlockInfo::IsSolid(m_World->GetBlock(x, y - 1, z)))
{
- TeleportToCoords(x, y, z);
+ cEntity::SetPosition(x, y, z);
return;
}
}
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 556a118b5..aaf92b24a 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -134,8 +134,6 @@ public:
/** Returns whether the player is climbing (ladders, vines etc.) */
bool IsClimbing(void) const;
- virtual void TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ) override;
-
// tolua_begin
/** Sends the "look" packet to the player, forcing them to set their rotation to the specified values.
@@ -436,6 +434,12 @@ public:
Loads the m_Rank, m_Permissions, m_MsgPrefix, m_MsgSuffix and m_MsgNameColorCode members. */
void LoadRank(void);
+ /** Sets the speed and sends it to the client, so that they are forced to move so. */
+ void SetPosition(const Vector3d & a_Position, bool a_Teleport);
+
+ /** Adds to the speed and sends it to the client, so that they are forced to move so. */
+ void AddPosition(const Vector3d & a_Position, bool a_Teleport);
+
// tolua_end
// cEntity overrides:
@@ -586,12 +590,6 @@ protected:
/** Adds to the speed and sends it to the client, so that they are forced to move so. */
virtual void AddSpeed(const Vector3d & a_Speed) override;
- /** Sets the speed and sends it to the client, so that they are forced to move so. */
- virtual void SetPosition(const Vector3d & a_Position) override;
-
- /** Adds to the speed and sends it to the client, so that they are forced to move so. */
- virtual void AddPosition(const Vector3d & a_Position) override;
-
void ResolvePermissions(void);
void ResolveGroups(void);
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index acc9bd674..de551bb10 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -217,8 +217,8 @@ protected:
////////////////////////////////////////////////////////////////////////////////
// cProjectileEntity:
-cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height) :
- super(etProjectile, a_X, a_Y, a_Z, a_Width, a_Height),
+cProjectileEntity::cProjectileEntity(CreateEntityInfo Info, eKind a_Kind, cEntity * a_Creator, double a_Width, double a_Height) :
+ super(Info, etProjectile, a_Width, a_Height, 1),
m_ProjectileKind(a_Kind),
m_CreatorData(
((a_Creator != NULL) ? a_Creator->GetUniqueID() : -1),
@@ -227,19 +227,6 @@ cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a
),
m_IsInGround(false)
{
-}
-
-
-
-
-
-cProjectileEntity::cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height) :
- super(etProjectile, a_Pos.x, a_Pos.y, a_Pos.z, a_Width, a_Height),
- m_ProjectileKind(a_Kind),
- m_CreatorData(a_Creator->GetUniqueID(), a_Creator->IsPlayer() ? ((cPlayer *)a_Creator)->GetName() : "", a_Creator->GetEquippedWeapon().m_Enchantments),
- m_IsInGround(false)
-{
- SetSpeed(a_Speed);
SetYawFromSpeed();
SetPitchFromSpeed();
}
diff --git a/src/Entities/ProjectileEntity.h b/src/Entities/ProjectileEntity.h
index 990136a32..d05e215fc 100644
--- a/src/Entities/ProjectileEntity.h
+++ b/src/Entities/ProjectileEntity.h
@@ -43,8 +43,7 @@ public:
CLASS_PROTODEF(cProjectileEntity)
- cProjectileEntity(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, double a_Width, double a_Height);
- cProjectileEntity(eKind a_Kind, cEntity * a_Creator, const Vector3d & a_Pos, const Vector3d & a_Speed, double a_Width, double a_Height);
+ cProjectileEntity(CreateEntityInfo Info, eKind a_Kind, cEntity * a_Creator, double a_Width, double a_Height);
static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = NULL);
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index fd1a0179b..5fd15ca11 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -68,16 +68,10 @@ private:
////////////////////////////////////////////////////////////////////////////////
// cSplashPotionEntity:
-cSplashPotionEntity::cSplashPotionEntity(
- cEntity * a_Creator,
- double a_X, double a_Y, double a_Z,
- const Vector3d & a_Speed,
- const cItem & a_Item
-) :
- super(pkSplashPotion, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
+cSplashPotionEntity::cSplashPotionEntity(CreateEntityInfo a_Info, cEntity * a_Creator, const cItem & a_Item) :
+ super(a_Info, pkSplashPotion, a_Creator, 0.25, 0.25),
m_DestroyTimer(-1)
{
- SetSpeed(a_Speed);
m_EntityEffectType = cEntityEffect::GetPotionEffectType(a_Item.m_ItemDamage);
m_EntityEffect = cEntityEffect(
cEntityEffect::GetPotionEffectDuration(a_Item.m_ItemDamage),
diff --git a/src/Entities/SplashPotionEntity.h b/src/Entities/SplashPotionEntity.h
index 4afc5f204..c427458c2 100644
--- a/src/Entities/SplashPotionEntity.h
+++ b/src/Entities/SplashPotionEntity.h
@@ -25,12 +25,7 @@ public:
CLASS_PROTODEF(cSplashPotionEntity)
- cSplashPotionEntity(
- cEntity * a_Creator,
- double a_X, double a_Y, double a_Z,
- const Vector3d & a_Speed,
- const cItem & a_Item
- );
+ cSplashPotionEntity(CreateEntityInfo a_Info, cEntity * a_Creator, const cItem & a_Item);
cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp
index 53af446cc..aa9802969 100644
--- a/src/Entities/TNTEntity.cpp
+++ b/src/Entities/TNTEntity.cpp
@@ -8,18 +8,8 @@
-cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks) :
- super(etTNT, a_X, a_Y, a_Z, 0.98, 0.98),
- m_FuseTicks(a_FuseTicks)
-{
-}
-
-
-
-
-
-cTNTEntity::cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks) :
- super(etTNT, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98),
+cTNTEntity::cTNTEntity(CreateEntityInfo a_Info, int a_FuseTicks) :
+ super(etTNT, a_Info, 0.98, 0.98, 1),
m_FuseTicks(a_FuseTicks)
{
}
diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h
index 48503cf76..8d29aeb47 100644
--- a/src/Entities/TNTEntity.h
+++ b/src/Entities/TNTEntity.h
@@ -16,8 +16,7 @@ public:
// tolua_end
CLASS_PROTODEF(cTNTEntity)
- cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks = 80);
- cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks = 80);
+ cTNTEntity(CreateEntityInfo a_Info, int a_FuseTicks = 80);
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
diff --git a/src/Entities/ThrownEggEntity.cpp b/src/Entities/ThrownEggEntity.cpp
index 5ae85bee8..a6ae549ff 100644
--- a/src/Entities/ThrownEggEntity.cpp
+++ b/src/Entities/ThrownEggEntity.cpp
@@ -7,11 +7,10 @@
-cThrownEggEntity::cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkEgg, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
+cThrownEggEntity::cThrownEggEntity(CreateEntityInfo a_Info, cEntity * a_Creator) :
+ super(a_Info, pkEgg, a_Creator, 0.25, 0.25),
m_DestroyTimer(-1)
{
- SetSpeed(a_Speed);
}
diff --git a/src/Entities/ThrownEggEntity.h b/src/Entities/ThrownEggEntity.h
index a0b7d5340..de401d389 100644
--- a/src/Entities/ThrownEggEntity.h
+++ b/src/Entities/ThrownEggEntity.h
@@ -23,7 +23,7 @@ public:
CLASS_PROTODEF(cThrownEggEntity)
- cThrownEggEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+ cThrownEggEntity(CreateEntityInfo a_Info, cEntity * a_Creator);
protected:
diff --git a/src/Entities/ThrownEnderPearlEntity.cpp b/src/Entities/ThrownEnderPearlEntity.cpp
index c7407e6ae..555c10688 100644
--- a/src/Entities/ThrownEnderPearlEntity.cpp
+++ b/src/Entities/ThrownEnderPearlEntity.cpp
@@ -7,11 +7,10 @@
-cThrownEnderPearlEntity::cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkEnderPearl, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
+cThrownEnderPearlEntity::cThrownEnderPearlEntity(CreateEntityInfo a_Info, cEntity * a_Creator) :
+ super(a_Info, pkEnderPearl, a_Creator, 0.25, 0.25),
m_DestroyTimer(-1)
{
- SetSpeed(a_Speed);
}
@@ -64,7 +63,7 @@ void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos)
virtual bool Item(cPlayer * a_Entity) override
{
// Teleport the creator here, make them take 5 damage:
- a_Entity->TeleportToCoords(m_HitPos.x, m_HitPos.y + 0.2, m_HitPos.z);
+ a_Entity->SetPosition(m_HitPos, true);
a_Entity->TakeDamage(dtEnderPearl, m_Attacker, 5, 0);
return true;
}
diff --git a/src/Entities/ThrownEnderPearlEntity.h b/src/Entities/ThrownEnderPearlEntity.h
index 436450013..3ff109764 100644
--- a/src/Entities/ThrownEnderPearlEntity.h
+++ b/src/Entities/ThrownEnderPearlEntity.h
@@ -23,7 +23,7 @@ public:
CLASS_PROTODEF(cThrownEnderPearlEntity)
- cThrownEnderPearlEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+ cThrownEnderPearlEntity(CreateEntityInfo a_Info, cEntity * a_Creator);
protected:
diff --git a/src/Entities/ThrownSnowballEntity.cpp b/src/Entities/ThrownSnowballEntity.cpp
index 496397100..74b7f02e4 100644
--- a/src/Entities/ThrownSnowballEntity.cpp
+++ b/src/Entities/ThrownSnowballEntity.cpp
@@ -7,11 +7,10 @@
-cThrownSnowballEntity::cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkSnowball, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
+cThrownSnowballEntity::cThrownSnowballEntity(CreateEntityInfo a_Info, cEntity * a_Creator) :
+ super(a_Info, pkSnowball, a_Creator, 0.25, 0.25),
m_DestroyTimer(-1)
{
- SetSpeed(a_Speed);
}
diff --git a/src/Entities/ThrownSnowballEntity.h b/src/Entities/ThrownSnowballEntity.h
index 8d195ced1..b0c2164bb 100644
--- a/src/Entities/ThrownSnowballEntity.h
+++ b/src/Entities/ThrownSnowballEntity.h
@@ -23,7 +23,7 @@ public:
CLASS_PROTODEF(cThrownSnowballEntity)
- cThrownSnowballEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+ cThrownSnowballEntity(CreateEntityInfo a_Info, cEntity * a_Creator);
protected:
diff --git a/src/Entities/WitherSkullEntity.cpp b/src/Entities/WitherSkullEntity.cpp
index a7e774bba..453d51342 100644
--- a/src/Entities/WitherSkullEntity.cpp
+++ b/src/Entities/WitherSkullEntity.cpp
@@ -12,10 +12,9 @@
-cWitherSkullEntity::cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed) :
- super(pkWitherSkull, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25)
+cWitherSkullEntity::cWitherSkullEntity(CreateEntityInfo a_Info, cEntity * a_Creator) :
+ super(a_Info, pkWitherSkull, a_Creator, 0.25, 0.25)
{
- SetSpeed(a_Speed);
}
@@ -41,7 +40,7 @@ void cWitherSkullEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_H
// TODO: Explode
// TODO: Apply wither effect to entity and others nearby
- Destroy(true);
+ Destroy();
}
diff --git a/src/Entities/WitherSkullEntity.h b/src/Entities/WitherSkullEntity.h
index c59acd807..1f007ba87 100644
--- a/src/Entities/WitherSkullEntity.h
+++ b/src/Entities/WitherSkullEntity.h
@@ -24,7 +24,7 @@ public:
CLASS_PROTODEF(cWitherSkullEntity)
- cWitherSkullEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
+ cWitherSkullEntity(CreateEntityInfo a_Info, cEntity * a_Creator);
protected:
diff --git a/src/Items/ItemLilypad.h b/src/Items/ItemLilypad.h
index 9ffecd133..7b6f9fc26 100644
--- a/src/Items/ItemLilypad.h
+++ b/src/Items/ItemLilypad.h
@@ -96,7 +96,7 @@ public:
// A plugin doesn't agree with placing the block, revert the block on the client:
a_World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
a_Player->GetInventory().SendEquippedSlot();
- return;
+ return false;
}
a_World->SetBlock(Callbacks.m_Pos.x, Callbacks.m_Pos.y, Callbacks.m_Pos.z, E_BLOCK_LILY_PAD, 0);
diff --git a/src/Mobs/AggressiveMonster.cpp b/src/Mobs/AggressiveMonster.cpp
index be2f71f7a..0043348c0 100644
--- a/src/Mobs/AggressiveMonster.cpp
+++ b/src/Mobs/AggressiveMonster.cpp
@@ -11,8 +11,8 @@
-cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
- super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
+cAggressiveMonster::cAggressiveMonster(CreateMonsterInfo a_Info, const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
+ super(a_Info, a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
{
m_EMPersonality = AGGRESSIVE;
}
diff --git a/src/Mobs/AggressiveMonster.h b/src/Mobs/AggressiveMonster.h
index 2549ba2d3..bce8508d7 100644
--- a/src/Mobs/AggressiveMonster.h
+++ b/src/Mobs/AggressiveMonster.h
@@ -14,7 +14,7 @@ class cAggressiveMonster :
public:
- cAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
+ cAggressiveMonster(CreateMonsterInfo a_Info, const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
virtual void InStateChasing(float a_Dt) override;
diff --git a/src/Mobs/Bat.cpp b/src/Mobs/Bat.cpp
index c072d4f48..afbd1ba08 100644
--- a/src/Mobs/Bat.cpp
+++ b/src/Mobs/Bat.cpp
@@ -6,8 +6,8 @@
#include "../Chunk.h"
-cBat::cBat(void) :
- super("Bat", mtBat, "mob.bat.hurt", "mob.bat.death", 0.5, 0.9)
+cBat::cBat(CreateMonsterInfo a_Info) :
+ super(a_Info, "Bat", mtBat, "mob.bat.hurt", "mob.bat.death", 0.5, 0.9)
{
}
diff --git a/src/Mobs/Bat.h b/src/Mobs/Bat.h
index 6b06aeb4f..f3012508f 100644
--- a/src/Mobs/Bat.h
+++ b/src/Mobs/Bat.h
@@ -13,7 +13,7 @@ class cBat :
typedef cPassiveMonster super;
public:
- cBat(void);
+ cBat(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cBat)
diff --git a/src/Mobs/Blaze.cpp b/src/Mobs/Blaze.cpp
index b4104d530..35d3c197d 100644
--- a/src/Mobs/Blaze.cpp
+++ b/src/Mobs/Blaze.cpp
@@ -8,8 +8,8 @@
-cBlaze::cBlaze(void) :
- super("Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.6, 1.8)
+cBlaze::cBlaze(CreateMonsterInfo a_Info) :
+ super(a_Info, "Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.6, 1.8)
{
}
diff --git a/src/Mobs/Blaze.h b/src/Mobs/Blaze.h
index f283b1070..b7734449e 100644
--- a/src/Mobs/Blaze.h
+++ b/src/Mobs/Blaze.h
@@ -13,7 +13,7 @@ class cBlaze :
typedef cAggressiveMonster super;
public:
- cBlaze(void);
+ cBlaze(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cBlaze)
diff --git a/src/Mobs/CaveSpider.cpp b/src/Mobs/CaveSpider.cpp
index 118a6e93b..f1d91afe9 100644
--- a/src/Mobs/CaveSpider.cpp
+++ b/src/Mobs/CaveSpider.cpp
@@ -7,8 +7,8 @@
-cCaveSpider::cCaveSpider(void) :
- super("CaveSpider", mtCaveSpider, "mob.spider.say", "mob.spider.death", 0.7, 0.5)
+cCaveSpider::cCaveSpider(CreateMonsterInfo a_Info) :
+ super(a_Info, "CaveSpider", mtCaveSpider, "mob.spider.say", "mob.spider.death", 0.7, 0.5)
{
}
diff --git a/src/Mobs/CaveSpider.h b/src/Mobs/CaveSpider.h
index f9ed10e1b..b9145a09a 100644
--- a/src/Mobs/CaveSpider.h
+++ b/src/Mobs/CaveSpider.h
@@ -12,7 +12,7 @@ class cCaveSpider :
typedef cAggressiveMonster super;
public:
- cCaveSpider(void);
+ cCaveSpider(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cCaveSpider)
diff --git a/src/Mobs/Chicken.cpp b/src/Mobs/Chicken.cpp
index f7e44238f..0206f8294 100644
--- a/src/Mobs/Chicken.cpp
+++ b/src/Mobs/Chicken.cpp
@@ -9,8 +9,8 @@
-cChicken::cChicken(void) :
- super("Chicken", mtChicken, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4),
+cChicken::cChicken(CreateMonsterInfo a_Info) :
+ super(a_Info, "Chicken", mtChicken, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4),
m_EggDropTimer(0)
{
}
diff --git a/src/Mobs/Chicken.h b/src/Mobs/Chicken.h
index b1a50b61c..169c42fca 100644
--- a/src/Mobs/Chicken.h
+++ b/src/Mobs/Chicken.h
@@ -12,7 +12,7 @@ class cChicken :
typedef cPassiveMonster super;
public:
- cChicken(void);
+ cChicken(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cChicken)
diff --git a/src/Mobs/Cow.cpp b/src/Mobs/Cow.cpp
index 9914df6b5..0b5b05b07 100644
--- a/src/Mobs/Cow.cpp
+++ b/src/Mobs/Cow.cpp
@@ -10,8 +10,8 @@
-cCow::cCow(void) :
- super("Cow", mtCow, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3)
+cCow::cCow(CreateMonsterInfo a_Info) :
+ super(a_Info, "Cow", mtCow, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3)
{
}
diff --git a/src/Mobs/Cow.h b/src/Mobs/Cow.h
index 8814b7e09..fad1d0cda 100644
--- a/src/Mobs/Cow.h
+++ b/src/Mobs/Cow.h
@@ -13,7 +13,7 @@ class cCow :
typedef cPassiveMonster super;
public:
- cCow();
+ cCow(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cCow)
diff --git a/src/Mobs/Creeper.cpp b/src/Mobs/Creeper.cpp
index 02718edf8..f49c8c858 100644
--- a/src/Mobs/Creeper.cpp
+++ b/src/Mobs/Creeper.cpp
@@ -10,8 +10,8 @@
-cCreeper::cCreeper(void) :
- super("Creeper", mtCreeper, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8),
+cCreeper::cCreeper(CreateMonsterInfo a_Info) :
+ super(a_Info, "Creeper", mtCreeper, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8),
m_bIsBlowing(false),
m_bIsCharged(false),
m_BurnedWithFlintAndSteel(false),
diff --git a/src/Mobs/Creeper.h b/src/Mobs/Creeper.h
index 747daca09..a8f5345b6 100644
--- a/src/Mobs/Creeper.h
+++ b/src/Mobs/Creeper.h
@@ -13,7 +13,7 @@ class cCreeper :
typedef cAggressiveMonster super;
public:
- cCreeper(void);
+ cCreeper(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cCreeper)
diff --git a/src/Mobs/EnderDragon.cpp b/src/Mobs/EnderDragon.cpp
index acd81cde1..5e6f949d1 100644
--- a/src/Mobs/EnderDragon.cpp
+++ b/src/Mobs/EnderDragon.cpp
@@ -7,9 +7,9 @@
-cEnderDragon::cEnderDragon(void) :
+cEnderDragon::cEnderDragon(CreateMonsterInfo a_Info) :
// TODO: Vanilla source says this, but is it right? Dragons fly, they don't stand
- super("EnderDragon", mtEnderDragon, "mob.enderdragon.hit", "mob.enderdragon.end", 16.0, 8.0)
+ super(a_Info, "EnderDragon", mtEnderDragon, "mob.enderdragon.hit", "mob.enderdragon.end", 16.0, 8.0)
{
}
diff --git a/src/Mobs/EnderDragon.h b/src/Mobs/EnderDragon.h
index 1d4cd657c..30d1acf2e 100644
--- a/src/Mobs/EnderDragon.h
+++ b/src/Mobs/EnderDragon.h
@@ -13,7 +13,7 @@ class cEnderDragon :
typedef cAggressiveMonster super;
public:
- cEnderDragon(void);
+ cEnderDragon(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cEnderDragon)
diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp
index 567714382..b5d552d26 100644
--- a/src/Mobs/Enderman.cpp
+++ b/src/Mobs/Enderman.cpp
@@ -77,8 +77,8 @@ protected:
-cEnderman::cEnderman(void) :
- super("Enderman", mtEnderman, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.9),
+cEnderman::cEnderman(CreateMonsterInfo a_Info) :
+ super(a_Info, "Enderman", mtEnderman, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.9),
m_bIsScreaming(false),
CarriedBlock(E_BLOCK_AIR),
CarriedMeta(0)
diff --git a/src/Mobs/Enderman.h b/src/Mobs/Enderman.h
index 947c32b96..84ad91114 100644
--- a/src/Mobs/Enderman.h
+++ b/src/Mobs/Enderman.h
@@ -13,7 +13,7 @@ class cEnderman :
typedef cPassiveAggressiveMonster super;
public:
- cEnderman(void);
+ cEnderman(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cEnderman)
diff --git a/src/Mobs/Ghast.cpp b/src/Mobs/Ghast.cpp
index 6aac14779..73b9d1bc1 100644
--- a/src/Mobs/Ghast.cpp
+++ b/src/Mobs/Ghast.cpp
@@ -8,8 +8,8 @@
-cGhast::cGhast(void) :
- super("Ghast", mtGhast, "mob.ghast.scream", "mob.ghast.death", 4, 4)
+cGhast::cGhast(CreateMonsterInfo a_Info) :
+ super(a_Info, "Ghast", mtGhast, "mob.ghast.scream", "mob.ghast.death", 4, 4)
{
}
diff --git a/src/Mobs/Ghast.h b/src/Mobs/Ghast.h
index 1d4e6b94a..a0fbf9cf8 100644
--- a/src/Mobs/Ghast.h
+++ b/src/Mobs/Ghast.h
@@ -13,7 +13,7 @@ class cGhast :
typedef cAggressiveMonster super;
public:
- cGhast(void);
+ cGhast(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cGhast)
diff --git a/src/Mobs/Giant.cpp b/src/Mobs/Giant.cpp
index bbcad46f0..68ff8453e 100644
--- a/src/Mobs/Giant.cpp
+++ b/src/Mobs/Giant.cpp
@@ -7,8 +7,8 @@
-cGiant::cGiant(void) :
- super("Giant", mtGiant, "mob.zombie.hurt", "mob.zombie.death", 3.6, 10.8)
+cGiant::cGiant(CreateMonsterInfo a_Info) :
+ super(a_Info, "Giant", mtGiant, "mob.zombie.hurt", "mob.zombie.death", 3.6, 10.8)
{
}
diff --git a/src/Mobs/Giant.h b/src/Mobs/Giant.h
index 7c04c9b4f..7b403c3a2 100644
--- a/src/Mobs/Giant.h
+++ b/src/Mobs/Giant.h
@@ -13,7 +13,7 @@ class cGiant :
typedef cAggressiveMonster super;
public:
- cGiant(void);
+ cGiant(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cGiant)
diff --git a/src/Mobs/Horse.cpp b/src/Mobs/Horse.cpp
index 67a09d4ab..e91b796c9 100644
--- a/src/Mobs/Horse.cpp
+++ b/src/Mobs/Horse.cpp
@@ -8,8 +8,8 @@
-cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
- super("Horse", mtHorse, "mob.horse.hit", "mob.horse.death", 1.4, 1.6),
+cHorse::cHorse(CreateMonsterInfo a_Info, int Type, int Color, int Style, int TameTimes) :
+ super(a_Info, "Horse", mtHorse, "mob.horse.hit", "mob.horse.death", 1.4, 1.6),
m_bHasChest(false),
m_bIsEating(false),
m_bIsRearing(false),
diff --git a/src/Mobs/Horse.h b/src/Mobs/Horse.h
index 47189b3b0..beb1c7d9f 100644
--- a/src/Mobs/Horse.h
+++ b/src/Mobs/Horse.h
@@ -13,7 +13,7 @@ class cHorse :
typedef cPassiveMonster super;
public:
- cHorse(int Type, int Color, int Style, int TameTimes);
+ cHorse(CreateMonsterInfo a_Info, int Type, int Color, int Style, int TameTimes);
CLASS_PROTODEF(cHorse)
diff --git a/src/Mobs/IronGolem.cpp b/src/Mobs/IronGolem.cpp
index dae4615e4..c542585b3 100644
--- a/src/Mobs/IronGolem.cpp
+++ b/src/Mobs/IronGolem.cpp
@@ -7,8 +7,8 @@
-cIronGolem::cIronGolem(void) :
- super("IronGolem", mtIronGolem, "mob.IronGolem.hit", "mob.IronGolem.death", 1.4, 2.9)
+cIronGolem::cIronGolem(CreateMonsterInfo a_Info) :
+ super(a_Info, "IronGolem", mtIronGolem, "mob.IronGolem.hit", "mob.IronGolem.death", 1.4, 2.9)
{
}
diff --git a/src/Mobs/IronGolem.h b/src/Mobs/IronGolem.h
index c5341ed76..87df42c28 100644
--- a/src/Mobs/IronGolem.h
+++ b/src/Mobs/IronGolem.h
@@ -13,7 +13,7 @@ class cIronGolem :
typedef cPassiveAggressiveMonster super;
public:
- cIronGolem(void);
+ cIronGolem(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cIronGolem)
diff --git a/src/Mobs/MagmaCube.cpp b/src/Mobs/MagmaCube.cpp
index 3e9abc108..99a3ddb7e 100644
--- a/src/Mobs/MagmaCube.cpp
+++ b/src/Mobs/MagmaCube.cpp
@@ -6,8 +6,8 @@
-cMagmaCube::cMagmaCube(int a_Size) :
- super("MagmaCube", mtMagmaCube, "mob.MagmaCube.big", "mob.MagmaCube.big", 0.6 * a_Size, 0.6 * a_Size),
+cMagmaCube::cMagmaCube(CreateMonsterInfo a_Info, int a_Size) :
+ super(a_Info, "MagmaCube", mtMagmaCube, "mob.MagmaCube.big", "mob.MagmaCube.big", 0.6 * a_Size, 0.6 * a_Size),
m_Size(a_Size)
{
}
diff --git a/src/Mobs/MagmaCube.h b/src/Mobs/MagmaCube.h
index bfe63fa2e..af926c37c 100644
--- a/src/Mobs/MagmaCube.h
+++ b/src/Mobs/MagmaCube.h
@@ -13,7 +13,7 @@ class cMagmaCube :
public:
/// Creates a MagmaCube of the specified size; size is 1 .. 3, with 1 being the smallest
- cMagmaCube(int a_Size);
+ cMagmaCube(CreateMonsterInfo a_Info, int a_Size);
CLASS_PROTODEF(cMagmaCube)
diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp
index 12ca6bbbe..50692ebc2 100644
--- a/src/Mobs/Monster.cpp
+++ b/src/Mobs/Monster.cpp
@@ -2,13 +2,11 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "IncludeAllMonsters.h"
-#include "../Root.h"
#include "../Server.h"
#include "../ClientHandle.h"
#include "../World.h"
#include "../Entities/Player.h"
#include "../Entities/ExpOrb.h"
-#include "../MonsterConfig.h"
#include "../MersenneTwister.h"
#include "../Chunk.h"
@@ -65,38 +63,34 @@ static const struct
////////////////////////////////////////////////////////////////////////////////
// cMonster:
-cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
- : super(etMonster, a_Width, a_Height)
- , m_EMState(IDLE)
- , m_EMPersonality(AGGRESSIVE)
- , m_Target(NULL)
- , m_bMovingToDestination(false)
- , m_LastGroundHeight(POSY_TOINT)
- , m_IdleInterval(0)
- , m_DestroyTimer(0)
- , m_MobType(a_MobType)
- , m_CustomName("")
- , m_CustomNameAlwaysVisible(false)
- , m_SoundHurt(a_SoundHurt)
- , m_SoundDeath(a_SoundDeath)
- , m_AttackRate(3)
- , m_AttackDamage(1)
- , m_AttackRange(2)
- , m_AttackInterval(0)
- , m_SightDistance(25)
- , m_DropChanceWeapon(0.085f)
- , m_DropChanceHelmet(0.085f)
- , m_DropChanceChestplate(0.085f)
- , m_DropChanceLeggings(0.085f)
- , m_DropChanceBoots(0.085f)
- , m_CanPickUpLoot(true)
- , m_BurnsInDaylight(false)
- , m_RelativeWalkSpeed(1.0)
+cMonster::cMonster(CreateMonsterInfo a_Info, const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
+ super(a_Info, etMonster, a_Width, a_Height),
+ m_EMState(IDLE),
+ m_EMPersonality(AGGRESSIVE),
+ m_Target(NULL),
+ m_bMovingToDestination(false),
+ m_LastGroundHeight(POSY_TOINT),
+ m_IdleInterval(0),
+ m_DestroyTimer(0),
+ m_MobType(a_MobType),
+ m_CustomName(a_Info.CustomName),
+ m_CustomNameAlwaysVisible(a_Info.CustomNameAlwaysVisible),
+ m_SoundHurt(a_SoundHurt),
+ m_SoundDeath(a_SoundDeath),
+ m_AttackRate(a_Info.MonsterInfo.m_AttackRate),
+ m_AttackDamage(a_Info.MonsterInfo.m_AttackDamage),
+ m_AttackRange(a_Info.MonsterInfo.m_AttackRange),
+ m_AttackInterval(a_Info.MonsterInfo.m_AttackRate),
+ m_SightDistance(a_Info.MonsterInfo.m_SightDistance),
+ m_DropChanceWeapon(a_Info.DropChanceWeapon),
+ m_DropChanceHelmet(a_Info.DropChanceHelmet),
+ m_DropChanceChestplate(a_Info.DropChanceChestplate),
+ m_DropChanceLeggings(a_Info.DropChanceLeggings),
+ m_DropChanceBoots(a_Info.DropChanceBoots),
+ m_CanPickUpLoot(a_Info.CanPickUpLoot),
+ m_BurnsInDaylight(false),
+ m_RelativeWalkSpeed(1.0)
{
- if (!a_ConfigName.empty())
- {
- GetMonsterConfig(a_ConfigName);
- }
}
@@ -737,15 +731,6 @@ void cMonster::SetCustomNameAlwaysVisible(bool a_CustomNameAlwaysVisible)
-void cMonster::GetMonsterConfig(const AString & a_Name)
-{
- cRoot::Get()->GetMonsterConfig()->AssignAttributes(this, a_Name);
-}
-
-
-
-
-
bool cMonster::IsUndead(void)
{
return false;
diff --git a/src/Mobs/Monster.h b/src/Mobs/Monster.h
index a1f9c4a5b..f6fe88638 100644
--- a/src/Mobs/Monster.h
+++ b/src/Mobs/Monster.h
@@ -6,6 +6,8 @@
#include "../BlockID.h"
#include "../Item.h"
#include "../Enchantments.h"
+#include "../Root.h"
+#include "../MonsterConfig.h"
#include "MonsterTypes.h"
@@ -18,6 +20,31 @@ class cWorld;
+
+struct CreateMonsterInfo
+{
+ CreateMonsterInfo(const AString & a_ClassName) :
+ MonsterInfo(cRoot::Get()->GetMonsterConfig()->ReturnAttributes(a_ClassName))
+ {
+ }
+
+ CreateEntityInfo EntityInfo;
+ cMonsterConfig::sReturnAttributes MonsterInfo;
+
+ float DropChanceWeapon;
+ float DropChanceHelmet;
+ float DropChanceChestplate;
+ float DropChanceLeggings;
+ float DropChanceBoots;
+
+ AString CustomName;
+ bool CustomNameAlwaysVisible;
+ bool CanPickUpLoot;
+};
+
+
+
+
// tolua_begin
class cMonster :
public cPawn
@@ -49,7 +76,7 @@ public:
a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs 2012_12_22))
a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively
*/
- cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
+ cMonster(CreateMonsterInfo a_Info, const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
CLASS_PROTODEF(cMonster)
@@ -74,9 +101,6 @@ public:
virtual void CheckEventSeePlayer(void);
virtual void EventSeePlayer(cEntity * a_Player);
- /// Reads the monster configuration for the specified monster name and assigns it to this object.
- void GetMonsterConfig(const AString & a_Name);
-
/** Returns whether this mob is undead (skeleton, zombie, etc.) */
virtual bool IsUndead(void);
diff --git a/src/Mobs/Mooshroom.cpp b/src/Mobs/Mooshroom.cpp
index 99958720f..586c4cafc 100644
--- a/src/Mobs/Mooshroom.cpp
+++ b/src/Mobs/Mooshroom.cpp
@@ -13,8 +13,8 @@
-cMooshroom::cMooshroom(void) :
- super("Mooshroom", mtMooshroom, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3)
+cMooshroom::cMooshroom(CreateMonsterInfo a_Info) :
+ super(a_Info, "Mooshroom", mtMooshroom, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3)
{
}
diff --git a/src/Mobs/Mooshroom.h b/src/Mobs/Mooshroom.h
index fb002c2bf..2b033308d 100644
--- a/src/Mobs/Mooshroom.h
+++ b/src/Mobs/Mooshroom.h
@@ -13,7 +13,7 @@ class cMooshroom :
typedef cPassiveMonster super;
public:
- cMooshroom(void);
+ cMooshroom(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cMooshroom)
diff --git a/src/Mobs/Ocelot.h b/src/Mobs/Ocelot.h
index f2727d354..4f0739eec 100644
--- a/src/Mobs/Ocelot.h
+++ b/src/Mobs/Ocelot.h
@@ -13,7 +13,7 @@ class cOcelot :
typedef cPassiveMonster super;
public:
- cOcelot(void) :
+ cOcelot(CreateMonsterInfo a_Info) :
super("Ocelot", mtOcelot, "mob.cat.hitt", "mob.cat.hitt", 0.6, 0.8)
{
}
diff --git a/src/Mobs/PassiveAggressiveMonster.cpp b/src/Mobs/PassiveAggressiveMonster.cpp
index e0cc2fd21..4919d4139 100644
--- a/src/Mobs/PassiveAggressiveMonster.cpp
+++ b/src/Mobs/PassiveAggressiveMonster.cpp
@@ -9,8 +9,8 @@
-cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
- super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
+cPassiveAggressiveMonster::cPassiveAggressiveMonster(CreateMonsterInfo a_Info, const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
+ super(a_Info, a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
{
m_EMPersonality = PASSIVE;
}
diff --git a/src/Mobs/PassiveAggressiveMonster.h b/src/Mobs/PassiveAggressiveMonster.h
index 72f472281..f0c7c3bc1 100644
--- a/src/Mobs/PassiveAggressiveMonster.h
+++ b/src/Mobs/PassiveAggressiveMonster.h
@@ -13,7 +13,7 @@ class cPassiveAggressiveMonster :
typedef cAggressiveMonster super;
public:
- cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
+ cPassiveAggressiveMonster(CreateMonsterInfo a_Info, const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
} ;
diff --git a/src/Mobs/PassiveMonster.cpp b/src/Mobs/PassiveMonster.cpp
index be3043e3d..6ddb0dde0 100644
--- a/src/Mobs/PassiveMonster.cpp
+++ b/src/Mobs/PassiveMonster.cpp
@@ -8,8 +8,8 @@
-cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
- super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
+cPassiveMonster::cPassiveMonster(CreateMonsterInfo a_Info, const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
+ super(a_Info, a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
{
m_EMPersonality = PASSIVE;
}
diff --git a/src/Mobs/PassiveMonster.h b/src/Mobs/PassiveMonster.h
index 9221d9a6e..6b9084ade 100644
--- a/src/Mobs/PassiveMonster.h
+++ b/src/Mobs/PassiveMonster.h
@@ -13,7 +13,7 @@ class cPassiveMonster :
typedef cMonster super;
public:
- cPassiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
+ cPassiveMonster(CreateMonsterInfo a_Info, const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
diff --git a/src/Mobs/Pig.cpp b/src/Mobs/Pig.cpp
index 1f77cf613..90f9998db 100644
--- a/src/Mobs/Pig.cpp
+++ b/src/Mobs/Pig.cpp
@@ -9,8 +9,8 @@
-cPig::cPig(void) :
- super("Pig", mtPig, "mob.pig.say", "mob.pig.death", 0.9, 0.9),
+cPig::cPig(CreateMonsterInfo a_Info) :
+ super(a_Info, "Pig", mtPig, "mob.pig.say", "mob.pig.death", 0.9, 0.9),
m_bIsSaddled(false)
{
}
diff --git a/src/Mobs/Pig.h b/src/Mobs/Pig.h
index 534a0ca6f..1e19c7fba 100644
--- a/src/Mobs/Pig.h
+++ b/src/Mobs/Pig.h
@@ -13,7 +13,7 @@ class cPig :
typedef cPassiveMonster super;
public:
- cPig(void);
+ cPig(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cPig)
diff --git a/src/Mobs/Sheep.cpp b/src/Mobs/Sheep.cpp
index cbb33cb90..06bec9dc8 100644
--- a/src/Mobs/Sheep.cpp
+++ b/src/Mobs/Sheep.cpp
@@ -11,8 +11,8 @@
-cSheep::cSheep(int a_Color) :
- super("Sheep", mtSheep, "mob.sheep.say", "mob.sheep.say", 0.6, 1.3),
+cSheep::cSheep(CreateMonsterInfo a_Info, int a_Color) :
+ super(a_Info, "Sheep", mtSheep, "mob.sheep.say", "mob.sheep.say", 0.6, 1.3),
m_IsSheared(false),
m_WoolColor(a_Color),
m_TimeToStopEating(-1)
diff --git a/src/Mobs/Sheep.h b/src/Mobs/Sheep.h
index 28e1c7254..c0ef02162 100644
--- a/src/Mobs/Sheep.h
+++ b/src/Mobs/Sheep.h
@@ -18,7 +18,7 @@ public:
Use E_META_WOOL_* constants for the wool color.
If you type -1, the server will generate a random color
with the GenerateNaturalRandomColor() function. */
- cSheep(int a_Color = -1);
+ cSheep(CreateMonsterInfo a_Info, int a_Color = -1);
CLASS_PROTODEF(cSheep)
diff --git a/src/Mobs/Silverfish.h b/src/Mobs/Silverfish.h
index 2df333dbc..1a82fd22d 100644
--- a/src/Mobs/Silverfish.h
+++ b/src/Mobs/Silverfish.h
@@ -13,7 +13,7 @@ class cSilverfish :
typedef cAggressiveMonster super;
public:
- cSilverfish(void) :
+ cSilverfish(CreateMonsterInfo a_Info) :
super("Silverfish", mtSilverfish, "mob.silverfish.hit", "mob.silverfish.kill", 0.3, 0.7)
{
}
diff --git a/src/Mobs/Skeleton.cpp b/src/Mobs/Skeleton.cpp
index cd707f4bb..2267613b5 100644
--- a/src/Mobs/Skeleton.cpp
+++ b/src/Mobs/Skeleton.cpp
@@ -9,8 +9,8 @@
-cSkeleton::cSkeleton(bool IsWither) :
- super("Skeleton", mtSkeleton, "mob.skeleton.hurt", "mob.skeleton.death", 0.6, 1.8),
+cSkeleton::cSkeleton(CreateMonsterInfo a_Info, bool IsWither) :
+ super(a_Info, "Skeleton", mtSkeleton, "mob.skeleton.hurt", "mob.skeleton.death", 0.6, 1.8),
m_bIsWither(IsWither)
{
SetBurnsInDaylight(true);
diff --git a/src/Mobs/Skeleton.h b/src/Mobs/Skeleton.h
index 577588b32..519ae0b52 100644
--- a/src/Mobs/Skeleton.h
+++ b/src/Mobs/Skeleton.h
@@ -13,7 +13,7 @@ class cSkeleton :
typedef cAggressiveMonster super;
public:
- cSkeleton(bool IsWither);
+ cSkeleton(CreateMonsterInfo a_Info, bool IsWither);
CLASS_PROTODEF(cSkeleton)
diff --git a/src/Mobs/Slime.cpp b/src/Mobs/Slime.cpp
index b709ec664..bfdee64c8 100644
--- a/src/Mobs/Slime.cpp
+++ b/src/Mobs/Slime.cpp
@@ -9,8 +9,9 @@
-cSlime::cSlime(int a_Size) :
- super("Slime",
+cSlime::cSlime(CreateMonsterInfo a_Info, int a_Size) :
+ super(a_Info,
+ "Slime",
mtSlime,
Printf("mob.slime.%s", GetSizeName(a_Size).c_str()),
Printf("mob.slime.%s", GetSizeName(a_Size).c_str()),
diff --git a/src/Mobs/Slime.h b/src/Mobs/Slime.h
index f0b800f94..0671f1b4d 100644
--- a/src/Mobs/Slime.h
+++ b/src/Mobs/Slime.h
@@ -14,7 +14,7 @@ class cSlime :
public:
/** Creates a slime of the specified size; size can be 1, 2 or 4, with 1 is the smallest and 4 is the tallest. */
- cSlime(int a_Size);
+ cSlime(CreateMonsterInfo a_Info, int a_Size);
CLASS_PROTODEF(cSlime)
diff --git a/src/Mobs/SnowGolem.cpp b/src/Mobs/SnowGolem.cpp
index 76334d970..a17965765 100644
--- a/src/Mobs/SnowGolem.cpp
+++ b/src/Mobs/SnowGolem.cpp
@@ -8,8 +8,8 @@
-cSnowGolem::cSnowGolem(void) :
- super("SnowGolem", mtSnowGolem, "", "", 0.4, 1.8)
+cSnowGolem::cSnowGolem(CreateMonsterInfo a_Info) :
+ super(a_Info, "SnowGolem", mtSnowGolem, "", "", 0.4, 1.8)
{
}
diff --git a/src/Mobs/SnowGolem.h b/src/Mobs/SnowGolem.h
index aba89e52d..8d09e8816 100644
--- a/src/Mobs/SnowGolem.h
+++ b/src/Mobs/SnowGolem.h
@@ -13,7 +13,7 @@ class cSnowGolem :
typedef cAggressiveMonster super;
public:
- cSnowGolem(void);
+ cSnowGolem(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cSnowGolem)
diff --git a/src/Mobs/Spider.cpp b/src/Mobs/Spider.cpp
index 8b978ff6b..7840214c9 100644
--- a/src/Mobs/Spider.cpp
+++ b/src/Mobs/Spider.cpp
@@ -7,8 +7,8 @@
-cSpider::cSpider(void) :
- super("Spider", mtSpider, "mob.spider.say", "mob.spider.death", 1.4, 0.9)
+cSpider::cSpider(CreateMonsterInfo a_Info) :
+ super(a_Info, "Spider", mtSpider, "mob.spider.say", "mob.spider.death", 1.4, 0.9)
{
}
diff --git a/src/Mobs/Spider.h b/src/Mobs/Spider.h
index 813d2e266..f9c12a662 100644
--- a/src/Mobs/Spider.h
+++ b/src/Mobs/Spider.h
@@ -13,7 +13,7 @@ class cSpider :
typedef cAggressiveMonster super;
public:
- cSpider(void);
+ cSpider(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cSpider)
diff --git a/src/Mobs/Squid.cpp b/src/Mobs/Squid.cpp
index bd0e141a0..3f757d617 100644
--- a/src/Mobs/Squid.cpp
+++ b/src/Mobs/Squid.cpp
@@ -9,8 +9,8 @@
-cSquid::cSquid(void) :
- super("Squid", mtSquid, "", "", 0.95, 0.95)
+cSquid::cSquid(CreateMonsterInfo a_Info) :
+ super(a_Info, "Squid", mtSquid, "", "", 0.95, 0.95)
{
}
diff --git a/src/Mobs/Squid.h b/src/Mobs/Squid.h
index b57340427..7ddbe2dea 100644
--- a/src/Mobs/Squid.h
+++ b/src/Mobs/Squid.h
@@ -13,7 +13,7 @@ class cSquid :
typedef cPassiveMonster super;
public:
- cSquid();
+ cSquid(CreateMonsterInfo a_Info);
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp
index 781816c75..5b9c1d1b4 100644
--- a/src/Mobs/Villager.cpp
+++ b/src/Mobs/Villager.cpp
@@ -11,8 +11,8 @@
-cVillager::cVillager(eVillagerType VillagerType) :
- super("Villager", mtVillager, "", "", 0.6, 1.8),
+cVillager::cVillager(CreateMonsterInfo a_Info, eVillagerType VillagerType) :
+ super(a_Info, "Villager", mtVillager, "", "", 0.6, 1.8),
m_ActionCountDown(-1),
m_Type(VillagerType),
m_VillagerAction(false)
diff --git a/src/Mobs/Villager.h b/src/Mobs/Villager.h
index d3a38dbf0..8f23f87f1 100644
--- a/src/Mobs/Villager.h
+++ b/src/Mobs/Villager.h
@@ -25,7 +25,7 @@ public:
vtMax
} ;
- cVillager(eVillagerType VillagerType);
+ cVillager(CreateMonsterInfo a_Info, eVillagerType VillagerType);
CLASS_PROTODEF(cVillager)
diff --git a/src/Mobs/Witch.cpp b/src/Mobs/Witch.cpp
index 6956f7b7a..cfce7a094 100644
--- a/src/Mobs/Witch.cpp
+++ b/src/Mobs/Witch.cpp
@@ -7,8 +7,8 @@
-cWitch::cWitch(void) :
- super("Witch", mtWitch, "", "", 0.6, 1.8)
+cWitch::cWitch(CreateMonsterInfo a_Info) :
+ super(a_Info, "Witch", mtWitch, "", "", 0.6, 1.8)
{
}
diff --git a/src/Mobs/Witch.h b/src/Mobs/Witch.h
index bd059f61d..884dc94c6 100644
--- a/src/Mobs/Witch.h
+++ b/src/Mobs/Witch.h
@@ -14,7 +14,7 @@ class cWitch :
typedef cAggressiveMonster super;
public:
- cWitch();
+ cWitch(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cWitch)
diff --git a/src/Mobs/Wither.cpp b/src/Mobs/Wither.cpp
index 578b47995..c3ac78220 100644
--- a/src/Mobs/Wither.cpp
+++ b/src/Mobs/Wither.cpp
@@ -10,8 +10,8 @@
-cWither::cWither(void) :
- super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0),
+cWither::cWither(CreateMonsterInfo a_Info) :
+ super(a_Info, "Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0),
m_WitherInvulnerableTicks(220)
{
SetMaxHealth(300);
diff --git a/src/Mobs/Wither.h b/src/Mobs/Wither.h
index 2403823ed..2b5b21633 100644
--- a/src/Mobs/Wither.h
+++ b/src/Mobs/Wither.h
@@ -13,7 +13,7 @@ class cWither :
typedef cAggressiveMonster super;
public:
- cWither(void);
+ cWither(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cWither)
diff --git a/src/Mobs/Wolf.cpp b/src/Mobs/Wolf.cpp
index 4fe1ff1d6..94d516841 100644
--- a/src/Mobs/Wolf.cpp
+++ b/src/Mobs/Wolf.cpp
@@ -10,8 +10,8 @@
-cWolf::cWolf(void) :
- super("Wolf", mtWolf, "mob.wolf.hurt", "mob.wolf.death", 0.6, 0.8),
+cWolf::cWolf(CreateMonsterInfo a_Info) :
+ super(a_Info, "Wolf", mtWolf, "mob.wolf.hurt", "mob.wolf.death", 0.6, 0.8),
m_IsSitting(false),
m_IsTame(false),
m_IsBegging(false),
@@ -232,7 +232,7 @@ void cWolf::TickFollowPlayer()
if (Distance > 30)
{
Callback.OwnerPos.y = FindFirstNonAirBlockPosition(Callback.OwnerPos.x, Callback.OwnerPos.z);
- TeleportToCoords(Callback.OwnerPos.x, Callback.OwnerPos.y, Callback.OwnerPos.z);
+ SetPosition(Callback.OwnerPos);
}
else
{
diff --git a/src/Mobs/Wolf.h b/src/Mobs/Wolf.h
index 7500854f8..f2aa7094b 100644
--- a/src/Mobs/Wolf.h
+++ b/src/Mobs/Wolf.h
@@ -14,7 +14,7 @@ class cWolf :
typedef cPassiveAggressiveMonster super;
public:
- cWolf(void);
+ cWolf(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cWolf)
diff --git a/src/Mobs/Zombie.cpp b/src/Mobs/Zombie.cpp
index 30225c32d..0d7f123d3 100644
--- a/src/Mobs/Zombie.cpp
+++ b/src/Mobs/Zombie.cpp
@@ -9,8 +9,8 @@
-cZombie::cZombie(bool a_IsVillagerZombie) :
- super("Zombie", mtZombie, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8),
+cZombie::cZombie(CreateMonsterInfo a_Info, bool a_IsVillagerZombie) :
+ super(a_Info, "Zombie", mtZombie, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8),
m_IsVillagerZombie(a_IsVillagerZombie),
m_IsConverting(false)
{
diff --git a/src/Mobs/Zombie.h b/src/Mobs/Zombie.h
index 118b6e6e7..b0a0361f4 100644
--- a/src/Mobs/Zombie.h
+++ b/src/Mobs/Zombie.h
@@ -12,7 +12,7 @@ class cZombie :
typedef cAggressiveMonster super;
public:
- cZombie(bool a_IsVillagerZombie);
+ cZombie(CreateMonsterInfo a_Info, bool a_IsVillagerZombie);
CLASS_PROTODEF(cZombie)
diff --git a/src/Mobs/ZombiePigman.cpp b/src/Mobs/ZombiePigman.cpp
index 05350f877..5a6f78918 100644
--- a/src/Mobs/ZombiePigman.cpp
+++ b/src/Mobs/ZombiePigman.cpp
@@ -7,8 +7,8 @@
-cZombiePigman::cZombiePigman(void) :
- super("ZombiePigman", mtZombiePigman, "mob.zombiepig.zpighurt", "mob.zombiepig.zpigdeath", 0.6, 1.8)
+cZombiePigman::cZombiePigman(CreateMonsterInfo a_Info) :
+ super(a_Info, "ZombiePigman", mtZombiePigman, "mob.zombiepig.zpighurt", "mob.zombiepig.zpigdeath", 0.6, 1.8)
{
}
diff --git a/src/Mobs/ZombiePigman.h b/src/Mobs/ZombiePigman.h
index bae0115eb..e21f2012e 100644
--- a/src/Mobs/ZombiePigman.h
+++ b/src/Mobs/ZombiePigman.h
@@ -12,7 +12,7 @@ class cZombiePigman :
typedef cPassiveAggressiveMonster super;
public:
- cZombiePigman(void);
+ cZombiePigman(CreateMonsterInfo a_Info);
CLASS_PROTODEF(cZombiePigman)
diff --git a/src/MonsterConfig.cpp b/src/MonsterConfig.cpp
index f5e078213..f31aef9f6 100644
--- a/src/MonsterConfig.cpp
+++ b/src/MonsterConfig.cpp
@@ -9,33 +9,8 @@
-struct cMonsterConfig::sAttributesStruct
-{
- AString m_Name;
- int m_SightDistance;
- int m_AttackDamage;
- int m_AttackRange;
- double m_AttackRate;
- int m_MaxHealth;
- bool m_IsFireproof;
-};
-
-
-
-
-
-struct cMonsterConfig::sMonsterConfigState
-{
- AString MonsterTypes;
- std::list< sAttributesStruct > AttributesList;
-};
-
-
-
-
-
cMonsterConfig::cMonsterConfig(void)
- : m_pState( new sMonsterConfigState)
+ : m_pState(new sMonsterConfigState)
{
Initialize();
}
@@ -83,20 +58,22 @@ void cMonsterConfig::Initialize()
-void cMonsterConfig::AssignAttributes(cMonster * a_Monster, const AString & a_Name)
+cMonsterConfig::sReturnAttributes cMonsterConfig::ReturnAttributes(const AString & a_Name)
{
std::list<sAttributesStruct>::const_iterator itr;
for (itr = m_pState->AttributesList.begin(); itr != m_pState->AttributesList.end(); ++itr)
{
- if (itr->m_Name.compare(a_Name) == 0)
+ if (itr->m_Name == a_Name)
{
- a_Monster->SetAttackDamage (itr->m_AttackDamage);
- a_Monster->SetAttackRange (itr->m_AttackRange);
- a_Monster->SetSightDistance(itr->m_SightDistance);
- a_Monster->SetAttackRate ((float)itr->m_AttackRate);
- a_Monster->SetMaxHealth (itr->m_MaxHealth);
- a_Monster->SetIsFireproof (itr->m_IsFireproof);
- return;
+ cMonsterConfig::sReturnAttributes Attr {
+ itr->m_SightDistance,
+ itr->m_AttackDamage,
+ itr->m_AttackRange,
+ itr->m_AttackRate,
+ itr->m_MaxHealth,
+ itr->m_IsFireproof
+ };
+ return Attr;
}
} // for itr - m_pState->AttributesList[]
}
diff --git a/src/MonsterConfig.h b/src/MonsterConfig.h
index 371d324c2..122cd43fd 100644
--- a/src/MonsterConfig.h
+++ b/src/MonsterConfig.h
@@ -17,12 +17,37 @@ class cMonsterConfig
public:
cMonsterConfig(void);
~cMonsterConfig();
+
+ struct sReturnAttributes
+ {
+ int m_SightDistance;
+ int m_AttackDamage;
+ int m_AttackRange;
+ double m_AttackRate;
+ int m_MaxHealth;
+ bool m_IsFireproof;
+ };
- void AssignAttributes(cMonster * a_Monster, const AString & a_Name);
+ sReturnAttributes ReturnAttributes(const AString & a_Name);
private:
- struct sAttributesStruct;
- struct sMonsterConfigState;
+ struct sAttributesStruct
+ {
+ AString m_Name;
+ int m_SightDistance;
+ int m_AttackDamage;
+ int m_AttackRange;
+ double m_AttackRate;
+ int m_MaxHealth;
+ bool m_IsFireproof;
+ };
+
+ struct sMonsterConfigState
+ {
+ AString MonsterTypes;
+ std::list< sAttributesStruct > AttributesList;
+ };
+
sMonsterConfigState* m_pState;
void Initialize();
} ;
diff --git a/src/Simulator/FireSimulator.cpp b/src/Simulator/FireSimulator.cpp
index 7ae84af7b..388d45a04 100644
--- a/src/Simulator/FireSimulator.cpp
+++ b/src/Simulator/FireSimulator.cpp
@@ -71,7 +71,7 @@ cFireSimulator::cFireSimulator(cWorld & a_World, cIniFile & a_IniFile) :
{
// Read params from the ini file:
m_BurnStepTimeFuel = a_IniFile.GetValueSetI("FireSimulator", "BurnStepTimeFuel", 500);
- m_BurnStepTimeNonfuel = a_IniFile.GetValueSetI("FireSimulator", "BurnStepTimeNonfuel", 100);
+ m_BurnStepTimeNonFuel = a_IniFile.GetValueSetI("FireSimulator", "BurnStepTimeNonfuel", 100);
m_Flammability = a_IniFile.GetValueSetI("FireSimulator", "Flammability", 50);
m_ReplaceFuelChance = a_IniFile.GetValueSetI("FireSimulator", "ReplaceFuelChance", 50000);
}
@@ -98,7 +98,9 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun
int x = itr->x;
int y = itr->y;
int z = itr->z;
- BLOCKTYPE BlockType = a_Chunk->GetBlock(x, y, z);
+ BLOCKTYPE BlockType;
+ NIBBLETYPE BlockMeta;
+ a_Chunk->GetBlockTypeMeta(x, y, z, BlockType, BlockMeta);
if (!IsAllowedBlock(BlockType))
{
@@ -113,6 +115,16 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun
// Try to spread the fire:
TrySpreadFire(a_Chunk, itr->x, itr->y, itr->z);
+ BLOCKTYPE BlockBelow = E_BLOCK_AIR;
+ if (y > 0)
+ {
+ BlockBelow = a_Chunk->GetBlock(x, y - 1, z);
+ if (DoesBurnForever(BlockBelow))
+ {
+ continue;
+ }
+ }
+
itr->Data -= NumMSecs;
if (itr->Data >= 0)
{
@@ -127,7 +139,6 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun
itr->x + a_ChunkX * cChunkDef::Width, itr->y, itr->z + a_ChunkZ * cChunkDef::Width
);
*/
- NIBBLETYPE BlockMeta = a_Chunk->GetMeta(x, y, z);
if (BlockMeta == 0x0f)
{
// The fire burnt out completely
@@ -140,11 +151,26 @@ void cFireSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, cChun
continue;
}
- if ((itr->y > 0) && (!DoesBurnForever(a_Chunk->GetBlock(itr->x, itr->y - 1, itr->z))))
+ int NextCheck = GetBurnStepTime(a_Chunk, BlockBelow, x, y, z);
+ if (NextCheck == 0)
{
- a_Chunk->SetMeta(x, y, z, BlockMeta + 1);
+ /*
+ A return value of zero means the fire block can't exist here
+ The fire block's CanBeAt() doesn't check for this because fire can exist depending on its surroundings,
+ and since we're checking that here, we might as well amalgamate all checks
+ */
+ FLOG("FS: Removing block {%d, %d, %d}",
+ itr->x + a_ChunkX * cChunkDef::Width, itr->y, itr->z + a_ChunkZ * cChunkDef::Width
+ );
+ a_Chunk->SetBlock(itr->x, itr->y, itr->z, E_BLOCK_AIR, 0);
+ itr = Data.erase(itr);
+ continue;
}
- itr->Data = GetBurnStepTime(a_Chunk, itr->x, itr->y, itr->z); // TODO: Add some randomness into this
+
+ a_Chunk->SetMeta(x, y, z, BlockMeta + 1);
+ x = x + a_Chunk->GetPosX() * cChunkDef::Width;
+ z = z + a_Chunk->GetPosZ() * cChunkDef::Width;
+ itr->Data = (NextCheck / ((m_World.IsWeatherWetAt(x, z) && (a_Chunk->GetHeight(x, z) == y)) ? 10 : 1)) + (m_World.GetTickRandomNumber(40) - 20);
} // for itr - Data[]
}
@@ -252,22 +278,11 @@ void cFireSimulator::AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk *
-int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ)
+int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, BLOCKTYPE a_BlockBelow, int a_RelX, int a_RelY, int a_RelZ)
{
- bool IsBlockBelowSolid = false;
- if (a_RelY > 0)
+ if (IsFuel(a_BlockBelow))
{
- BLOCKTYPE BlockBelow = a_Chunk->GetBlock(a_RelX, a_RelY - 1, a_RelZ);
- if (DoesBurnForever(BlockBelow))
- {
- // Is burning atop of netherrack, burn forever (re-check in 10 sec)
- return 10000;
- }
- if (IsFuel(BlockBelow))
- {
- return m_BurnStepTimeFuel;
- }
- IsBlockBelowSolid = cBlockInfo::IsSolid(BlockBelow);
+ return m_BurnStepTimeFuel;
}
for (size_t i = 0; i < ARRAYCOUNT(gCrossCoords); i++)
@@ -283,15 +298,14 @@ int cFireSimulator::GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, in
}
} // for i - gCrossCoords[]
- if (!IsBlockBelowSolid && (a_RelY >= 0))
+ if (!cBlockInfo::IsSolid(a_BlockBelow))
{
// Checked through everything, nothing was flammable
// If block below isn't solid, we can't have fire, it would be a non-fueled fire
- // SetBlock just to make sure fire doesn't spawn
- a_Chunk->SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
+ // Return zero to tell our caller to kill us
return 0;
}
- return m_BurnStepTimeNonfuel;
+ return m_BurnStepTimeNonFuel;
}
diff --git a/src/Simulator/FireSimulator.h b/src/Simulator/FireSimulator.h
index f76dbe342..df01bfc70 100644
--- a/src/Simulator/FireSimulator.h
+++ b/src/Simulator/FireSimulator.h
@@ -35,7 +35,7 @@ protected:
unsigned m_BurnStepTimeFuel;
/// Time (in msec) that a fire block takes to burn without a fuel block into the next step
- unsigned m_BurnStepTimeNonfuel;
+ unsigned m_BurnStepTimeNonFuel;
/// Chance [0..100000] of an adjacent fuel to catch fire on each tick
int m_Flammability;
@@ -47,7 +47,7 @@ protected:
virtual void AddBlock(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk * a_Chunk) override;
/// Returns the time [msec] after which the specified fire block is stepped again; based on surrounding fuels
- int GetBurnStepTime(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
+ int GetBurnStepTime(cChunk * a_Chunk, BLOCKTYPE BlockBelow, int a_RelX, int a_RelY, int a_RelZ);
/// Tries to spread fire to a neighborhood of the specified block
void TrySpreadFire(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ);
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 28b9dd042..c04ed91e6 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -617,7 +617,7 @@ void cNBTChunkSerializer::AddPickupEntity(cPickup * a_Pickup)
m_Writer.BeginCompound("");
AddBasicEntity(a_Pickup, "Item");
AddItem(a_Pickup->GetItem(), -1, "Item");
- m_Writer.AddShort("Age", (Int16)a_Pickup->GetAge());
+ m_Writer.AddShort("Age", (Int16)a_Pickup->GetTicksAlive());
m_Writer.EndCompound();
}
@@ -725,7 +725,7 @@ void cNBTChunkSerializer::AddExpOrbEntity(cExpOrb * a_ExpOrb)
{
m_Writer.BeginCompound("");
AddBasicEntity(a_ExpOrb, "XPOrb");
- m_Writer.AddShort("Age", (Int16)a_ExpOrb->GetAge());
+ m_Writer.AddShort("Age", (Int16)a_ExpOrb->GetTicksAlive());
m_Writer.AddShort("Value", (Int16)a_ExpOrb->GetReward());
m_Writer.EndCompound();
}
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index 092b9514c..692f0cf5e 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -1222,23 +1222,6 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a
{
LoadFallingBlockFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
}
- else if (strncmp(a_IDTag, "Minecart", a_IDTagLength) == 0)
- {
- // It is a minecart, old style, find out the type:
- int TypeTag = a_NBT.FindChildByName(a_EntityTagIdx, "Type");
- if ((TypeTag < 0) || (a_NBT.GetType(TypeTag) != TAG_Int))
- {
- return;
- }
- switch (a_NBT.GetInt(TypeTag))
- {
- case 0: LoadMinecartRFromNBT(a_Entities, a_NBT, a_EntityTagIdx); break; // Rideable minecart
- case 1: LoadMinecartCFromNBT(a_Entities, a_NBT, a_EntityTagIdx); break; // Minecart with chest
- case 2: LoadMinecartFFromNBT(a_Entities, a_NBT, a_EntityTagIdx); break; // Minecart with furnace
- case 3: LoadMinecartTFromNBT(a_Entities, a_NBT, a_EntityTagIdx); break; // Minecart with TNT
- case 4: LoadMinecartHFromNBT(a_Entities, a_NBT, a_EntityTagIdx); break; // Minecart with Hopper
- }
- }
else if (strncmp(a_IDTag, "MinecartRideable", a_IDTagLength) == 0)
{
LoadMinecartRFromNBT(a_Entities, a_NBT, a_EntityTagIdx);
@@ -1428,11 +1411,13 @@ void cWSSAnvil::LoadEntityFromNBT(cEntityList & a_Entities, const cParsedNBT & a
void cWSSAnvil::LoadBoatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cBoat> Boat(new cBoat(0, 0, 0));
- if (!LoadEntityBaseFromNBT(*Boat.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+
+ std::auto_ptr<cBoat> Boat(new cBoat(Info));
a_Entities.push_back(Boat.release());
}
@@ -1442,11 +1427,13 @@ void cWSSAnvil::LoadBoatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N
void cWSSAnvil::LoadEnderCrystalFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cEnderCrystal> EnderCrystal(new cEnderCrystal(0, 0, 0));
- if (!LoadEntityBaseFromNBT(*EnderCrystal.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+
+ std::auto_ptr<cEnderCrystal> EnderCrystal(new cEnderCrystal(Info));
a_Entities.push_back(EnderCrystal.release());
}
@@ -1464,11 +1451,13 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN
int Type = a_NBT.GetInt(TypeIdx);
NIBBLETYPE Meta = (NIBBLETYPE)a_NBT.GetByte(MetaIdx);
- std::auto_ptr<cFallingBlock> FallingBlock(new cFallingBlock(Vector3i(0, 0, 0), Type, Meta));
- if (!LoadEntityBaseFromNBT(*FallingBlock.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+
+ std::auto_ptr<cFallingBlock> FallingBlock(new cFallingBlock(Info, Type, Meta));
a_Entities.push_back(FallingBlock.release());
}
@@ -1478,11 +1467,13 @@ void cWSSAnvil::LoadFallingBlockFromNBT(cEntityList & a_Entities, const cParsedN
void cWSSAnvil::LoadMinecartRFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cRideableMinecart> Minecart(new cRideableMinecart(0, 0, 0, cItem(), 1)); // TODO: Load the block and the height
- if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+
+ std::auto_ptr<cRideableMinecart> Minecart(new cRideableMinecart(Info, cItem(), 1)); // TODO: Load the block and the height
a_Entities.push_back(Minecart.release());
}
@@ -1497,11 +1488,14 @@ void cWSSAnvil::LoadMinecartCFromNBT(cEntityList & a_Entities, const cParsedNBT
{
return; // Make it an empty chest - the chunk loader will provide an empty cChestEntity for this
}
- std::auto_ptr<cMinecartWithChest> Minecart(new cMinecartWithChest(0, 0, 0));
- if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx))
+
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cMinecartWithChest> Minecart(new cMinecartWithChest(Info));
+
for (int Child = a_NBT.GetFirstChild(Items); Child != -1; Child = a_NBT.GetNextSibling(Child))
{
int Slot = a_NBT.FindChildByName(Child, "Slot");
@@ -1524,11 +1518,13 @@ void cWSSAnvil::LoadMinecartCFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadMinecartFFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cMinecartWithFurnace> Minecart(new cMinecartWithFurnace(0, 0, 0));
- if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+
+ std::auto_ptr<cMinecartWithFurnace> Minecart(new cMinecartWithFurnace(Info));
// TODO: Load the Push and Fuel tags
@@ -1541,11 +1537,13 @@ void cWSSAnvil::LoadMinecartFFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadMinecartTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cMinecartWithTNT> Minecart(new cMinecartWithTNT(0, 0, 0));
- if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+
+ std::auto_ptr<cMinecartWithTNT> Minecart(new cMinecartWithTNT(Info));
// TODO: Everything to do with TNT carts
@@ -1558,11 +1556,13 @@ void cWSSAnvil::LoadMinecartTFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadMinecartHFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cMinecartWithHopper> Minecart(new cMinecartWithHopper(0, 0, 0));
- if (!LoadEntityBaseFromNBT(*Minecart.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+
+ std::auto_ptr<cMinecartWithHopper> Minecart(new cMinecartWithHopper(Info));
// TODO: Everything to do with hopper carts
@@ -1587,17 +1587,18 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a
return;
}
- std::auto_ptr<cPickup> Pickup(new cPickup(0, 0, 0, Item, false)); // Pickup delay doesn't matter, just say false
- if (!LoadEntityBaseFromNBT(*Pickup.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cPickup> Pickup(new cPickup(Info, Item, false)); // Pickup delay doesn't matter, just say false
// Load age:
int Age = a_NBT.FindChildByName(a_TagIdx, "Age");
if (Age > 0)
{
- Pickup->SetAge(a_NBT.GetShort(Age));
+ Pickup->SetTicksAlive(a_NBT.GetShort(Age));
}
a_Entities.push_back(Pickup.release());
@@ -1609,11 +1610,12 @@ void cWSSAnvil::LoadPickupFromNBT(cEntityList & a_Entities, const cParsedNBT & a
void cWSSAnvil::LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cTNTEntity> TNT(new cTNTEntity(0.0, 0.0, 0.0, 0));
- if (!LoadEntityBaseFromNBT(*TNT.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cTNTEntity> TNT(new cTNTEntity(Info));
// Load Fuse Ticks:
int FuseTicks = a_NBT.FindChildByName(a_TagIdx, "Fuse");
@@ -1631,24 +1633,26 @@ void cWSSAnvil::LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
void cWSSAnvil::LoadExpOrbFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cExpOrb> ExpOrb(new cExpOrb(0.0, 0.0, 0.0, 0));
- if (!LoadEntityBaseFromNBT(*ExpOrb.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
- // Load Age:
- int Age = a_NBT.FindChildByName(a_TagIdx, "Age");
- if (Age > 0)
+ // Load Reward (Value):
+ int Reward = a_NBT.FindChildByName(a_TagIdx, "Value");
+ if (Reward <= 0)
{
- ExpOrb->SetAge(a_NBT.GetShort(Age));
+ return;
}
- // Load Reward (Value):
- int Reward = a_NBT.FindChildByName(a_TagIdx, "Value");
- if (Reward > 0)
+ std::auto_ptr<cExpOrb> ExpOrb(new cExpOrb(Info, a_NBT.GetShort(Reward)));
+
+ // Load Age:
+ int Age = a_NBT.FindChildByName(a_TagIdx, "Age");
+ if (Age > 0)
{
- ExpOrb->SetReward(a_NBT.GetShort(Reward));
+ ExpOrb->SetTicksAlive(a_NBT.GetShort(Age));
}
a_Entities.push_back(ExpOrb.release());
@@ -1719,11 +1723,12 @@ void cWSSAnvil::LoadItemFrameFromNBT(cEntityList & a_Entities, const cParsedNBT
return;
}
- std::auto_ptr<cItemFrame> ItemFrame(new cItemFrame(BLOCK_FACE_NONE, 0.0, 0.0, 0.0));
- if (!LoadEntityBaseFromNBT(*ItemFrame.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cItemFrame> ItemFrame(new cItemFrame(BLOCK_FACE_NONE, Info));
ItemFrame->SetItem(Item);
LoadHangingFromNBT(*ItemFrame.get(), a_NBT, a_TagIdx);
@@ -1744,11 +1749,14 @@ void cWSSAnvil::LoadItemFrameFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadArrowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cArrowEntity> Arrow(new cArrowEntity(NULL, 0, 0, 0, Vector3d(0, 0, 0)));
- if (!LoadProjectileBaseFromNBT(*Arrow.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ bool InGround;
+ if (!LoadProjectileBaseFromNBT(Info, a_NBT, a_TagIdx, InGround))
{
return;
}
+ std::auto_ptr<cArrowEntity> Arrow(new cArrowEntity(Info, NULL));
+ Arrow->SetIsInGround(InGround);
// Load pickup state:
int PickupIdx = a_NBT.FindChildByName(a_TagIdx, "pickup");
@@ -1808,11 +1816,14 @@ 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), cItem()));
- if (!LoadProjectileBaseFromNBT(*SplashPotion.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ bool InGround;
+ if (!LoadProjectileBaseFromNBT(Info, a_NBT, a_TagIdx, InGround))
{
return;
}
+ std::auto_ptr<cSplashPotionEntity> SplashPotion(new cSplashPotionEntity(Info, NULL, cItem()));
+ SplashPotion->SetIsInGround(InGround);
int EffectDuration = a_NBT.FindChildByName(a_TagIdx, "EffectDuration");
int EffectIntensity = a_NBT.FindChildByName(a_TagIdx, "EffectIntensity");
@@ -1832,11 +1843,12 @@ void cWSSAnvil::LoadSplashPotionFromNBT(cEntityList & a_Entities, const cParsedN
void cWSSAnvil::LoadSnowballFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cThrownSnowballEntity> Snowball(new cThrownSnowballEntity(NULL, 0, 0, 0, Vector3d(0, 0, 0)));
- if (!LoadProjectileBaseFromNBT(*Snowball.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadProjectileBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cThrownSnowballEntity> Snowball(new cThrownSnowballEntity(Info, NULL));
// Store the new snowball in the entities list:
a_Entities.push_back(Snowball.release());
@@ -1848,11 +1860,12 @@ void cWSSAnvil::LoadSnowballFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadEggFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cThrownEggEntity> Egg(new cThrownEggEntity(NULL, 0, 0, 0, Vector3d(0, 0, 0)));
- if (!LoadProjectileBaseFromNBT(*Egg.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadProjectileBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cThrownEggEntity> Egg(new cThrownEggEntity(Info, NULL));
// Store the new egg in the entities list:
a_Entities.push_back(Egg.release());
@@ -1864,11 +1877,12 @@ void cWSSAnvil::LoadEggFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
void cWSSAnvil::LoadFireballFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cGhastFireballEntity> Fireball(new cGhastFireballEntity(NULL, 0, 0, 0, Vector3d(0, 0, 0)));
- if (!LoadProjectileBaseFromNBT(*Fireball.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadProjectileBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cGhastFireballEntity> Fireball(new cGhastFireballEntity(Info, NULL));
// Store the new fireball in the entities list:
a_Entities.push_back(Fireball.release());
@@ -1880,11 +1894,12 @@ void cWSSAnvil::LoadFireballFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadFireChargeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cFireChargeEntity> FireCharge(new cFireChargeEntity(NULL, 0, 0, 0, Vector3d(0, 0, 0)));
- if (!LoadProjectileBaseFromNBT(*FireCharge.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadProjectileBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cFireChargeEntity> FireCharge(new cFireChargeEntity(Info, NULL));
// Store the new FireCharge in the entities list:
a_Entities.push_back(FireCharge.release());
@@ -1896,11 +1911,12 @@ void cWSSAnvil::LoadFireChargeFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadThrownEnderpearlFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cThrownEnderPearlEntity> Enderpearl(new cThrownEnderPearlEntity(NULL, 0, 0, 0, Vector3d(0, 0, 0)));
- if (!LoadProjectileBaseFromNBT(*Enderpearl.get(), a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadProjectileBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cThrownEnderPearlEntity> Enderpearl(new cThrownEnderPearlEntity(Info, NULL));
// Store the new enderpearl in the entities list:
a_Entities.push_back(Enderpearl.release());
@@ -1912,17 +1928,18 @@ void cWSSAnvil::LoadThrownEnderpearlFromNBT(cEntityList & a_Entities, const cPar
void cWSSAnvil::LoadBatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cBat> Monster(new cBat());
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cBat::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cBat> Monster(new cBat(Info));
a_Entities.push_back(Monster.release());
}
@@ -1932,17 +1949,18 @@ void cWSSAnvil::LoadBatFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
void cWSSAnvil::LoadBlazeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cBlaze> Monster(new cBlaze());
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cBlaze::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
-
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cBlaze> Monster(new cBlaze(Info));
a_Entities.push_back(Monster.release());
}
@@ -1952,17 +1970,18 @@ void cWSSAnvil::LoadBlazeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadCaveSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cCaveSpider> Monster(new cCaveSpider());
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cCaveSpider::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
-
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cCaveSpider> Monster(new cCaveSpider(Info));
a_Entities.push_back(Monster.release());
}
@@ -1972,17 +1991,18 @@ void cWSSAnvil::LoadCaveSpiderFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadChickenFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cChicken> Monster(new cChicken());
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cChicken::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
-
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cChicken> Monster(new cChicken(Info));
a_Entities.push_back(Monster.release());
}
@@ -1992,17 +2012,18 @@ void cWSSAnvil::LoadChickenFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadCowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cCow> Monster(new cCow());
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cCow::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
-
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cCow> Monster(new cCow(Info));
a_Entities.push_back(Monster.release());
}
@@ -2012,17 +2033,18 @@ void cWSSAnvil::LoadCowFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
void cWSSAnvil::LoadCreeperFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cCreeper> Monster(new cCreeper());
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cCreeper::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
-
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cCreeper> Monster(new cCreeper(Info));
a_Entities.push_back(Monster.release());
}
@@ -2032,17 +2054,18 @@ void cWSSAnvil::LoadCreeperFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadEnderDragonFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cEnderDragon> Monster(new cEnderDragon());
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cEnderDragon::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
-
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cEnderDragon> Monster(new cEnderDragon(Info));
a_Entities.push_back(Monster.release());
}
@@ -2052,17 +2075,18 @@ void cWSSAnvil::LoadEnderDragonFromNBT(cEntityList & a_Entities, const cParsedNB
void cWSSAnvil::LoadEndermanFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cEnderman> Monster(new cEnderman());
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cEnderman::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cEnderman> Monster(new cEnderman(Info));
a_Entities.push_back(Monster.release());
}
@@ -2072,17 +2096,18 @@ void cWSSAnvil::LoadEndermanFromNBT(cEntityList & a_Entities, const cParsedNBT &
void cWSSAnvil::LoadGhastFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cGhast> Monster(new cGhast());
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cGhast::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cGhast> Monster(new cGhast(Info));
a_Entities.push_back(Monster.release());
}
@@ -2092,17 +2117,18 @@ void cWSSAnvil::LoadGhastFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadGiantFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cGiant> Monster(new cGiant());
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cGiant::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
-
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cGiant> Monster(new cGiant(Info));
a_Entities.push_back(Monster.release());
}
@@ -2122,18 +2148,18 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
int Color = a_NBT.GetInt(ColorIdx);
int Style = a_NBT.GetInt(StyleIdx);
- std::auto_ptr<cHorse> Monster(new cHorse(Type, Color, Style, 1));
-
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cHorse::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
-
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cHorse> Monster(new cHorse(Info, Type, Color, Style, 1));
a_Entities.push_back(Monster.release());
}
@@ -2143,17 +2169,18 @@ void cWSSAnvil::LoadHorseFromNBT(cEntityList & a_Entities, const cParsedNBT & a_
void cWSSAnvil::LoadIronGolemFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cIronGolem> Monster(new cIronGolem());
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cIronGolem::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
-
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cIronGolem> Monster(new cIronGolem(Info));
a_Entities.push_back(Monster.release());
}
@@ -2164,25 +2191,24 @@ void cWSSAnvil::LoadIronGolemFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadMagmaCubeFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
int SizeIdx = a_NBT.FindChildByName(a_TagIdx, "Size");
-
if (SizeIdx < 0)
{
return;
}
-
int Size = a_NBT.GetInt(SizeIdx);
- std::auto_ptr<cMagmaCube> Monster(new cMagmaCube(Size));
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cMagmaCube::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
-
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cMagmaCube> Monster(new cMagmaCube(Size));
a_Entities.push_back(Monster.release());
}
@@ -2192,17 +2218,18 @@ void cWSSAnvil::LoadMagmaCubeFromNBT(cEntityList & a_Entities, const cParsedNBT
void cWSSAnvil::LoadMooshroomFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NBT, int a_TagIdx)
{
- std::auto_ptr<cMooshroom> Monster(new cMooshroom());
- if (!LoadEntityBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+ CreateMonsterInfo Info(cMooshroom::GetClassStatic());
+ if (!LoadEntityBaseFromNBT(Info.EntityInfo, a_NBT, a_TagIdx))
{
return;
}
-
- if (!LoadMonsterBaseFromNBT(*Monster.get(), a_NBT, a_TagIdx))
+
+ if (!LoadMonsterBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return;
}
+ std::auto_ptr<cMooshroom> Monster(new cMooshroom(Info));
a_Entities.push_back(Monster.release());
}
@@ -2647,14 +2674,14 @@ void cWSSAnvil::LoadWolfOwner(cWolf & a_Wolf, const cParsedNBT & a_NBT, int a_Ta
-bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_NBT, int a_TagIdx)
+bool cWSSAnvil::LoadEntityBaseFromNBT(CreateEntityInfo & a_EntityInfo, const cParsedNBT & a_NBT, int a_TagIdx)
{
double Pos[3];
if (!LoadDoublesListFromNBT(Pos, 3, a_NBT, a_NBT.FindChildByName(a_TagIdx, "Pos")))
{
return false;
}
- a_Entity.SetPosition(Pos[0], Pos[1], Pos[2]);
+ a_EntityInfo.Position = Vector3d(Pos[0], Pos[1], Pos[2]);
double Speed[3];
if (!LoadDoublesListFromNBT(Speed, 3, a_NBT, a_NBT.FindChildByName(a_TagIdx, "Motion")))
@@ -2664,7 +2691,7 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N
Speed[1] = 0;
Speed[2] = 0;
}
- a_Entity.SetSpeed(Speed[0], Speed[1], Speed[2]);
+ a_EntityInfo.Speed = Vector3d(Speed[0], Speed[1], Speed[2]);
double Rotation[3];
if (!LoadDoublesListFromNBT(Rotation, 2, a_NBT, a_NBT.FindChildByName(a_TagIdx, "Rotation")))
@@ -2673,12 +2700,12 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N
Rotation[0] = 0;
Rotation[1] = 0;
}
- a_Entity.SetYaw(Rotation[0]);
- a_Entity.SetRoll(Rotation[1]);
+ a_EntityInfo.Rotation.x = Rotation[0];
+ a_EntityInfo.Rotation.y = Rotation[1];
// Load health:
int Health = a_NBT.FindChildByName(a_TagIdx, "Health");
- a_Entity.SetHealth(Health > 0 ? a_NBT.GetShort(Health) : a_Entity.GetMaxHealth());
+ a_EntityInfo.Health= (Health > 0 ? a_NBT.GetShort(Health) : -1);
return true;
}
@@ -2687,37 +2714,37 @@ bool cWSSAnvil::LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_N
-bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT & a_NBT, int a_TagIdx)
+bool cWSSAnvil::LoadMonsterBaseFromNBT(CreateMonsterInfo a_MonsterInfo, const cParsedNBT & a_NBT, int a_TagIdx)
{
float DropChance[5];
if (!LoadFloatsListFromNBT(DropChance, 5, a_NBT, a_NBT.FindChildByName(a_TagIdx, "DropChances")))
{
return false;
}
- a_Monster.SetDropChanceWeapon(DropChance[0]);
- a_Monster.SetDropChanceHelmet(DropChance[1]);
- a_Monster.SetDropChanceChestplate(DropChance[2]);
- a_Monster.SetDropChanceLeggings(DropChance[3]);
- a_Monster.SetDropChanceBoots(DropChance[4]);
+ a_MonsterInfo.DropChanceWeapon = DropChance[0];
+ a_MonsterInfo.DropChanceHelmet = DropChance[1];
+ a_MonsterInfo.DropChanceChestplate = DropChance[2];
+ a_MonsterInfo.DropChanceLeggings = DropChance[3;;
+ a_MonsterInfo.DropChanceBoots = DropChance[4];
int LootTag = a_NBT.FindChildByName(a_TagIdx, "CanPickUpLoot");
if (LootTag > 0)
{
bool CanPickUpLoot = (a_NBT.GetByte(LootTag) == 1);
- a_Monster.SetCanPickUpLoot(CanPickUpLoot);
+ a_MonsterInfo.CanPickUpLoot = CanPickUpLoot;
}
int CustomNameTag = a_NBT.FindChildByName(a_TagIdx, "CustomName");
if ((CustomNameTag > 0) && (a_NBT.GetType(CustomNameTag) == TAG_String))
{
- a_Monster.SetCustomName(a_NBT.GetString(CustomNameTag));
+ a_MonsterInfo.CustomName = a_NBT.GetString(CustomNameTag);
}
int CustomNameVisibleTag = a_NBT.FindChildByName(a_TagIdx, "CustomNameVisible");
if ((CustomNameVisibleTag > 0) && (a_NBT.GetType(CustomNameVisibleTag) == TAG_Byte))
{
bool CustomNameVisible = (a_NBT.GetByte(CustomNameVisibleTag) == 1);
- a_Monster.SetCustomNameAlwaysVisible(CustomNameVisible);
+ a_MonsterInfo.CustomNameAlwaysVisible = CustomNameVisible;
}
return true;
@@ -2727,9 +2754,10 @@ bool cWSSAnvil::LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT &
-bool cWSSAnvil::LoadProjectileBaseFromNBT(cProjectileEntity & a_Entity, const cParsedNBT & a_NBT, int a_TagIdx)
+bool cWSSAnvil::LoadProjectileBaseFromNBT(CreateEntityInfo & a_EntityInfo, cProjectileEntity & a_Entity, const cParsedNBT & a_NBT, int a_TagIdx)
{
- if (!LoadEntityBaseFromNBT(a_Entity, a_NBT, a_TagIdx))
+ CreateEntityInfo Info;
+ if (!LoadEntityBaseFromNBT(Info, a_NBT, a_TagIdx))
{
return false;
}
diff --git a/src/WorldStorage/WSSAnvil.h b/src/WorldStorage/WSSAnvil.h
index 591ec6757..721242c52 100644
--- a/src/WorldStorage/WSSAnvil.h
+++ b/src/WorldStorage/WSSAnvil.h
@@ -213,13 +213,13 @@ protected:
void LoadWolfOwner(cWolf & a_Wolf, const cParsedNBT & a_NBT, int a_TagIdx);
/// Loads entity common data from the NBT compound; returns true if successful
- bool LoadEntityBaseFromNBT(cEntity & a_Entity, const cParsedNBT & a_NBT, int a_TagIdx);
+ bool LoadEntityBaseFromNBT(CreateEntityInfo & a_EntityInfo, const cParsedNBT & a_NBT, int a_TagIdx);
/// Loads monster common data from the NBT compound; returns true if successful
- bool LoadMonsterBaseFromNBT(cMonster & a_Monster, const cParsedNBT & a_NBT, int a_TagIdx);
+ bool LoadMonsterBaseFromNBT(CreateMonsterInfo a_MonsterInfo, const cParsedNBT & a_NBT, int a_TagIdx);
/// Loads projectile common data from the NBT compound; returns true if successful
- bool LoadProjectileBaseFromNBT(cProjectileEntity & a_Entity, const cParsedNBT & a_NBT, int a_TagIx);
+ bool LoadProjectileBaseFromNBT(CreateEntityInfo & a_EntityInfo, const cParsedNBT & a_NBT, int a_TagIx, bool & a_IsInGround);
/// Loads an array of doubles of the specified length from the specified NBT list tag a_TagIdx; returns true if successful
bool LoadDoublesListFromNBT(double * a_Doubles, int a_NumDoubles, const cParsedNBT & a_NBT, int a_TagIdx);