summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-08-25 16:11:19 +0200
committermadmaxoft <github@xoft.cz>2013-08-25 16:11:19 +0200
commit104a31e23d146fe69fed78932e442f4894af2a86 (patch)
treeb9b2f6ffd83d1fba85361e66955673bf322d94e8
parentFixed logging in cTracer. (diff)
parentFixed iron door opening by hand (diff)
downloadcuberite-104a31e23d146fe69fed78932e442f4894af2a86.tar
cuberite-104a31e23d146fe69fed78932e442f4894af2a86.tar.gz
cuberite-104a31e23d146fe69fed78932e442f4894af2a86.tar.bz2
cuberite-104a31e23d146fe69fed78932e442f4894af2a86.tar.lz
cuberite-104a31e23d146fe69fed78932e442f4894af2a86.tar.xz
cuberite-104a31e23d146fe69fed78932e442f4894af2a86.tar.zst
cuberite-104a31e23d146fe69fed78932e442f4894af2a86.zip
Diffstat (limited to '')
-rw-r--r--source/Bindings.cpp58
-rw-r--r--source/Bindings.h2
-rw-r--r--source/BlockID.h70
-rw-r--r--source/Blocks/BlockCarpet.h12
-rw-r--r--source/Blocks/BlockDoor.cpp5
-rw-r--r--source/Blocks/BlockHandler.cpp5
-rw-r--r--source/Blocks/BlockSlab.h132
-rw-r--r--source/Blocks/BlockVine.h7
-rw-r--r--source/ClientHandle.cpp88
-rw-r--r--source/ClientHandle.h6
-rw-r--r--source/Items/ItemLighter.h9
-rw-r--r--source/Simulator/RedstoneSimulator.cpp24
12 files changed, 318 insertions, 100 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 77d64f661..7bcf81b52 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 08/21/13 19:38:47.
+** Generated automatically by tolua++-1.0.92 on 08/25/13 15:54:49.
*/
#ifndef __cplusplus
@@ -27440,14 +27440,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
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);
- tolua_constant(tolua_S,"E_META_DOUBLE_STEP_COBBLESTONE",E_META_DOUBLE_STEP_COBBLESTONE);
- tolua_constant(tolua_S,"E_META_DOUBLE_STEP_BRICK",E_META_DOUBLE_STEP_BRICK);
- 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_DOUBLE_STONE_SLAB_STONE",E_META_DOUBLE_STONE_SLAB_STONE);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_SANDSTONE",E_META_DOUBLE_STONE_SLAB_SANDSTONE);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_WOODEN",E_META_DOUBLE_STONE_SLAB_WOODEN);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_COBBLESTONE",E_META_DOUBLE_STONE_SLAB_COBBLESTONE);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_BRICK",E_META_DOUBLE_STONE_SLAB_BRICK);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_STONE_BRICK",E_META_DOUBLE_STONE_SLAB_STONE_BRICK);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_NETHER_BRICK",E_META_DOUBLE_STONE_SLAB_NETHER_BRICK);
+ tolua_constant(tolua_S,"E_META_DOUBLE_STONE_SLAB_STONE_SECRET",E_META_DOUBLE_STONE_SLAB_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);
@@ -27476,14 +27476,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_SILVERFISH_EGG_STONE",E_META_SILVERFISH_EGG_STONE);
tolua_constant(tolua_S,"E_META_SILVERFISH_EGG_COBBLESTONE",E_META_SILVERFISH_EGG_COBBLESTONE);
tolua_constant(tolua_S,"E_META_SILVERFISH_EGG_STONE_BRICK",E_META_SILVERFISH_EGG_STONE_BRICK);
- tolua_constant(tolua_S,"E_META_STEP_STONE",E_META_STEP_STONE);
- tolua_constant(tolua_S,"E_META_STEP_SANDSTONE",E_META_STEP_SANDSTONE);
- tolua_constant(tolua_S,"E_META_STEP_PLANKS",E_META_STEP_PLANKS);
- tolua_constant(tolua_S,"E_META_STEP_COBBLESTONE",E_META_STEP_COBBLESTONE);
- tolua_constant(tolua_S,"E_META_STEP_BRICK",E_META_STEP_BRICK);
- tolua_constant(tolua_S,"E_META_STEP_STONE_BRICK",E_META_STEP_STONE_BRICK);
- tolua_constant(tolua_S,"E_META_STEP_NETHER_BRICK",E_META_STEP_NETHER_BRICK);
- tolua_constant(tolua_S,"E_META_STEP_STONE_SECRET",E_META_STEP_STONE_SECRET);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_STONE",E_META_STONE_SLAB_STONE);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_SANDSTONE",E_META_STONE_SLAB_SANDSTONE);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_PLANKS",E_META_STONE_SLAB_PLANKS);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_COBBLESTONE",E_META_STONE_SLAB_COBBLESTONE);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_BRICK",E_META_STONE_SLAB_BRICK);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_STONE_BRICK",E_META_STONE_SLAB_STONE_BRICK);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_NETHER_BRICK",E_META_STONE_SLAB_NETHER_BRICK);
+ tolua_constant(tolua_S,"E_META_STONE_SLAB_STONE_SECRET",E_META_STONE_SLAB_STONE_SECRET);
tolua_constant(tolua_S,"E_META_STONE_BRICK_NORMAL",E_META_STONE_BRICK_NORMAL);
tolua_constant(tolua_S,"E_META_STONE_BRICK_MOSSY",E_META_STONE_BRICK_MOSSY);
tolua_constant(tolua_S,"E_META_STONE_BRICK_CRACKED",E_META_STONE_BRICK_CRACKED);
@@ -27500,14 +27500,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_TORCH_XP",E_META_TORCH_XP);
tolua_constant(tolua_S,"E_META_TORCH_ZM",E_META_TORCH_ZM);
tolua_constant(tolua_S,"E_META_TORCH_ZP",E_META_TORCH_ZP);
- tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_STEP_APPLE",E_META_WOODEN_DOUBLE_STEP_APPLE);
- tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_STEP_CONIFER",E_META_WOODEN_DOUBLE_STEP_CONIFER);
- tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_STEP_BIRCH",E_META_WOODEN_DOUBLE_STEP_BIRCH);
- tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_STEP_JUNGLE",E_META_WOODEN_DOUBLE_STEP_JUNGLE);
- tolua_constant(tolua_S,"E_META_WOODEN_STEP_APPLE",E_META_WOODEN_STEP_APPLE);
- tolua_constant(tolua_S,"E_META_WOODEN_STEP_CONIFER",E_META_WOODEN_STEP_CONIFER);
- tolua_constant(tolua_S,"E_META_WOODEN_STEP_BIRCH",E_META_WOODEN_STEP_BIRCH);
- tolua_constant(tolua_S,"E_META_WOODEN_STEP_JUNGLE",E_META_WOODEN_STEP_JUNGLE);
+ tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_SLAB_APPLE",E_META_WOODEN_DOUBLE_SLAB_APPLE);
+ tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_SLAB_CONIFER",E_META_WOODEN_DOUBLE_SLAB_CONIFER);
+ tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_SLAB_BIRCH",E_META_WOODEN_DOUBLE_SLAB_BIRCH);
+ tolua_constant(tolua_S,"E_META_WOODEN_DOUBLE_SLAB_JUNGLE",E_META_WOODEN_DOUBLE_SLAB_JUNGLE);
+ tolua_constant(tolua_S,"E_META_WOODEN_SLAB_APPLE",E_META_WOODEN_SLAB_APPLE);
+ tolua_constant(tolua_S,"E_META_WOODEN_SLAB_CONIFER",E_META_WOODEN_SLAB_CONIFER);
+ tolua_constant(tolua_S,"E_META_WOODEN_SLAB_BIRCH",E_META_WOODEN_SLAB_BIRCH);
+ tolua_constant(tolua_S,"E_META_WOODEN_SLAB_JUNGLE",E_META_WOODEN_SLAB_JUNGLE);
tolua_constant(tolua_S,"E_META_WOOL_WHITE",E_META_WOOL_WHITE);
tolua_constant(tolua_S,"E_META_WOOL_ORANGE",E_META_WOOL_ORANGE);
tolua_constant(tolua_S,"E_META_WOOL_MAGENTA",E_META_WOOL_MAGENTA);
@@ -27556,6 +27556,14 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_META_STAINED_CLAY_GREEN",E_META_STAINED_CLAY_GREEN);
tolua_constant(tolua_S,"E_META_STAINED_CLAY_RED",E_META_STAINED_CLAY_RED);
tolua_constant(tolua_S,"E_META_STAINED_CLAY_BLACK",E_META_STAINED_CLAY_BLACK);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_ONE",E_META_SNOW_LAYER_ONE);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_TWO",E_META_SNOW_LAYER_TWO);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_THREE",E_META_SNOW_LAYER_THREE);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_FOUR",E_META_SNOW_LAYER_FOUR);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_FIVE",E_META_SNOW_LAYER_FIVE);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_SIX",E_META_SNOW_LAYER_SIX);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_SEVEN",E_META_SNOW_LAYER_SEVEN);
+ tolua_constant(tolua_S,"E_META_SNOW_LAYER_EIGHT",E_META_SNOW_LAYER_EIGHT);
tolua_constant(tolua_S,"E_META_COAL_NORMAL",E_META_COAL_NORMAL);
tolua_constant(tolua_S,"E_META_COAL_CHARCOAL",E_META_COAL_CHARCOAL);
tolua_constant(tolua_S,"E_META_DYE_BLACK",E_META_DYE_BLACK);
diff --git a/source/Bindings.h b/source/Bindings.h
index 7d9240e3f..97c582582 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 08/21/13 19:38:48.
+** Generated automatically by tolua++-1.0.92 on 08/25/13 15:54:49.
*/
/* Exported function */
diff --git a/source/BlockID.h b/source/BlockID.h
index 3c4381ae1..0eb3df96d 100644
--- a/source/BlockID.h
+++ b/source/BlockID.h
@@ -396,15 +396,17 @@ enum
E_META_DROPSPENSER_FACING_XM = 4,
E_META_DROPSPENSER_FACING_XP = 5,
- // E_BLOCK_DOUBLE_STEP metas:
- E_META_DOUBLE_STEP_STONE = 0,
- E_META_DOUBLE_STEP_SANDSTONE = 1,
- E_META_DOUBLE_STEP_WOODEN = 2,
- E_META_DOUBLE_STEP_COBBLESTONE = 3,
- E_META_DOUBLE_STEP_BRICK = 4,
- E_META_DOUBLE_STEP_STONE_BRICK = 5,
- E_META_DOUBLE_STEP_NETHER_BRICK = 6,
- E_META_DOUBLE_STEP_STONE_SECRET = 7,
+ // E_BLOCK_DOUBLE_STONE_SLAB metas:
+ E_META_DOUBLE_STONE_SLAB_STONE = 0,
+ E_META_DOUBLE_STONE_SLAB_SANDSTONE = 1,
+ E_META_DOUBLE_STONE_SLAB_WOODEN = 2,
+ E_META_DOUBLE_STONE_SLAB_COBBLESTONE = 3,
+ E_META_DOUBLE_STONE_SLAB_BRICK = 4,
+ E_META_DOUBLE_STONE_SLAB_STONE_BRICK = 5,
+ E_META_DOUBLE_STONE_SLAB_NETHER_BRICK = 6,
+ E_META_DOUBLE_STONE_SLAB_STONE_SECRET = 7,
+
+
// E_BLOCK_HOPPER metas:
E_META_HOPPER_FACING_YM = 0,
@@ -448,15 +450,15 @@ enum
E_META_SILVERFISH_EGG_COBBLESTONE = 1,
E_META_SILVERFISH_EGG_STONE_BRICK = 2,
- // E_BLOCK_STEP metas:
- E_META_STEP_STONE = 0,
- E_META_STEP_SANDSTONE = 1,
- E_META_STEP_PLANKS = 2,
- E_META_STEP_COBBLESTONE = 3,
- E_META_STEP_BRICK = 4,
- E_META_STEP_STONE_BRICK = 5,
- E_META_STEP_NETHER_BRICK = 6,
- E_META_STEP_STONE_SECRET = 7,
+ // E_BLOCK_STONE_SLAB metas:
+ E_META_STONE_SLAB_STONE = 0,
+ E_META_STONE_SLAB_SANDSTONE = 1,
+ E_META_STONE_SLAB_PLANKS = 2,
+ E_META_STONE_SLAB_COBBLESTONE = 3,
+ E_META_STONE_SLAB_BRICK = 4,
+ E_META_STONE_SLAB_STONE_BRICK = 5,
+ E_META_STONE_SLAB_NETHER_BRICK = 6,
+ E_META_STONE_SLAB_STONE_SECRET = 7,
// E_BLOCK_STONE_BRICKS metas:
E_META_STONE_BRICK_NORMAL = 0,
@@ -480,17 +482,17 @@ enum
E_META_TORCH_ZM = 3, // Torch attached to the ZM side of its block
E_META_TORCH_ZP = 4, // Torch attached to the ZP side of its block
- // E_BLOCK_WOODEN_DOUBLE_STEP metas:
- E_META_WOODEN_DOUBLE_STEP_APPLE = 0,
- E_META_WOODEN_DOUBLE_STEP_CONIFER = 1,
- E_META_WOODEN_DOUBLE_STEP_BIRCH = 2,
- E_META_WOODEN_DOUBLE_STEP_JUNGLE = 3,
+ // E_BLOCK_WOODEN_DOUBLE_SLAB metas:
+ E_META_WOODEN_DOUBLE_SLAB_APPLE = 0,
+ E_META_WOODEN_DOUBLE_SLAB_CONIFER = 1,
+ E_META_WOODEN_DOUBLE_SLAB_BIRCH = 2,
+ E_META_WOODEN_DOUBLE_SLAB_JUNGLE = 3,
- // E_BLOCK_WOODEN_STEP metas:
- E_META_WOODEN_STEP_APPLE = 0,
- E_META_WOODEN_STEP_CONIFER = 1,
- E_META_WOODEN_STEP_BIRCH = 2,
- E_META_WOODEN_STEP_JUNGLE = 3,
+ // E_BLOCK_WOODEN_SLAB metas:
+ E_META_WOODEN_SLAB_APPLE = 0,
+ E_META_WOODEN_SLAB_CONIFER = 1,
+ E_META_WOODEN_SLAB_BIRCH = 2,
+ E_META_WOODEN_SLAB_JUNGLE = 3,
// E_BLOCK_WOOL metas:
E_META_WOOL_WHITE = 0,
@@ -545,7 +547,17 @@ enum
E_META_STAINED_CLAY_GREEN = 13,
E_META_STAINED_CLAY_RED = 14,
E_META_STAINED_CLAY_BLACK = 15,
-
+
+ // E_BLOCK_SNOW metas:
+ E_META_SNOW_LAYER_ONE = 0,
+ E_META_SNOW_LAYER_TWO = 1,
+ E_META_SNOW_LAYER_THREE = 2,
+ E_META_SNOW_LAYER_FOUR = 3,
+ E_META_SNOW_LAYER_FIVE = 4,
+ E_META_SNOW_LAYER_SIX = 5,
+ E_META_SNOW_LAYER_SEVEN = 6,
+ E_META_SNOW_LAYER_EIGHT = 7,
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Item metas:
diff --git a/source/Blocks/BlockCarpet.h b/source/Blocks/BlockCarpet.h
index f70ff45b6..5eafd8c21 100644
--- a/source/Blocks/BlockCarpet.h
+++ b/source/Blocks/BlockCarpet.h
@@ -8,6 +8,8 @@
#pragma once
+#include "BlockHandler.h"
+
@@ -16,7 +18,11 @@ class cBlockCarpetHandler :
public cBlockHandler
{
public:
- cBlockCarpetHandler(BLOCKTYPE a_BlockType);
+ cBlockCarpetHandler(BLOCKTYPE a_BlockType) :
+ cBlockHandler(a_BlockType)
+ {
+ }
+
virtual const char * GetStepSound(void) override
{
@@ -39,13 +45,13 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- a_Pickups.push_back(cItem(E_BLOCK_CARPET, a_BlockMeta));
+ a_Pickups.push_back(cItem(E_BLOCK_CARPET, 1, a_BlockMeta));
}
virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
- return ((a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR));
+ return (a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) != E_BLOCK_AIR);
}
} ;
diff --git a/source/Blocks/BlockDoor.cpp b/source/Blocks/BlockDoor.cpp
index 267486c47..02cbd28e2 100644
--- a/source/Blocks/BlockDoor.cpp
+++ b/source/Blocks/BlockDoor.cpp
@@ -47,7 +47,10 @@ void cBlockDoorHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY
void cBlockDoorHandler::OnUse(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)
{
- cDoors::ChangeDoor(a_World, a_BlockX, a_BlockY, a_BlockZ);
+ if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_DOOR)
+ {
+ cDoors::ChangeDoor(a_World, a_BlockX, a_BlockY, a_BlockZ);
+ }
}
diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp
index 6584eeed4..5134c1103 100644
--- a/source/Blocks/BlockHandler.cpp
+++ b/source/Blocks/BlockHandler.cpp
@@ -104,6 +104,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_BROWN_MUSHROOM: return new cBlockMushroomHandler (a_BlockType);
case E_BLOCK_CACTUS: return new cBlockCactusHandler (a_BlockType);
case E_BLOCK_CARROTS: return new cBlockCropsHandler (a_BlockType);
+ case E_BLOCK_CARPET: return new cBlockCarpetHandler (a_BlockType);
case E_BLOCK_CAULDRON: return new cBlockCauldronHandler (a_BlockType);
case E_BLOCK_CHEST: return new cBlockChestHandler (a_BlockType);
case E_BLOCK_COAL_ORE: return new cBlockOreHandler (a_BlockType);
@@ -116,8 +117,8 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE 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);
- case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockSlabHandler (a_BlockType);
- case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType);
+ case E_BLOCK_DOUBLE_STONE_SLAB: return new cBlockDoubleSlabHandler (a_BlockType);
+ case E_BLOCK_DOUBLE_WOODEN_SLAB: return new cBlockDoubleSlabHandler (a_BlockType);
case E_BLOCK_DROPPER: return new cBlockDropSpenserHandler (a_BlockType);
case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
diff --git a/source/Blocks/BlockSlab.h b/source/Blocks/BlockSlab.h
index f34f42bae..7c1251b28 100644
--- a/source/Blocks/BlockSlab.h
+++ b/source/Blocks/BlockSlab.h
@@ -1,7 +1,16 @@
+// BlockSlab.h
+
+// Declares cBlockSlabHandler and cBlockDoubleSlabHandler classes
+
+
+
+
+
#pragma once
#include "BlockHandler.h"
+#include "../Items/ItemHandler.h"
@@ -19,8 +28,7 @@ public:
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
- 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));
+ a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta));
}
@@ -32,11 +40,55 @@ public:
) override
{
a_BlockType = m_BlockType;
+ BLOCKTYPE Type = (BLOCKTYPE) (a_Player->GetEquippedItem().m_ItemType);
NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07);
+
+ // HandlePlaceBlock wants a cItemHandler pointer thing, so let's give it one
+ cItemHandler * ItemHandler = cItemHandler::GetItemHandler(GetDoubleSlabType(Type));
+
+ // Check if the block at the coordinates is a slab. Eligibility for combining has already been processed in ClientHandle
+ if (IsAnySlabType(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ)))
+ {
+ // Call the function in ClientHandle that places a block when the client sends the packet,
+ // so that plugins may interfere with the placement.
+
+ if ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM))
+ {
+ // Top and bottom faces need no parameter modification
+ a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
+ }
+ else
+ {
+ // The other faces need to distinguish between top and bottom cursor positions
+ if (a_CursorY > 7)
+ {
+ // Edit the call to use BLOCK_FACE_BOTTOM, otherwise it places incorrectly
+ a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_TOP, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
+ }
+ else
+ {
+ // Edit the call to use BLOCK_FACE_TOP, otherwise it places incorrectly
+ a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_BOTTOM, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler);
+ }
+ }
+ return false; // Cancel the event, because dblslabs were already placed, nothing else needed
+ }
+
+ // Place the single-slab with correct metas:
switch (a_BlockFace)
{
- case BLOCK_FACE_TOP: a_BlockMeta = Meta & 0x7; break; // Always bottom half of the slab when placing on top of something
- case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; // Always top half of the slab when placing on bottom of something
+ case BLOCK_FACE_TOP:
+ {
+ // Bottom half slab block
+ a_BlockMeta = Meta & 0x7;
+ break;
+ }
+ case BLOCK_FACE_BOTTOM:
+ {
+ // Top half slab block
+ a_BlockMeta = Meta | 0x8;
+ break;
+ }
case BLOCK_FACE_EAST:
case BLOCK_FACE_NORTH:
case BLOCK_FACE_SOUTH:
@@ -44,15 +96,14 @@ public:
{
if (a_CursorY > 7)
{
- // Cursor at the top half of the face, place a top half of slab
- a_BlockMeta = Meta | 0x8;
+ // Cursor at top half of block, place top slab
+ a_BlockMeta = Meta | 0x8; break;
}
else
{
- // Cursor at the bottom half of the face, place a bottom half of slab:
- a_BlockMeta = Meta & 0x7;
+ // Cursor at bottom half of block, place bottom slab
+ a_BlockMeta = Meta & 0x7; break;
}
- break;
}
} // switch (a_BlockFace)
return true;
@@ -60,8 +111,69 @@ public:
virtual const char * GetStepSound(void) override
+ {
+ switch (m_BlockType)
+ {
+ case E_BLOCK_WOODEN_SLAB: return "step.wood";
+ case E_BLOCK_STONE_SLAB: return "step.stone";
+ }
+ ASSERT(!"Unhandled slab type!");
+ return "";
+ }
+
+
+ /// Returns true if the specified blocktype is one of the slabs handled by this handler
+ static bool IsAnySlabType(BLOCKTYPE a_BlockType)
+ {
+ return ((a_BlockType == E_BLOCK_WOODEN_SLAB) || (a_BlockType == E_BLOCK_STONE_SLAB));
+ }
+
+
+ /// Converts the single-slab blocktype to its equivalent double-slab blocktype
+ static BLOCKTYPE GetDoubleSlabType(BLOCKTYPE a_SingleSlabBlockType)
+ {
+ switch (a_SingleSlabBlockType)
+ {
+ case E_BLOCK_STONE_SLAB: return E_BLOCK_DOUBLE_STONE_SLAB;
+ case E_BLOCK_WOODEN_SLAB: return E_BLOCK_DOUBLE_WOODEN_SLAB;
+ }
+ ASSERT(!"Unhandled slab type!");
+ return E_BLOCK_AIR;
+ }
+
+} ;
+
+
+
+
+
+class cBlockDoubleSlabHandler :
+ public cBlockHandler
+{
+public:
+ cBlockDoubleSlabHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ if (m_BlockType == E_BLOCK_DOUBLE_STONE_SLAB)
+ {
+ m_BlockType = E_BLOCK_STONE_SLAB;
+ }
+ else
+ {
+ m_BlockType = E_BLOCK_WOODEN_SLAB;
+ }
+ a_Pickups.push_back(cItem(m_BlockType, 2, a_BlockMeta));
+ }
+
+
+ virtual const char * GetStepSound(void) override
{
- return ((m_BlockType == E_BLOCK_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone";
+ return ((m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone";
}
} ;
diff --git a/source/Blocks/BlockVine.h b/source/Blocks/BlockVine.h
index 0bc935272..37d9f1a45 100644
--- a/source/Blocks/BlockVine.h
+++ b/source/Blocks/BlockVine.h
@@ -168,6 +168,13 @@ public:
return false;
}
+ virtual void OnUpdate(cWorld * a_World, int X, int Y, int Z)
+ {
+ if (a_World->GetBlock(X, Y - 1, Z) == E_BLOCK_AIR)
+ {
+ a_World->SetBlock(X, Y - 1, Z, E_BLOCK_VINES, a_World->GetBlockMeta(X, Y, Z));
+ }
+ }
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
{
diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp
index 8125fc127..bed9fab92 100644
--- a/source/ClientHandle.cpp
+++ b/source/ClientHandle.cpp
@@ -19,6 +19,7 @@
#include "OSSupport/Timer.h"
#include "Items/ItemHandler.h"
#include "Blocks/BlockHandler.h"
+#include "Blocks/BlockSlab.h"
#include "Vector3f.h"
#include "Vector3d.h"
@@ -850,41 +851,82 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c
}
cWorld * World = m_Player->GetWorld();
+
+ BLOCKTYPE ClickedBlock;
+ NIBBLETYPE ClickedBlockMeta;
+ BLOCKTYPE EquippedBlock = (BLOCKTYPE)(m_Player->GetEquippedItem().m_ItemType);
+ NIBBLETYPE EquippedBlockDamage = (NIBBLETYPE)(m_Player->GetEquippedItem().m_ItemDamage);
+
+ if ((a_BlockY < 0) || (a_BlockY >= cChunkDef::Height))
+ {
+ // The block is being placed outside the world, ignore this packet altogether (#128)
+ return;
+ }
- // Check if the block ignores build collision (water, grass etc.):
- BLOCKTYPE ClickedBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
- cBlockHandler * Handler = cBlockHandler::GetBlockHandler(ClickedBlock);
- if (Handler->DoesIgnoreBuildCollision())
+ World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta);
+
+ // Special slab handling - placing a slab onto another slab produces a dblslab instead:
+ if (
+ cBlockSlabHandler::IsAnySlabType(ClickedBlock) && // Is there a slab already?
+ cBlockSlabHandler::IsAnySlabType(EquippedBlock) && // Is the player placing another slab?
+ ((ClickedBlockMeta & 0x07) == (EquippedBlockDamage & 0x07)) && // Is it the same slab type?
+ (
+ (a_BlockFace == BLOCK_FACE_TOP) || // Clicking the top of a bottom slab
+ (a_BlockFace == BLOCK_FACE_BOTTOM) // Clicking the bottom of a top slab
+ )
+ )
{
- Handler->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
- // World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
+ // Coordinates at CLICKED block, don't move them anywhere
}
else
{
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- // Check for Blocks not allowing placement on top
- if ((a_BlockFace == BLOCK_FACE_TOP) && !Handler->DoesAllowBlockOnTop())
+ // Check if the block ignores build collision (water, grass etc.):
+ cBlockHandler * Handler = cBlockHandler::GetBlockHandler(ClickedBlock);
+ if (Handler->DoesIgnoreBuildCollision())
{
- // Resend the old block
- // Some times the client still places the block O.o
- World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
- return;
+ Handler->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ);
}
- if ((a_BlockY < 0) || (a_BlockY >= cChunkDef::Height))
- {
- // The block is being placed outside the world, ignore this packet altogether (#128)
- return;
- }
-
BLOCKTYPE PlaceBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
if (!BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision())
{
- // Tried to place a block *into* another?
- return; // Happens when you place a block aiming at side of block like torch or stem
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+
+ if ((a_BlockY < 0) || (a_BlockY >= cChunkDef::Height))
+ {
+ // The block is being placed outside the world, ignore this packet altogether (#128)
+ return;
+ }
+
+ BLOCKTYPE PlaceBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+
+ // Clicked on side of block, make sure that placement won't be cancelled if there is a slab able to be double slabbed.
+ // No need to do combinability (dblslab) checks, client will do that here.
+ if (cBlockSlabHandler::IsAnySlabType(PlaceBlock))
+ {
+ // It's a slab, don't do checks and proceed to double-slabbing
+ }
+ else
+ {
+ // Check for Blocks not allowing placement on top
+ if ((a_BlockFace == BLOCK_FACE_TOP) && !Handler->DoesAllowBlockOnTop())
+ {
+ // Resend the old block
+ // Sometimes the client still places the block O.o
+ World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player);
+ return;
+ }
+
+ if (!BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision())
+ {
+ // Tried to place a block *into* another?
+ // Happens when you place a block aiming at side of block like torch or stem
+ return;
+ }
+ }
}
}
-
+
BLOCKTYPE BlockType;
NIBBLETYPE BlockMeta;
if (!a_ItemHandler.GetPlacementBlockTypeMeta(World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta))
@@ -919,7 +961,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c
NewBlock->OnPlacedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
// Step sound with 0.8f pitch is used as block placement sound
- World->BroadcastSoundEffect(NewBlock->GetStepSound(),a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.8f);
+ World->BroadcastSoundEffect(NewBlock->GetStepSound(), a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 0.8f);
cRoot::Get()->GetPluginManager()->CallHookPlayerPlacedBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta);
}
diff --git a/source/ClientHandle.h b/source/ClientHandle.h
index 62616ba08..9fae93d95 100644
--- a/source/ClientHandle.h
+++ b/source/ClientHandle.h
@@ -198,6 +198,9 @@ public:
/// Called when the player moves into a different world; queues sreaming the new chunks
void MoveToWorld(cWorld & a_World, bool a_SendRespawnPacket);
+ /// Handles the block placing packet when it is a real block placement (not block-using, item-using or eating)
+ void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler);
+
private:
int m_ViewDistance; // Number of chunks the player can see in each direction; 4 is the minimum ( http://wiki.vg/Protocol_FAQ#.E2.80.A6all_connecting_clients_spasm_and_jerk_uncontrollably.21 )
@@ -314,9 +317,6 @@ private:
/// Handles the DIG_FINISHED dig packet:
void HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_OldBlock, NIBBLETYPE a_OldMeta);
-
- /// Handles the block placing packet when it is a real block placement (not block-using, item-using or eating)
- void HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, cItemHandler & a_ItemHandler);
// cSocketThreads::cCallback overrides:
virtual void DataReceived (const char * a_Data, int a_Size) override; // Data is received from the client
diff --git a/source/Items/ItemLighter.h b/source/Items/ItemLighter.h
index 39534c7b1..4281a2d0c 100644
--- a/source/Items/ItemLighter.h
+++ b/source/Items/ItemLighter.h
@@ -40,10 +40,13 @@ public:
}
default:
{
- // Light a fire next to the block:
+ // Light a fire next to/on top of the block if air:
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0);
- break;
+ if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR)
+ {
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0);
+ break;
+ }
}
}
diff --git a/source/Simulator/RedstoneSimulator.cpp b/source/Simulator/RedstoneSimulator.cpp
index 615e36a49..8526a888e 100644
--- a/source/Simulator/RedstoneSimulator.cpp
+++ b/source/Simulator/RedstoneSimulator.cpp
@@ -53,6 +53,10 @@ void cRedstoneSimulator::WakeUp(int a_BlockX, int a_BlockY, int a_BlockZ, cChunk
}
switch (BlockType)
{
+ case E_BLOCK_PISTON:
+ case E_BLOCK_STICKY_PISTON:
+ case E_BLOCK_DISPENSER:
+ case E_BLOCK_DROPPER:
case E_BLOCK_REDSTONE_LAMP_OFF:
case E_BLOCK_REDSTONE_LAMP_ON:
case E_BLOCK_REDSTONE_REPEATER_OFF:
@@ -514,6 +518,20 @@ bool cRedstoneSimulator::PowerBlock(const Vector3i & a_BlockPos, const Vector3i
break;
}
+ case E_BLOCK_REDSTONE_LAMP_OFF:
+ {
+ m_World.FastSetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, E_BLOCK_REDSTONE_LAMP_ON, 0);
+ break;
+ }
+
+ case E_BLOCK_TNT:
+ {
+ m_World.BroadcastSoundEffect("random.fuse", a_BlockPos.x * 8, a_BlockPos.y * 8, a_BlockPos.z * 8, 0.5f, 0.6f);
+ m_World.SpawnPrimedTNT(a_BlockPos.x + 0.5, a_BlockPos.y + 0.5, a_BlockPos.z + 0.5, 4); // 4 seconds to boom
+ m_World.SetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, E_BLOCK_AIR, 0);
+ break;
+ }
+
default:
{
if (
@@ -614,6 +632,12 @@ int cRedstoneSimulator::UnPowerBlock(const Vector3i & a_BlockPos, const Vector3i
}
break;
}
+
+ case E_BLOCK_REDSTONE_LAMP_ON:
+ {
+ m_World.FastSetBlock(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, E_BLOCK_REDSTONE_LAMP_OFF, 0);
+ break;
+ }
default:
{