14 #include "../BlockArea.h"
16 #include "../ClientHandle.h"
51 static const auto FarmlandHeight = 0.9375;
52 static const auto FullHeightDelta = 0.0625;
58 const auto GroundHeight = a_AbsPos.
y + 1;
65 if ((Entity.
GetPosY() < a_AbsPos.
y + FarmlandHeight) || (Entity.
GetPosY() >= GroundHeight))
73 const auto HeightIncrease = GroundHeight - Entity.GetPosY();
74 const auto Player = static_cast<const cPlayer *>(&Entity);
76 Player->GetClientHandle()->SendPlayerMoveLook(Vector3d(0.0, HeightIncrease, 0.0), 0.0f, 0.0f, true);
110 auto BlockMeta = a_Chunk.
GetMeta(a_RelPos);
169 auto upperBlock = a_ChunkInterface.
GetBlock(a_BlockPos.
addedY(1));
209 for (
size_t i = 0; i < NumBlocks; i++)
bool IsBlockWater(BLOCKTYPE a_BlockType)
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
unsigned char BLOCKTYPE
The datatype used by blockdata.
eBlockFace
Block face constants, used in PlayerDigging and PlayerBlockPlacement packets and bbox collision calc.
Vector3< double > Vector3d
size_t GetBlockCount(void) const
BLOCKTYPE * GetBlockTypes(void) const
Returns the internal pointer to the block types.
bool Read(cForEachChunkProvider &a_ForEachChunkProvider, int a_MinBlockX, int a_MaxBlockX, int a_MinBlockY, int a_MaxBlockY, int a_MinBlockZ, int a_MaxBlockZ, int a_DataTypes=baTypes|baMetas|baBlockEntities)
Reads an area of blocks specified.
static bool FullyOccupiesVoxel(BLOCKTYPE Block)
Does this block fully occupy its voxel - is it a 'full' block?
static void TurnToDirt(cChunk &a_Chunk, Vector3i a_AbsPos)
Turns farmland into dirt.
virtual bool CanSustainPlant(BLOCKTYPE a_Plant) const override
Checks whether the block has an effect on growing the plant.
virtual void OnUpdate(cChunkInterface &a_ChunkInterface, cWorldInterface &a_WorldInterface, cBlockPluginInterface &a_PluginInterface, cChunk &a_Chunk, const Vector3i a_RelPos) const override
Called when the block gets ticked either by a random tick or by a queued tick.
virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem *const a_Tool) const override
Returns the pickups that would result if the block was mined by a_Digger using a_Tool.
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 void TurnToDirt(cChunk &a_Chunk, const Vector3i a_AbsPos, const Vector3i a_RelPos)
Turns farmland into dirt.
static bool IsWaterInNear(const cChunk &a_Chunk, const Vector3i a_RelPos)
Returns true if there's either a water source block close enough to hydrate the specified position,...
constexpr cBlockHandler(BLOCKTYPE a_BlockType)
const BLOCKTYPE m_BlockType
This interface is used to decouple block handlers from the cPluginManager dependency through cWorld.
bool DoWithChunkAt(Vector3i a_BlockPos, cFunctionRef< bool(cChunk &)> a_Callback)
BLOCKTYPE GetBlock(Vector3i a_Pos)
Represents two sets of coords, minimum and maximum for each direction.
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
Vector3i RelativeToAbsolute(Vector3i a_RelBlockPosition) const
Converts the coord relative to this chunk into an absolute coord.
void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
bool ForEachEntityInBox(const cBoundingBox &a_Box, cEntityCallback a_Callback) const
Calls the callback for each entity that has a nonempty intersection with the specified boundingbox.
bool IsWeatherWetAt(int a_RelX, int a_RelZ) const
Returns true if it is raining or storming at the specified location, taking into account biomes.
cWorld * GetWorld(void) const
static bool IsValidHeight(Vector3i a_BlockPosition)
Validates a height-coordinate.
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:
bool IsPlayer(void) const
void SetPosY(double a_PosY)
double GetPosY(void) const
This class bridges a vector of cItem for safe access via Lua.
Vector3< T > addedY(T a_AddY) const
Returns a copy of this vector moved by the specified amount on the y axis.