8 #include "../BlockInfo.h"
10 #include "../ClientHandle.h"
50 Super(etBoat, a_Pos, 1.375f, 0.5625f),
51 m_LastDamage(0), m_ForwardDirection(0),
52 m_DamageTaken(0.0f), m_Material(a_Material),
53 m_RightPaddleUsed(false), m_LeftPaddleUsed(false)
82 if ((
GetWorld()->GetWorldTickAge() % 2_tick) != 0_tick)
88 if (
Diff.HasNonZeroLength())
279 case bmOak:
return "oak";
295 if (a_Material ==
"oak")
299 else if (a_Material ==
"spruce")
303 else if (a_Material ==
"birch")
307 else if (a_Material ==
"jungle")
311 else if (a_Material ==
"acacia")
315 else if (a_Material ==
"dark_oak")
bool IsBlockWater(BLOCKTYPE a_BlockType)
T Diff(T a_Val1, T a_Val2)
void LOGWARNING(std::string_view a_Format, const Args &... args)
Vector3< double > Vector3d
Represents two sets of coords, minimum and maximum for each direction.
void SendSpawnEntity(const cEntity &a_Entity)
void SendEntityMetadata(const cEntity &a_Entity)
bool operator()(cEntity &a_Entity)
cBoatCollisionCallback(cBoat &a_Boat, cEntity *a_Attachee)
virtual void BroadcastMovementUpdate(const cClientHandle *a_Exclude=nullptr) override
Updates clients of changes in the entity.
cBoat(Vector3d a_Pos, eMaterial a_Material)
virtual void SpawnOn(cClientHandle &a_ClientHandle) override
Descendants override this function to send a command to the specified client to spawn the entity on t...
static AString MaterialToString(const eMaterial a_Material)
Returns the eMaterial as string.
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
static eMaterial ItemToMaterial(const cItem &a_Item)
Returns the eMaterial that should be used for a boat created from the specified item.
virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk &a_Chunk) override
Handles the physics of the entity - updates position based on speed, updates speed based on environme...
static eMaterial StringToMaterial(const AString &a_Material)
Returns the boat material for the passed string.
void UpdatePaddles(bool rightPaddleUsed, bool leftPaddleUsed)
int GetLastDamage(void) const
virtual bool DoTakeDamage(TakeDamageInfo &TDI) override
Makes this entity take damage specified in the a_TDI.
void SetLastDamage(int TimeSinceLastHit)
virtual void OnRightClicked(cPlayer &a_Player) override
Called when the specified player right-clicks this entity.
virtual void HandleSpeedFromAttachee(float a_Forward, float a_Sideways) override
static cItem MaterialToItem(eMaterial a_Material)
Returns the boat item of the boat material.
Vector3d m_LastSentPosition
Last position sent to client via the Relative Move or Teleport packets (not Velocity) Only updated if...
const Vector3d & GetSpeed(void) const
Exported in ManualBindings.
bool IsPlayer(void) const
virtual void Tick(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
cEntity * m_Attachee
The entity which is attached to this entity (rider), nullptr if none.
void Detach(void)
Detaches from the currently attached entity, if any.
void AddSpeed(double a_AddSpeedX, double a_AddSpeedY, double a_AddSpeedZ)
bool m_bDirtyOrientation
Stores whether our yaw / pitch / roll (body orientation) has been set manually.
void SetHealth(float a_Health)
Sets the health of this entity; doesn't broadcast any hurt animation.
double GetSpeedY(void) const
bool IsTicking(void) const
Returns true if the entity is valid and ticking.
void SetGravity(float a_Gravity)
void SetSpeed(double a_SpeedX, double a_SpeedY, double a_SpeedZ)
Sets the speed of the entity, measured in m / sec.
double GetPosX(void) const
float GetWidth(void) const
double GetPosZ(void) const
UInt32 GetUniqueID(void) const
void Destroy()
Destroys the entity, schedules it for memory freeing and broadcasts the DestroyEntity packet.
void AddSpeedY(double a_AddSpeedY)
double GetPosY(void) const
virtual void HandlePhysics(std::chrono::milliseconds a_Dt, cChunk &a_Chunk)
Handles the physics of the entity - updates position based on speed, updates speed based on environme...
void SetMass(double a_Mass)
float GetHeight(void) const
void SetAirDrag(float a_AirDrag)
virtual bool DoTakeDamage(TakeDamageInfo &a_TDI)
Makes this entity take damage specified in the a_TDI.
float GetHealth(void) const
Returns the health of this entity.
void SetMaxHealth(float a_MaxHealth)
Sets the maximum value for the health.
virtual void OnRightClicked(cPlayer &a_Player)
Called when the specified player right-clicks this entity.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
Vector3d GetLookVector(void) const
void AttachTo(cEntity &a_AttachTo)
Attaches to the specified entity; detaches from any previous one first.
cWorld * GetWorld(void) const
bool IsGameModeCreative(void) const
Returns true if the player is in Creative mode, either explicitly, or by inheriting from current worl...
This class bridges a vector of cItem for safe access via Lua.
void Add(const cItem &a_Item)
virtual void BroadcastEntityMetadata(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
BLOCKTYPE GetBlock(Vector3i a_BlockPos) const
Returns the block type at the specified position.
virtual bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback) override
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox.
void SpawnItemPickups(const cItems &a_Pickups, Vector3i a_BlockPos, double a_FlyAwaySpeed=1.0, bool a_IsPlayerCreated=false)
Spawns item pickups for each item in the list.
virtual void BroadcastEntityPosition(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override