6 #include "../BlockEntities/MobHeadEntity.h" 26 int a_BlockX,
int a_BlockY,
int a_BlockZ,
eBlockFace a_BlockFace,
27 int a_CursorX,
int a_CursorY,
int a_CursorZ
35 auto placedX = a_BlockX, placedY = a_BlockY, placedZ = a_BlockZ;
48 cItem itemCopy(a_EquippedItem);
49 if (!
super::OnPlayerPlace(a_World, a_Player, a_EquippedItem, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
53 RegularHeadPlaced(a_World, a_Player, itemCopy, placedX, placedY, placedZ, a_BlockFace);
62 int a_BlockX,
int a_BlockY,
int a_BlockZ,
eBlockFace a_BlockFace
66 auto BlockMeta =
static_cast<NIBBLETYPE>(a_BlockFace);
75 auto & MobHeadEntity =
static_cast<cMobHeadEntity &
>(a_BlockEntity);
80 Rotation =
FloorC(a_Player.
GetYaw() * 16.0f / 360.0f + 0.5f) & 0x0f;
83 MobHeadEntity.SetType(HeadType);
84 MobHeadEntity.SetRotation(static_cast<eMobHeadRotation>(Rotation));
85 MobHeadEntity.GetWorld()->BroadcastBlockEntity(MobHeadEntity.GetPos());
100 if (a_BlockPos.
y < 2)
114 for (
auto & RelCoord : RelCoords)
119 RelCoord.
x, RelCoord.z
138 int a_OffsetX,
int a_OffsetZ
172 a_World, a_Player, ImageWitherX,
ARRAYCOUNT(ImageWitherX),
177 a_World, a_Player, ImageWitherZ,
ARRAYCOUNT(ImageWitherZ),
193 int a_OffsetX,
int a_OffsetZ
198 AirBlocks.reserve(a_ImageCount);
199 for (
size_t i = 0; i < a_ImageCount; i++)
202 int BlockX = a_PlacedHeadPos.
x + a_OffsetX + a_Image[i].
GetX();
203 int BlockY = a_PlacedHeadPos.
y + a_Image[i].
GetY();
204 int BlockZ = a_PlacedHeadPos.
z + a_OffsetZ + a_Image[i].
GetZ();
207 if ((BlockX == a_PlacedHeadPos.
x) && (BlockY == a_PlacedHeadPos.
y) && (BlockZ == a_PlacedHeadPos.
z))
219 if (!a_World.
GetBlockTypeMeta(BlockX, BlockY, BlockZ, BlockType, BlockMeta))
226 if (BlockType != a_Image[i].m_BlockType)
234 bool IsWitherHead =
false;
249 AirBlocks.emplace_back(BlockX, BlockY, BlockZ,
E_BLOCK_AIR, 0);
259 int BlockX = a_PlacedHeadPos.
x + a_OffsetX;
260 int BlockZ = a_PlacedHeadPos.
z + a_OffsetZ;
261 a_World.
SpawnMob(static_cast<double>(BlockX) + 0.5, a_PlacedHeadPos.
y - 2, static_cast<double>(BlockZ) + 0.5,
mtWither,
false);
274 double Dist = (a_Player.
GetPosition() - Pos).Length();
298 ASSERT(!
"Unhandled block face");
313 int a_BlockX,
int a_BlockY,
int a_BlockZ,
eBlockFace a_BlockFace,
314 int a_CursorX,
int a_CursorY,
int a_CursorZ,
virtual UInt32 SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType, bool a_Baby=false) override
Spawns a mob of the specified type.
void AwardSpawnWitherAchievement(cWorld &a_World, Vector3i a_BlockPos)
Awards the achievement to all players close to the specified point.
virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback a_Callback) override
Calls the callback for the block entity at the specified coords; returns false if there's no block en...
BLOCKTYPE GetBlockType() const
unsigned int AwardAchievement(const eStatistic a_Ach)
Awards the player an achievement.
unsigned char BLOCKTYPE
The datatype used by blockdata.
int GetY(void) const
Returns the absolute Y coord of the stored block.
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
int GetZ(void) const
Returns the absolute Z coord of the stored block.
bool TrySpawnWitherFromImage(cWorld &a_World, cPlayer &a_Player, const sSetBlock *a_Image, size_t a_ImageCount, Vector3i a_PlacedHeadPos, int a_OffsetX, int a_OffsetZ)
Tries to spawn a wither from the specified image at the specified offset from the placed head block...
static NIBBLETYPE BlockFaceToBlockMeta(int a_BlockFace)
Converts the block face of the placement (which face of the block was clicked to place the head) into...
bool PlaceBlocks(const sSetBlockVector &a_Blocks)
Calls the block placement hooks and places the blocks in the world.
int GetX(void) const
Returns the absolute X coord of the stored block.
void AddFaceDirection(int &a_BlockX, int &a_BlockY, int &a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse=false)
bool GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta)
Retrieves the block type and meta at the specified coords.
virtual bool OnPlayerPlace(cWorld &a_World, cPlayer &a_Player, const cItem &a_EquippedItem, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
Called when the player tries to place the item (right mouse button, IsPlaceable() == true)...
cItemMobHeadHandler(int a_ItemType)
bool TrySpawnWitherAt(cWorld &a_World, cPlayer &a_Player, Vector3i a_PlacedHeadPos, int a_OffsetX, int a_OffsetZ)
Tries to spawn a wither at the specified offset from the placed head block.
double GetYaw(void) const
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
virtual bool OnPlayerPlace(cWorld &a_World, cPlayer &a_Player, const cItem &a_EquippedItem, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
Called when the player tries to place the item (right mouse button, IsPlaceable() == true)...
virtual bool GetPlacementBlockTypeMeta(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) override
Called when the player right-clicks with this item and IsPlaceable() == true, and OnPlayerPlace() is ...
void RegularHeadPlaced(cWorld &a_World, cPlayer &a_Player, const cItem &a_EquippedItem, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
Called after placing a regular head block with no mob spawning.
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
virtual bool IsPlaceable(void) override
Blocks simply get placed.
bool TrySpawnWitherAround(cWorld &a_World, cPlayer &a_Player, Vector3i a_BlockPos)
Spawns a wither if the wither skull placed at the specified coords completes wither's spawning formul...
std::enable_if< std::is_arithmetic< T >::value, C >::type FloorC(T a_Value)
Floors a value, then casts it to C (an int by default)
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)
std::vector< sSetBlock > sSetBlockVector
virtual bool ForEachPlayer(cPlayerListCallback a_Callback) override
Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true.