5 #include "../Blocks/BlockChest.h" 26 int a_BlockX,
int a_BlockY,
int a_BlockZ,
eBlockFace a_BlockFace,
27 int a_CursorX,
int a_CursorY,
int a_CursorZ
45 Vector3i blockPos(a_BlockX, a_BlockY, a_BlockZ);
46 a_World.
GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, clickedBlock, clickedBlockMeta);
49 if (blockHandler->DoesIgnoreBuildCollision(ChunkInterface, blockPos, a_Player, clickedBlockMeta))
51 blockHandler->OnPlayerBreakingBlock(ChunkInterface, a_World, a_Player, blockPos);
65 a_World.
GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, PlaceBlock, PlaceMeta);
69 if (blockHandler->DoesIgnoreBuildCollision(ChunkInterface, blockPos, a_Player, clickedBlockMeta))
78 static const Vector3i CrossCoords[] =
86 for (
size_t i = 0; i <
ARRAYCOUNT(CrossCoords); i++)
88 if (a_World.
GetBlock(a_BlockX + CrossCoords[i].
x, a_BlockY, a_BlockZ + CrossCoords[i].
z) !=
m_ItemType)
97 NeighborIdx =
static_cast<int>(i);
100 int bx = a_BlockX + CrossCoords[i].
x;
101 int bz = a_BlockZ + CrossCoords[i].
z;
102 for (
size_t j = 0; j <
ARRAYCOUNT(CrossCoords); j++)
114 auto yaw = a_Player.
GetYaw();
139 if (!a_Player.
PlaceBlock(a_BlockX, a_BlockY, a_BlockZ, ChestBlockType, Meta))
145 if (NeighborIdx != -1)
147 a_World.
FastSetBlock(a_BlockX + CrossCoords[NeighborIdx].x, a_BlockY, a_BlockZ + CrossCoords[NeighborIdx].z, ChestBlockType, Meta);
static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
Translates player yaw when placing a chest into the chest block metadata.
BLOCKTYPE GetBlock(Vector3i a_BlockPos)
Returns the block type at the specified position.
unsigned char BLOCKTYPE
The datatype used by blockdata.
bool RemoveOneEquippedItem(void)
Removes one item out of the currently equipped item stack, returns true if successful, false if empty-handed.
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
bool PlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Calls the block-placement hook and places the block in the world, unless refused by the hook...
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
We need an OnPlayerPlace override because we're processing neighbor chests and changing their metas...
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.
cItemChestHandler(int a_ItemType)
cBlockHandler * BlockHandler(BLOCKTYPE a_BlockType)
double GetYaw(void) const
cChunkMap * GetChunkMap(void)
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
bool IsGameModeSurvival(void) const
Returns true if the player is in Survival mode, either explicitly, or by inheriting from current worl...
void FastSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
cInventory & GetInventory(void)
#define ARRAYCOUNT(X)
Evaluates to the number of elements in an array (compile-time!)