4 #include "../../Blocks/BlockComparator.h"
17 return static_cast<unsigned char>(std::max(
static_cast<char>(a_HighestRearPowerLevel) - a_HighestSidePowerLevel, 0));
22 return (a_HighestRearPowerLevel < a_HighestSidePowerLevel) ? 0 : a_HighestRearPowerLevel;
31 const auto Meta = a_Chunk.
GetMeta(a_Position);
40 UInt8 SignalStrength = 0;
44 if ((RearChunk ==
nullptr) || !RearChunk->IsValid())
46 return SignalStrength;
53 if (BlockEntityWithItems ==
nullptr)
60 auto & Contents = BlockEntityWithItems->
GetContents();
63 for (
int Slot = 0; Slot != Contents.GetNumSlots(); ++Slot)
65 Fullness +=
static_cast<float>(Contents.GetSlot(Slot).m_ItemCount) / Contents.
GetSlot(Slot).
GetMaxStackSize();
68 SignalStrength = (Fullness < 0.001 ) ? 0 :
static_cast<UInt8>(1 + (Fullness / Contents.GetNumSlots()) * 14);
72 const auto RearType = RearChunk->GetBlock(RearCoordinate);
76 *RearChunk, RearCoordinate, RearType,
88 auto DelayInfo = Data.GetMechanismDelayInfo(a_Position);
91 if (DelayInfo ==
nullptr)
93 const auto RearPower =
GetPowerLevel(a_Chunk, a_Position, a_BlockType, a_Meta);
95 const auto PreviousFrontPower = Data.GetCachedPowerData(a_Position);
96 const bool ShouldUpdate = (FrontPower != PreviousFrontPower);
100 Data.m_MechanismDelays[a_Position] = std::make_pair(1,
bool());
107 std::tie(DelayTicks, std::ignore) = *DelayInfo;
114 const auto RearPower =
GetPowerLevel(a_Chunk, a_Position, a_BlockType, a_Meta);
116 const NIBBLETYPE NewMeta = (FrontPower > 0) ? (a_Meta | 0x08u) : (a_Meta & 0x07u);
119 Data.ExchangeUpdateOncePowerData(a_Position, FrontPower);
121 a_Chunk.
SetMeta(a_Position, NewMeta);
122 Data.m_MechanismDelays.erase(a_Position);
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
auto & DataForChunk(const cChunk &a_Chunk)
void UpdateAdjustedRelative(const cChunk &a_Chunk, const cChunk &a_TickingChunk, const Vector3i a_Position, const Vector3i a_Offset)
unsigned char Power(const BlockState Block)
static unsigned char GetPowerLevel(cChunk &a_Chunk, Vector3i Position, BLOCKTYPE BlockType, NIBBLETYPE Meta)
static PowerLevel GetPowerDeliveredToPosition(const cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, Vector3i a_QueryPosition, BLOCKTYPE a_QueryBlockType, bool IsLinked)
static unsigned char GetFrontPowerLevel(NIBBLETYPE a_Meta, unsigned char a_HighestSidePowerLevel, unsigned char a_HighestRearPowerLevel)
static void Update(cChunk &a_Chunk, cChunk &CurrentlyTicking, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, const PowerLevel Power)
static void ForValidSourcePositions(const cChunk &a_Chunk, Vector3i a_Position, BLOCKTYPE a_BlockType, NIBBLETYPE a_Meta, ForEachSourceCallback &Callback)
PowerLevel GetPowerDeliveredToPosition(const cChunk &Chunk, const Vector3i Position, const BLOCKTYPE BlockType, const Vector3i QueryPosition, const BLOCKTYPE QueryBlockType, const bool IsLinked)
Asks a redstone component at the source position how much power it will deliver to the querying posit...
cItemGrid & GetContents(void)
Returns the ItemGrid used for storing the contents.
static Vector3i GetRearCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta)
static Vector3i GetSideCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta, bool a_bInverse)
static Vector3i GetFrontCoordinate(Vector3i a_Position, NIBBLETYPE a_Meta)
static bool IsInSubtractionMode(NIBBLETYPE a_Meta)
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
bool DoWithBlockEntityAt(Vector3i a_Position, cBlockEntityCallback a_Callback)
Calls the callback for the block entity at the specified coords; returns false if there's no block en...
cChunk * GetRelNeighborChunkAdjustCoords(Vector3i &a_RelPos) const
Returns the chunk into which the relatively-specified block belongs.
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
char GetMaxStackSize(void) const
Returns the maximum amount of stacked items of this type.
const cItem & GetSlot(int a_X, int a_Y) const
static Vector3i RebaseRelativePosition(const cChunk &From, const cChunk &To, const Vector3i Position)
Adjust From-relative coordinates into To-relative coordinates.