Bulk clearing of whitespace
This commit is contained in:
@@ -18,7 +18,7 @@ public:
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
a_Pickups.push_back(cItem(E_BLOCK_ANVIL, 1, a_BlockMeta >> 2));
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
a_Player->OpenWindow(Window);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
: cMetaRotator<cBlockHandler, 0x3, 0x02, 0x03, 0x00, 0x01, true>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
// Reset meta to zero
|
||||
|
||||
@@ -34,12 +34,12 @@ public:
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_BlockMeta & 0x7;
|
||||
|
||||
|
||||
if ((Meta == E_META_BIG_FLOWER_DOUBLE_TALL_GRASS) || (Meta == E_META_BIG_FLOWER_LARGE_FERN))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
a_Pickups.push_back(cItem(E_BLOCK_BIG_FLOWER, 1, Meta));
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
{
|
||||
Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY - 1, a_BlockZ);
|
||||
}
|
||||
|
||||
|
||||
NIBBLETYPE FlowerMeta = Meta & 0x7;
|
||||
if (!a_Player->IsGameModeCreative())
|
||||
{
|
||||
|
||||
@@ -15,11 +15,11 @@ public:
|
||||
: cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, true>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
|
||||
double x(a_BlockX);
|
||||
double y(a_BlockY);
|
||||
double z(a_BlockZ);
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
// Reset meta to 0
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (Meta >= 5)
|
||||
{
|
||||
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
a_BlockMeta = a_Player->GetEquippedItem().m_ItemDamage & 0x0f;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
a_Pickups.push_back(cItem(E_BLOCK_CARPET, 1, a_BlockMeta));
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
: cMetaRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
@@ -27,14 +27,14 @@ public:
|
||||
) override
|
||||
{
|
||||
a_BlockType = m_BlockType;
|
||||
|
||||
|
||||
// Is there a doublechest already next to this block?
|
||||
if (!CanBeAt(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ))
|
||||
{
|
||||
// Yup, cannot form a triple-chest, refuse:
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Check if this forms a doublechest, if so, need to adjust the meta:
|
||||
cBlockArea Area;
|
||||
if (!Area.Read(&a_ChunkInterface, a_BlockX - 1, a_BlockX + 1, a_BlockY, a_BlockY, a_BlockZ - 1, a_BlockZ + 1))
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
a_BlockMeta = (yaw < 0) ? 4 : 5;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Single chest, get meta from rotation only
|
||||
a_BlockMeta = PlayerYawToMetaData(yaw);
|
||||
return true;
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
|
||||
return CanBeAt(a_ChunkInterface, BlockX, a_RelY, BlockZ);
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
cBlockArea Area;
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
// Cannot read the surroundings, probably at the edge of loaded chunks. Disallow.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int NumChestNeighbors = 0;
|
||||
if (Area.GetRelBlockType(1, 0, 2) == m_BlockType)
|
||||
{
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
}
|
||||
return (NumChestNeighbors < 2);
|
||||
}
|
||||
|
||||
|
||||
/** Translates player yaw when placing a chest into the chest block metadata. Valid for single chests only */
|
||||
static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
|
||||
{
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
return 0x03;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** If there's a chest in the a_Area in the specified coords, modifies its meta to a_NewMeta and returns true. */
|
||||
bool CheckAndAdjustNeighbor(cChunkInterface & a_ChunkInterface, const cBlockArea & a_Area, int a_RelX, int a_RelZ, NIBBLETYPE a_NewMeta)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
: cMetaRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03, true>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
|
||||
{
|
||||
return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
if (a_BlockMeta == E_META_DIRT_COARSE)
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
a_Pickups.Add(E_BLOCK_DIRT, 1, E_META_DIRT_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
|
||||
{
|
||||
if (m_BlockType != E_BLOCK_GRASS)
|
||||
@@ -50,21 +50,21 @@ public:
|
||||
else if ((a_RelY < cChunkDef::Height - 1))
|
||||
{
|
||||
BLOCKTYPE above = a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ);
|
||||
|
||||
|
||||
// Grass turns back to dirt when the block above is not transparent
|
||||
if (!cBlockInfo::IsTransparent(above))
|
||||
{
|
||||
a_Chunk.FastSetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_DIRT, E_META_DIRT_NORMAL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NIBBLETYPE light = std::max(a_Chunk.GetBlockLight(a_RelX, a_RelY + 1, a_RelZ), a_Chunk.GetTimeAlteredLight(a_Chunk.GetSkyLight(a_RelX, a_RelY + 1, a_RelZ)));
|
||||
// Source block is not bright enough to spread
|
||||
if (light < 9)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Grass spreads to adjacent dirt blocks:
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
int OfsX = rand.NextInt(3) - 1; // [-1 .. 1]
|
||||
int OfsY = rand.NextInt(5) - 3; // [-3 .. 1]
|
||||
int OfsZ = rand.NextInt(3) - 1; // [-1 .. 1]
|
||||
|
||||
|
||||
BLOCKTYPE DestBlock;
|
||||
NIBBLETYPE DestMeta;
|
||||
if (!cChunkDef::IsValidHeight(a_RelY + OfsY))
|
||||
|
||||
@@ -86,10 +86,10 @@ bool cBlockDoorHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterfac
|
||||
void cBlockDoorHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace)
|
||||
{
|
||||
UNUSED(a_ChunkInterface);
|
||||
|
||||
|
||||
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
|
||||
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
|
||||
if (Meta & 0x8)
|
||||
{
|
||||
// Current block is top of the door
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
a_BlockType = m_BlockType;
|
||||
a_BlockMeta = PlayerYawToMetaData(a_Player->GetYaw());
|
||||
return true;
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
{
|
||||
// Vanilla refuses to place doors on transparent blocks, except top-half slabs and other doors
|
||||
// We need to keep the door compatible with itself, otherwise the top half drops while the bottom half stays
|
||||
|
||||
|
||||
// Doors can be placed on upside-down slabs
|
||||
if (cBlockSlabHandler::IsAnySlabType(a_BlockType) && ((a_BlockMeta & 0x08) != 0))
|
||||
{
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
|
||||
{
|
||||
ASSERT((a_Yaw >= -180) && (a_Yaw < 180));
|
||||
|
||||
|
||||
a_Yaw += 90 + 45;
|
||||
if (a_Yaw > 360)
|
||||
{
|
||||
|
||||
@@ -29,12 +29,12 @@ public:
|
||||
) override
|
||||
{
|
||||
a_BlockType = m_BlockType;
|
||||
|
||||
|
||||
// FIXME: Do not use cPiston class for dispenser placement!
|
||||
a_BlockMeta = cBlockPistonHandler::RotationPitchToMetaData(a_Player->GetYaw(), a_Player->GetPitch());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Bit 0x08 is a flag. Lowest three bits are position. 0x08 == 1000
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
a_BlockMeta = RotationToMetaData(a_Player->GetYaw());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static NIBBLETYPE RotationToMetaData(double a_Rotation)
|
||||
{
|
||||
a_Rotation += 90 + 45; // So its not aligned with axis
|
||||
|
||||
@@ -14,12 +14,12 @@ public:
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
|
||||
{
|
||||
return a_ChunkInterface.UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
|
||||
|
||||
virtual bool IsUseable() override
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
|
||||
{
|
||||
ASSERT((a_Yaw >= -180) && (a_Yaw < 180));
|
||||
|
||||
|
||||
a_Yaw += 360 + 45;
|
||||
if (a_Yaw > 360)
|
||||
{
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
for (int newY = Y + 1; newY < cChunkDef::Height; newY++)
|
||||
{
|
||||
BLOCKTYPE Block = a_ChunkInterface.GetBlock(X, newY, Z);
|
||||
|
||||
@@ -11,24 +11,24 @@ class cBlockFluidHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
typedef cBlockHandler super;
|
||||
|
||||
|
||||
public:
|
||||
cBlockFluidHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
// No pickups
|
||||
}
|
||||
|
||||
|
||||
virtual bool DoesIgnoreBuildCollision(void) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual void Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) override
|
||||
{
|
||||
switch (m_BlockType)
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
super(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/** Called to tick the block */
|
||||
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
|
||||
{
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Tries to start a fire near the lava at given coords. Returns true if fire started. */
|
||||
static bool TryStartFireNear(int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
int x = (rnd % 3) - 1; // -1 .. 1
|
||||
int y = ((rnd / 4) % 4) - 1; // -1 .. 2
|
||||
int z = ((rnd / 16) % 3) - 1; // -1 .. 1
|
||||
|
||||
|
||||
// Check if it's fuel:
|
||||
BLOCKTYPE BlockType;
|
||||
if (
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Try to set it on fire:
|
||||
static struct
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
{
|
||||
a_Pickups.push_back(cItem(E_BLOCK_FURNACE, 1, 0));
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
@@ -31,10 +31,10 @@ public:
|
||||
) override
|
||||
{
|
||||
a_BlockType = m_BlockType;
|
||||
|
||||
|
||||
// FIXME: Do not use cPiston class for furnace placement!
|
||||
a_BlockMeta = cBlockPistonHandler::RotationPitchToMetaData(a_Player->GetYaw(), 0);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
// CW rotation of a CCW rotation should produce no change in the meta
|
||||
printf("Handler for blocktype %d (%s) fails CW(CCW) rotation test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
|
||||
}
|
||||
|
||||
|
||||
// Test the mirroring:
|
||||
TestMeta = Handler->MetaMirrorXY(Handler->MetaMirrorXY(Meta));
|
||||
if (TestMeta != Meta)
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
// Double-mirroring should produce the same meta:
|
||||
printf("Handler for blocktype %d (%s) fails YZ mirror test for meta %d: got back %d\n", Type, BlockName.c_str(), Meta, TestMeta);
|
||||
}
|
||||
|
||||
|
||||
// Test mirror-rotating:
|
||||
TestMeta = Handler->MetaRotateCW(Handler->MetaRotateCW(Handler->MetaMirrorXY(Handler->MetaMirrorYZ(Meta))));
|
||||
if (TestMeta != Meta)
|
||||
@@ -331,7 +331,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
||||
case E_BLOCK_WOOL: return new cBlockClothHandler (a_BlockType);
|
||||
case E_BLOCK_WORKBENCH: return new cBlockWorkbenchHandler (a_BlockType);
|
||||
case E_BLOCK_YELLOW_FLOWER: return new cBlockFlowerHandler (a_BlockType);
|
||||
|
||||
|
||||
default: return new cBlockHandler(a_BlockType);
|
||||
}
|
||||
}
|
||||
@@ -512,7 +512,7 @@ void cBlockHandler::DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterfac
|
||||
|
||||
// Allow plugins to modify the pickups:
|
||||
a_BlockPluginInterface.CallHookBlockToPickups(a_Digger, a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta, Pickups);
|
||||
|
||||
|
||||
if (!Pickups.empty())
|
||||
{
|
||||
MTRand r1;
|
||||
@@ -600,7 +600,7 @@ void cBlockHandler::Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterf
|
||||
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
|
||||
DropBlock(a_ChunkInterface, *a_Chunk.GetWorld(), a_PluginInterface, nullptr, BlockX, a_RelY, BlockZ);
|
||||
}
|
||||
|
||||
|
||||
a_Chunk.SetBlock(a_RelX, a_RelY, a_RelZ, E_BLOCK_AIR, 0);
|
||||
}
|
||||
else
|
||||
|
||||
+21
-21
@@ -23,7 +23,7 @@ class cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockHandler(BLOCKTYPE a_BlockType);
|
||||
|
||||
|
||||
virtual ~cBlockHandler() {}
|
||||
|
||||
/** Called when the block gets ticked either by a random tick or by a queued tick.
|
||||
@@ -43,71 +43,71 @@ public:
|
||||
|
||||
/** Called by cWorld::SetBlock() after the block has been set */
|
||||
virtual void OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
||||
|
||||
|
||||
/** Called by cPlayer::PlaceBlocks() for each block after it has been set to the world. Called after OnPlaced(). */
|
||||
virtual void OnPlacedByPlayer(
|
||||
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, const sSetBlock & a_BlockChange
|
||||
);
|
||||
|
||||
|
||||
/** Called before the player has destroyed a block */
|
||||
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
|
||||
/** Called before a block gets destroyed / replaced with air */
|
||||
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
|
||||
/** Called when a direct neighbor of this block has been changed (The position is the block's own position, not the changing neighbor's position)
|
||||
a_WhichNeighbor indicates which neighbor has changed. For example, BLOCK_FACE_YP meant the neighbor above has changed.
|
||||
BLOCK_FACE_NONE means that it is a neighbor not directly adjacent (diagonal, etc.) */
|
||||
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_WhichNeighbor) {}
|
||||
|
||||
|
||||
/** Notifies the specified neighbor that the current block has changed.
|
||||
a_NeighborXYZ coords are the coords of the neighbor
|
||||
a_WhichNeighbor specifies which neighbor (relative to a_NeighborXYZ) has changed.
|
||||
For example BLOCK_FACE_YP means that the block at {a_NeighborX, a_NeighborY + 1, a_NeighborZ} has changed.
|
||||
BLOCK_FACE_NONE means that it is a neighbor not directly adjacent (diagonal, etc.) */
|
||||
static void NeighborChanged(cChunkInterface & a_ChunkInterface, int a_NeighborX, int a_NeighborY, int a_NeighborZ, eBlockFace a_WhichNeighbor);
|
||||
|
||||
|
||||
/** Called when the player starts digging the block. */
|
||||
virtual void OnDigging(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) {}
|
||||
|
||||
|
||||
/** Called if the user right clicks the block and the block is useable
|
||||
returns true if the use was successful, return false to use the block as a "normal" block */
|
||||
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) { return false; }
|
||||
|
||||
|
||||
/** Called when a right click to this block is cancelled */
|
||||
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) {}
|
||||
|
||||
|
||||
/** Called when the item is mined to convert it into pickups. Pickups may specify multiple items. Appends items to a_Pickups, preserves its original contents */
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta);
|
||||
|
||||
|
||||
/** Handles the dropping, but not destruction, of a block based on what ConvertTo(Verbatim)Pickups() returns, including the spawning of pickups and alertion of plugins
|
||||
@param a_Digger The entity causing the drop; it may be nullptr
|
||||
@param a_CanDrop Informs the handler whether the block should be dropped at all. One example when this is false is when stone is destroyed by hand
|
||||
@param a_DropVerbatim Calls ConvertToVerbatimPickups() instead of its counterpart, meaning the block itself is dropped by default (due to a speical tool or enchantment)
|
||||
*/
|
||||
virtual void DropBlock(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_BlockPluginInterface, cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_CanDrop = true);
|
||||
|
||||
|
||||
/** Checks if the block can stay at the specified relative coords in the chunk */
|
||||
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk);
|
||||
|
||||
/** Checks whether the block has an effect on growing the plant */
|
||||
virtual bool CanSustainPlant(BLOCKTYPE a_Plant) { return false; }
|
||||
|
||||
|
||||
/** Checks if the block can be placed at this point.
|
||||
Default: CanBeAt(...)
|
||||
NOTE: This call doesn't actually place the block
|
||||
*/
|
||||
// virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir);
|
||||
|
||||
|
||||
/** Called to check whether this block supports a rclk action.
|
||||
If it returns true, OnUse() is called */
|
||||
virtual bool IsUseable(void);
|
||||
|
||||
|
||||
/** Indicates whether the client will click through this block.
|
||||
For example digging a fire will hit the block below the fire so fire is clicked through
|
||||
*/
|
||||
virtual bool IsClickedThrough(void);
|
||||
|
||||
|
||||
/** Checks if the player can build "inside" this block.
|
||||
For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision
|
||||
*/
|
||||
@@ -136,15 +136,15 @@ public:
|
||||
|
||||
/** Returns the base colour ID of the block, as will be represented on a map, as per documentation: http://minecraft.gamepedia.com/Map_item_format */
|
||||
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta);
|
||||
|
||||
|
||||
/** Rotates a given block meta counter-clockwise. Default: no change
|
||||
Returns block meta following rotation */
|
||||
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) { return a_Meta; }
|
||||
|
||||
|
||||
/** Rotates a given block meta clockwise. Default: no change
|
||||
Returns block meta following rotation */
|
||||
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) { return a_Meta; }
|
||||
|
||||
|
||||
/** Mirrors a given block meta around the XY plane. Default: no change
|
||||
Returns block meta following rotation */
|
||||
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) { return a_Meta; }
|
||||
@@ -156,10 +156,10 @@ public:
|
||||
/** Mirros a given block meta around the YZ plane. Default: no change
|
||||
Returns block meta following rotation */
|
||||
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) { return a_Meta; }
|
||||
|
||||
|
||||
protected:
|
||||
BLOCKTYPE m_BlockType;
|
||||
|
||||
|
||||
// Creates a new blockhandler for the given block type. For internal use only, use ::GetBlockHandler() instead.
|
||||
static cBlockHandler * CreateBlockHandler(BLOCKTYPE a_BlockType);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
) override
|
||||
{
|
||||
a_BlockType = m_BlockType;
|
||||
|
||||
|
||||
// Convert the blockface into meta:
|
||||
switch (a_BlockFace)
|
||||
{
|
||||
|
||||
@@ -21,14 +21,14 @@ public:
|
||||
{
|
||||
// No pickups
|
||||
}
|
||||
|
||||
|
||||
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
if (a_Player->IsGameModeCreative() || (a_BlockY <= 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
cEnchantments Enchantments = a_Player->GetInventory().GetEquippedItem().m_Enchantments;
|
||||
if (Enchantments.GetLevel(cEnchantments::enchSilkTouch) == 0)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
if (!LadderCanBePlacedAt(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace))
|
||||
{
|
||||
a_BlockFace = FindSuitableBlockFace(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
|
||||
if (a_BlockFace == BLOCK_FACE_BOTTOM)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void OnUpdate(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
|
||||
@@ -159,7 +159,7 @@ bool HasNearLog(cBlockArea & a_Area, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
}
|
||||
}
|
||||
} // for i - Types[]
|
||||
|
||||
|
||||
// Perform a breadth-first search to see if there's a log connected within 4 blocks of the leaves block:
|
||||
// Simply replace all reachable leaves blocks with a sponge block plus iteration (in the Area) and see if we can reach a log in 4 iterations
|
||||
a_Area.SetBlockType(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_SPONGE);
|
||||
|
||||
@@ -10,13 +10,13 @@ class cBlockLeverHandler :
|
||||
public cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false>
|
||||
{
|
||||
typedef cMetaRotator<cBlockHandler, 0x07, 0x04, 0x01, 0x03, 0x02, false> super;
|
||||
|
||||
|
||||
public:
|
||||
cBlockLeverHandler(BLOCKTYPE a_BlockType) :
|
||||
super(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
|
||||
{
|
||||
// Flip the ON bit on / off using the XOR bitwise operation
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
|
||||
|
||||
|
||||
eBlockFace Face = BlockMetaDataToBlockFace(Meta);
|
||||
|
||||
AddFaceDirection(a_RelX, a_RelY, a_RelZ, Face, true);
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
cFastRandom Random;
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
cMobHeadEntity * MobHeadEntity = static_cast<cMobHeadEntity*>(a_BlockEntity);
|
||||
|
||||
|
||||
cItems Pickups;
|
||||
Pickups.Add(E_ITEM_HEAD, 1, static_cast<short>(MobHeadEntity->GetType()));
|
||||
MTRand r1;
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
} Callback;
|
||||
|
||||
|
||||
a_WorldInterface.DoWithBlockEntityAt(a_BlockX, a_BlockY, a_BlockZ, Callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ public:
|
||||
{
|
||||
// No pickups
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
cItemHandler * Handler = a_Player->GetEquippedItem().GetHandler();
|
||||
|
||||
@@ -30,9 +30,9 @@ public:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// TODO: Cannot be at too much daylight
|
||||
|
||||
|
||||
switch (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ))
|
||||
{
|
||||
case E_BLOCK_GLASS:
|
||||
|
||||
@@ -14,7 +14,7 @@ class cBlockPistonHandler :
|
||||
{
|
||||
public:
|
||||
cBlockPistonHandler(BLOCKTYPE a_BlockType);
|
||||
|
||||
|
||||
virtual void OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override;
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
typedef std::unordered_set<Vector3i, VectorHasher<int>> Vector3iSet;
|
||||
|
||||
/** Returns true if the piston (specified by blocktype) is a sticky piston */
|
||||
@@ -153,7 +153,7 @@ private:
|
||||
const Vector3i & a_BlockPos, cWorld * a_World, bool a_RequirePushable,
|
||||
Vector3iSet & a_BlocksPushed, const Vector3i & a_PushDir
|
||||
);
|
||||
|
||||
|
||||
/** Moves a list of blocks in a specific direction */
|
||||
static void PushBlocks(const Vector3iSet & a_BlocksToPush,
|
||||
cWorld * a_World, const Vector3i & a_PushDir
|
||||
@@ -168,10 +168,10 @@ class cBlockPistonHeadHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
typedef cBlockHandler super;
|
||||
|
||||
|
||||
public:
|
||||
cBlockPistonHeadHandler(void);
|
||||
|
||||
|
||||
virtual void OnDestroyedByPlayer(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
|
||||
@@ -28,7 +28,7 @@ class cBlockPluginInterface
|
||||
{
|
||||
public:
|
||||
virtual ~cBlockPluginInterface() {}
|
||||
|
||||
|
||||
virtual bool CallHookBlockSpread(int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source) = 0;
|
||||
virtual bool CallHookBlockToPickups(cEntity * a_Digger, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, cItems & a_Pickups) = 0;
|
||||
virtual bool CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) = 0;
|
||||
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
UNUSED(a_Meta);
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
super(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
inline static NIBBLETYPE PlayerYawToMetaData(double a_Yaw)
|
||||
{
|
||||
ASSERT((a_Yaw >= -180) && (a_Yaw < 180));
|
||||
|
||||
|
||||
a_Yaw += 180 + 45;
|
||||
if (a_Yaw > 360)
|
||||
{
|
||||
|
||||
+15
-15
@@ -22,13 +22,13 @@ class cBlockRailHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
typedef cBlockHandler super;
|
||||
|
||||
|
||||
public:
|
||||
cBlockRailHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
{
|
||||
super::ConvertToPickups(a_Pickups, 0);
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
|
||||
{
|
||||
if (a_RelY <= 0)
|
||||
@@ -279,7 +279,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case E_META_RAIL_XM_XP:
|
||||
{
|
||||
if (
|
||||
@@ -291,7 +291,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case E_META_RAIL_ASCEND_XP:
|
||||
{
|
||||
if (
|
||||
@@ -303,7 +303,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case E_META_RAIL_ASCEND_XM:
|
||||
{
|
||||
if (
|
||||
@@ -315,7 +315,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case E_META_RAIL_ASCEND_ZM:
|
||||
{
|
||||
if (
|
||||
@@ -327,7 +327,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case E_META_RAIL_ASCEND_ZP:
|
||||
{
|
||||
if (
|
||||
@@ -339,7 +339,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case E_META_RAIL_CURVED_ZP_XP:
|
||||
{
|
||||
if (
|
||||
@@ -351,7 +351,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case E_META_RAIL_CURVED_ZP_XM:
|
||||
{
|
||||
if (
|
||||
@@ -363,7 +363,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case E_META_RAIL_CURVED_ZM_XM:
|
||||
{
|
||||
if (
|
||||
@@ -375,7 +375,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case E_META_RAIL_CURVED_ZM_XP:
|
||||
{
|
||||
if (
|
||||
@@ -417,7 +417,7 @@ public:
|
||||
{
|
||||
Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
|
||||
|
||||
switch (a_BlockFace)
|
||||
{
|
||||
case BLOCK_FACE_NORTH:
|
||||
@@ -434,7 +434,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case BLOCK_FACE_SOUTH:
|
||||
{
|
||||
if (
|
||||
@@ -449,7 +449,7 @@ public:
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case BLOCK_FACE_EAST:
|
||||
{
|
||||
if (
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
// Reset meta to zero
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
a_Pickups.push_back(cItem(E_BLOCK_REDSTONE_LAMP_OFF, 1, 0));
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
|
||||
{
|
||||
if (a_RelY <= 0)
|
||||
|
||||
@@ -17,18 +17,18 @@ public:
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
// Only the first 2 bits contain the display information and the 4th bit is for the growth indicator, but, we use 0x07 for forward compatibility
|
||||
a_Pickups.push_back(cItem(E_BLOCK_SAPLING, 1, a_BlockMeta & 0x07));
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
|
||||
{
|
||||
return (a_RelY > 0) && IsBlockTypeOfDirt(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ));
|
||||
}
|
||||
|
||||
|
||||
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
|
||||
@@ -13,7 +13,7 @@ class cBlockSignPostHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
typedef cBlockHandler super;
|
||||
|
||||
|
||||
public:
|
||||
cBlockSignPostHandler(BLOCKTYPE a_BlockType) :
|
||||
super(a_BlockType)
|
||||
@@ -43,9 +43,9 @@ public:
|
||||
{
|
||||
a_Rotation -= 360;
|
||||
}
|
||||
|
||||
|
||||
a_Rotation = (a_Rotation / 360) * 16;
|
||||
|
||||
|
||||
return (static_cast<char>(a_Rotation)) % 16;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
{
|
||||
a_BlockType = m_BlockType;
|
||||
NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_Player->GetEquippedItem().m_ItemDamage);
|
||||
|
||||
|
||||
// Set the correct metadata based on player equipped item (i.e. a_BlockMeta not initialised yet)
|
||||
switch (a_BlockFace)
|
||||
{
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** Returns true if the specified blocktype is one of the slabs handled by this handler */
|
||||
static bool IsAnySlabType(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
// Sends the slab back to the client. It's to refuse a doubleslab placement. */
|
||||
a_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
|
||||
}
|
||||
|
||||
|
||||
/** Converts the single-slab blocktype to its equivalent double-slab blocktype */
|
||||
static BLOCKTYPE GetDoubleSlabType(BLOCKTYPE a_SingleSlabBlockType)
|
||||
{
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
ASSERT(!"Unhandled slab type!");
|
||||
return E_BLOCK_AIR;
|
||||
}
|
||||
|
||||
|
||||
virtual NIBBLETYPE MetaMirrorXZ(NIBBLETYPE a_Meta) override
|
||||
{
|
||||
// Toggle the 4th bit - up / down:
|
||||
@@ -203,7 +203,7 @@ public:
|
||||
BLOCKTYPE Block = GetSingleSlabType(m_BlockType);
|
||||
a_Pickups.push_back(cItem(Block, 2, a_BlockMeta & 0x7));
|
||||
}
|
||||
|
||||
|
||||
inline static BLOCKTYPE GetSingleSlabType(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
switch (a_BlockType)
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
// - Height is smaller than 7, the maximum possible height
|
||||
MetaBeforePlacement++;
|
||||
}
|
||||
|
||||
|
||||
a_BlockMeta = MetaBeforePlacement;
|
||||
return true;
|
||||
}
|
||||
@@ -67,17 +67,17 @@ public:
|
||||
{
|
||||
BLOCKTYPE BlockBelow = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
|
||||
NIBBLETYPE MetaBelow = a_Chunk.GetMeta(a_RelX, a_RelY - 1, a_RelZ);
|
||||
|
||||
|
||||
if (cBlockInfo::IsSnowable(BlockBelow) || ((BlockBelow == E_BLOCK_SNOW) && (MetaBelow == 7)))
|
||||
{
|
||||
// If block below is snowable, or it is a thin slow block and has a meta of 7 (full thin snow block), say yay
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
virtual bool DoesDropOnUnsuitable(void) override
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
short ItemType = (m_BlockType == E_BLOCK_MELON_STEM) ? E_ITEM_MELON_SEEDS : E_ITEM_PUMPKIN_SEEDS;
|
||||
a_Pickups.push_back(cItem(ItemType, 1, 0));
|
||||
}
|
||||
|
||||
|
||||
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
|
||||
{
|
||||
auto Action = CanGrow(a_Chunk, a_RelX, a_RelY, a_RelZ);
|
||||
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
virtual void OnUpdate(cChunkInterface & cChunkInterface, cWorldInterface & a_WorldInterface, cBlockPluginInterface & a_PluginInterface, cChunk & a_Chunk, int a_RelX, int a_RelY, int a_RelZ) override
|
||||
{
|
||||
if (CanGrow(a_Chunk, a_RelX, a_RelY, a_RelZ) == paGrowth)
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
: cMetaRotator<cBlockHandler, 0x7, 0x4, 0x1, 0x3, 0x2>(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Finds a suitable face to place the torch, returning BLOCK_FACE_NONE on failure */
|
||||
static eBlockFace FindSuitableFace(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
// Flip the ON bit on / off using the XOR bitwise operation
|
||||
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x04);
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
|
||||
|
||||
|
||||
cWorld * World = static_cast<cWorld *>(&a_WorldInterface);
|
||||
World->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_DOOR_OPEN_CLOSE, a_BlockX, a_BlockY, a_BlockZ, 0, a_Player->GetClientHandle());
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||
@@ -117,18 +117,18 @@ public:
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void Check(cChunkInterface & a_ChunkInterface, cBlockPluginInterface & a_PluginInterface, int a_RelX, int a_RelY, int a_RelZ, cChunk & a_Chunk) override
|
||||
{
|
||||
NIBBLETYPE CurMeta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);
|
||||
NIBBLETYPE MaxMeta = GetMaxMeta(a_Chunk, a_RelX, a_RelY, a_RelZ);
|
||||
|
||||
|
||||
// Check if vine above us, add its meta to MaxMeta
|
||||
if ((a_RelY < cChunkDef::Height - 1) && (a_Chunk.GetBlock(a_RelX, a_RelY + 1, a_RelZ) == m_BlockType))
|
||||
{
|
||||
MaxMeta |= a_Chunk.GetMeta(a_RelX, a_RelY + 1, a_RelZ);
|
||||
}
|
||||
|
||||
|
||||
NIBBLETYPE Common = CurMeta & MaxMeta; // Neighbors that we have and are legal
|
||||
if (Common != CurMeta)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
|
||||
{
|
||||
cWindow * Window = new cCraftingWindow(a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
@@ -5,7 +5,7 @@ class cBroadcastInterface
|
||||
{
|
||||
public:
|
||||
virtual ~cBroadcastInterface() {}
|
||||
|
||||
|
||||
virtual void BroadcastUseBed (const cEntity & a_Entity, int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
|
||||
virtual void BroadcastSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = nullptr) = 0;
|
||||
virtual void BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = nullptr) = 0;
|
||||
|
||||
@@ -21,32 +21,32 @@ public:
|
||||
NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
|
||||
|
||||
|
||||
/** Sets the block at the specified coords to the specified value.
|
||||
Full processing, incl. updating neighbors, is performed.
|
||||
*/
|
||||
void SetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
||||
|
||||
|
||||
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData);
|
||||
|
||||
|
||||
/** Sets the block at the specified coords to the specified value.
|
||||
The replacement doesn't trigger block updates.
|
||||
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block)
|
||||
*/
|
||||
void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
||||
|
||||
|
||||
void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
||||
|
||||
/** Use block entity on coordinate.
|
||||
returns true if the use was successful, return false to use the block as a "normal" block */
|
||||
bool UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
|
||||
virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override;
|
||||
|
||||
|
||||
virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override;
|
||||
|
||||
|
||||
bool DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z);
|
||||
|
||||
|
||||
private:
|
||||
cChunkMap * m_ChunkMap;
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
cClearMetaOnDrop(BLOCKTYPE a_BlockType) :
|
||||
Base(a_BlockType)
|
||||
{}
|
||||
|
||||
|
||||
virtual ~cClearMetaOnDrop() {}
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
cMetaRotator(BLOCKTYPE a_BlockType) :
|
||||
Base(a_BlockType)
|
||||
{}
|
||||
|
||||
|
||||
virtual ~cMetaRotator() {}
|
||||
|
||||
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override;
|
||||
|
||||
@@ -17,22 +17,22 @@ class cWorldInterface
|
||||
{
|
||||
public:
|
||||
virtual ~cWorldInterface() {}
|
||||
|
||||
|
||||
virtual int GetTimeOfDay(void) const = 0;
|
||||
virtual Int64 GetWorldAge(void) const = 0;
|
||||
|
||||
|
||||
virtual eDimension GetDimension(void) const = 0;
|
||||
|
||||
|
||||
virtual cBroadcastInterface & GetBroadcastManager() = 0;
|
||||
|
||||
|
||||
virtual void DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_BlockY, double a_BlockZ, bool a_CanCauseFire, eExplosionSource a_Source, void * a_SourceData) = 0;
|
||||
|
||||
|
||||
/** Spawns item pickups for each item in the list. May compress pickups if too many entities: */
|
||||
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_FlyAwaySpeed = 1.0, bool IsPlayerCreated = false) = 0;
|
||||
|
||||
|
||||
/** Spawns item pickups for each item in the list. May compress pickups if too many entities. All pickups get the speed specified. */
|
||||
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) = 0;
|
||||
|
||||
|
||||
/** Spawns a mob of the specified type.
|
||||
Returns the mob's UniqueID if recognized and spawned, or cEntity::INVALID_ID on failure. */
|
||||
virtual UInt32 SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType, bool a_Baby) = 0;
|
||||
|
||||
Reference in New Issue
Block a user