1
0

Removed cLadder, cSign, cStairs, cTorch and cVine classes, moved their functionality into the appropriate BlockHandlers / ItemHandlers

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1555 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-06-04 19:22:14 +00:00
parent 1161c4982c
commit 3ee5236284
22 changed files with 221 additions and 575 deletions

View File

@ -1000,10 +1000,6 @@
RelativePath="..\source\Sign.h"
>
</File>
<File
RelativePath="..\source\Stairs.h"
>
</File>
<File
RelativePath="..\source\TNTEntity.cpp"
>
@ -1012,14 +1008,6 @@
RelativePath="..\source\TNTEntity.h"
>
</File>
<File
RelativePath="..\source\Torch.h"
>
</File>
<File
RelativePath="..\source\Vine.h"
>
</File>
</Filter>
<Filter
Name="UI"

View File

@ -15,11 +15,6 @@ typedef unsigned short UInt16;
$cfile "ChunkDef.h"
$cfile "Torch.h"
$cfile "Stairs.h"
$cfile "Ladder.h"
$cfile "Vine.h"
$cfile "../iniFile/iniFile.h"
$cfile "BlockID.h"

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 06/04/13 13:50:42.
** Generated automatically by tolua++-1.0.92 on 06/04/13 21:16:57.
*/
#ifndef __cplusplus
@ -16,10 +16,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "tolua_base.h"
#include "ChunkDef.h"
#include "Torch.h"
#include "Stairs.h"
#include "Ladder.h"
#include "Vine.h"
#include "../iniFile/iniFile.h"
#include "BlockID.h"
#include "Defines.h"
@ -190,10 +186,8 @@ static int tolua_collect_Vector3d (lua_State* tolua_S)
static void tolua_reg_types (lua_State* tolua_S)
{
tolua_usertype(tolua_S,"TakeDamageInfo");
tolua_usertype(tolua_S,"cCraftingGrid");
tolua_usertype(tolua_S,"cCraftingRecipe");
tolua_usertype(tolua_S,"cPlugin");
tolua_usertype(tolua_S,"cWindow");
tolua_usertype(tolua_S,"cEntity");
tolua_usertype(tolua_S,"cStringMap");
tolua_usertype(tolua_S,"cItemGrid");
tolua_usertype(tolua_S,"cBlockArea");
@ -201,265 +195,53 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cLuaWindow");
tolua_usertype(tolua_S,"cInventory");
tolua_usertype(tolua_S,"cRoot");
tolua_usertype(tolua_S,"cStairs");
tolua_usertype(tolua_S,"cGroup");
tolua_usertype(tolua_S,"cTracer");
tolua_usertype(tolua_S,"cCuboid");
tolua_usertype(tolua_S,"cWindow");
tolua_usertype(tolua_S,"cCraftingGrid");
tolua_usertype(tolua_S,"cPickup");
tolua_usertype(tolua_S,"cItems");
tolua_usertype(tolua_S,"Vector3i");
tolua_usertype(tolua_S,"cGroup");
tolua_usertype(tolua_S,"cClientHandle");
tolua_usertype(tolua_S,"cChunkDesc");
tolua_usertype(tolua_S,"cFurnaceRecipe");
tolua_usertype(tolua_S,"Lua__cPickup");
tolua_usertype(tolua_S,"cTracer");
tolua_usertype(tolua_S,"cChatColor");
tolua_usertype(tolua_S,"cWebAdmin");
tolua_usertype(tolua_S,"cCraftingRecipes");
tolua_usertype(tolua_S,"cCuboid");
tolua_usertype(tolua_S,"Vector3i");
tolua_usertype(tolua_S,"Lua__cWebPlugin");
tolua_usertype(tolua_S,"Lua__cPawn");
tolua_usertype(tolua_S,"cGroupManager");
tolua_usertype(tolua_S,"cPlugin_NewLua");
tolua_usertype(tolua_S,"cItem");
tolua_usertype(tolua_S,"Vector3f");
tolua_usertype(tolua_S,"cWebPlugin");
tolua_usertype(tolua_S,"cWebAdmin");
tolua_usertype(tolua_S,"cDropSpenserEntity");
tolua_usertype(tolua_S,"Lua__cPlayer");
tolua_usertype(tolua_S,"HTTPRequest");
tolua_usertype(tolua_S,"cCraftingRecipes");
tolua_usertype(tolua_S,"cChestEntity");
tolua_usertype(tolua_S,"cDispenserEntity");
tolua_usertype(tolua_S,"HTTPFormData");
tolua_usertype(tolua_S,"cBlockEntity");
tolua_usertype(tolua_S,"cItemGrid::cListener");
tolua_usertype(tolua_S,"cDropperEntity");
tolua_usertype(tolua_S,"cServer");
tolua_usertype(tolua_S,"cPluginManager");
tolua_usertype(tolua_S,"cBlockEntityWithItems");
tolua_usertype(tolua_S,"cLadder");
tolua_usertype(tolua_S,"cBlockEntity");
tolua_usertype(tolua_S,"cCriticalSection");
tolua_usertype(tolua_S,"cEntity");
tolua_usertype(tolua_S,"cIniFile");
tolua_usertype(tolua_S,"cListeners");
tolua_usertype(tolua_S,"AStringVector");
tolua_usertype(tolua_S,"cVine");
tolua_usertype(tolua_S,"cPlayer");
tolua_usertype(tolua_S,"cTorch");
tolua_usertype(tolua_S,"cBlockEntityWindowOwner");
tolua_usertype(tolua_S,"Lua__cPickup");
tolua_usertype(tolua_S,"cWebPlugin");
tolua_usertype(tolua_S,"HTTPRequest");
tolua_usertype(tolua_S,"HTTPFormData");
tolua_usertype(tolua_S,"cDropperEntity");
tolua_usertype(tolua_S,"cPluginManager");
tolua_usertype(tolua_S,"cWorld");
tolua_usertype(tolua_S,"cPlugin_NewLua");
tolua_usertype(tolua_S,"cIniFile");
tolua_usertype(tolua_S,"cPlugin");
tolua_usertype(tolua_S,"AStringVector");
tolua_usertype(tolua_S,"cPawn");
tolua_usertype(tolua_S,"cPlayer");
tolua_usertype(tolua_S,"cGroupManager");
tolua_usertype(tolua_S,"cBlockEntityWindowOwner");
tolua_usertype(tolua_S,"cBlockEntityWithItems");
tolua_usertype(tolua_S,"cServer");
tolua_usertype(tolua_S,"cListeners");
tolua_usertype(tolua_S,"Lua__cEntity");
tolua_usertype(tolua_S,"Vector3d");
}
/* method: DirectionToMetaData of class cTorch */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cTorch_DirectionToMetaData00
static int tolua_AllToLua_cTorch_DirectionToMetaData00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"cTorch",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
char a_Direction = ((char) tolua_tonumber(tolua_S,2,0));
{
char tolua_ret = (char) cTorch::DirectionToMetaData(a_Direction);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'DirectionToMetaData'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: MetaDataToDirection of class cTorch */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cTorch_MetaDataToDirection00
static int tolua_AllToLua_cTorch_MetaDataToDirection00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"cTorch",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
char a_MetaData = ((char) tolua_tonumber(tolua_S,2,0));
{
char tolua_ret = (char) cTorch::MetaDataToDirection(a_MetaData);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'MetaDataToDirection'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: RotationToMetaData of class cStairs */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cStairs_RotationToMetaData00
static int tolua_AllToLua_cStairs_RotationToMetaData00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"cStairs",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
double a_Rotation = ((double) tolua_tonumber(tolua_S,2,0));
{
unsigned char tolua_ret = (unsigned char) cStairs::RotationToMetaData(a_Rotation);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'RotationToMetaData'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: DirectionToMetaData of class cLadder */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cLadder_DirectionToMetaData00
static int tolua_AllToLua_cLadder_DirectionToMetaData00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"cLadder",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
char a_Direction = ((char) tolua_tonumber(tolua_S,2,0));
{
char tolua_ret = (char) cLadder::DirectionToMetaData(a_Direction);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'DirectionToMetaData'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: MetaDataToDirection of class cLadder */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cLadder_MetaDataToDirection00
static int tolua_AllToLua_cLadder_MetaDataToDirection00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"cLadder",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
char a_MetaData = ((char) tolua_tonumber(tolua_S,2,0));
{
char tolua_ret = (char) cLadder::MetaDataToDirection(a_MetaData);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'MetaDataToDirection'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: DirectionToMetaData of class cVine */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cVine_DirectionToMetaData00
static int tolua_AllToLua_cVine_DirectionToMetaData00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"cVine",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
char a_BlockFace = ((char) tolua_tonumber(tolua_S,2,0));
{
unsigned char tolua_ret = (unsigned char) cVine::DirectionToMetaData(a_BlockFace);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'DirectionToMetaData'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: MetaDataToDirection of class cVine */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cVine_MetaDataToDirection00
static int tolua_AllToLua_cVine_MetaDataToDirection00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertable(tolua_S,1,"cVine",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
unsigned char a_MetaData = (( unsigned char) tolua_tonumber(tolua_S,2,0));
{
char tolua_ret = (char) cVine::MetaDataToDirection(a_MetaData);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'MetaDataToDirection'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: new of class cIniFile */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cIniFile_new00
static int tolua_AllToLua_cIniFile_new00(lua_State* tolua_S)
@ -26656,25 +26438,6 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"biJungleHills",biJungleHills);
tolua_constant(tolua_S,"biNumBiomes",biNumBiomes);
tolua_constant(tolua_S,"biMaxBiome",biMaxBiome);
tolua_cclass(tolua_S,"cTorch","cTorch","",NULL);
tolua_beginmodule(tolua_S,"cTorch");
tolua_function(tolua_S,"DirectionToMetaData",tolua_AllToLua_cTorch_DirectionToMetaData00);
tolua_function(tolua_S,"MetaDataToDirection",tolua_AllToLua_cTorch_MetaDataToDirection00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cStairs","cStairs","",NULL);
tolua_beginmodule(tolua_S,"cStairs");
tolua_function(tolua_S,"RotationToMetaData",tolua_AllToLua_cStairs_RotationToMetaData00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cLadder","cLadder","",NULL);
tolua_beginmodule(tolua_S,"cLadder");
tolua_function(tolua_S,"DirectionToMetaData",tolua_AllToLua_cLadder_DirectionToMetaData00);
tolua_function(tolua_S,"MetaDataToDirection",tolua_AllToLua_cLadder_MetaDataToDirection00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cVine","cVine","",NULL);
tolua_beginmodule(tolua_S,"cVine");
tolua_function(tolua_S,"DirectionToMetaData",tolua_AllToLua_cVine_DirectionToMetaData00);
tolua_function(tolua_S,"MetaDataToDirection",tolua_AllToLua_cVine_MetaDataToDirection00);
tolua_endmodule(tolua_S);
#ifdef __cplusplus
tolua_cclass(tolua_S,"cIniFile","cIniFile","",tolua_collect_cIniFile);
#else

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 06/04/13 13:50:43.
** Generated automatically by tolua++-1.0.92 on 06/04/13 21:16:57.
*/
/* Exported function */

View File

@ -3,7 +3,6 @@
#include "BlockHandler.h"
#include "../World.h"
#include "../Sign.h"
#include "../Player.h"
@ -44,13 +43,11 @@ public:
}
// Bed specific helper functions
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
a_Rotation += 180 + (180/4); // So its not aligned with axis
if( a_Rotation > 360 ) a_Rotation -= 360;
a_Rotation += 180 + (180 / 4); // So its not aligned with axis
if (a_Rotation > 360) a_Rotation -= 360;
a_Rotation = (a_Rotation / 360) * 4;
@ -62,15 +59,11 @@ public:
{
switch (a_MetaData)
{
case 0: // south +z
return Vector3i(0, 0, 1);
case 1: // west -x
return Vector3i(-1, 0, 0);
case 2: // north -z
return Vector3i(0, 0, -1);
case 3: // east +x
return Vector3i(1, 0, 0);
};
case 0: return Vector3i(0, 0, 1);
case 1: return Vector3i(-1, 0, 0);
case 2: return Vector3i(0, 0, -1);
case 3: return Vector3i(1, 0, 0);
}
return Vector3i();
}
} ;

View File

@ -3,7 +3,6 @@
#include "BlockHandler.h"
#include "../World.h"
#include "../Ladder.h"
@ -37,11 +36,37 @@ public:
}
a_BlockType = m_BlockType;
a_BlockMeta = cLadder::DirectionToMetaData(a_BlockFace);
a_BlockMeta = DirectionToMetaData(a_BlockFace);
return true;
}
static NIBBLETYPE DirectionToMetaData(char a_Direction) // tolua_export
{ // tolua_export
switch (a_Direction)
{
case 0x2: return 0x2;
case 0x3: return 0x3;
case 0x4: return 0x4;
case 0x5: return 0x5;
default: return 0x2;
}
} // tolua_export
static char MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export
{ // tolua_export
switch (a_MetaData)
{
case 0x2: return 0x2;
case 0x3: return 0x3;
case 0x4: return 0x4;
case 0x5: return 0x5;
default: return 0x2;
}
} // tolua_export
/// Finds a suitable Direction for the Ladder. Returns BLOCK_FACE_BOTTOM on failure
static char FindSuitableBlockFace(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ)
{
@ -71,8 +96,8 @@ public:
virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
// TODO: Use cTorch::AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison
char BlockFace = cLadder::MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
// TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison
char BlockFace = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
return LadderCanBePlacedAt(a_Chunk.GetWorld(), BlockX, a_RelY, BlockZ, BlockFace);

View File

@ -3,7 +3,6 @@
#include "BlockRedstone.h"
#include "../Item.h"
#include "../World.h"
#include "../Torch.h"

View File

@ -3,7 +3,6 @@
#include "BlockRedstone.h"
#include "BlockTorch.h"
#include "../Torch.h"

View File

@ -3,7 +3,6 @@
#include "BlockHandler.h"
#include "../World.h"
#include "../Sign.h"
#include "../Player.h"
@ -36,6 +35,37 @@ public:
{
return "step.wood";
}
static char RotationToMetaData(double a_Rotation)
{
a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
if (a_Rotation > 360)
{
a_Rotation -= 360;
}
a_Rotation = (a_Rotation / 360) * 16;
return ((char)a_Rotation) % 16;
}
static char DirectionToMetaData(char a_Direction)
{
switch (a_Direction)
{
case 0x2: return 0x2;
case 0x3: return 0x3;
case 0x4: return 0x4;
case 0x5: return 0x5;
default:
{
break;
}
}
return 0x2;
}
} ;

View File

@ -2,7 +2,6 @@
#pragma once
#include "BlockHandler.h"
#include "../Stairs.h"
@ -27,7 +26,7 @@ public:
) override
{
a_BlockType = m_BlockType;
a_BlockMeta = cStairs::RotationToMetaData(a_Player->GetRotation());
a_BlockMeta = RotationToMetaData(a_Player->GetRotation());
switch (a_BlockFace)
{
case BLOCK_FACE_TOP: break;
@ -51,6 +50,33 @@ public:
// TODO: step sound
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
a_Rotation += 90 + 45; // So its not aligned with axis
NIBBLETYPE result = 0x0;
if (a_Rotation > 360)
{
a_Rotation -= 360;
}
if ((a_Rotation >= 0) && (a_Rotation < 90))
{
return 0x0;
}
else if ((a_Rotation >= 180) && (a_Rotation < 270))
{
return 0x1;
}
else if ((a_Rotation >= 90) && (a_Rotation < 180))
{
return 0x2;
}
else
{
return 0x3;
}
}
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
{
// Bits 3 and 4 stay, the rest is swapped around according to a table:

View File

@ -2,7 +2,6 @@
#pragma once
#include "BlockHandler.h"
#include "../Torch.h"
#include "../World.h"
@ -37,11 +36,71 @@ public:
}
}
a_BlockType = m_BlockType;
a_BlockMeta = cTorch::DirectionToMetaData(a_BlockFace);
a_BlockMeta = DirectionToMetaData(a_BlockFace);
return true;
}
static NIBBLETYPE DirectionToMetaData(char a_Direction) // tolua_export
{ // tolua_export
switch (a_Direction)
{
case BLOCK_FACE_BOTTOM: ASSERT(!"Shouldn't be getting this face"); return 0;
case BLOCK_FACE_TOP: return E_META_TORCH_FLOOR;
case BLOCK_FACE_EAST: return E_META_TORCH_EAST;
case BLOCK_FACE_WEST: return E_META_TORCH_WEST;
case BLOCK_FACE_NORTH: return E_META_TORCH_NORTH;
case BLOCK_FACE_SOUTH: return E_META_TORCH_SOUTH;
default:
{
ASSERT(!"Unhandled torch direction!");
break;
}
};
return 0x0;
} // tolua_export
static char MetaDataToDirection(NIBBLETYPE a_MetaData) // tolua_export
{ // tolua_export
switch (a_MetaData)
{
case 0: return BLOCK_FACE_TOP; // by default, the torches stand on the ground
case E_META_TORCH_FLOOR: return BLOCK_FACE_TOP;
case E_META_TORCH_EAST: return BLOCK_FACE_EAST;
case E_META_TORCH_WEST: return BLOCK_FACE_WEST;
case E_META_TORCH_NORTH: return BLOCK_FACE_NORTH;
case E_META_TORCH_SOUTH: return BLOCK_FACE_SOUTH;
default:
{
ASSERT(!"Unhandled torch metadata");
break;
}
}
return 0;
} // tolua_export
static bool IsAttachedTo(const Vector3i & a_TorchPos, char a_TorchMeta, const Vector3i & a_BlockPos)
{
switch (a_TorchMeta)
{
case 0x0:
case E_META_TORCH_FLOOR: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 1, 0)));
case E_META_TORCH_EAST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, -1)));
case E_META_TORCH_WEST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, 1)));
case E_META_TORCH_NORTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(-1, 0, 0)));
case E_META_TORCH_SOUTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(1, 0, 0)));
default:
{
ASSERT(!"Unhandled torch meta!");
break;
}
}
return false;
}
virtual bool DoesAllowBlockOnTop(void) override
{
return false;
@ -113,8 +172,8 @@ public:
virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
// TODO: Use cTorch::AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison
char Face = cTorch::MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
// TODO: Use AdjustCoordsByMeta(), then cChunk::UnboundedRelGetBlock() and finally some comparison
char Face = MetaDataToDirection(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ));
int BlockX = a_RelX + a_Chunk.GetPosX() * cChunkDef::Width;
int BlockZ = a_RelZ + a_Chunk.GetPosZ() * cChunkDef::Width;
return TorchCanBePlacedAt(a_Chunk.GetWorld(), BlockX, a_RelY, BlockZ, Face);

