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-c427514a06d6master
parent
9fa165488b
commit
ea2ed2c918
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
** Lua binding: AllToLua
|
||||
** Generated automatically by tolua++-1.0.92 on 10/03/12 09:15:14.
|
||||
** Generated automatically by tolua++-1.0.92 on 10/03/12 10:03:23.
|
||||
*/
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
@ -2874,9 +2874,9 @@ static int tolua_AllToLua_IsValidBlock00(lua_State* tolua_S)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
int a_BlockID = ((int) tolua_tonumber(tolua_S,1,0));
|
||||
int a_BlockType = ((int) tolua_tonumber(tolua_S,1,0));
|
||||
{
|
||||
bool tolua_ret = (bool) IsValidBlock(a_BlockID);
|
||||
bool tolua_ret = (bool) IsValidBlock(a_BlockType);
|
||||
tolua_pushboolean(tolua_S,(bool)tolua_ret);
|
||||
}
|
||||
}
|
||||
|
@ -12181,9 +12181,9 @@ static int tolua_AllToLua_cWorld_GrowTreeByBiome00(lua_State* tolua_S)
|
|||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: GrowPlant of class cWorld */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GrowPlant00
|
||||
static int tolua_AllToLua_cWorld_GrowPlant00(lua_State* tolua_S)
|
||||
/* method: GrowRipePlant of class cWorld */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GrowRipePlant00
|
||||
static int tolua_AllToLua_cWorld_GrowRipePlant00(lua_State* tolua_S)
|
||||
{
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
|
@ -12205,17 +12205,56 @@ static int tolua_AllToLua_cWorld_GrowPlant00(lua_State* tolua_S)
|
|||
int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
|
||||
bool a_IsByBonemeal = ((bool) tolua_toboolean(tolua_S,5,false));
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GrowPlant'", NULL);
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GrowRipePlant'", NULL);
|
||||
#endif
|
||||
{
|
||||
bool tolua_ret = (bool) self->GrowPlant(a_BlockX,a_BlockY,a_BlockZ,a_IsByBonemeal);
|
||||
bool tolua_ret = (bool) self->GrowRipePlant(a_BlockX,a_BlockY,a_BlockZ,a_IsByBonemeal);
|
||||
tolua_pushboolean(tolua_S,(bool)tolua_ret);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'GrowPlant'.",&tolua_err);
|
||||
tolua_error(tolua_S,"#ferror in function 'GrowRipePlant'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: GrowCactus of class cWorld */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GrowCactus00
|
||||
static int tolua_AllToLua_cWorld_GrowCactus00(lua_State* tolua_S)
|
||||
{
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,5,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,6,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
|
||||
int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
|
||||
int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
|
||||
int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
|
||||
int a_NumBlocksToGrow = ((int) tolua_tonumber(tolua_S,5,0));
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GrowCactus'", NULL);
|
||||
#endif
|
||||
{
|
||||
self->GrowCactus(a_BlockX,a_BlockY,a_BlockZ,a_NumBlocksToGrow);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'GrowCactus'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
@ -12260,6 +12299,45 @@ static int tolua_AllToLua_cWorld_GrowMelonPumpkin00(lua_State* tolua_S)
|
|||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: GrowSugarcane of class cWorld */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GrowSugarcane00
|
||||
static int tolua_AllToLua_cWorld_GrowSugarcane00(lua_State* tolua_S)
|
||||
{
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_Error tolua_err;
|
||||
if (
|
||||
!tolua_isusertype(tolua_S,1,"cWorld",0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
|
||||
!tolua_isnumber(tolua_S,5,0,&tolua_err) ||
|
||||
!tolua_isnoobj(tolua_S,6,&tolua_err)
|
||||
)
|
||||
goto tolua_lerror;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
cWorld* self = (cWorld*) tolua_tousertype(tolua_S,1,0);
|
||||
int a_BlockX = ((int) tolua_tonumber(tolua_S,2,0));
|
||||
int a_BlockY = ((int) tolua_tonumber(tolua_S,3,0));
|
||||
int a_BlockZ = ((int) tolua_tonumber(tolua_S,4,0));
|
||||
int a_NumBlocksToGrow = ((int) tolua_tonumber(tolua_S,5,0));
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GrowSugarcane'", NULL);
|
||||
#endif
|
||||
{
|
||||
self->GrowSugarcane(a_BlockX,a_BlockY,a_BlockZ,a_NumBlocksToGrow);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
#ifndef TOLUA_RELEASE
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'GrowSugarcane'.",&tolua_err);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif //#ifndef TOLUA_DISABLE
|
||||
|
||||
/* method: GetBiomeAt of class cWorld */
|
||||
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWorld_GetBiomeAt00
|
||||
static int tolua_AllToLua_cWorld_GetBiomeAt00(lua_State* tolua_S)
|
||||
|
@ -19440,13 +19518,13 @@ static int tolua_AllToLua_cLuaChunk_FillBlocks00(lua_State* tolua_S)
|
|||
#endif
|
||||
{
|
||||
cLuaChunk* self = (cLuaChunk*) tolua_tousertype(tolua_S,1,0);
|
||||
char a_BlockID = ((char) tolua_tonumber(tolua_S,2,0));
|
||||
char a_BlockType = ((char) tolua_tonumber(tolua_S,2,0));
|
||||
unsigned char a_BlockMeta = ((unsigned char) tolua_tonumber(tolua_S,3,0));
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'FillBlocks'", NULL);
|
||||
#endif
|
||||
{
|
||||
self->FillBlocks(a_BlockID,a_BlockMeta);
|
||||
self->FillBlocks(a_BlockType,a_BlockMeta);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -19481,13 +19559,13 @@ static int tolua_AllToLua_cLuaChunk_SetBlock00(lua_State* tolua_S)
|
|||
int a_X = ((int) tolua_tonumber(tolua_S,2,0));
|
||||
int a_Y = ((int) tolua_tonumber(tolua_S,3,0));
|
||||
int a_Z = ((int) tolua_tonumber(tolua_S,4,0));
|
||||
char a_BlockID = ((char) tolua_tonumber(tolua_S,5,0));
|
||||
char a_BlockType = ((char) tolua_tonumber(tolua_S,5,0));
|
||||
unsigned char a_BlockMeta = ((unsigned char) tolua_tonumber(tolua_S,6,0));
|
||||
#ifndef TOLUA_RELEASE
|
||||
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'SetBlock'", NULL);
|
||||
#endif
|
||||
{
|
||||
self->SetBlock(a_X,a_Y,a_Z,a_BlockID,a_BlockMeta);
|
||||
self->SetBlock(a_X,a_Y,a_Z,a_BlockType,a_BlockMeta);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -22025,8 +22103,10 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
|
|||
tolua_function(tolua_S,"GrowTree",tolua_AllToLua_cWorld_GrowTree00);
|
||||
tolua_function(tolua_S,"GrowTreeFromSapling",tolua_AllToLua_cWorld_GrowTreeFromSapling00);
|
||||
tolua_function(tolua_S,"GrowTreeByBiome",tolua_AllToLua_cWorld_GrowTreeByBiome00);
|
||||
tolua_function(tolua_S,"GrowPlant",tolua_AllToLua_cWorld_GrowPlant00);
|
||||
tolua_function(tolua_S,"GrowRipePlant",tolua_AllToLua_cWorld_GrowRipePlant00);
|
||||
tolua_function(tolua_S,"GrowCactus",tolua_AllToLua_cWorld_GrowCactus00);
|
||||
tolua_function(tolua_S,"GrowMelonPumpkin",tolua_AllToLua_cWorld_GrowMelonPumpkin00);
|
||||
tolua_function(tolua_S,"GrowSugarcane",tolua_AllToLua_cWorld_GrowSugarcane00);
|
||||
tolua_function(tolua_S,"GetBiomeAt",tolua_AllToLua_cWorld_GetBiomeAt00);
|
||||
tolua_function(tolua_S,"GetName",tolua_AllToLua_cWorld_GetName00);
|
||||
tolua_function(tolua_S,"SaveAllChunks",tolua_AllToLua_cWorld_SaveAllChunks00);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
** Lua binding: AllToLua
|
||||
** Generated automatically by tolua++-1.0.92 on 10/03/12 09:15:15.
|
||||
** Generated automatically by tolua++-1.0.92 on 10/03/12 10:03:23.
|
||||
*/
|
||||
|
||||
/* Exported function */
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -482,22 +482,7 @@ void cChunk::TickBlocks(MTRand & a_TickRandom)
|
|||
BLOCKTYPE ID = m_BlockTypes[Index];
|
||||
switch( ID )
|
||||
{
|
||||
case E_BLOCK_CROPS:
|
||||
{
|
||||
NIBBLETYPE Meta = GetMeta(Index);
|
||||
if (Meta < 7)
|
||||
{
|
||||
FastSetBlock(m_BlockTickX, m_BlockTickY, m_BlockTickZ, E_BLOCK_CROPS, ++Meta);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case E_BLOCK_PUMPKIN_STEM:
|
||||
case E_BLOCK_MELON_STEM: TickMelonPumpkin(m_BlockTickX, m_BlockTickY, m_BlockTickZ, Index, ID, a_TickRandom); break;
|
||||
case E_BLOCK_FARMLAND: TickFarmland (m_BlockTickX, m_BlockTickY, m_BlockTickZ); break;
|
||||
case E_BLOCK_SUGARCANE: GrowSugarcane (m_BlockTickX, m_BlockTickY, m_BlockTickZ, 1); break;
|
||||
case E_BLOCK_CACTUS: GrowCactus (m_BlockTickX, m_BlockTickY, m_BlockTickZ, 1); break;
|
||||
|
||||
case E_BLOCK_FARMLAND: TickFarmland (m_BlockTickX, m_BlockTickY, m_BlockTickZ); break;
|
||||
|
||||
default:
|
||||
{
|
||||
|
@ -514,21 +499,6 @@ void cChunk::TickBlocks(MTRand & a_TickRandom)
|
|||
|
||||
|
||||
|
||||
void cChunk::TickMelonPumpkin(int a_RelX, int a_RelY, int a_RelZ, int a_BlockIdx, BLOCKTYPE a_BlockType, MTRand & a_TickRandom)
|
||||
{
|
||||
NIBBLETYPE Meta = GetMeta(a_BlockIdx);
|
||||
if (Meta < 7)
|
||||
{
|
||||
FastSetBlock(m_BlockTickX, m_BlockTickY, m_BlockTickZ, a_BlockType, ++Meta);
|
||||
return;
|
||||
}
|
||||
GrowMelonPumpkin(a_RelX, a_RelY, a_RelZ, a_BlockType, a_TickRandom);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cChunk::TickFarmland(int a_RelX, int a_RelY, int a_RelZ)
|
||||
{
|
||||
// TODO: Rain hydrates blocks, too. Check world weather, don't search for water if raining.
|
||||
|
|
|
@ -279,10 +279,9 @@ private:
|
|||
/// Checks the block scheduled for checking in m_ToTickBlocks[]
|
||||
void CheckBlocks(void);
|
||||
|
||||
void TickBlocks (MTRand & a_TickRandom);
|
||||
void TickGrass (int a_RelX, int a_RelY, int a_RelZ, MTRand & a_TickRandom);
|
||||
void TickMelonPumpkin(int a_RelX, int a_RelY, int a_RelZ, int a_BlockIdx, BLOCKTYPE a_BlockType, MTRand & a_TickRandom);
|
||||
void TickFarmland (int a_RelX, int a_RelY, int a_RelZ);
|
||||
void TickBlocks (MTRand & a_TickRandom);
|
||||
void TickGrass (int a_RelX, int a_RelY, int a_RelZ, MTRand & a_TickRandom);
|
||||
void TickFarmland(int a_RelX, int a_RelY, int a_RelZ);
|
||||
|
||||
/// Grows sugarcane by the specified number of blocks, but no more than 3 blocks high (used by both bonemeal and ticking)
|
||||
void GrowSugarcane (int a_RelX, int a_RelY, int a_RelZ, int a_NumBlocks);
|
||||
|
|
|
@ -222,10 +222,10 @@ public:
|
|||
/// Grows a melon or a pumpkin next to the block specified (assumed to be the stem)
|
||||
void GrowMelonPumpkin(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, MTRand & a_Rand);
|
||||
|
||||
/// Grows a sugarcane present at the block specified by the amount of blocks specified, up to the max height of 3
|
||||
/// Grows a sugarcane present at the block specified by the amount of blocks specified, up to the max height specified in the config
|
||||
void GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow);
|
||||
|
||||
/// Grows a cactus present at the block specified by the amount of blocks specified, up to the max height of 3
|
||||
/// Grows a cactus present at the block specified by the amount of blocks specified, up to the max height specified in the config
|
||||
void GrowCactus(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow);
|
||||
|
||||
/// Sets the blockticking to start at the specified block. Only one blocktick per chunk may be set, second call overwrites the first call
|
||||
|
|
|
@ -44,14 +44,14 @@ enum
|
|||
|
||||
|
||||
|
||||
inline bool IsValidBlock( int a_BlockID ) //tolua_export
|
||||
inline bool IsValidBlock( int a_BlockType ) //tolua_export
|
||||
{ //tolua_export
|
||||
if( a_BlockID > -1 &&
|
||||
a_BlockID <= 126 && //items to 109 are valid for Beta1.8.1.. 1.2.5 is up to 126
|
||||
//a_BlockID != 29 && allow pistons
|
||||
//a_BlockID != 33 && allow pistons
|
||||
a_BlockID != 34 &&
|
||||
a_BlockID != 36 )
|
||||
if( a_BlockType > -1 &&
|
||||
a_BlockType <= 126 && //items to 109 are valid for Beta1.8.1.. 1.2.5 is up to 126
|
||||
//a_BlockType != 29 && allow pistons
|
||||
//a_BlockType != 33 && allow pistons
|
||||
a_BlockType != 34 &&
|
||||
a_BlockType != 36 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -82,29 +82,29 @@ inline bool IsValidItem( int a_ItemID ) //tolua_export
|
|||
|
||||
|
||||
|
||||
inline bool IsBlockWater(BLOCKTYPE a_BlockID)
|
||||
inline bool IsBlockWater(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
return (a_BlockID == E_BLOCK_WATER || a_BlockID == E_BLOCK_STATIONARY_WATER);
|
||||
return (a_BlockType == E_BLOCK_WATER || a_BlockType == E_BLOCK_STATIONARY_WATER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
inline bool IsBlockLava(BLOCKTYPE a_BlockID)
|
||||
inline bool IsBlockLava(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
return (a_BlockID == E_BLOCK_LAVA || a_BlockID == E_BLOCK_STATIONARY_LAVA);
|
||||
return (a_BlockType == E_BLOCK_LAVA || a_BlockType == E_BLOCK_STATIONARY_LAVA);
|
||||
}
|
||||
|
||||
|
||||
inline bool IsBlockLiquid(BLOCKTYPE a_BlockID)
|
||||
inline bool IsBlockLiquid(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
return IsBlockWater(a_BlockID) || IsBlockLava(a_BlockID);
|
||||
return IsBlockWater(a_BlockType) || IsBlockLava(a_BlockType);
|
||||
}
|
||||
|
||||
inline bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockID)
|
||||
inline bool IsBlockTypeOfDirt(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
switch (a_BlockID)
|
||||
switch (a_BlockType)
|
||||
{
|
||||
case E_BLOCK_DIRT:
|
||||
case E_BLOCK_GRASS:
|
||||
|
@ -342,10 +342,10 @@ namespace ItemCategory
|
|||
//tolua_end
|
||||
|
||||
|
||||
inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockID)
|
||||
inline bool BlockRequiresSpecialTool(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
if(!IsValidBlock(a_BlockID)) return false;
|
||||
return g_BlockRequiresSpecialTool[a_BlockID];
|
||||
if(!IsValidBlock(a_BlockType)) return false;
|
||||
return g_BlockRequiresSpecialTool[a_BlockType];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ void cFireSimulator::Simulate( float a_Dt )
|
|||
}
|
||||
|
||||
|
||||
bool cFireSimulator::IsAllowedBlock( BLOCKTYPE a_BlockID )
|
||||
bool cFireSimulator::IsAllowedBlock( BLOCKTYPE a_BlockType )
|
||||
{
|
||||
return a_BlockID == E_BLOCK_FIRE
|
||||
|| IsBlockLava(a_BlockID);
|
||||
return a_BlockType == E_BLOCK_FIRE
|
||||
|| IsBlockLava(a_BlockType);
|
||||
}
|
||||
|
||||
void cFireSimulator::AddBlock(int a_X, int a_Y, int a_Z)
|
||||
|
@ -78,26 +78,26 @@ void cFireSimulator::_AddBlock(int a_X, int a_Y, int a_Z)
|
|||
|
||||
}
|
||||
|
||||
bool cFireSimulator::IsForeverBurnable( BLOCKTYPE a_BlockID )
|
||||
bool cFireSimulator::IsForeverBurnable( BLOCKTYPE a_BlockType )
|
||||
{
|
||||
return a_BlockID == E_BLOCK_BLOODSTONE;
|
||||
return a_BlockType == E_BLOCK_BLOODSTONE;
|
||||
}
|
||||
|
||||
bool cFireSimulator::IsBurnable( BLOCKTYPE a_BlockID )
|
||||
bool cFireSimulator::IsBurnable( BLOCKTYPE a_BlockType )
|
||||
{
|
||||
return a_BlockID == E_BLOCK_PLANKS
|
||||
|| a_BlockID == E_BLOCK_LEAVES
|
||||
|| a_BlockID == E_BLOCK_LOG
|
||||
|| a_BlockID == E_BLOCK_WOOL
|
||||
|| a_BlockID == E_BLOCK_BOOKCASE
|
||||
|| a_BlockID == E_BLOCK_FENCE
|
||||
|| a_BlockID == E_BLOCK_TNT
|
||||
|| a_BlockID == E_BLOCK_VINES;
|
||||
return a_BlockType == E_BLOCK_PLANKS
|
||||
|| a_BlockType == E_BLOCK_LEAVES
|
||||
|| a_BlockType == E_BLOCK_LOG
|
||||
|| a_BlockType == E_BLOCK_WOOL
|
||||
|| a_BlockType == E_BLOCK_BOOKCASE
|
||||
|| a_BlockType == E_BLOCK_FENCE
|
||||
|| a_BlockType == E_BLOCK_TNT
|
||||
|| a_BlockType == E_BLOCK_VINES;
|
||||
}
|
||||
|
||||
bool cFireSimulator::FiresForever( BLOCKTYPE a_BlockID )
|
||||
bool cFireSimulator::FiresForever( BLOCKTYPE a_BlockType )
|
||||
{
|
||||
return a_BlockID != E_BLOCK_FIRE;
|
||||
return a_BlockType != E_BLOCK_FIRE;
|
||||
}
|
||||
|
||||
bool cFireSimulator::BurnBlockAround(int a_X, int a_Y, int a_Z)
|
||||
|
|
|
@ -23,11 +23,11 @@ public:
|
|||
|
||||
virtual void Simulate( float a_Dt ) override;
|
||||
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockID ) override;
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) override;
|
||||
|
||||
virtual bool IsBurnable( BLOCKTYPE a_BlockID );
|
||||
virtual bool IsForeverBurnable( BLOCKTYPE a_BlockID );
|
||||
virtual bool FiresForever( BLOCKTYPE a_BlockID );
|
||||
virtual bool IsBurnable( BLOCKTYPE a_BlockType );
|
||||
virtual bool IsForeverBurnable( BLOCKTYPE a_BlockType );
|
||||
virtual bool FiresForever( BLOCKTYPE a_BlockType );
|
||||
|
||||
protected:
|
||||
virtual void AddBlock(int a_X, int a_Y, int a_Z) override;
|
||||
|
|
|
@ -436,30 +436,30 @@ void cFluidSimulator::Simulate( float a_Dt )
|
|||
|
||||
|
||||
|
||||
bool cFluidSimulator::IsPassableForFluid(BLOCKTYPE a_BlockID)
|
||||
bool cFluidSimulator::IsPassableForFluid(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
return a_BlockID == E_BLOCK_AIR
|
||||
|| a_BlockID == E_BLOCK_FIRE
|
||||
|| IsAllowedBlock(a_BlockID)
|
||||
|| CanWashAway(a_BlockID);
|
||||
return a_BlockType == E_BLOCK_AIR
|
||||
|| a_BlockType == E_BLOCK_FIRE
|
||||
|| IsAllowedBlock(a_BlockType)
|
||||
|| CanWashAway(a_BlockType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cFluidSimulator::IsStationaryBlock (BLOCKTYPE a_BlockID)
|
||||
bool cFluidSimulator::IsStationaryBlock (BLOCKTYPE a_BlockType)
|
||||
{
|
||||
return a_BlockID == m_StationaryFluidBlock;
|
||||
return a_BlockType == m_StationaryFluidBlock;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool cFluidSimulator::CanWashAway( BLOCKTYPE a_BlockID )
|
||||
bool cFluidSimulator::CanWashAway( BLOCKTYPE a_BlockType )
|
||||
{
|
||||
switch( a_BlockID )
|
||||
switch( a_BlockType )
|
||||
{
|
||||
case E_BLOCK_YELLOW_FLOWER:
|
||||
case E_BLOCK_RED_ROSE:
|
||||
|
@ -476,13 +476,13 @@ bool cFluidSimulator::CanWashAway( BLOCKTYPE a_BlockID )
|
|||
|
||||
|
||||
|
||||
bool cFluidSimulator::IsSolidBlock( BLOCKTYPE a_BlockID )
|
||||
bool cFluidSimulator::IsSolidBlock( BLOCKTYPE a_BlockType )
|
||||
{
|
||||
return !(a_BlockID == E_BLOCK_AIR
|
||||
|| a_BlockID == E_BLOCK_FIRE
|
||||
|| IsBlockLava(a_BlockID)
|
||||
|| IsBlockWater(a_BlockID)
|
||||
|| CanWashAway(a_BlockID));
|
||||
return !(a_BlockType == E_BLOCK_AIR
|
||||
|| a_BlockType == E_BLOCK_FIRE
|
||||
|| IsBlockLava(a_BlockType)
|
||||
|| IsBlockWater(a_BlockType)
|
||||
|| CanWashAway(a_BlockType));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@ public:
|
|||
//Gets the flowing direction. if a_Over is true also the block over the current block affects the direction (standard)
|
||||
Direction GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a_Over = true);
|
||||
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockID ) = 0;
|
||||
virtual bool IsStationaryBlock( BLOCKTYPE a_BlockID);
|
||||
virtual bool IsPassableForFluid( BLOCKTYPE a_BlockID );
|
||||
bool CanWashAway( BLOCKTYPE a_BlockID );
|
||||
bool IsSolidBlock(BLOCKTYPE a_BlockID);
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) = 0;
|
||||
virtual bool IsStationaryBlock( BLOCKTYPE a_BlockType);
|
||||
virtual bool IsPassableForFluid( BLOCKTYPE a_BlockType );
|
||||
bool CanWashAway( BLOCKTYPE a_BlockType );
|
||||
bool IsSolidBlock(BLOCKTYPE a_BlockType);
|
||||
protected:
|
||||
virtual void AddBlock( int a_X, int a_Y, int a_Z);
|
||||
char GetHighestLevelAround( int a_X, int a_Y, int a_Z );
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
#include "../World.h"
|
||||
#include "../Player.h"
|
||||
|
||||
class cItemDyeHandler : public cItemHandler
|
||||
|
||||
|
||||
|
||||
|
||||
class cItemDyeHandler :
|
||||
public cItemHandler
|
||||
{
|
||||
public:
|
||||
cItemDyeHandler(int a_ItemID)
|
||||
|
@ -20,7 +25,7 @@ public:
|
|||
// Handle growing the plants:
|
||||
if (a_Item->m_ItemHealth == E_META_DYE_WHITE)
|
||||
{
|
||||
if(a_World->GrowPlant(a_X, a_Y, a_Z, true))
|
||||
if (a_World->GrowRipePlant(a_X, a_Y, a_Z, true))
|
||||
{
|
||||
if (a_Player->GetGameMode() == eGameMode_Survival)
|
||||
{
|
||||
|
@ -32,4 +37,8 @@ public:
|
|||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ bool cItemHandler::IsPlaceable()
|
|||
|
||||
|
||||
|
||||
bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockID)
|
||||
bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
//Returns the block meta on placement
|
||||
virtual NIBBLETYPE GetBlockMeta(short a_ItemDamage);
|
||||
// Returns whether this tool/item can harvest a specific block (e.g. wooden pickaxe can harvest stone, but wood can´t) DEFAULT: False
|
||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockID);
|
||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType);
|
||||
|
||||
static cItemHandler *GetItemHandler(int a_ItemID);
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockID) override
|
||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
||||
{
|
||||
switch(a_BlockID)
|
||||
switch(a_BlockType)
|
||||
{
|
||||
case E_BLOCK_OBSIDIAN:
|
||||
return PickaxeLevel() >= 4;
|
||||
|
|
|
@ -34,9 +34,9 @@ public:
|
|||
}
|
||||
|
||||
|
||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockID) override
|
||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
||||
{
|
||||
return a_BlockID == E_BLOCK_COBWEB
|
||||
|| a_BlockID == E_BLOCK_VINES;
|
||||
return a_BlockType == E_BLOCK_COBWEB
|
||||
|| a_BlockType == E_BLOCK_VINES;
|
||||
}
|
||||
};
|
|
@ -34,8 +34,8 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockID) override
|
||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
||||
{
|
||||
return a_BlockID == E_BLOCK_SNOW;
|
||||
return a_BlockType == E_BLOCK_SNOW;
|
||||
}
|
||||
};
|
|
@ -14,8 +14,8 @@ public:
|
|||
|
||||
}
|
||||
|
||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockID) override
|
||||
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockType) override
|
||||
{
|
||||
return a_BlockID == E_BLOCK_COBWEB;
|
||||
return a_BlockType == E_BLOCK_COBWEB;
|
||||
}
|
||||
};
|
|
@ -14,7 +14,7 @@ cLavaSimulator::cLavaSimulator(cWorld *a_World)
|
|||
}
|
||||
|
||||
|
||||
bool cLavaSimulator::IsAllowedBlock(BLOCKTYPE a_BlockID)
|
||||
bool cLavaSimulator::IsAllowedBlock(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
return IsBlockLava(a_BlockID);
|
||||
return IsBlockLava(a_BlockType);
|
||||
}
|
|
@ -6,7 +6,7 @@ class cLavaSimulator : public cFluidSimulator
|
|||
public:
|
||||
cLavaSimulator( cWorld* a_World );
|
||||
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockID ) override;
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) override;
|
||||
|
||||
|
||||
};
|
|
@ -30,16 +30,16 @@ public:
|
|||
//tolua_begin
|
||||
|
||||
// Block functions
|
||||
void FillBlocks( char a_BlockID, unsigned char a_BlockMeta )
|
||||
void FillBlocks( char a_BlockType, unsigned char a_BlockMeta )
|
||||
{
|
||||
const NIBBLETYPE CompressedMeta = a_BlockMeta | a_BlockMeta << 4;
|
||||
memset( m_BlockTypes, a_BlockID, sizeof( cChunkDef::BlockTypes ) );
|
||||
memset( m_BlockTypes, a_BlockType, sizeof( cChunkDef::BlockTypes ) );
|
||||
memset( m_BlockMeta, CompressedMeta, sizeof( cChunkDef::BlockNibbles ) );
|
||||
}
|
||||
|
||||
void SetBlock( int a_X, int a_Y, int a_Z, char a_BlockID, unsigned char a_BlockMeta )
|
||||
void SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, unsigned char a_BlockMeta )
|
||||
{
|
||||
cChunkDef::SetBlock( m_BlockTypes, a_X, a_Y, a_Z, a_BlockID );
|
||||
cChunkDef::SetBlock( m_BlockTypes, a_X, a_Y, a_Z, a_BlockType );
|
||||
cChunkDef::SetNibble( m_BlockMeta, a_X, a_Y, a_Z, a_BlockMeta );
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ public:
|
|||
~cRedstoneSimulator();
|
||||
|
||||
virtual void Simulate( float a_Dt ) override;
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockID ) override { return true; }
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) override { return true; }
|
||||
|
||||
virtual void WakeUp( int a_X, int a_Y, int a_Z ) override;
|
||||
|
||||
|
|
|
@ -61,10 +61,10 @@ void cSandSimulator::Simulate( float a_Dt )
|
|||
|
||||
|
||||
|
||||
bool cSandSimulator::IsAllowedBlock( BLOCKTYPE a_BlockID )
|
||||
bool cSandSimulator::IsAllowedBlock( BLOCKTYPE a_BlockType )
|
||||
{
|
||||
return a_BlockID == E_BLOCK_SAND
|
||||
|| a_BlockID == E_BLOCK_GRAVEL;
|
||||
return a_BlockType == E_BLOCK_SAND
|
||||
|| a_BlockType == E_BLOCK_GRAVEL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -93,10 +93,10 @@ void cSandSimulator::AddBlock(int a_X, int a_Y, int a_Z)
|
|||
|
||||
|
||||
|
||||
bool cSandSimulator::IsPassable( BLOCKTYPE a_BlockID )
|
||||
bool cSandSimulator::IsPassable( BLOCKTYPE a_BlockType )
|
||||
{
|
||||
return a_BlockID == E_BLOCK_AIR
|
||||
|| IsBlockWater(a_BlockID)
|
||||
|| IsBlockLava(a_BlockID)
|
||||
|| a_BlockID == E_BLOCK_FIRE;
|
||||
return a_BlockType == E_BLOCK_AIR
|
||||
|| IsBlockWater(a_BlockType)
|
||||
|| IsBlockLava(a_BlockType)
|
||||
|| a_BlockType == E_BLOCK_FIRE;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ public:
|
|||
|
||||
virtual void Simulate( float a_Dt ) override;
|
||||
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockID ) override;
|
||||
virtual bool IsPassable( BLOCKTYPE a_BlockID );
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) override;
|
||||
virtual bool IsPassable( BLOCKTYPE a_BlockType );
|
||||
|
||||
protected:
|
||||
virtual void AddBlock(int a_X, int a_Y, int a_Z) override;
|
||||
|
|
|
@ -11,7 +11,7 @@ public:
|
|||
virtual void Simulate( float a_Dt ) = 0;
|
||||
virtual void WakeUp( int a_X, int a_Y, int a_Z );
|
||||
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockID ) = 0;
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) = 0;
|
||||
|
||||
protected:
|
||||
virtual void AddBlock(int a_X, int a_Y, int a_Z) = 0;
|
||||
|
|
|
@ -15,8 +15,8 @@ cWaterSimulator::cWaterSimulator(cWorld *a_World)
|
|||
}
|
||||
|
||||
|
||||
bool cWaterSimulator::IsAllowedBlock(BLOCKTYPE a_BlockID)
|
||||
bool cWaterSimulator::IsAllowedBlock(BLOCKTYPE a_BlockType)
|
||||
{
|
||||
return IsBlockWater(a_BlockID);
|
||||
return IsBlockWater(a_BlockType);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,6 @@ class cWaterSimulator : public cFluidSimulator
|
|||
public:
|
||||
cWaterSimulator( cWorld* a_World );
|
||||
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockID ) override;
|
||||
virtual bool IsAllowedBlock( BLOCKTYPE a_BlockType ) override;
|
||||
|
||||
};
|
|
@ -860,7 +860,7 @@ void cWorld::GrowTreeImage(const sSetBlockVector & a_Blocks)
|
|||
|
||||
|
||||
|
||||
bool cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBonemeal)
|
||||
bool cWorld::GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBonemeal)
|
||||
{
|
||||
BLOCKTYPE BlockType;
|
||||
NIBBLETYPE BlockMeta;
|
||||
|
@ -966,7 +966,7 @@ bool cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBone
|
|||
SpawnMeta = E_META_TALL_GRASS_GRASS;
|
||||
break;
|
||||
}
|
||||
} // switch (random spawn block)
|
||||
} // switch (random spawn block type)
|
||||
FastSetBlock(a_BlockX + OfsX, a_BlockY + OfsY + 1, a_BlockZ + OfsZ, SpawnType, SpawnMeta);
|
||||
} // for i - 50 times
|
||||
return true;
|
||||
|
@ -999,6 +999,15 @@ bool cWorld::GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBone
|
|||
|
||||
|
||||
|
||||
void cWorld::GrowCactus(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow)
|
||||
{
|
||||
m_ChunkMap->GrowCactus(a_BlockX, a_BlockY, a_BlockZ, a_NumBlocksToGrow);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cWorld::GrowMelonPumpkin(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockType)
|
||||
{
|
||||
MTRand Rand;
|
||||
|
@ -1009,6 +1018,15 @@ void cWorld::GrowMelonPumpkin(int a_BlockX, int a_BlockY, int a_BlockZ, char a_B
|
|||
|
||||
|
||||
|
||||
void cWorld::GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow)
|
||||
{
|
||||
m_ChunkMap->GrowSugarcane(a_BlockX, a_BlockY, a_BlockZ, a_NumBlocksToGrow);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int cWorld::GetBiomeAt (int a_BlockX, int a_BlockZ)
|
||||
{
|
||||
return m_ChunkMap->GetBiomeAt(a_BlockX, a_BlockZ);
|
||||
|
|
|
@ -300,11 +300,17 @@ public:
|
|||
void GrowTreeImage(const sSetBlockVector & a_Blocks);
|
||||
|
||||
/// Grows the plant at the specified block to its ripe stage (bonemeal used); returns false if the block is not growable. If a_IsBonemeal is true, block is not grown if not allowed in world.ini
|
||||
bool GrowPlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBonemeal = false); // tolua_export
|
||||
bool GrowRipePlant(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_IsByBonemeal = false); // tolua_export
|
||||
|
||||
/// Grows a cactus present at the block specified by the amount of blocks specified, up to the max height specified in the config
|
||||
void GrowCactus(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow); // tolua_export
|
||||
|
||||
/// Grows a melon or a pumpkin next to the block specified (assumed to be the stem)
|
||||
void GrowMelonPumpkin(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockType); // tolua_export
|
||||
|
||||
/// Grows a sugarcane present at the block specified by the amount of blocks specified, up to the max height specified in the config
|
||||
void GrowSugarcane(int a_BlockX, int a_BlockY, int a_BlockZ, int a_NumBlocksToGrow); // tolua_export
|
||||
|
||||
int GetBiomeAt (int a_BlockX, int a_BlockZ); // tolua_export
|
||||
|
||||
const AString & GetName(void) const { return m_WorldName; } //tolua_export
|
||||
|
|
Loading…
Reference in New Issue