Implemented the Hopper block handler
Hoppers can be placed properly, but won't work yet. git-svn-id: http://mc-server.googlecode.com/svn/trunk@1583 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
fe3712284e
commit
007e75de9d
@ -1888,6 +1888,10 @@
|
||||
RelativePath="..\source\blocks\BlockHandler.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\Blocks\BlockHopper.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\blocks\BlockIce.h"
|
||||
>
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Lua binding: AllToLua
|
||||
** Generated automatically by tolua++-1.0.92 on 06/12/13 09:09:44.
|
||||
** Generated automatically by tolua++-1.0.92 on 06/12/13 10:17:24.
|
||||
*/
|
||||
|
||||
#ifndef __cplusplus
|
||||
@ -26902,13 +26902,12 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
|
||||
tolua_constant(tolua_S,"E_META_CHEST_FACING_ZP",E_META_CHEST_FACING_ZP);
|
||||
tolua_constant(tolua_S,"E_META_CHEST_FACING_XM",E_META_CHEST_FACING_XM);
|
||||
tolua_constant(tolua_S,"E_META_CHEST_FACING_XP",E_META_CHEST_FACING_XP);
|
||||
tolua_constant(tolua_S,"E_META_DISPENSER_FACING_YM",E_META_DISPENSER_FACING_YM);
|
||||
tolua_constant(tolua_S,"E_META_DISPENSER_FACING_YP",E_META_DISPENSER_FACING_YP);
|
||||
tolua_constant(tolua_S,"E_META_HOPPER_UNATTACHED",E_META_HOPPER_UNATTACHED);
|
||||
tolua_constant(tolua_S,"E_META_DISPENSER_FACING_ZM",E_META_DISPENSER_FACING_ZM);
|
||||
tolua_constant(tolua_S,"E_META_DISPENSER_FACING_ZP",E_META_DISPENSER_FACING_ZP);
|
||||
tolua_constant(tolua_S,"E_META_DISPENSER_FACING_XM",E_META_DISPENSER_FACING_XM);
|
||||
tolua_constant(tolua_S,"E_META_DISPENSER_FACING_XP",E_META_DISPENSER_FACING_XP);
|
||||
tolua_constant(tolua_S,"E_META_DROPSPENSER_FACING_YM",E_META_DROPSPENSER_FACING_YM);
|
||||
tolua_constant(tolua_S,"E_META_DROPSPENSER_FACING_YP",E_META_DROPSPENSER_FACING_YP);
|
||||
tolua_constant(tolua_S,"E_META_DROPSPENSER_FACING_ZM",E_META_DROPSPENSER_FACING_ZM);
|
||||
tolua_constant(tolua_S,"E_META_DROPSPENSER_FACING_ZP",E_META_DROPSPENSER_FACING_ZP);
|
||||
tolua_constant(tolua_S,"E_META_DROPSPENSER_FACING_XM",E_META_DROPSPENSER_FACING_XM);
|
||||
tolua_constant(tolua_S,"E_META_DROPSPENSER_FACING_XP",E_META_DROPSPENSER_FACING_XP);
|
||||
tolua_constant(tolua_S,"E_META_DOUBLE_STEP_STONE",E_META_DOUBLE_STEP_STONE);
|
||||
tolua_constant(tolua_S,"E_META_DOUBLE_STEP_SANDSTONE",E_META_DOUBLE_STEP_SANDSTONE);
|
||||
tolua_constant(tolua_S,"E_META_DOUBLE_STEP_WOODEN",E_META_DOUBLE_STEP_WOODEN);
|
||||
@ -26917,6 +26916,12 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
|
||||
tolua_constant(tolua_S,"E_META_DOUBLE_STEP_STONE_BRICK",E_META_DOUBLE_STEP_STONE_BRICK);
|
||||
tolua_constant(tolua_S,"E_META_DOUBLE_STEP_NETHER_BRICK",E_META_DOUBLE_STEP_NETHER_BRICK);
|
||||
tolua_constant(tolua_S,"E_META_DOUBLE_STEP_STONE_SECRET",E_META_DOUBLE_STEP_STONE_SECRET);
|
||||
tolua_constant(tolua_S,"E_META_HOPPER_FACING_YM",E_META_HOPPER_FACING_YM);
|
||||
tolua_constant(tolua_S,"E_META_HOPPER_UNATTACHED",E_META_HOPPER_UNATTACHED);
|
||||
tolua_constant(tolua_S,"E_META_HOPPER_FACING_ZM",E_META_HOPPER_FACING_ZM);
|
||||
tolua_constant(tolua_S,"E_META_HOPPER_FACING_ZP",E_META_HOPPER_FACING_ZP);
|
||||
tolua_constant(tolua_S,"E_META_HOPPER_FACING_XM",E_META_HOPPER_FACING_XM);
|
||||
tolua_constant(tolua_S,"E_META_HOPPER_FACING_XP",E_META_HOPPER_FACING_XP);
|
||||
tolua_constant(tolua_S,"E_META_LEAVES_APPLE",E_META_LEAVES_APPLE);
|
||||
tolua_constant(tolua_S,"E_META_LEAVES_CONIFER",E_META_LEAVES_CONIFER);
|
||||
tolua_constant(tolua_S,"E_META_LEAVES_BIRCH",E_META_LEAVES_BIRCH);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
** Lua binding: AllToLua
|
||||
** Generated automatically by tolua++-1.0.92 on 06/12/13 09:09:45.
|
||||
** Generated automatically by tolua++-1.0.92 on 06/12/13 10:17:24.
|
||||
*/
|
||||
|
||||
/* Exported function */
|
||||
|
@ -43,12 +43,12 @@ void cDropSpenserEntity::AddDropSpenserDir(int & a_BlockX, int & a_BlockY, int &
|
||||
{
|
||||
switch (a_Direction)
|
||||
{
|
||||
case E_META_DISPENSER_FACING_YM: a_BlockY--; return;
|
||||
case E_META_DISPENSER_FACING_YP: a_BlockY++; return;
|
||||
case E_META_DISPENSER_FACING_ZM: a_BlockZ--; return;
|
||||
case E_META_DISPENSER_FACING_ZP: a_BlockZ++; return;
|
||||
case E_META_DISPENSER_FACING_XM: a_BlockX--; return;
|
||||
case E_META_DISPENSER_FACING_XP: a_BlockX++; return;
|
||||
case E_META_DROPSPENSER_FACING_YM: a_BlockY--; return;
|
||||
case E_META_DROPSPENSER_FACING_YP: a_BlockY++; return;
|
||||
case E_META_DROPSPENSER_FACING_ZM: a_BlockZ--; return;
|
||||
case E_META_DROPSPENSER_FACING_ZP: a_BlockZ++; return;
|
||||
case E_META_DROPSPENSER_FACING_XM: a_BlockX--; return;
|
||||
case E_META_DROPSPENSER_FACING_XP: a_BlockX++; return;
|
||||
}
|
||||
LOGWARNING("%s: Unhandled direction: %d", __FUNCTION__, a_Direction);
|
||||
return;
|
||||
@ -89,10 +89,10 @@ void cDropSpenserEntity::DropSpense(cChunk & a_Chunk)
|
||||
int SmokeDir = 0;
|
||||
switch (Meta)
|
||||
{
|
||||
case E_META_DISPENSER_FACING_XM: SmokeDir = 3; break;
|
||||
case E_META_DISPENSER_FACING_XP: SmokeDir = 5; break;
|
||||
case E_META_DISPENSER_FACING_ZM: SmokeDir = 1; break;
|
||||
case E_META_DISPENSER_FACING_ZP: SmokeDir = 7; break;
|
||||
case E_META_DROPSPENSER_FACING_XM: SmokeDir = 3; break;
|
||||
case E_META_DROPSPENSER_FACING_XP: SmokeDir = 5; break;
|
||||
case E_META_DROPSPENSER_FACING_ZM: SmokeDir = 1; break;
|
||||
case E_META_DROPSPENSER_FACING_ZP: SmokeDir = 7; break;
|
||||
}
|
||||
m_World->BroadcastSoundParticleEffect(2000, m_PosX * 8, m_PosY * 8, m_PosZ * 8, SmokeDir);
|
||||
m_World->BroadcastSoundEffect("random.click", m_PosX * 8, m_PosY * 8, m_PosZ * 8, 1.0f, 1.0f);
|
||||
|
@ -380,14 +380,13 @@ enum
|
||||
E_META_CHEST_FACING_XM = 4,
|
||||
E_META_CHEST_FACING_XP = 5,
|
||||
|
||||
// E_BLOCK_DISPENSER / E_BLOCK_DROPPER / E_BLOCK_HOPPER metas:
|
||||
E_META_DISPENSER_FACING_YM = 0,
|
||||
E_META_DISPENSER_FACING_YP = 1,
|
||||
E_META_HOPPER_UNATTACHED = 1, // Hopper doesn't move items up
|
||||
E_META_DISPENSER_FACING_ZM = 2,
|
||||
E_META_DISPENSER_FACING_ZP = 3,
|
||||
E_META_DISPENSER_FACING_XM = 4,
|
||||
E_META_DISPENSER_FACING_XP = 5,
|
||||
// E_BLOCK_DISPENSER / E_BLOCK_DROPPER metas:
|
||||
E_META_DROPSPENSER_FACING_YM = 0,
|
||||
E_META_DROPSPENSER_FACING_YP = 1,
|
||||
E_META_DROPSPENSER_FACING_ZM = 2,
|
||||
E_META_DROPSPENSER_FACING_ZP = 3,
|
||||
E_META_DROPSPENSER_FACING_XM = 4,
|
||||
E_META_DROPSPENSER_FACING_XP = 5,
|
||||
|
||||
// E_BLOCK_DOUBLE_STEP metas:
|
||||
E_META_DOUBLE_STEP_STONE = 0,
|
||||
@ -399,6 +398,14 @@ enum
|
||||
E_META_DOUBLE_STEP_NETHER_BRICK = 6,
|
||||
E_META_DOUBLE_STEP_STONE_SECRET = 7,
|
||||
|
||||
// E_BLOCK_HOPPER metas:
|
||||
E_META_HOPPER_FACING_YM = 0,
|
||||
E_META_HOPPER_UNATTACHED = 1, // Hopper doesn't move items up, there's no YP
|
||||
E_META_HOPPER_FACING_ZM = 2,
|
||||
E_META_HOPPER_FACING_ZP = 3,
|
||||
E_META_HOPPER_FACING_XM = 4,
|
||||
E_META_HOPPER_FACING_XP = 5,
|
||||
|
||||
// E_BLOCK_LEAVES metas:
|
||||
E_META_LEAVES_APPLE = 0,
|
||||
E_META_LEAVES_CONIFER = 1,
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include "BlockCobWeb.h"
|
||||
#include "BlockTNT.h"
|
||||
#include "BlockDeadBush.h"
|
||||
#include "BlockHopper.h"
|
||||
|
||||
|
||||
|
||||
@ -109,6 +110,8 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
||||
case E_BLOCK_COBBLESTONE_STAIRS: return new cBlockStairsHandler (a_BlockType);
|
||||
case E_BLOCK_COBWEB: return new cBlockCobWebHandler (a_BlockType);
|
||||
case E_BLOCK_CROPS: return new cBlockCropsHandler (a_BlockType);
|
||||
case E_BLOCK_DEAD_BUSH: return new cBlockDeadBushHandler (a_BlockType);
|
||||
case E_BLOCK_DETECTOR_RAIL: return new cBlockRailHandler (a_BlockType);
|
||||
case E_BLOCK_DIAMOND_ORE: return new cBlockOreHandler (a_BlockType);
|
||||
case E_BLOCK_DIRT: return new cBlockDirtHandler (a_BlockType);
|
||||
case E_BLOCK_DISPENSER: return new cBlockDropSpenserHandler (a_BlockType);
|
||||
@ -127,6 +130,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
||||
case E_BLOCK_GLASS: return new cBlockGlassHandler (a_BlockType);
|
||||
case E_BLOCK_GRASS: return new cBlockDirtHandler (a_BlockType);
|
||||
case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType);
|
||||
case E_BLOCK_HOPPER: return new cBlockHopperHandler (a_BlockType);
|
||||
case E_BLOCK_ICE: return new cBlockIceHandler (a_BlockType);
|
||||
case E_BLOCK_IRON_DOOR: return new cBlockDoorHandler (a_BlockType);
|
||||
case E_BLOCK_IRON_ORE: return new cBlockOreHandler (a_BlockType);
|
||||
@ -150,8 +154,6 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
|
||||
case E_BLOCK_RAIL: return new cBlockRailHandler (a_BlockType);
|
||||
case E_BLOCK_POTATOES: return new cBlockCropsHandler (a_BlockType);
|
||||
case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType);
|
||||
case E_BLOCK_DEAD_BUSH: return new cBlockDeadBushHandler (a_BlockType);
|
||||
case E_BLOCK_DETECTOR_RAIL: return new cBlockRailHandler (a_BlockType);
|
||||
case E_BLOCK_REDSTONE_ORE: return new cBlockOreHandler (a_BlockType);
|
||||
case E_BLOCK_REDSTONE_ORE_GLOWING: return new cBlockOreHandler (a_BlockType);
|
||||
case E_BLOCK_REDSTONE_REPEATER_OFF: return new cBlockRedstoneRepeaterHandler(a_BlockType);
|
||||
|
46
source/Blocks/BlockHopper.h
Normal file
46
source/Blocks/BlockHopper.h
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
// BlockHopper.h
|
||||
|
||||
// Declares the cBlockHopperHandler class representing the handler for the Hopper block
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class cBlockHopperHandler :
|
||||
public cBlockEntityHandler
|
||||
{
|
||||
public:
|
||||
cBlockHopperHandler(BLOCKTYPE a_BlockType)
|
||||
: cBlockEntityHandler(a_BlockType)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
virtual bool GetPlacementBlockTypeMeta(
|
||||
cWorld * a_World, cPlayer * a_Player,
|
||||
int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
|
||||
int a_CursorX, int a_CursorY, int a_CursorZ,
|
||||
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
||||
) override
|
||||
{
|
||||
a_BlockType = m_BlockType;
|
||||
|
||||
// Convert the blockface into meta:
|
||||
switch (a_BlockFace)
|
||||
{
|
||||
case BLOCK_FACE_BOTTOM: a_BlockMeta = E_META_HOPPER_FACING_YM; break;
|
||||
case BLOCK_FACE_TOP: a_BlockMeta = E_META_HOPPER_FACING_YM; break;
|
||||
case BLOCK_FACE_EAST: a_BlockMeta = E_META_HOPPER_FACING_XM; break;
|
||||
case BLOCK_FACE_NORTH: a_BlockMeta = E_META_HOPPER_FACING_ZP; break;
|
||||
case BLOCK_FACE_SOUTH: a_BlockMeta = E_META_HOPPER_FACING_ZM; break;
|
||||
case BLOCK_FACE_WEST: a_BlockMeta = E_META_HOPPER_FACING_XP; break;
|
||||
default: a_BlockMeta = E_META_HOPPER_UNATTACHED; break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
@ -37,12 +37,12 @@ extern bool g_BlockOneHitDig[];
|
||||
enum
|
||||
{
|
||||
BLOCK_FACE_NONE = -1, // Interacting with no block face - swinging the item in the air
|
||||
BLOCK_FACE_BOTTOM = 0, // Interacting with the bottom face of the block
|
||||
BLOCK_FACE_TOP = 1, // Interacting with the top face of the block
|
||||
BLOCK_FACE_NORTH = 2, // Interacting with the northern face of the block
|
||||
BLOCK_FACE_SOUTH = 3, // Interacting with the southern face of the block
|
||||
BLOCK_FACE_WEST = 4, // Interacting with the western face of the block
|
||||
BLOCK_FACE_EAST = 5, // Interacting with the eastern face of the block
|
||||
BLOCK_FACE_BOTTOM = 0, // Interacting with the bottom face of the block (YM)
|
||||
BLOCK_FACE_TOP = 1, // Interacting with the top face of the block (YP)
|
||||
BLOCK_FACE_NORTH = 2, // Interacting with the northern face of the block (ZP)
|
||||
BLOCK_FACE_SOUTH = 3, // Interacting with the southern face of the block (ZM)
|
||||
BLOCK_FACE_WEST = 4, // Interacting with the western face of the block (XP)
|
||||
BLOCK_FACE_EAST = 5, // Interacting with the eastern face of the block (XM)
|
||||
} ;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user