View File

@ -2,7 +2,6 @@
#pragma once
#include "BlockHandler.h"
#include "../Vine.h"
@ -31,17 +30,43 @@ public:
a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, BlockType, BlockMeta);
if (BlockType == m_BlockType)
{
a_BlockMeta = BlockMeta | cVine::DirectionToMetaData(a_BlockFace);
a_BlockMeta = BlockMeta | DirectionToMetaData(a_BlockFace);
}
else
{
a_BlockMeta = cVine::DirectionToMetaData(a_BlockFace);
a_BlockMeta = DirectionToMetaData(a_BlockFace);
}
a_BlockType = m_BlockType;
return true;
}
static NIBBLETYPE DirectionToMetaData(char a_BlockFace)
{
switch (a_BlockFace)
{
case BLOCK_FACE_NORTH: return 0x1;
case BLOCK_FACE_SOUTH: return 0x4;
case BLOCK_FACE_WEST: return 0x8;
case BLOCK_FACE_EAST: return 0x2;
default: return 0x0;
}
}
static char MetaDataToDirection(NIBBLETYPE a_MetaData)
{
switch(a_MetaData)
{
case 0x1: return BLOCK_FACE_NORTH;
case 0x4: return BLOCK_FACE_SOUTH;
case 0x8: return BLOCK_FACE_WEST;
case 0x2: return BLOCK_FACE_EAST;
default: return BLOCK_FACE_TOP;
}
}
/// Returns true if the specified block type is good for vines to attach to
static bool IsBlockAttachable(BLOCKTYPE a_BlockType)
{

View File

@ -19,8 +19,6 @@
#include "BlockEntities/JukeboxEntity.h"
#include "BlockEntities/NoteEntity.h"
#include "BlockEntities/SignEntity.h"
#include "Torch.h"
#include "Ladder.h"
#include "Pickup.h"
#include "Item.h"
#include "Noise.h"

View File

@ -12,11 +12,7 @@
#include "BlockEntities/SignEntity.h"
#include "UI/Window.h"
#include "Item.h"
#include "Torch.h"
#include "Doors.h"
#include "Ladder.h"
#include "Vine.h"
#include "Sign.h"
#include "Piston.h"
#include "Mobs/Monster.h"
#include "ChatColor.h"

View File

@ -90,11 +90,11 @@ public:
/// Returns true if a_Other contains exactly the same enchantments and levels
bool operator ==(const cEnchantments & a_Other) const;
// tolua_end
/// Returns true if a_Other doesn't contain exactly the same enchantments and levels
bool operator !=(const cEnchantments & a_Other) const;
// tolua_end
/// Writes the enchantments into the specified NBT writer; begins with the LIST tag of the specified name ("ench" or "StoredEnchantments")
void WriteToNBTCompound(cFastNBTWriter & a_Writer, const AString & a_ListTagName) const;

View File

@ -3,7 +3,7 @@
#include "ItemHandler.h"
#include "../World.h"
#include "../Sign.h"
#include "../Blocks/BlockSign.h"
@ -34,12 +34,12 @@ public:
{
if (a_BlockFace == BLOCK_FACE_TOP)
{
a_BlockMeta = cSign::RotationToMetaData(a_Player->GetRotation());
a_BlockMeta = cBlockSignHandler::RotationToMetaData(a_Player->GetRotation());
a_BlockType = E_BLOCK_SIGN_POST;
}
else
{
a_BlockMeta = cSign::DirectionToMetaData(a_BlockFace);
a_BlockMeta = cBlockSignHandler::DirectionToMetaData(a_BlockFace);
a_BlockType = E_BLOCK_WALLSIGN;
}
return true;

View File

@ -1,43 +0,0 @@
#pragma once
class cLadder // tolua_export
{ // tolua_export
public:
static char DirectionToMetaData( char a_Direction ) // tolua_export
{ // tolua_export
switch( a_Direction )
{
case 0x2:
return 0x2;
case 0x3:
return 0x3;
case 0x4:
return 0x4;
case 0x5:
return 0x5;
default:
break;
};
return 0x2;
} // tolua_export
static char MetaDataToDirection( char a_MetaData ) // tolua_export
{ // tolua_export
switch( a_MetaData )
{
case 0x2:
return 0x2;
case 0x3:
return 0x3;
case 0x4:
return 0x4;
case 0x5:
return 0x5;
default:
break;
};
return 0x2;
} // tolua_export
}; // tolua_export

View File

@ -1,44 +0,0 @@
#pragma once
// tolua_begin
class cSign
{
public:
static char RotationToMetaData(double a_Rotation)
{
a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
if (a_Rotation > 360)
{
a_Rotation -= 360;
}
a_Rotation = (a_Rotation / 360) * 16;
return ((char)a_Rotation) % 16;
}
static char DirectionToMetaData(char a_Direction)
{
switch (a_Direction)
{
case 0x2: return 0x2;
case 0x3: return 0x3;
case 0x4: return 0x4;
case 0x5: return 0x5;
default:
break;
};
return 0x2;
}
} ;
// tolua_end

View File

@ -3,10 +3,10 @@
#include "RedstoneSimulator.h"
#include "../BlockEntities/DropSpenserEntity.h"
#include "../Blocks/BlockTorch.h"
#include "../Piston.h"
#include "../World.h"
#include "../BlockID.h"
#include "../Torch.h"
#include "../Chunk.h"
@ -179,7 +179,7 @@ void cRedstoneSimulator::RefreshTorchesAround(const Vector3i & a_BlockPos)
{
if (BlockType != TargetBlockType)
{
if (cTorch::IsAttachedTo(TorchPos, BlockMeta, a_BlockPos))
if (cBlockTorchHandler::IsAttachedTo(TorchPos, BlockMeta, a_BlockPos))
{
m_World.FastSetBlock(TorchPos.x, TorchPos.y, TorchPos.z, TargetBlockType, BlockMeta);
m_Blocks.push_back(TorchPos);

View File

@ -1,44 +0,0 @@
#pragma once
// tolua_begin
class cStairs
{
public:
/// Converts player rotation to stair rotation metadata. To get upside-down stairs, OR with 0x4
static NIBBLETYPE RotationToMetaData(double a_Rotation)
{
a_Rotation += 90 + 45; // So its not aligned with axis
NIBBLETYPE result = 0x0;
if (a_Rotation > 360)
{
a_Rotation -= 360;
}
if ((a_Rotation >= 0) && (a_Rotation < 90))
{
return 0x0;
}
else if ((a_Rotation >= 180) && (a_Rotation < 270))
{
return 0x1;
}
else if ((a_Rotation >= 90) && (a_Rotation < 180))
{
return 0x2;
}
else
{
return 0x3;
}
}
} ;
// tolua_end

View File

@ -1,77 +0,0 @@
#pragma once
#include "Vector3i.h"
#include "Defines.h"
class cTorch // tolua_export
{ // tolua_export
public:
static char DirectionToMetaData( char a_Direction ) // tolua_export
{ // tolua_export
switch (a_Direction)
{
case BLOCK_FACE_BOTTOM: ASSERT(!"Shouldn't be getting this face"); return 0;
case BLOCK_FACE_TOP: return E_META_TORCH_FLOOR;
case BLOCK_FACE_EAST: return E_META_TORCH_EAST;
case BLOCK_FACE_WEST: return E_META_TORCH_WEST;
case BLOCK_FACE_NORTH: return E_META_TORCH_NORTH;
case BLOCK_FACE_SOUTH: return E_META_TORCH_SOUTH;
default:
{
ASSERT(!"Unhandled torch direction!");
break;
}
};
return 0x0;
} // tolua_export
static char MetaDataToDirection(char a_MetaData) // tolua_export
{ // tolua_export
switch (a_MetaData)
{
case 0: return BLOCK_FACE_TOP; // by default, the torches stand on the ground
case E_META_TORCH_FLOOR: return BLOCK_FACE_TOP;
case E_META_TORCH_EAST: return BLOCK_FACE_EAST;
case E_META_TORCH_WEST: return BLOCK_FACE_WEST;
case E_META_TORCH_NORTH: return BLOCK_FACE_NORTH;
case E_META_TORCH_SOUTH: return BLOCK_FACE_SOUTH;
default:
{
ASSERT(!"Unhandled torch metadata");
break;
}
}
return 0;
} // tolua_export
static bool IsAttachedTo(const Vector3i & a_TorchPos, char a_TorchMeta, const Vector3i & a_BlockPos)
{
switch (a_TorchMeta)
{
case 0x0:
case E_META_TORCH_FLOOR: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 1, 0)));
case E_META_TORCH_EAST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, -1)));
case E_META_TORCH_WEST: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(0, 0, 1)));
case E_META_TORCH_NORTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(-1, 0, 0)));
case E_META_TORCH_SOUTH: return ((a_TorchPos - a_BlockPos).Equals(Vector3i(1, 0, 0)));
default:
{
ASSERT(!"Unhandled torch meta!");
break;
}
}
return false;
}
} ; // tolua_export

View File

@ -1,42 +0,0 @@
#pragma once
// tolua_begin
class cVine
{
public:
static NIBBLETYPE DirectionToMetaData(char a_BlockFace)
{
switch (a_BlockFace)
{
case BLOCK_FACE_NORTH: return 0x1;
case BLOCK_FACE_SOUTH: return 0x4;
case BLOCK_FACE_WEST: return 0x8;
case BLOCK_FACE_EAST: return 0x2;
default: return 0x0;
}
}
static char MetaDataToDirection(NIBBLETYPE a_MetaData)
{
switch(a_MetaData)
{
case 0x1: return BLOCK_FACE_NORTH;
case 0x4: return BLOCK_FACE_SOUTH;
case 0x8: return BLOCK_FACE_WEST;
case 0x2: return BLOCK_FACE_EAST;
default: return BLOCK_FACE_TOP;
}
}
} ;
// tolua_end