8 #include "../BlockInfo.h"
42 memset(Neighbors, 0,
sizeof(Neighbors));
67 for (
int i = 0; i < 8; i++)
80 else if (Neighbors[6])
84 else if (Neighbors[5])
88 else if (Neighbors[4])
92 else if (Neighbors[0] || Neighbors[1])
96 else if (Neighbors[2] || Neighbors[3])
100 ASSERT(!
"Weird neighbor count");
103 for (
int i = 0; i < 4; i++)
105 if (Neighbors[i + 4])
114 if (Neighbors[3] && Neighbors[0] && CanCurve)
118 else if (Neighbors[3] && Neighbors[1] && CanCurve)
122 else if (Neighbors[2] && Neighbors[0] && CanCurve)
126 else if (Neighbors[2] && Neighbors[1] && CanCurve)
130 else if (Neighbors[7] && Neighbors[2])
134 else if (Neighbors[3] && Neighbors[6])
138 else if (Neighbors[5] && Neighbors[0])
142 else if (Neighbors[4] && Neighbors[1])
146 else if (Neighbors[0] && Neighbors[1])
150 else if (Neighbors[2] && Neighbors[3])
157 ASSERT(!
"Weird neighbor count");
460 Super::OnBroken(a_ChunkInterface, a_WorldInterface, a_BlockPos, a_OldBlockType, a_OldBlockMeta, a_Digger);
476 const auto Meta = a_ChunkInterface.
GetBlockMeta(a_BlockPos);
478 if ((Meta != NewMeta) &&
IsUnstable(a_ChunkInterface, a_BlockPos))
493 Super::OnPlaced(a_ChunkInterface, a_WorldInterface, a_BlockPos, a_BlockType, a_BlockMeta);
511 if ((a_Meta < 0x06) || (a_Meta > 0x09))
517 switch (a_Meta & 0x07)
519 case 0x00:
return 0x01 + OtherMeta;
520 case 0x01:
return 0x00 + OtherMeta;
522 case 0x02:
return 0x04 + OtherMeta;
523 case 0x04:
return 0x03 + OtherMeta;
524 case 0x03:
return 0x05 + OtherMeta;
525 case 0x05:
return 0x02 + OtherMeta;
533 case 0x06:
return 0x09;
534 case 0x07:
return 0x06;
535 case 0x08:
return 0x07;
536 case 0x09:
return 0x08;
547 if ((a_Meta < 0x06) || (a_Meta > 0x09))
553 switch (a_Meta & 0x07)
555 case 0x00:
return 0x01 + OtherMeta;
556 case 0x01:
return 0x00 + OtherMeta;
558 case 0x02:
return 0x05 + OtherMeta;
559 case 0x05:
return 0x03 + OtherMeta;
560 case 0x03:
return 0x04 + OtherMeta;
561 case 0x04:
return 0x02 + OtherMeta;
569 case 0x06:
return 0x07;
570 case 0x07:
return 0x08;
571 case 0x08:
return 0x09;
572 case 0x09:
return 0x06;
604 switch (a_Meta & 0x07)
614 ASSERT(!
"Unknown rail meta");
643 switch (a_Meta & 0x07)
653 ASSERT(!
"Unknown rail meta");
bool IsBlockRail(BLOCKTYPE a_BlockType)
@ E_META_RAIL_CURVED_ZP_XP
@ E_META_WOODEN_SLAB_UPSIDE_DOWN
@ E_BLOCK_STAIRS_UPSIDE_DOWN
@ E_META_RAIL_CURVED_ZP_XM
@ E_META_RAIL_CURVED_ZM_XM
@ E_META_RAIL_CURVED_ZM_XP
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
void AddFaceDirection(int &a_BlockX, int &a_BlockY, int &a_BlockZ, eBlockFace a_BlockFace, bool a_bInverse)
Modifies the specified coords so that they point to the block adjacent to the one specified through i...
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
static bool FullyOccupiesVoxel(BLOCKTYPE Block)
Does this block fully occupy its voxel - is it a 'full' block?
static void NeighborChanged(cChunkInterface &a_ChunkInterface, Vector3i a_NeighborPos, eBlockFace a_WhichNeighbor)
Notifies the specified neighbor that the current block has changed.
virtual void OnPlaced(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) const
Called by cWorld::SetBlock() after the block has been set.
virtual void OnNeighborChanged(cChunkInterface &a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const
Called when a direct neighbor of this block has been changed.
virtual void OnBroken(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta, const cEntity *a_Digger) const
Called after a block gets broken (replaced with air), by natural means.
const BLOCKTYPE m_BlockType
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) const override
Rotates a given block meta clockwise.
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
Returns the base colour ID of the block, as will be represented on a map, as per documentation: https...
virtual void OnNeighborChanged(cChunkInterface &a_ChunkInterface, Vector3i a_BlockPos, eBlockFace a_WhichNeighbor) const override
Called when a direct neighbor of this block has been changed.
static bool IsUnstable(cChunkInterface &a_ChunkInterface, Vector3i a_Pos)
static bool IsNotConnected(cChunkInterface &a_ChunkInterface, Vector3i a_Pos, eBlockFace a_BlockFace, char a_Pure=0)
virtual void OnPlaced(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) const override
Called by cWorld::SetBlock() after the block has been set.
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 NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) const override
Mirros a given block meta around the YZ plane.
static NIBBLETYPE FindMeta(cChunkInterface &a_ChunkInterface, Vector3i a_BlockPos, BLOCKTYPE a_RailType)
static bool CanBeSupportedBy(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) const override
Mirrors a given block meta around the XY plane.
virtual bool CanBeAt(const cChunk &a_Chunk, const Vector3i a_Position, NIBBLETYPE a_Meta) const override
Checks if the block can stay at the specified relative coords in the chunk.
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) const override
Rotates a given block meta counter-clockwise.
static bool IsAnySlabType(BLOCKTYPE a_BlockType)
Returns true if the specified blocktype is one of the slabs handled by this handler.
static bool IsAnyStairType(BLOCKTYPE a_Block)
NIBBLETYPE GetBlockMeta(Vector3i a_Pos)
BLOCKTYPE GetBlock(Vector3i a_Pos)
void FastSetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
Sets the block at the specified coords to the specified value.
Mixin to clear the block's meta value when converting to a pickup.
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 ...
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.