22 template <
class OffsetCallback>
34 else if (Offset.
x == 1)
43 else if (Offset.
z == 1)
56 using FrontState = std::remove_reference_t<decltype(Front)>;
66 Front = FrontState::Side;
85 return a_Offset.
x != 0;
88 return a_Offset.
z != 0;
99 default:
return false;
105 const auto Position = a_Position +
OffsetYP;
113 const auto YPTerraceBlock = a_Chunk.
GetBlock(Position);
127 auto Adjacent = a_Position + Offset;
130 if ((NeighbourChunk ==
nullptr) || !NeighbourChunk->IsValid())
149 auto & NeighbourBlock =
DataForChunk(*NeighbourChunk).WireStates.find(Adjacent)->second;
164 if (NeighbourChunk != &a_Chunk)
166 auto & NeighbourBlock =
DataForChunk(*NeighbourChunk).WireStates.find(Adjacent +
OffsetYP)->second;
182 if (NeighbourChunk != &a_Chunk)
184 auto & NeighbourBlock =
DataForChunk(*NeighbourChunk).WireStates.find(Adjacent +
OffsetYM)->second;
191 const auto FindResult = States.find(a_Position);
192 if (FindResult != States.end())
194 if (
Block != FindResult->second)
196 FindResult->second =
Block;
213 const auto QueryOffset = a_QueryPosition - a_Position;
230 const auto Block = Data.WireStates.find(a_Position)->second;
234 using LeftState = std::remove_reference_t<decltype(Left)>;
235 using FrontState = std::remove_reference_t<decltype(Front)>;
236 using RightState = std::remove_reference_t<decltype(Right)>;
239 if (Front != FrontState::None)
259 if ((Left == LeftState::None) && (Right == RightState::None))
298 const auto Block = Data.WireStates.find(a_Position)->second;
303 const auto Relative = a_Position + Offset;
308 using FrontState = std::remove_reference_t<decltype(Front)>;
314 else if (Front == FrontState::Side)
319 const auto YMDiagonalPosition = Relative +
OffsetYM;
327 Callback(YMDiagonalPosition);
@ E_META_REDSTONE_REPEATER_FACING_XP
@ E_META_REDSTONE_REPEATER_FACING_MASK
@ E_META_REDSTONE_REPEATER_FACING_XM
@ E_BLOCK_REDSTONE_TORCH_ON
@ E_BLOCK_REDSTONE_REPEATER_ON
@ E_BLOCK_BLOCK_OF_REDSTONE
@ E_BLOCK_INACTIVE_COMPARATOR
@ E_BLOCK_ACTIVE_COMPARATOR
@ E_BLOCK_REDSTONE_TORCH_OFF
@ E_BLOCK_REDSTONE_REPEATER_OFF
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
constexpr Vector3i OffsetYP
auto & DataForChunk(const cChunk &a_Chunk)
constexpr Vector3i OffsetYM
constexpr std::array< Vector3i, 4 > RelativeLaterals
void UpdateAdjustedRelatives(const cChunk &a_Chunk, const cChunk &a_TickingChunk, const Vector3i a_Position, const ArrayType &a_Relative)
void UpdateAdjustedRelative(const cChunk &a_Chunk, const cChunk &a_TickingChunk, const Vector3i a_Position, const Vector3i a_Offset)
bool Up(const BlockState Block)
unsigned char Power(const BlockState Block)
BlockState RedstoneWire()
static bool IsYPTerracingBlocked(const cChunk &a_Chunk, const Vector3i a_Position)
TemporaryDirection
A unified representation of wire direction.
static void Update(cChunk &a_Chunk, cChunk &CurrentlyTicking, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const PowerLevel Power)
static void SetDirectionState(const Vector3i Offset, BlockState &Block, TemporaryDirection Direction)
Adjusts a given wire block so that the direction represented by Offset has state Direction.
static void ForValidSourcePositions(const cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, ForEachSourceCallback &Callback)
static PowerLevel GetPowerDeliveredToPosition(const cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked)
static void SetWireState(const cChunk &a_Chunk, const Vector3i a_Position)
Temporary.
static bool IsDirectlyConnectingMechanism(BLOCKTYPE a_Block, NIBBLETYPE a_BlockMeta, const Vector3i a_Offset)
static BlockState DoWithDirectionState(const Vector3i Offset, BlockState Block, OffsetCallback Callback)
Invokes Callback with the wire's left, front, and right direction state corresponding to Offset.
Represents the state of a single block (previously known as "block meta").
static bool IsSolid(BLOCKTYPE Block)
Is this block solid (player cannot walk through)?
static bool IsTransparent(BLOCKTYPE Block)
Is a block transparent? (https://minecraft.wiki/w/Opacity)
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
cChunk * GetRelNeighborChunkAdjustCoords(Vector3i &a_RelPos) const
Returns the chunk into which the relatively-specified block belongs.
cChunkCoords GetPos() const
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
cWorld * GetWorld(void) const
bool UnboundedRelGetBlockType(Vector3i a_RelCoords, BLOCKTYPE &a_BlockType) const
Same as GetBlockType(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap...
void GetBlockTypeMeta(Vector3i a_RelPos, BLOCKTYPE &a_BlockType, NIBBLETYPE &a_BlockMeta) const
static bool IsValidHeight(Vector3i a_BlockPosition)
Validates a height-coordinate.
static Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition, cChunkCoords a_ChunkCoords)
Converts relative block coordinates into absolute coordinates with a known chunk location.
virtual void WakeUpSimulators(Vector3i a_Block) override
Wakes up the simulators for the specified block.