Moved blockticking into blockhandler classes.
Also slightly refactored the variable / argument names (BlockID is deprecated, use BlockType instead) git-svn-id: http://mc-server.googlecode.com/svn/trunk@921 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -5,34 +5,36 @@
|
||||
|
||||
|
||||
|
||||
void cBlockBedHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir)
|
||||
void cBlockBedHandler::PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
|
||||
{
|
||||
if( a_Dir != 1 ) // Can only be placed on the floor
|
||||
return;
|
||||
|
||||
NIBBLETYPE Meta = RotationToMetaData( a_Player->GetRotation() );
|
||||
Vector3i Direction = MetaDataToDirection( Meta );
|
||||
|
||||
if (a_World->GetBlock(a_X+Direction.x, a_Y, a_Z+Direction.z) != E_BLOCK_AIR)
|
||||
if (a_Dir != 1) // Can only be placed on the floor
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, E_BLOCK_BED, Meta);
|
||||
a_World->SetBlock(a_X + Direction.x, a_Y, a_Z + Direction.z, E_BLOCK_BED, Meta | 0x8);
|
||||
NIBBLETYPE Meta = RotationToMetaData( a_Player->GetRotation() );
|
||||
Vector3i Direction = MetaDataToDirection( Meta );
|
||||
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
if (a_World->GetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z) != E_BLOCK_AIR)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_BED, Meta);
|
||||
a_World->SetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z, E_BLOCK_BED, Meta | 0x8);
|
||||
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBlockBedHandler::OnDestroyed(cWorld *a_World, int a_X, int a_Y, int a_Z)
|
||||
void cBlockBedHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
NIBBLETYPE OldMeta = a_World->GetBlockMeta(a_X, a_Y, a_Z);
|
||||
NIBBLETYPE OldMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
Vector3i ThisPos( a_X, a_Y, a_Z );
|
||||
Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ );
|
||||
Vector3i Direction = MetaDataToDirection( OldMeta & 0x7 );
|
||||
if (OldMeta & 0x8)
|
||||
{
|
||||
@@ -56,22 +58,26 @@ void cBlockBedHandler::OnDestroyed(cWorld *a_World, int a_X, int a_Y, int a_Z)
|
||||
|
||||
|
||||
|
||||
void cBlockBedHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_X, int a_Y, int a_Z)
|
||||
void cBlockBedHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_X, a_Y, a_Z);
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
if (Meta & 0x8)
|
||||
{
|
||||
// Is pillow
|
||||
a_World->BroadcastUseBed( *a_Player, a_X, a_Y, a_Z );
|
||||
a_World->BroadcastUseBed( *a_Player, a_BlockX, a_BlockY, a_BlockZ );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Is foot end
|
||||
Vector3i Direction = MetaDataToDirection( Meta & 0x7 );
|
||||
if (a_World->GetBlock(a_X + Direction.x, a_Y, a_Z + Direction.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
|
||||
if (a_World->GetBlock(a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
|
||||
{
|
||||
a_World->BroadcastUseBed( *a_Player, a_X + Direction.x, a_Y, a_Z + Direction.z );
|
||||
a_World->BroadcastUseBed(*a_Player, a_BlockX + Direction.x, a_BlockY, a_BlockZ + Direction.z );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,15 +14,15 @@ class cBlockBedHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockBedHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockBedHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override;
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_X, int a_Y, int a_Z) override;
|
||||
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z) override;
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override;
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
|
||||
|
||||
virtual bool IsUseable(void) override
|
||||
|
||||
@@ -11,8 +11,8 @@ class cBlockCactusHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockCactusHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockCactusHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ public:
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
// Reset meta to 0
|
||||
a_Pickups.push_back(cItem(m_BlockID, 1, 0));
|
||||
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
BLOCKTYPE Surface = a_World->GetBlock(a_X, a_Y - 1, a_Z);
|
||||
BLOCKTYPE Surface = a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ);
|
||||
if ((Surface != E_BLOCK_SAND) && (Surface != E_BLOCK_CACTUS))
|
||||
{
|
||||
// Cactus can only be placed on sand and itself
|
||||
@@ -35,10 +35,10 @@ public:
|
||||
|
||||
// Check surroundings. Cacti may ONLY be surrounded by air
|
||||
if (
|
||||
(a_World->GetBlock(a_X - 1, a_Y, a_Z) != E_BLOCK_AIR) ||
|
||||
(a_World->GetBlock(a_X + 1, a_Y, a_Z) != E_BLOCK_AIR) ||
|
||||
(a_World->GetBlock(a_X, a_Y, a_Z - 1) != E_BLOCK_AIR) ||
|
||||
(a_World->GetBlock(a_X, a_Y, a_Z + 1) != E_BLOCK_AIR)
|
||||
(a_World->GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ) != E_BLOCK_AIR) ||
|
||||
(a_World->GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ) != E_BLOCK_AIR) ||
|
||||
(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1) != E_BLOCK_AIR) ||
|
||||
(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1) != E_BLOCK_AIR)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
@@ -54,6 +54,12 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
a_World->GrowCactus(a_BlockX, a_BlockY, a_BlockZ, 1);
|
||||
}
|
||||
|
||||
|
||||
virtual const char * GetStepSound(void) override
|
||||
{
|
||||
return "step.cloth";
|
||||
|
||||
@@ -14,16 +14,16 @@ class cBlockChestHandler :
|
||||
public cBlockEntityHandler
|
||||
{
|
||||
public:
|
||||
cBlockChestHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockEntityHandler(a_BlockID)
|
||||
cBlockChestHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockEntityHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||
{
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, cPiston::RotationPitchToMetaData(a_Player->GetRotation(), 0));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, cPiston::RotationPitchToMetaData(a_Player->GetRotation(), 0));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ class cBlockClothHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockClothHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockClothHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
class cBlockCropsHandler : public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockCropsHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockCropsHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
MTRand rand;
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_X, a_Y, a_Z);
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
cItems Drops;
|
||||
|
||||
@@ -30,19 +30,23 @@ public:
|
||||
Drops.push_back(cItem(E_ITEM_WHEAT, 1, 0));
|
||||
}
|
||||
Drops.push_back(cItem(E_ITEM_SEEDS, (rand.randInt(3) == 0) ? 2 : 1, 0));
|
||||
a_World->SpawnItemPickups(Drops, a_X, a_Y, a_Z);
|
||||
a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
|
||||
|
||||
void OnUpdate(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
// TODO: Handle Growing here
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
if (Meta < 7)
|
||||
{
|
||||
a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_CROPS, ++Meta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
return a_World->GetBlock(a_X, a_Y - 1, a_Z) == E_BLOCK_FARMLAND;
|
||||
return a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) == E_BLOCK_FARMLAND;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ class cBlockDirtHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockDirtHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockDirtHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -26,18 +26,18 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void OnUpdate(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
if (m_BlockID != E_BLOCK_GRASS)
|
||||
if (m_BlockType != E_BLOCK_GRASS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Grass becomes dirt if there is something on top of it:
|
||||
BLOCKTYPE Above = a_World->GetBlock(a_X, a_Y + 1, a_Z);
|
||||
BLOCKTYPE Above = a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ);
|
||||
if (!g_BlockTransparent[Above] && !g_BlockOneHitDig[Above])
|
||||
{
|
||||
a_World->FastSetBlock(a_X, a_Y, a_Z, E_BLOCK_DIRT, 0);
|
||||
a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_DIRT, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
BLOCKTYPE DestBlock;
|
||||
NIBBLETYPE DestMeta;
|
||||
a_World->GetBlockTypeMeta(a_X + OfsX, a_Y + OfsY, a_Z + OfsZ, DestBlock, DestMeta);
|
||||
a_World->GetBlockTypeMeta(a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ, DestBlock, DestMeta);
|
||||
if(DestBlock != E_BLOCK_DIRT)
|
||||
{
|
||||
continue;
|
||||
@@ -59,10 +59,10 @@ public:
|
||||
|
||||
BLOCKTYPE AboveDest;
|
||||
NIBBLETYPE AboveMeta;
|
||||
a_World->GetBlockTypeMeta(a_X + OfsX, a_Y + OfsY + 1, a_Z + OfsZ, AboveDest, AboveMeta);
|
||||
a_World->GetBlockTypeMeta(a_BlockX + OfsX, a_BlockY + OfsY + 1, a_BlockZ + OfsZ, AboveDest, AboveMeta);
|
||||
if (g_BlockOneHitDig[AboveDest] || g_BlockTransparent[AboveDest])
|
||||
{
|
||||
a_World->FastSetBlock(a_X + OfsX, a_Y + OfsY, a_Z + OfsZ, E_BLOCK_GRASS, 0);
|
||||
a_World->FastSetBlock(a_BlockX + OfsX, a_BlockY + OfsY, a_BlockZ + OfsZ, E_BLOCK_GRASS, 0);
|
||||
}
|
||||
} // for i - repeat twice
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
class cBlockDispenserHandler : public cBlockEntityHandler
|
||||
{
|
||||
public:
|
||||
cBlockDispenserHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockEntityHandler(a_BlockID)
|
||||
cBlockDispenserHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockEntityHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||
{
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, cPiston::RotationPitchToMetaData(a_Player->GetRotation(), 0));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, cPiston::RotationPitchToMetaData(a_Player->GetRotation(), 0));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
|
||||
|
||||
cBlockDoorHandler::cBlockDoorHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockDoorHandler::cBlockDoorHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ cBlockDoorHandler::cBlockDoorHandler(BLOCKTYPE a_BlockID)
|
||||
|
||||
|
||||
|
||||
void cBlockDoorHandler::OnPlaced(cWorld * a_World, int a_X, int a_Y, int a_Z, int a_Dir)
|
||||
void cBlockDoorHandler::OnPlaced(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -28,24 +28,24 @@ void cBlockDoorHandler::OnPlaced(cWorld * a_World, int a_X, int a_Y, int a_Z, in
|
||||
|
||||
|
||||
|
||||
void cBlockDoorHandler::OnDestroyed(cWorld * a_World, int a_X, int a_Y, int a_Z)
|
||||
void cBlockDoorHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
char OldMeta = a_World->GetBlockMeta(a_X, a_Y, a_Z);
|
||||
char OldMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
if (OldMeta & 8)
|
||||
{
|
||||
// Was upper part of door
|
||||
if (cDoors::IsDoor(a_World->GetBlock(a_X, a_Y - 1, a_Z)))
|
||||
if (cDoors::IsDoor(a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ)))
|
||||
{
|
||||
a_World->FastSetBlock(a_X, a_Y - 1, a_Z, E_BLOCK_AIR, 0);
|
||||
a_World->FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_AIR, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Was lower part
|
||||
if (cDoors::IsDoor(a_World->GetBlock(a_X, a_Y + 1, a_Z)))
|
||||
if (cDoors::IsDoor(a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ)))
|
||||
{
|
||||
a_World->FastSetBlock(a_X, a_Y + 1, a_Z, E_BLOCK_AIR, 0);
|
||||
a_World->FastSetBlock(a_BlockX, a_BlockY + 1, a_BlockZ, E_BLOCK_AIR, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,32 +54,32 @@ void cBlockDoorHandler::OnDestroyed(cWorld * a_World, int a_X, int a_Y, int a_Z)
|
||||
|
||||
|
||||
|
||||
void cBlockDoorHandler::OnDigging(cWorld * a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z)
|
||||
void cBlockDoorHandler::OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
cDoors::ChangeDoor(a_World, a_X, a_Y, a_Z);
|
||||
cDoors::ChangeDoor(a_World, a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBlockDoorHandler::OnUse(cWorld * a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z)
|
||||
void cBlockDoorHandler::OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
cDoors::ChangeDoor(a_World, a_X, a_Y, a_Z);
|
||||
cDoors::ChangeDoor(a_World, a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBlockDoorHandler::PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir)
|
||||
void cBlockDoorHandler::PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
|
||||
{
|
||||
if (a_World->GetBlock(a_X, a_Y + 1, a_Z) == E_BLOCK_AIR)
|
||||
if (a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ) == E_BLOCK_AIR)
|
||||
{
|
||||
a_BlockMeta = cDoors::RotationToMetaData(a_Player->GetRotation());
|
||||
a_World->SetBlock(a_X, a_Y + 1, a_Z, m_BlockID, a_BlockMeta + 8);
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, a_BlockMeta);
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY + 1, a_BlockZ, m_BlockType, a_BlockMeta + 8);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, a_BlockMeta);
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ void cBlockDoorHandler::PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLET
|
||||
|
||||
const char * cBlockDoorHandler::GetStepSound(void)
|
||||
{
|
||||
return (m_BlockID == E_BLOCK_WOODEN_DOOR) ? "step.wood" : "step.stone";
|
||||
return (m_BlockType == E_BLOCK_WOODEN_DOOR) ? "step.wood" : "step.stone";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,16 +11,16 @@ class cBlockDoorHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockDoorHandler(BLOCKTYPE a_BlockID);
|
||||
virtual void OnPlaced(cWorld * a_World, int a_X, int a_Y, int a_Z, int a_Dir) override;
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_X, int a_Y, int a_Z) override;
|
||||
virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z) override;
|
||||
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z) override;
|
||||
cBlockDoorHandler(BLOCKTYPE a_BlockType);
|
||||
virtual void OnPlaced(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir) override;
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
virtual const char * GetStepSound(void) override;
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
a_Pickups.push_back(cItem((m_BlockID == E_BLOCK_WOODEN_DOOR) ? E_ITEM_WOODEN_DOOR : E_ITEM_IRON_DOOR, 1, 0));
|
||||
a_Pickups.push_back(cItem((m_BlockType == E_BLOCK_WOODEN_DOOR) ? E_ITEM_WOODEN_DOOR : E_ITEM_IRON_DOOR, 1, 0));
|
||||
}
|
||||
|
||||
virtual bool IsUseable() override
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override;
|
||||
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override;
|
||||
|
||||
virtual bool CanBePlacedOnSide(void) override
|
||||
{
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
class cBlockEntityHandler : public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockEntityHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockEntityHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@ class cBlockFireHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockFireHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockFireHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z) override
|
||||
virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
a_World->DigBlock(a_X, a_Y, a_Z);
|
||||
a_World->DigBlock(a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
|
||||
@@ -11,8 +11,8 @@ class cBlockFlowerHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockFlowerHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockFlowerHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ public:
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
// Reset meta to 0
|
||||
a_Pickups.push_back(cItem(m_BlockID, 1, 0));
|
||||
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
return IsBlockTypeOfDirt(a_World->GetBlock(a_X, a_Y - 1, a_Z));
|
||||
return IsBlockTypeOfDirt(a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ class cBlockFluidHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockFluidHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockFluidHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ class cBlockFurnaceHandler :
|
||||
public cBlockEntityHandler
|
||||
{
|
||||
public:
|
||||
cBlockFurnaceHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockEntityHandler(a_BlockID)
|
||||
cBlockFurnaceHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockEntityHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||
{
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, cPiston::RotationPitchToMetaData(a_Player->GetRotation(), 0));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, cPiston::RotationPitchToMetaData(a_Player->GetRotation(), 0));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ class cBlockGlowstoneHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockGlowstoneHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockGlowstoneHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ class cBlockGravelHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockGravelHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockGravelHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ cBlockHandler *cBlockHandler::m_BlockHandler[256];
|
||||
|
||||
|
||||
|
||||
cBlockHandler *cBlockHandler::GetBlockHandler(BLOCKTYPE a_BlockID)
|
||||
cBlockHandler *cBlockHandler::GetBlockHandler(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
if (!m_HandlerInitialized)
|
||||
{
|
||||
@@ -62,85 +62,85 @@ cBlockHandler *cBlockHandler::GetBlockHandler(BLOCKTYPE a_BlockID)
|
||||
memset(m_BlockHandler, 0, sizeof(m_BlockHandler));
|
||||
m_HandlerInitialized = true;
|
||||
}
|
||||
if (m_BlockHandler[a_BlockID] != NULL)
|
||||
if (m_BlockHandler[a_BlockType] != NULL)
|
||||
{
|
||||
return m_BlockHandler[a_BlockID];
|
||||
return m_BlockHandler[a_BlockType];
|
||||
}
|
||||
|
||||
return m_BlockHandler[a_BlockID] = CreateBlockHandler(a_BlockID);
|
||||
return m_BlockHandler[a_BlockType] = CreateBlockHandler(a_BlockType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cBlockHandler *cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockID)
|
||||
cBlockHandler *cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
switch(a_BlockID)
|
||||
switch(a_BlockType)
|
||||
{
|
||||
case E_BLOCK_SAND:
|
||||
return new cBlockSandHandler(a_BlockID);
|
||||
return new cBlockSandHandler(a_BlockType);
|
||||
case E_BLOCK_GRAVEL:
|
||||
return new cBlockGravelHandler(a_BlockID);
|
||||
return new cBlockGravelHandler(a_BlockType);
|
||||
case E_BLOCK_WOODEN_DOOR:
|
||||
case E_BLOCK_IRON_DOOR:
|
||||
return new cBlockDoorHandler(a_BlockID);
|
||||
return new cBlockDoorHandler(a_BlockType);
|
||||
case E_BLOCK_FIRE:
|
||||
return new cBlockFireHandler(a_BlockID);
|
||||
return new cBlockFireHandler(a_BlockType);
|
||||
case E_BLOCK_REDSTONE_TORCH_ON:
|
||||
case E_BLOCK_REDSTONE_TORCH_OFF:
|
||||
return new cBlockRedstoneTorchHandler(a_BlockID);
|
||||
return new cBlockRedstoneTorchHandler(a_BlockType);
|
||||
case E_BLOCK_REDSTONE_WIRE:
|
||||
return new cBlockRedstoneHandler(a_BlockID);
|
||||
return new cBlockRedstoneHandler(a_BlockType);
|
||||
case E_BLOCK_PISTON:
|
||||
case E_BLOCK_STICKY_PISTON:
|
||||
return new cBlockPistonHandler(a_BlockID);
|
||||
return new cBlockPistonHandler(a_BlockType);
|
||||
case E_BLOCK_REDSTONE_REPEATER_ON:
|
||||
case E_BLOCK_REDSTONE_REPEATER_OFF:
|
||||
return new cBlockRedstoneRepeaterHandler(a_BlockID);
|
||||
return new cBlockRedstoneRepeaterHandler(a_BlockType);
|
||||
case E_BLOCK_WORKBENCH:
|
||||
return new cBlockWorkbenchHandler(a_BlockID);
|
||||
return new cBlockWorkbenchHandler(a_BlockType);
|
||||
case E_BLOCK_SNOW:
|
||||
return new cBlockSnowHandler(a_BlockID);
|
||||
return new cBlockSnowHandler(a_BlockType);
|
||||
case E_BLOCK_TALL_GRASS:
|
||||
return new cBlockTallGrassHandler(a_BlockID);
|
||||
return new cBlockTallGrassHandler(a_BlockType);
|
||||
case E_BLOCK_VINES:
|
||||
return new cBlockVineHandler(a_BlockID);
|
||||
return new cBlockVineHandler(a_BlockType);
|
||||
case ::E_BLOCK_WOOL:
|
||||
return new cBlockClothHandler(a_BlockID);
|
||||
return new cBlockClothHandler(a_BlockType);
|
||||
case E_BLOCK_WOODEN_SLAB:
|
||||
case E_BLOCK_STONE_SLAB:
|
||||
case E_BLOCK_DOUBLE_WOODEN_SLAB:
|
||||
case E_BLOCK_DOUBLE_STONE_SLAB:
|
||||
return new cBlockSlabHandler(a_BlockID);
|
||||
return new cBlockSlabHandler(a_BlockType);
|
||||
case E_BLOCK_LOG:
|
||||
case E_BLOCK_PLANKS:
|
||||
return new cBlockWoodHandler(a_BlockID);
|
||||
return new cBlockWoodHandler(a_BlockType);
|
||||
case E_BLOCK_TORCH:
|
||||
return new cBlockTorchHandler(a_BlockID);
|
||||
return new cBlockTorchHandler(a_BlockType);
|
||||
case E_BLOCK_DIRT:
|
||||
case E_BLOCK_GRASS:
|
||||
return new cBlockDirtHandler(a_BlockID);
|
||||
return new cBlockDirtHandler(a_BlockType);
|
||||
case E_BLOCK_LEAVES:
|
||||
return new cBlockLeavesHandler(a_BlockID);
|
||||
return new cBlockLeavesHandler(a_BlockType);
|
||||
case E_BLOCK_SAPLING:
|
||||
return new cBlockSaplingHandler(a_BlockID);
|
||||
return new cBlockSaplingHandler(a_BlockType);
|
||||
case E_BLOCK_WATER:
|
||||
case E_BLOCK_STATIONARY_WATER:
|
||||
case E_BLOCK_STATIONARY_LAVA:
|
||||
case E_BLOCK_LAVA:
|
||||
return new cBlockFluidHandler(a_BlockID);
|
||||
return new cBlockFluidHandler(a_BlockType);
|
||||
case E_BLOCK_DISPENSER:
|
||||
return new cBlockDispenserHandler(a_BlockID);
|
||||
return new cBlockDispenserHandler(a_BlockType);
|
||||
case E_BLOCK_FURNACE:
|
||||
case E_BLOCK_LIT_FURNACE:
|
||||
return new cBlockFurnaceHandler(a_BlockID);
|
||||
return new cBlockFurnaceHandler(a_BlockType);
|
||||
case E_BLOCK_CHEST:
|
||||
return new cBlockChestHandler(a_BlockID);
|
||||
return new cBlockChestHandler(a_BlockType);
|
||||
case E_BLOCK_ICE:
|
||||
return new cBlockIceHandler(a_BlockID);
|
||||
return new cBlockIceHandler(a_BlockType);
|
||||
case E_BLOCK_LADDER:
|
||||
return new cBlockLadderHandler(a_BlockID);
|
||||
return new cBlockLadderHandler(a_BlockType);
|
||||
case E_BLOCK_COBBLESTONE_STAIRS:
|
||||
case E_BLOCK_BRICK_STAIRS:
|
||||
case E_BLOCK_STONE_BRICK_STAIRS:
|
||||
@@ -149,27 +149,27 @@ cBlockHandler *cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockID)
|
||||
case E_BLOCK_SPRUCE_WOOD_STAIRS:
|
||||
case E_BLOCK_BIRCH_WOOD_STAIRS:
|
||||
case E_BLOCK_JUNGLE_WOOD_STAIRS:
|
||||
return new cBlockStairsHandler(a_BlockID);
|
||||
return new cBlockStairsHandler(a_BlockType);
|
||||
case E_BLOCK_SIGN_POST:
|
||||
case E_BLOCK_WALLSIGN:
|
||||
return new cBlockSignHandler(a_BlockID);
|
||||
return new cBlockSignHandler(a_BlockType);
|
||||
case E_BLOCK_CROPS:
|
||||
return new cBlockCropsHandler(a_BlockID);
|
||||
return new cBlockCropsHandler(a_BlockType);
|
||||
case E_BLOCK_SUGARCANE:
|
||||
return new cBlockSugarcaneHandler(a_BlockID);
|
||||
return new cBlockSugarcaneHandler(a_BlockType);
|
||||
case E_BLOCK_YELLOW_FLOWER:
|
||||
case E_BLOCK_RED_ROSE:
|
||||
return new cBlockFlowerHandler(a_BlockID);
|
||||
return new cBlockFlowerHandler(a_BlockType);
|
||||
case E_BLOCK_BROWN_MUSHROOM:
|
||||
case E_BLOCK_RED_MUSHROOM:
|
||||
return new cBlockMushroomHandler(a_BlockID);
|
||||
return new cBlockMushroomHandler(a_BlockType);
|
||||
case E_BLOCK_CACTUS:
|
||||
return new cBlockCactusHandler(a_BlockID);
|
||||
return new cBlockCactusHandler(a_BlockType);
|
||||
case E_BLOCK_MELON_STEM:
|
||||
case E_BLOCK_PUMPKIN_STEM:
|
||||
return new cBlockStemsHandler(a_BlockID);
|
||||
return new cBlockStemsHandler(a_BlockType);
|
||||
case E_BLOCK_GLOWSTONE:
|
||||
return new cBlockGlowstoneHandler(a_BlockID);
|
||||
return new cBlockGlowstoneHandler(a_BlockType);
|
||||
case E_BLOCK_DIAMOND_ORE:
|
||||
case E_BLOCK_GOLD_ORE:
|
||||
case E_BLOCK_REDSTONE_ORE:
|
||||
@@ -178,18 +178,18 @@ cBlockHandler *cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockID)
|
||||
case E_BLOCK_IRON_ORE:
|
||||
case E_BLOCK_LAPIS_ORE:
|
||||
case E_BLOCK_COAL_ORE:
|
||||
return new cBlockOreHandler(a_BlockID);
|
||||
return new cBlockOreHandler(a_BlockType);
|
||||
case E_BLOCK_STONE:
|
||||
case E_BLOCK_COBBLESTONE:
|
||||
return new cBlockStoneHandler(a_BlockID);
|
||||
return new cBlockStoneHandler(a_BlockType);
|
||||
case E_BLOCK_MELON:
|
||||
return new cBlockMelonHandler(a_BlockID);
|
||||
return new cBlockMelonHandler(a_BlockType);
|
||||
case E_BLOCK_NOTE_BLOCK:
|
||||
return new cBlockNoteHandler(a_BlockID);
|
||||
return new cBlockNoteHandler(a_BlockType);
|
||||
case E_BLOCK_BED:
|
||||
return new cBlockBedHandler(a_BlockID);
|
||||
return new cBlockBedHandler(a_BlockType);
|
||||
default:
|
||||
return new cBlockHandler(a_BlockID);
|
||||
return new cBlockHandler(a_BlockType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -211,16 +211,16 @@ void cBlockHandler::Deinit()
|
||||
|
||||
|
||||
|
||||
cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockID)
|
||||
cBlockHandler::cBlockHandler(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
m_BlockID = a_BlockID;
|
||||
m_BlockType = a_BlockType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBlockHandler::OnUpdate(cWorld *a_World, int a_X, int a_Y, int a_Z)
|
||||
void cBlockHandler::OnUpdate(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ void cBlockHandler::OnUpdate(cWorld *a_World, int a_X, int a_Y, int a_Z)
|
||||
|
||||
|
||||
|
||||
void cBlockHandler::OnPlacedByPlayer(cWorld *a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z, int a_Dir)
|
||||
void cBlockHandler::OnPlacedByPlayer(cWorld *a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ void cBlockHandler::OnPlacedByPlayer(cWorld *a_World, cPlayer * a_Player, int a_
|
||||
|
||||
|
||||
|
||||
void cBlockHandler::OnDestroyedByPlayer(cWorld *a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z)
|
||||
void cBlockHandler::OnDestroyedByPlayer(cWorld *a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -244,46 +244,46 @@ void cBlockHandler::OnDestroyedByPlayer(cWorld *a_World, cPlayer * a_Player, int
|
||||
|
||||
|
||||
|
||||
void cBlockHandler::OnPlaced(cWorld *a_World, int a_X, int a_Y, int a_Z, int a_Dir)
|
||||
void cBlockHandler::OnPlaced(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir)
|
||||
{
|
||||
//Notify the neighbors
|
||||
NeighborChanged(a_World, a_X - 1, a_Y, a_Z);
|
||||
NeighborChanged(a_World, a_X + 1, a_Y, a_Z);
|
||||
NeighborChanged(a_World, a_X, a_Y - 1, a_Z);
|
||||
NeighborChanged(a_World, a_X, a_Y + 1, a_Z);
|
||||
NeighborChanged(a_World, a_X, a_Y, a_Z - 1);
|
||||
NeighborChanged(a_World, a_X, a_Y, a_Z + 1);
|
||||
NeighborChanged(a_World, a_BlockX - 1, a_BlockY, a_BlockZ);
|
||||
NeighborChanged(a_World, a_BlockX + 1, a_BlockY, a_BlockZ);
|
||||
NeighborChanged(a_World, a_BlockX, a_BlockY - 1, a_BlockZ);
|
||||
NeighborChanged(a_World, a_BlockX, a_BlockY + 1, a_BlockZ);
|
||||
NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ - 1);
|
||||
NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ + 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBlockHandler::OnDestroyed(cWorld *a_World, int a_X, int a_Y, int a_Z)
|
||||
void cBlockHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
//Notify the neighbors
|
||||
NeighborChanged(a_World, a_X - 1, a_Y, a_Z);
|
||||
NeighborChanged(a_World, a_X + 1, a_Y, a_Z);
|
||||
NeighborChanged(a_World, a_X, a_Y - 1, a_Z);
|
||||
NeighborChanged(a_World, a_X, a_Y + 1, a_Z);
|
||||
NeighborChanged(a_World, a_X, a_Y, a_Z - 1);
|
||||
NeighborChanged(a_World, a_X, a_Y, a_Z + 1);
|
||||
NeighborChanged(a_World, a_BlockX - 1, a_BlockY, a_BlockZ);
|
||||
NeighborChanged(a_World, a_BlockX + 1, a_BlockY, a_BlockZ);
|
||||
NeighborChanged(a_World, a_BlockX, a_BlockY - 1, a_BlockZ);
|
||||
NeighborChanged(a_World, a_BlockX, a_BlockY + 1, a_BlockZ);
|
||||
NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ - 1);
|
||||
NeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ + 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBlockHandler::NeighborChanged(cWorld *a_World, int a_X, int a_Y, int a_Z)
|
||||
void cBlockHandler::NeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
GetBlockHandler(a_World->GetBlock(a_X, a_Y, a_Z))->OnNeighborChanged(a_World, a_X, a_Y, a_Z);
|
||||
GetBlockHandler(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ))->OnNeighborChanged(a_World, a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBlockHandler::OnNeighborChanged(cWorld *a_World, int a_X, int a_Y, int a_Z)
|
||||
void cBlockHandler::OnNeighborChanged(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ void cBlockHandler::OnNeighborChanged(cWorld *a_World, int a_X, int a_Y, int a_Z
|
||||
|
||||
|
||||
|
||||
void cBlockHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_X, int a_Y, int a_Z)
|
||||
void cBlockHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ void cBlockHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_X, int a
|
||||
|
||||
|
||||
|
||||
void cBlockHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_X, int a_Y, int a_Z)
|
||||
void cBlockHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -307,10 +307,10 @@ void cBlockHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_X, int a_Y,
|
||||
|
||||
|
||||
|
||||
void cBlockHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir)
|
||||
void cBlockHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
|
||||
{
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, a_BlockMeta);
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, a_BlockMeta);
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -320,21 +320,21 @@ void cBlockHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_
|
||||
void cBlockHandler::ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta)
|
||||
{
|
||||
// Setting the meta to a_BlockMeta keeps most textures. The few other blocks have to override this.
|
||||
a_Pickups.push_back(cItem(m_BlockID, 1, a_BlockMeta));
|
||||
a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cBlockHandler::DropBlock(cWorld * a_World, int a_X, int a_Y, int a_Z)
|
||||
void cBlockHandler::DropBlock(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
cItems Pickups;
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_X, a_Y, a_Z);
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
ConvertToPickups(Pickups, Meta);
|
||||
if (!Pickups.empty())
|
||||
{
|
||||
a_World->SpawnItemPickups(Pickups, a_X, a_Y, a_Z);
|
||||
a_World->SpawnItemPickups(Pickups, a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,16 +351,16 @@ const char * cBlockHandler::GetStepSound()
|
||||
|
||||
|
||||
|
||||
bool cBlockHandler::CanBePlacedAt(cWorld *a_World, int a_X, int a_Y, int a_Z, char a_Dir)
|
||||
bool cBlockHandler::CanBePlacedAt(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
|
||||
{
|
||||
return CanBeAt(a_World, a_X, a_Y, a_Z);
|
||||
return CanBeAt(a_World, a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cBlockHandler::CanBeAt(cWorld *a_World, int a_X, int a_Y, int a_Z)
|
||||
bool cBlockHandler::CanBeAt(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -389,7 +389,7 @@ bool cBlockHandler::IsClickedThrough(void)
|
||||
|
||||
bool cBlockHandler::DoesIgnoreBuildCollision(void)
|
||||
{
|
||||
return (m_BlockID == E_BLOCK_AIR);
|
||||
return (m_BlockType == E_BLOCK_AIR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,43 +19,43 @@ class cPlayer;
|
||||
class cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockHandler(BLOCKTYPE a_BlockID);
|
||||
cBlockHandler(BLOCKTYPE a_BlockType);
|
||||
|
||||
// Called when the block gets ticked either by a random tick or by a queued tick
|
||||
virtual void OnUpdate(cWorld *a_World, int a_X, int a_Y, int a_Z);
|
||||
virtual void OnUpdate(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
/// Called by cBlockHandler::PlaceBlock after the player has placed a new block
|
||||
virtual void OnPlacedByPlayer(cWorld * a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z, int a_Dir);
|
||||
virtual void OnPlacedByPlayer(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir);
|
||||
|
||||
/// Called before the player has destroyed a block
|
||||
virtual void OnDestroyedByPlayer(cWorld * a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z);
|
||||
virtual void OnDestroyedByPlayer(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
/// Called when a new block was placed. Called before OnPlacedByPlayer
|
||||
virtual void OnPlaced(cWorld * a_World, int a_X, int a_Y, int a_Z, int a_Dir);
|
||||
virtual void OnPlaced(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir);
|
||||
|
||||
/// Called before a block gets destroyed / replaced with air
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_X, int a_Y, int a_Z);
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
/// Called when a direct neighbor of this block has been changed (The position is the own position, not the neighbor position)
|
||||
virtual void OnNeighborChanged(cWorld * a_World, int a_X, int a_Y, int a_Z);
|
||||
virtual void OnNeighborChanged(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
/// Notifies all neighbors of the given block about a change
|
||||
static void NeighborChanged(cWorld * a_World, int a_X, int a_Y, int a_Z);
|
||||
static void NeighborChanged(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
/// Called while the player diggs the block.
|
||||
virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z);
|
||||
virtual void OnDigging(cWorld * a_World, 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
|
||||
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z);
|
||||
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
/// This function handles the real block placement for the give block by a player and also calls OnPlacedByPlayer()
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir);
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir);
|
||||
|
||||
/// Called when the item is mined to convert it into pickups. Pickups may specify multiple items.
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta);
|
||||
|
||||
/// Handles the dropping of a block based on what ConvertToDrops() returns. This will not destroy the block
|
||||
virtual void DropBlock(cWorld * a_World, int a_X, int a_Y, int a_Z);
|
||||
virtual void DropBlock(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||
|
||||
/// Returns step sound name of block
|
||||
virtual const char * GetStepSound(void);
|
||||
@@ -93,15 +93,16 @@ public:
|
||||
|
||||
|
||||
/// Get the blockhandler for a specific block id
|
||||
static cBlockHandler * GetBlockHandler(BLOCKTYPE a_BlockID);
|
||||
static cBlockHandler * GetBlockHandler(BLOCKTYPE a_BlockType);
|
||||
|
||||
/// Deletes all initialised block handlers
|
||||
static void Deinit();
|
||||
|
||||
protected:
|
||||
BLOCKTYPE m_BlockID;
|
||||
// Creates a new blockhandler for the given block id. For internal use only, use GetBlockHandler instead.
|
||||
static cBlockHandler *CreateBlockHandler(BLOCKTYPE a_BlockID);
|
||||
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);
|
||||
static cBlockHandler *m_BlockHandler[256];
|
||||
static bool m_HandlerInitialized; //used to detect if the blockhandlers are initialized
|
||||
};
|
||||
@@ -111,9 +112,9 @@ protected:
|
||||
|
||||
|
||||
// Shortcut to get the blockhandler for a specific block
|
||||
inline cBlockHandler *BlockHandler(BLOCKTYPE a_BlockID)
|
||||
inline cBlockHandler * BlockHandler(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
return cBlockHandler::GetBlockHandler(a_BlockID);
|
||||
return cBlockHandler::GetBlockHandler(a_BlockType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ class cBlockIceHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockIceHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockIceHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
// TODO: Ice destroyed with air below it should turn into air instead of water
|
||||
a_World->FastSetBlock(a_X, a_Y, a_Z, E_BLOCK_STATIONARY_WATER, 8);
|
||||
a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_STATIONARY_WATER, 8);
|
||||
// This is called later than the real destroying of this ice block
|
||||
}
|
||||
} ;
|
||||
|
||||
@@ -13,30 +13,30 @@ class cBlockLadderHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockLadderHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockLadderHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||
{
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, cLadder::DirectionToMetaData(a_Dir));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, cLadder::DirectionToMetaData(a_Dir));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBePlacedAt(cWorld * a_World, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||
{
|
||||
AddDirection( a_X, a_Y, a_Z, a_Dir, true );
|
||||
return a_World->GetBlock( a_X, a_Y, a_Z ) != E_BLOCK_AIR;
|
||||
AddDirection( a_BlockX, a_BlockY, a_BlockZ, a_Dir, true );
|
||||
return a_World->GetBlock( a_BlockX, a_BlockY, a_BlockZ ) != E_BLOCK_AIR;
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
char Dir = cLadder::MetaDataToDirection(a_World->GetBlockMeta( a_X, a_Y, a_Z));
|
||||
return CanBePlacedAt(a_World, a_X, a_Y, a_Z, Dir);
|
||||
char Dir = cLadder::MetaDataToDirection(a_World->GetBlockMeta( a_BlockX, a_BlockY, a_BlockZ));
|
||||
return CanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, Dir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@ class cBlockLeavesHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockLeavesHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockLeavesHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -53,33 +53,33 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void OnDestroyed(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
cBlockHandler::OnDestroyed(a_World, a_X, a_Y, a_Z);
|
||||
cBlockHandler::OnDestroyed(a_World, a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
//0.5% chance of dropping an apple
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_X, a_Y, a_Z);
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
//check if Oak (0x1 and 0x2 bit not set)
|
||||
MTRand rand;
|
||||
if(!(Meta & 3) && rand.randInt(200) == 100)
|
||||
{
|
||||
cItems Drops;
|
||||
Drops.push_back(cItem(E_ITEM_RED_APPLE, 1, 0));
|
||||
a_World->SpawnItemPickups(Drops, a_X, a_Y, a_Z);
|
||||
a_World->SpawnItemPickups(Drops, a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void OnNeighborChanged(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual void OnNeighborChanged(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_X, a_Y, a_Z);
|
||||
a_World->SetBlockMeta(a_X, a_Y, a_Z, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta & 0x7); // Unset 0x8 bit so it gets checked for decay
|
||||
}
|
||||
|
||||
|
||||
virtual void OnUpdate(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_X, a_Y, a_Z);
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
if ((Meta & 0x04) != 0)
|
||||
{
|
||||
// Player-placed leaves, don't decay
|
||||
@@ -96,9 +96,9 @@ public:
|
||||
cBlockArea Area;
|
||||
if (!Area.Read(
|
||||
a_World,
|
||||
a_X - LEAVES_CHECK_DISTANCE, a_X + LEAVES_CHECK_DISTANCE,
|
||||
a_Y - LEAVES_CHECK_DISTANCE, a_Y + LEAVES_CHECK_DISTANCE,
|
||||
a_Z - LEAVES_CHECK_DISTANCE, a_Z + LEAVES_CHECK_DISTANCE,
|
||||
a_BlockX - LEAVES_CHECK_DISTANCE, a_BlockX + LEAVES_CHECK_DISTANCE,
|
||||
a_BlockY - LEAVES_CHECK_DISTANCE, a_BlockY + LEAVES_CHECK_DISTANCE,
|
||||
a_BlockZ - LEAVES_CHECK_DISTANCE, a_BlockZ + LEAVES_CHECK_DISTANCE,
|
||||
cBlockArea::baTypes)
|
||||
)
|
||||
{
|
||||
@@ -106,16 +106,16 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if (HasNearLog(Area, a_X, a_Y, a_Z))
|
||||
if (HasNearLog(Area, a_BlockX, a_BlockY, a_BlockZ))
|
||||
{
|
||||
// Wood found, the leaves stay; mark them as checked:
|
||||
a_World->SetBlockMeta(a_X, a_Y, a_Z, Meta | 0x8);
|
||||
a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x8);
|
||||
return;
|
||||
}
|
||||
// Decay the leaves:
|
||||
DropBlock(a_World, a_X, a_Y, a_Z);
|
||||
DropBlock(a_World, a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
a_World->DigBlock(a_X, a_Y, a_Z);
|
||||
a_World->DigBlock(a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ class cBlockMelonHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockMelonHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockMelonHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ class cBlockMushroomHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockMushroomHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockMushroomHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -20,13 +20,13 @@ public:
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
// Reset meta to 0
|
||||
a_Pickups.push_back(cItem(m_BlockID, 1, 0));
|
||||
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
switch (a_World->GetBlock(a_X, a_Y - 1, a_Z))
|
||||
switch (a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))
|
||||
{
|
||||
case E_BLOCK_GLASS:
|
||||
case E_BLOCK_CACTUS:
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
class cBlockNoteHandler : public cBlockEntityHandler
|
||||
{
|
||||
public:
|
||||
cBlockNoteHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockEntityHandler(a_BlockID)
|
||||
cBlockNoteHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockEntityHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ class cBlockOreHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockOreHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockOreHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
short Meta = 0;
|
||||
|
||||
MTRand r1;
|
||||
switch (m_BlockID)
|
||||
switch (m_BlockType)
|
||||
{
|
||||
case E_BLOCK_LAPIS_ORE:
|
||||
{
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
switch (m_BlockID)
|
||||
switch (m_BlockType)
|
||||
{
|
||||
case E_BLOCK_DIAMOND_ORE:
|
||||
{
|
||||
|
||||
@@ -15,23 +15,30 @@
|
||||
|
||||
|
||||
|
||||
cBlockPistonHandler::cBlockPistonHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockPistonHandler::cBlockPistonHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
void cBlockPistonHandler::OnPlaced(cWorld *a_World, int a_X, int a_Y, int a_Z, int a_Dir)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
void cBlockPistonHandler::OnPlaced(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir)
|
||||
{
|
||||
}
|
||||
|
||||
void cBlockPistonHandler::OnDestroyed(cWorld *a_World, int a_X, int a_Y, int a_Z)
|
||||
{
|
||||
char OldMeta = a_World->GetBlockMeta(a_X, a_Y, a_Z);
|
||||
|
||||
int newX = a_X;
|
||||
int newY = a_Y;
|
||||
int newZ = a_Z;
|
||||
|
||||
|
||||
|
||||
void cBlockPistonHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
char OldMeta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
int newX = a_BlockX;
|
||||
int newY = a_BlockY;
|
||||
int newZ = a_BlockZ;
|
||||
AddPistonDir(newX, newY, newZ, OldMeta & ~(8), 1);
|
||||
|
||||
if (a_World->GetBlock(newX, newY, newZ) == E_BLOCK_PISTON_EXTENSION)
|
||||
@@ -40,12 +47,20 @@ void cBlockPistonHandler::OnDestroyed(cWorld *a_World, int a_X, int a_Y, int a_Z
|
||||
}
|
||||
}
|
||||
|
||||
void cBlockPistonHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir)
|
||||
|
||||
|
||||
|
||||
|
||||
void cBlockPistonHandler::PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
|
||||
{
|
||||
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, cPiston::RotationPitchToMetaData(a_Player->GetRotation(), a_Player->GetPitch()));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, cPiston::RotationPitchToMetaData(a_Player->GetRotation(), a_Player->GetPitch()));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
|
||||
cRedstone Redstone(a_World);
|
||||
Redstone.ChangeRedstone(a_X, a_Y, a_Z, false);
|
||||
}
|
||||
Redstone.ChangeRedstone(a_BlockX, a_BlockY, a_BlockZ, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
class cBlockPistonHandler : public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockPistonHandler(BLOCKTYPE a_BlockID);
|
||||
virtual void OnPlaced(cWorld *a_World, int a_X, int a_Y, int a_Z, int a_Dir) override;
|
||||
virtual void OnDestroyed(cWorld *a_World, int a_X, int a_Y, int a_Z) override;
|
||||
cBlockPistonHandler(BLOCKTYPE a_BlockType);
|
||||
virtual void OnPlaced(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir) override;
|
||||
virtual void OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
|
||||
|
||||
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override;
|
||||
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override;
|
||||
|
||||
};
|
||||
@@ -5,30 +5,30 @@
|
||||
#include "../Redstone.h"
|
||||
#include "../Torch.h"
|
||||
|
||||
cBlockRedstoneHandler::cBlockRedstoneHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockRedstoneHandler::cBlockRedstoneHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
void cBlockRedstoneHandler::OnPlaced(cWorld *a_World, int a_X, int a_Y, int a_Z, int a_Dir)
|
||||
void cBlockRedstoneHandler::OnPlaced(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir)
|
||||
{
|
||||
cRedstone Redstone(a_World);
|
||||
bool Added = false;
|
||||
if(a_World->GetBlock(a_X, a_Y, a_Z) == E_BLOCK_REDSTONE_TORCH_ON)
|
||||
if(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_REDSTONE_TORCH_ON)
|
||||
Added = true;
|
||||
|
||||
Redstone.ChangeRedstone(a_X, a_Y, a_Z, Added);
|
||||
Redstone.ChangeRedstone(a_BlockX, a_BlockY, a_BlockZ, Added);
|
||||
}
|
||||
|
||||
void cBlockRedstoneHandler::OnDestroyed(cWorld *a_World, int a_X, int a_Y, int a_Z)
|
||||
void cBlockRedstoneHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
cRedstone Redstone(a_World);
|
||||
Redstone.ChangeRedstone(a_X, a_Y, a_Z, false);
|
||||
Redstone.ChangeRedstone(a_BlockX, a_BlockY, a_BlockZ, false);
|
||||
}
|
||||
|
||||
void cBlockRedstoneHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir)
|
||||
void cBlockRedstoneHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
|
||||
{
|
||||
switch(m_BlockID)
|
||||
switch(m_BlockType)
|
||||
{
|
||||
case E_BLOCK_REDSTONE_TORCH_ON:
|
||||
case E_BLOCK_REDSTONE_TORCH_OFF:
|
||||
@@ -36,6 +36,6 @@ void cBlockRedstoneHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBL
|
||||
break;
|
||||
|
||||
}
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, a_BlockMeta);
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, a_BlockMeta);
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
@@ -12,30 +12,38 @@ class cBlockRedstoneHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockRedstoneHandler(BLOCKTYPE a_BlockID);
|
||||
virtual void OnPlaced(cWorld * a_World, int a_X, int a_Y, int a_Z, int a_Dir) override;
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_X, int a_Y, int a_Z) override;
|
||||
cBlockRedstoneHandler(BLOCKTYPE a_BlockType);
|
||||
virtual void OnPlaced(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir) override;
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override;
|
||||
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override;
|
||||
|
||||
virtual bool DoesAllowBlockOnTop(void) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
return a_World->GetBlock(a_X, a_Y - 1, a_Z) != E_BLOCK_AIR;
|
||||
return a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) != E_BLOCK_AIR;
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
// Reset meta to 0
|
||||
a_Pickups.push_back(cItem(E_ITEM_REDSTONE_DUST, 1));
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBePlacedOnSide(void) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,35 +5,35 @@
|
||||
#include "../Redstone.h"
|
||||
#include "../Player.h"
|
||||
|
||||
cBlockRedstoneRepeaterHandler::cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockRedstoneRepeaterHandler::cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
void cBlockRedstoneRepeaterHandler::OnPlaced(cWorld *a_World, int a_X, int a_Y, int a_Z, int a_Dir)
|
||||
void cBlockRedstoneRepeaterHandler::OnPlaced(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir)
|
||||
{
|
||||
cRedstone Redstone(a_World);
|
||||
Redstone.ChangeRedstone(a_X, a_Y, a_Z, false);
|
||||
Redstone.ChangeRedstone(a_BlockX, a_BlockY, a_BlockZ, false);
|
||||
}
|
||||
|
||||
void cBlockRedstoneRepeaterHandler::OnDestroyed(cWorld *a_World, int a_X, int a_Y, int a_Z)
|
||||
void cBlockRedstoneRepeaterHandler::OnDestroyed(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
cRedstone Redstone(a_World);
|
||||
Redstone.ChangeRedstone(a_X, a_Y, a_Z, false);
|
||||
Redstone.ChangeRedstone(a_BlockX, a_BlockY, a_BlockZ, false);
|
||||
}
|
||||
|
||||
void cBlockRedstoneRepeaterHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_X, int a_Y, int a_Z)
|
||||
void cBlockRedstoneRepeaterHandler::OnUse(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
a_World->FastSetBlock(a_X, a_Y, a_Z, m_BlockID, ((a_World->GetBlockMeta(a_X, a_Y, a_Z) + 0x04) & 0x0f));
|
||||
a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, ((a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) + 0x04) & 0x0f));
|
||||
}
|
||||
|
||||
void cBlockRedstoneRepeaterHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_X, int a_Y, int a_Z)
|
||||
void cBlockRedstoneRepeaterHandler::OnDigging(cWorld *a_World, cPlayer *a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
OnUse(a_World, a_Player, a_X, a_Y, a_Z);
|
||||
OnUse(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
|
||||
void cBlockRedstoneRepeaterHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir)
|
||||
void cBlockRedstoneRepeaterHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
|
||||
{
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, cRedstone::RepeaterRotationToMetaData(a_Player->GetRotation()));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, cRedstone::RepeaterRotationToMetaData(a_Player->GetRotation()));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
@@ -12,12 +12,12 @@ class cBlockRedstoneRepeaterHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockID);
|
||||
virtual void OnPlaced(cWorld * a_World, int a_X, int a_Y, int a_Z, int a_Dir) override;
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_X, int a_Y, int a_Z) override;
|
||||
cBlockRedstoneRepeaterHandler(BLOCKTYPE a_BlockType);
|
||||
virtual void OnPlaced(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir) override;
|
||||
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
|
||||
virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z) override;
|
||||
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_X, int a_Y, int a_Z) override;
|
||||
virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override;
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override;
|
||||
|
||||
|
||||
virtual bool DoesAllowBlockOnTop(void) override
|
||||
@@ -42,9 +42,9 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
return a_World->GetBlock(a_X, a_Y - 1, a_Z) != E_BLOCK_AIR;
|
||||
return a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) != E_BLOCK_AIR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ class cBlockRedstoneTorchHandler :
|
||||
public cBlockTorchHandler
|
||||
{
|
||||
public:
|
||||
cBlockRedstoneTorchHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockTorchHandler(a_BlockID)
|
||||
cBlockRedstoneTorchHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockTorchHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ class cBlockSandHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockSandHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockSandHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ class cBlockSaplingHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockSaplingHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockSaplingHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cWorld *a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual bool CanBeAt(cWorld *a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
return IsBlockTypeOfDirt(a_World->GetBlock(a_X, a_Y - 1, a_Z));
|
||||
return IsBlockTypeOfDirt(a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,17 +37,17 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void OnUpdate(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_X, a_Y, a_Z);
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
if ((Meta & 0x08) != 0)
|
||||
{
|
||||
a_World->GrowTree(a_X, a_Y, a_Z);
|
||||
a_World->GrowTree(a_BlockX, a_BlockY, a_BlockZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
a_World->SetBlockMeta(a_X, a_Y, a_Z, Meta | 0x08);
|
||||
a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x08);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@ class cBlockSignHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockSignHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockSignHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||
{
|
||||
BLOCKTYPE Block;
|
||||
NIBBLETYPE Meta;
|
||||
@@ -35,8 +35,8 @@ public:
|
||||
Block = E_BLOCK_WALLSIGN;
|
||||
}
|
||||
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, Block, Meta);
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, Block, Meta);
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,23 +11,23 @@ class cBlockSlabHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockSlabHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockSlabHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
char Count = ((m_BlockID == E_BLOCK_DOUBLE_STONE_SLAB) || (m_BlockID == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? 2 : 1;
|
||||
a_Pickups.push_back(cItem(m_BlockID, Count, a_BlockMeta));
|
||||
char Count = ((m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? 2 : 1;
|
||||
a_Pickups.push_back(cItem(m_BlockType, Count, a_BlockMeta));
|
||||
}
|
||||
|
||||
|
||||
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||
{
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, DirectionToMetaData( a_Dir, a_BlockMeta ));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, DirectionToMetaData( a_Dir, a_BlockMeta ));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
virtual const char * GetStepSound(void) override
|
||||
{
|
||||
return ((m_BlockID == E_BLOCK_WOODEN_SLAB) || (m_BlockID == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone";
|
||||
return ((m_BlockType == E_BLOCK_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone";
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ class cBlockSnowHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockSnowHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockSnowHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -29,9 +29,10 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
return (a_World->GetBlock(a_X, a_Y - 1, a_Z) != E_BLOCK_AIR);
|
||||
BLOCKTYPE UnderlyingBlock = a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ);
|
||||
return g_BlockIsSnowable[UnderlyingBlock];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
class cBlockStairsHandler : public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockStairsHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockStairsHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
virtual void PlaceBlock(cWorld *a_World, cPlayer *a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||
{
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, cStairs::RotationToMetaData(a_Player->GetRotation(), a_Dir));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, cStairs::RotationToMetaData(a_Player->GetRotation(), a_Dir));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
|
||||
//TODO: step sound
|
||||
|
||||
@@ -13,27 +13,37 @@ class cBlockStemsHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockStemsHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockStemsHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
int ItemType = (m_BlockID == E_BLOCK_MELON_STEM) ? E_ITEM_MELON_SEEDS : E_ITEM_PUMPKIN_SEEDS;
|
||||
int ItemType = (m_BlockType == E_BLOCK_MELON_STEM) ? E_ITEM_MELON_SEEDS : E_ITEM_PUMPKIN_SEEDS;
|
||||
a_Pickups.push_back(cItem(ItemType, 1, 0));
|
||||
}
|
||||
|
||||
|
||||
void OnUpdate(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
// TODO: Handle Growing here
|
||||
NIBBLETYPE Meta = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
|
||||
if (Meta >= 7)
|
||||
{
|
||||
// Grow the produce:
|
||||
a_World->GrowMelonPumpkin(a_BlockX, a_BlockY, a_BlockZ, m_BlockType);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Grow the stem:
|
||||
a_World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, Meta + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
return a_World->GetBlock(a_X, a_Y - 1, a_Z) == E_BLOCK_FARMLAND;
|
||||
return a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) == E_BLOCK_FARMLAND;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ class cBlockStoneHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockStoneHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockStoneHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ class cBlockSugarcaneHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockSugarcaneHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockSugarcaneHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -23,16 +23,16 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
switch (a_World->GetBlock(a_X, a_Y - 1, a_Z))
|
||||
switch (a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))
|
||||
{
|
||||
case E_BLOCK_DIRT:
|
||||
case E_BLOCK_GRASS:
|
||||
case E_BLOCK_FARMLAND:
|
||||
case E_BLOCK_SAND:
|
||||
{
|
||||
return a_World->IsBlockDirectlyWatered(a_X, a_Y - 1, a_Z);
|
||||
return a_World->IsBlockDirectlyWatered(a_BlockX, a_BlockY - 1, a_BlockZ);
|
||||
}
|
||||
case E_BLOCK_SUGARCANE:
|
||||
{
|
||||
@@ -43,17 +43,18 @@ public:
|
||||
}
|
||||
|
||||
|
||||
void OnUpdate(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
// TODO: Handle Growing here
|
||||
a_World->GrowSugarcane(a_BlockX, a_BlockY, a_BlockZ, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual bool CanBePlacedOnSide() override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
virtual const char * GetStepSound(void) override
|
||||
{
|
||||
return "step.grass";
|
||||
|
||||
@@ -11,8 +11,8 @@ class cBlockTallGrassHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockTallGrassHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockTallGrassHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
return a_World->GetBlock(a_X, a_Y - 1, a_Z) != E_BLOCK_AIR;
|
||||
return a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) != E_BLOCK_AIR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -13,17 +13,17 @@ class cBlockTorchHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockTorchHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockTorchHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||
{
|
||||
if (!TorchCanBePlacedAt(a_World, a_X, a_Y, a_Z, a_Dir))
|
||||
if (!TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Dir))
|
||||
{
|
||||
a_Dir = FindSuitableDirection(a_World, a_X, a_Y, a_Z);
|
||||
a_Dir = FindSuitableDirection(a_World, a_BlockX, a_BlockY, a_BlockZ);
|
||||
|
||||
if (a_Dir == BLOCK_FACE_BOTTOM)
|
||||
{
|
||||
@@ -31,8 +31,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, cTorch::DirectionToMetaData(a_Dir));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, cTorch::DirectionToMetaData(a_Dir));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
static bool TorchCanBePlacedAt(cWorld * a_World, int a_X, int a_Y, int a_Z, char a_Dir)
|
||||
static bool TorchCanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
|
||||
{
|
||||
// TODO: If placing a torch from below, check all 4 XZ neighbors, place it on that neighbor instead
|
||||
// How to propagate that change up?
|
||||
@@ -125,18 +125,18 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
AddDirection( a_X, a_Y, a_Z, a_Dir, true );
|
||||
AddDirection( a_BlockX, a_BlockY, a_BlockZ, a_Dir, true );
|
||||
|
||||
return CanBePlacedOn(a_World->GetBlock( a_X, a_Y, a_Z ), a_Dir);
|
||||
return CanBePlacedOn(a_World->GetBlock( a_BlockX, a_BlockY, a_BlockZ ), a_Dir);
|
||||
}
|
||||
|
||||
|
||||
/// Finds a suitable Direction for the Torch. Returns BLOCK_FACE_BOTTOM on failure
|
||||
static char FindSuitableDirection(cWorld * a_World, int a_X, int a_Y, int a_Z)
|
||||
static char FindSuitableDirection(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
|
||||
{
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
if (TorchCanBePlacedAt(a_World, a_X, a_Y, a_Z, i))
|
||||
if (TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, i))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
@@ -145,26 +145,26 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBePlacedAt(cWorld * a_World, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||
{
|
||||
if(TorchCanBePlacedAt(a_World, a_X, a_Y, a_Z, a_Dir))
|
||||
if(TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Dir))
|
||||
return true;
|
||||
|
||||
return FindSuitableDirection(a_World, a_X, a_Y, a_Z) != BLOCK_FACE_BOTTOM;
|
||||
return FindSuitableDirection(a_World, a_BlockX, a_BlockY, a_BlockZ) != BLOCK_FACE_BOTTOM;
|
||||
}
|
||||
|
||||
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_X, int a_Y, int a_Z) override
|
||||
virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
|
||||
{
|
||||
char Dir = cTorch::MetaDataToDirection(a_World->GetBlockMeta( a_X, a_Y, a_Z));
|
||||
return TorchCanBePlacedAt(a_World, a_X, a_Y, a_Z, Dir);
|
||||
char Dir = cTorch::MetaDataToDirection(a_World->GetBlockMeta( a_BlockX, a_BlockY, a_BlockZ));
|
||||
return TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, Dir);
|
||||
}
|
||||
|
||||
|
||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||
{
|
||||
// Always drop meta = 0
|
||||
a_Pickups.push_back(cItem(m_BlockID, 1, 0));
|
||||
a_Pickups.push_back(cItem(m_BlockType, 1, 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ class cBlockVineHandler :
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockVineHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockVineHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
virtual void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
|
||||
{
|
||||
a_World->SetBlock(a_X, a_Y, a_Z, m_BlockID, cVine::DirectionToMetaData(a_Dir));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_X, a_Y, a_Z, a_Dir);
|
||||
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, cVine::DirectionToMetaData(a_Dir));
|
||||
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
class cBlockWoodHandler : public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockWoodHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockWoodHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ class cBlockWorkbenchHandler:
|
||||
public cBlockHandler
|
||||
{
|
||||
public:
|
||||
cBlockWorkbenchHandler(BLOCKTYPE a_BlockID)
|
||||
: cBlockHandler(a_BlockID)
|
||||
cBlockWorkbenchHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user