5 #include "../BoundingBox.h"
6 #include "../EffectID.h"
7 #include "../Entities/LeashKnot.h"
8 #include "../BoundingBox.h"
9 #include "../Mobs/PassiveMonster.h"
61 if (XMSolid && ZMSolid)
65 if (XPSolid && ZMSolid)
67 PlacementBox = PlacementBox.
Union(
cBoundingBox(0.5, 1.0, 0, FENCE_HEIGHT, 0, 0.5));
69 if (XPSolid && ZPSolid)
71 PlacementBox = PlacementBox.
Union(
cBoundingBox(0.5, 1.0, 0, FENCE_HEIGHT, 0.5, 1.0));
73 if (XMSolid && ZPSolid)
75 PlacementBox = PlacementBox.
Union(
cBoundingBox(0, 0.5, 0, FENCE_HEIGHT, 0.5, 1.0));
95 auto KnotAlreadyExists = (LeashKnot !=
nullptr);
97 if (KnotAlreadyExists)
100 LeashKnot->TiePlayersLeashedMobs(a_Player, KnotAlreadyExists);
105 auto NewLeashKnot = std::make_unique<cLeashKnot>(a_BlockFace, a_BlockPos);
106 auto NewLeashKnotPtr = NewLeashKnot.get();
108 NewLeashKnotPtr->TiePlayersLeashedMobs(a_Player, KnotAlreadyExists);
111 if (NewLeashKnotPtr->HasAnyMobLeashed())
113 if (!NewLeashKnotPtr->Initialize(std::move(NewLeashKnot), *a_Player.
GetWorld()))
140 a_WorldInterface.
SendBlockTo(a_BlockPos, a_Player);
166 if (leashKnot !=
nullptr)
168 leashKnot->SetShouldSelfDestroy();
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
static float GetBlockHeight(BLOCKTYPE Block)
Block's height.
static bool IsSolid(BLOCKTYPE Block)
Is this block solid (player cannot walk through)?
virtual void OnBroken(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, const cEntity *a_Digger) const override
Called after a block gets broken (replaced with air), by natural means.
virtual cBoundingBox GetPlacementCollisionBox(BLOCKTYPE a_XM, BLOCKTYPE a_XP, BLOCKTYPE a_YM, BLOCKTYPE a_YP, BLOCKTYPE a_ZM, BLOCKTYPE a_ZP) const override
Returns the relative bounding box that must be entity-free in order for the block to be placed.
static constexpr double MAX_COORD
virtual void OnCancelRightClick(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace) const override
Called when a right click to this block is cancelled.
static constexpr double MIN_COORD
virtual bool OnUse(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cPlayer &a_Player, const Vector3i a_BlockPos, eBlockFace a_BlockFace, const Vector3i a_CursorPos) const override
Called when the user right clicks the block and the block is useable.
virtual bool IsUseable(void) const override
Called to check whether this block supports a rclk action.
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
const BLOCKTYPE m_BlockType
virtual void SendBlockTo(int a_BlockX, int a_BlockY, int a_BlockZ, const cPlayer &a_Player)=0
Sends the block on those coords to the player.
Represents two sets of coords, minimum and maximum for each direction.
cBoundingBox Union(const cBoundingBox &a_Other)
Returns the union of the two bounding boxes.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
cWorld * GetWorld(void) const
static cLeashKnot * FindKnotAtPos(cWorldInterface &a_WorldInterface, Vector3i a_BlockPos)
Returns the leash knot entity representing the knot at the specified position.
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override