6 #include "../BlockEntities/MobHeadEntity.h"
61 const auto BlockMeta =
static_cast<NIBBLETYPE>(a_ClickedBlockFace);
68 auto & MobHeadEntity =
static_cast<cMobHeadEntity &
>(a_BlockEntity);
76 MobHeadEntity.SetType(HeadType);
106 for (
auto & RelCoord : RelCoords)
111 RelCoord.
x, RelCoord.z
130 int a_OffsetX,
int a_OffsetZ
164 a_World, a_Player, ImageWitherX,
169 a_World, a_Player, ImageWitherZ,
188 int a_OffsetX,
int a_OffsetZ
191 std::array<Vector3i, 9> PositionsToClear;
194 for (
size_t i = 0; i != std::size(a_Image); i++)
198 a_PlacedHeadPos.
x + a_OffsetX + a_Image[i].GetX(),
199 a_PlacedHeadPos.
y + a_Image[i].GetY(),
200 a_PlacedHeadPos.
z + a_OffsetZ + a_Image[i].GetZ()
204 if (
Block == a_PlacedHeadPos)
211 PositionsToClear[i] =
Block;
235 ASSERT(a_BlockEntity.GetBlockType() == E_BLOCK_HEAD);
237 return static_cast<cMobHeadEntity &>(a_BlockEntity).GetType() == SKULL_TYPE_WITHER;
245 PositionsToClear[i] =
Block;
252 { PositionsToClear[0], E_BLOCK_AIR, 0 },
253 { PositionsToClear[1], E_BLOCK_AIR, 0 },
254 { PositionsToClear[2], E_BLOCK_AIR, 0 },
255 { PositionsToClear[3], E_BLOCK_AIR, 0 },
256 { PositionsToClear[4], E_BLOCK_AIR, 0 },
257 { PositionsToClear[5], E_BLOCK_AIR, 0 },
258 { PositionsToClear[6], E_BLOCK_AIR, 0 },
259 { PositionsToClear[7], E_BLOCK_AIR, 0 },
260 { PositionsToClear[8], E_BLOCK_AIR, 0 },
268 int BlockX = a_PlacedHeadPos.x + a_OffsetX;
269 int BlockZ = a_PlacedHeadPos.z + a_OffsetZ;
270 a_World.
SpawnMob(
static_cast<double>(BlockX) + 0.5, a_PlacedHeadPos.y - 2,
static_cast<double>(BlockZ) + 0.5,
mtWither,
false);
286 double Dist = (a_Player.
GetPosition() - Pos).Length();
313 ASSERT(!
"Unhandled block face");
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.
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).
unsigned char Rotation(const BlockState Block)
BLOCKTYPE GetBlockType() const
double GetYaw(void) const
const Vector3d & GetPosition(void) const
Exported in ManualBindings.
cWorld * GetWorld(void) const
void AwardAchievement(CustomStatistic a_Ach)
Awards the player an achievement.
bool PlaceBlocks(std::initializer_list< sSetBlock > a_Blocks)
Calls the block placement hooks and places the blocks in the world.
bool PlaceBlock(Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Attempts to place the block in the world with a call to PlaceBlocks.
constexpr cItemHandler(int a_ItemType)
bool TrySpawnWitherAround(cPlayer &a_Player, const Vector3i a_BlockPos) const
Spawns a wither if the wither skull placed at the specified coords completes wither's spawning formul...
bool TrySpawnWitherFromImage(cWorld &a_World, cPlayer &a_Player, const sSetBlock(&a_Image)[9], Vector3i a_PlacedHeadPos, int a_OffsetX, int a_OffsetZ) const
Tries to spawn a wither from the specified image at the specified offset from the placed head block.
void RegularHeadPlaced(const cPlayer &a_Player, const cItem &a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace) const
Called after placing a regular head block with no mob spawning.
bool TrySpawnWitherAt(cWorld &a_World, cPlayer &a_Player, Vector3i a_PlacedHeadPos, int a_OffsetX, int a_OffsetZ) const
Tries to spawn a wither at the specified offset from the placed head block.
virtual bool IsPlaceable(void) const override
Blocks simply get placed.
virtual bool CommitPlacement(cPlayer &a_Player, const cItem &a_HeldItem, const Vector3i a_PlacePosition, const eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPosition) const override
Performs the actual placement of this placeable item.
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...
void AwardSpawnWitherAchievement(cWorld &a_World, Vector3i a_BlockPos) const
Awards the achievement to all players close to the specified point.
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.
bool GetBlockTypeMeta(Vector3i a_BlockPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Retrieves the block type and meta at the specified coords.
virtual bool DoWithBlockEntityAt(Vector3i a_Position, cBlockEntityCallback a_Callback) override
Calls the callback for the block entity at the specified coords; returns false if there's no block en...
virtual bool ForEachPlayer(cPlayerListCallback a_Callback) override
Calls the callback for each player in the list; returns true if all players processed,...