33 int a_BlockX,
int a_BlockY,
int a_BlockZ,
eBlockFace a_BlockFace,
34 int a_CursorX,
int a_CursorY,
int a_CursorZ,
39 Vector3i Pos{ a_BlockX, a_BlockY, a_BlockZ };
40 a_BlockMeta =
FindMeta(a_ChunkInterface, Pos);
42 [
this, Pos, &a_ChunkInterface](
cChunk & a_Chunk)
45 return CanBeAt(a_ChunkInterface, RelPos.x, RelPos.y, RelPos.z, a_Chunk);
60 super::OnPlaced(a_ChunkInterface, a_WorldInterface, a_BlockPos, a_BlockType, a_BlockMeta);
83 super::OnBroken(a_ChunkInterface, a_WorldInterface, a_BlockPos, a_OldBlockType, a_OldBlockMeta);
103 auto newMeta =
FindMeta(a_ChunkInterface, a_BlockPos);
104 if (
IsUnstable(a_ChunkInterface, a_BlockPos) && (meta != newMeta))
147 if (!a_Chunk.
UnboundedRelGetBlock(a_RelX + Coords[Meta].x, a_RelY, a_RelZ + Coords[Meta].z, BlockType, BlockMeta))
163 memset(Neighbors, 0,
sizeof(Neighbors));
188 for (
int i = 0; i < 8; i++)
201 else if (Neighbors[6])
205 else if (Neighbors[5])
209 else if (Neighbors[4])
213 else if (Neighbors[0] || Neighbors[1])
217 else if (Neighbors[2] || Neighbors[3])
221 ASSERT(!
"Weird neighbor count");
224 for (
int i = 0; i < 4; i++)
226 if (Neighbors[i + 4])
249 else if (Neighbors[7] && Neighbors[2])
253 else if (Neighbors[3] && Neighbors[6])
257 else if (Neighbors[5] && Neighbors[0])
261 else if (Neighbors[4] && Neighbors[1])
265 else if (Neighbors[0] && Neighbors[1])
269 else if (Neighbors[2] && Neighbors[3])
276 ASSERT(!
"Weird neighbor count");
520 if ((a_Meta < 0x06) || (a_Meta > 0x09))
526 switch (a_Meta & 0x07)
528 case 0x00:
return 0x01 + OtherMeta;
529 case 0x01:
return 0x00 + OtherMeta;
531 case 0x02:
return 0x04 + OtherMeta;
532 case 0x04:
return 0x03 + OtherMeta;
533 case 0x03:
return 0x05 + OtherMeta;
534 case 0x05:
return 0x02 + OtherMeta;
542 case 0x06:
return 0x09;
543 case 0x07:
return 0x06;
544 case 0x08:
return 0x07;
545 case 0x09:
return 0x08;
557 if ((a_Meta < 0x06) || (a_Meta > 0x09))
563 switch (a_Meta & 0x07)
565 case 0x00:
return 0x01 + OtherMeta;
566 case 0x01:
return 0x00 + OtherMeta;
568 case 0x02:
return 0x05 + OtherMeta;
569 case 0x05:
return 0x03 + OtherMeta;
570 case 0x03:
return 0x04 + OtherMeta;
571 case 0x04:
return 0x02 + OtherMeta;
579 case 0x06:
return 0x07;
580 case 0x07:
return 0x08;
581 case 0x08:
return 0x09;
582 case 0x09:
return 0x06;
615 switch (a_Meta & 0x07)
625 ASSERT(!
"Unknown rail meta");
655 switch (a_Meta & 0x07)
665 ASSERT(!
"Unknown rail meta");
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
Rotates a given block meta counter-clockwise.
virtual void OnBroken(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta)
Called after a block gets broken (replaced with air), either by player or by natural means...
void FastSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
unsigned char BLOCKTYPE
The datatype used by blockdata.
bool DoWithChunkAt(Vector3i a_BlockPos, cChunkCallback a_Callback)
Calls the callback for the chunk at the block position specified, with ChunkMapCS locked...
virtual void OnNeighborChanged(cChunkInterface &a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) override
Called when a direct neighbor of this block has been changed.
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
Mirros a given block meta around the YZ plane.
cBlockRailHandler(BLOCKTYPE a_BlockType)
static void NeighborChanged(cChunkInterface &a_ChunkInterface, Vector3i a_NeighborPos, eBlockFace a_WhichNeighbor)
Notifies the specified neighbor that the current block has changed.
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
Mirrors a given block meta around the XY plane.
virtual void OnBroken(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta) override
Called after a block gets broken (replaced with air), either by player or by natural means...
void AddFaceDirection(int &a_BlockX, int &a_BlockY, int &a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse=false)
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
static void AbsoluteToRelative(int &a_X, int &a_Y, int &a_Z, int &a_ChunkX, int &a_ChunkZ)
Converts absolute block coords into relative (chunk + block) coords:
virtual bool GetPlacementBlockTypeMeta(cChunkInterface &a_ChunkInterface, 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 before a block is placed into a world.
NIBBLETYPE FindMeta(cChunkInterface &a_ChunkInterface, Vector3i a_BlockPos)
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
Rotates a given block meta clockwise.
bool CanThisRailCurve(void)
bool IsNotConnected(cChunkInterface &a_ChunkInterface, Vector3i a_Pos, eBlockFace a_BlockFace, char a_Pure=0)
bool IsBlockRail(BLOCKTYPE a_BlockType)
static bool FullyOccupiesVoxel(BLOCKTYPE a_Type)
bool IsUnstable(cChunkInterface &a_ChunkInterface, Vector3i a_Pos)
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc...
NIBBLETYPE GetBlockMeta(Vector3i a_Pos)
bool UnboundedRelGetBlock(Vector3i a_RelCoords, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Same as GetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in ...
BLOCKTYPE GetBlock(Vector3i a_Pos)
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
Returns the base colour ID of the block, as will be represented on a map, as per documentation: https...
virtual bool CanBeAt(cChunkInterface &a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk &a_Chunk) override
Checks if the block can stay at the specified relative coords in the chunk.
Mixin to clear the block's meta value when converting to a pickup.
virtual void OnPlaced(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Called by cWorld::SetBlock() after the block has been set.
virtual void OnPlaced(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override
Called by cWorld::SetBlock() after the block has been set.
cWorld * GetWorld(void) const