From b35771ca0d7faa6572025f8e9e61007df498e14c Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 20 Aug 2013 22:47:10 +0100 Subject: [PATCH 01/14] Fixed broken carpet handler [SEE DESC] Made BlockHandler pass on control to carpet handler Declared thinggummies in carpet handler Fixed carpet block pushback using incorrect format --- source/Blocks/BlockCarpet.h | 12 +++++++++--- source/Blocks/BlockHandler.cpp | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/source/Blocks/BlockCarpet.h b/source/Blocks/BlockCarpet.h index f70ff45b6..9ac998131 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/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 6584eeed4..0fa013058 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); From 8e153f6689880da1380af1bf9d858d1d3a8461bb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 20 Aug 2013 23:17:49 +0100 Subject: [PATCH 02/14] Fixed longstanding issue with slabs Fixes FS#298 --- source/Blocks/BlockSlab.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/Blocks/BlockSlab.h b/source/Blocks/BlockSlab.h index f34f42bae..dd80da27e 100644 --- a/source/Blocks/BlockSlab.h +++ b/source/Blocks/BlockSlab.h @@ -35,7 +35,18 @@ public: NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07); 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_TOP: + { + if (a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) == E_BLOCK_STONE_SLAB) + { + a_World->FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_DOUBLE_STONE_SLAB, Meta); + a_BlockType = E_BLOCK_AIR; + } + else + { + 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_EAST: case BLOCK_FACE_NORTH: From 0c44904766ee835dc07a96d563d3d109fcda293a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 20 Aug 2013 23:24:29 +0100 Subject: [PATCH 03/14] Changed comments to be more accurate --- source/Blocks/BlockSlab.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/Blocks/BlockSlab.h b/source/Blocks/BlockSlab.h index dd80da27e..44e1962b9 100644 --- a/source/Blocks/BlockSlab.h +++ b/source/Blocks/BlockSlab.h @@ -39,15 +39,15 @@ public: { if (a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) == E_BLOCK_STONE_SLAB) { - a_World->FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_DOUBLE_STONE_SLAB, Meta); - a_BlockType = E_BLOCK_AIR; + a_World->FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_DOUBLE_STONE_SLAB, Meta); //Set it to a slabby block + a_BlockType = E_BLOCK_AIR; //Stop the server trying to place another slab on top } else { - a_BlockMeta = Meta & 0x7; break; // Always bottom half of the slab when placing on top of something + a_BlockMeta = Meta & 0x7; break; //Bottom half if on top of non slab block } } - case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; // Always top half of the slab when placing on bottom of something + case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; //Always top when placing on bottom of something case BLOCK_FACE_EAST: case BLOCK_FACE_NORTH: case BLOCK_FACE_SOUTH: From 52d8da6ebe30be046566ba6a34099ba5ebb843a1 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 23 Aug 2013 18:13:54 +0100 Subject: [PATCH 04/14] Fixed lighters replacing blocks --- source/Items/ItemLighter.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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; + } } } From a671e45cd55adc4ae477225e59afb2969454b1d4 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 23 Aug 2013 19:38:39 +0100 Subject: [PATCH 05/14] Double slabs work *choke choke* --- VC2008/MCServer.vcproj | 3 ++ source/Blocks/BlockDoubleSlab.h | 36 +++++++++++++++++ source/Blocks/BlockHandler.cpp | 5 ++- source/Blocks/BlockSlab.h | 58 ++++++++++++++++++++++----- source/ClientHandle.cpp | 69 +++++++++++++++++++++++---------- source/ClientHandle.h | 2 +- 6 files changed, 140 insertions(+), 33 deletions(-) create mode 100644 source/Blocks/BlockDoubleSlab.h diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index fbbd999a9..9688aa981 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -2015,6 +2015,9 @@ RelativePath="..\source\Blocks\BlockDeadBush.h" > + diff --git a/source/Blocks/BlockDoubleSlab.h b/source/Blocks/BlockDoubleSlab.h new file mode 100644 index 000000000..c91fe64e6 --- /dev/null +++ b/source/Blocks/BlockDoubleSlab.h @@ -0,0 +1,36 @@ + +#pragma once + +#include "BlockHandler.h" +#include "../Items/ItemHandler.h" + + + + + +class cBlockDoubleSlabHandler : + public cBlockHandler +{ +public: + cBlockDoubleSlabHandler(BLOCKTYPE a_BlockType) + : cBlockHandler(a_BlockType) + { + } + + + 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)); + } + + + virtual const char * GetStepSound(void) override + { + return ((m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB) || (m_BlockType == E_BLOCK_DOUBLE_WOODEN_SLAB)) ? "step.wood" : "step.stone"; + } +} ; + + + + diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 0fa013058..22efa25f5 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -17,6 +17,7 @@ #include "BlockDeadBush.h" #include "BlockDirt.h" #include "BlockDoor.h" +#include "BlockDoubleSlab.h" #include "BlockDropSpenser.h" #include "BlockEnderchest.h" #include "BlockEntity.h" @@ -117,8 +118,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 44e1962b9..881a85615 100644 --- a/source/Blocks/BlockSlab.h +++ b/source/Blocks/BlockSlab.h @@ -6,7 +6,6 @@ - class cBlockSlabHandler : public cBlockHandler { @@ -19,7 +18,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; + char Count = ((m_BlockType == E_BLOCK_STONE_SLAB) || (m_BlockType == E_BLOCK_WOODEN_SLAB)) ? 1 : 1; a_Pickups.push_back(cItem(m_BlockType, Count, a_BlockMeta)); } @@ -32,22 +31,46 @@ public: ) override { a_BlockType = m_BlockType; + BLOCKTYPE Type = (BLOCKTYPE)(a_Player->GetEquippedItem().m_ItemType); NIBBLETYPE Meta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x07); + + int DoubleType; + if (Type == E_BLOCK_STONE_SLAB) + { + DoubleType = 43; //Make it a double slab (with old type wood) + } + else + { + DoubleType = 125; //Make it a wooden double slab (new type) + } + cItemHandler * ItemHandler = cItemHandler::GetItemHandler(DoubleType); + switch (a_BlockFace) { case BLOCK_FACE_TOP: { - if (a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) == E_BLOCK_STONE_SLAB) + if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) { - a_World->FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_DOUBLE_STONE_SLAB, Meta); //Set it to a slabby block - a_BlockType = E_BLOCK_AIR; //Stop the server trying to place another slab on top + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + return false; } else { a_BlockMeta = Meta & 0x7; break; //Bottom half if on top of non slab block } } - case BLOCK_FACE_BOTTOM: a_BlockMeta = Meta | 0x8; break; //Always top when placing on bottom of something + case BLOCK_FACE_BOTTOM: + { + if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + { + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + return false; + } + else + { + a_BlockMeta = Meta | 0x8; break; //Bottom half if on top of non slab block + } + } case BLOCK_FACE_EAST: case BLOCK_FACE_NORTH: case BLOCK_FACE_SOUTH: @@ -56,14 +79,29 @@ public: if (a_CursorY > 7) { // Cursor at the top half of the face, place a top half of slab - a_BlockMeta = Meta | 0x8; + if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + { + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + return false; + } + else + { + a_BlockMeta = Meta | 0x8; break; + } } else { // Cursor at the bottom half of the face, place a bottom half of slab: - a_BlockMeta = Meta & 0x7; + if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + { + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + return false; + } + else + { + a_BlockMeta = Meta & 0x7; break; + } } - break; } } // switch (a_BlockFace) return true; @@ -72,7 +110,7 @@ public: 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_WOODEN_SLAB) || (m_BlockType == E_BLOCK_STONE_SLAB)) ? "step.wood" : "step.stone"; } } ; diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 57830f63c..937aebd1a 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -846,33 +846,62 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c } cWorld * World = m_Player->GetWorld(); - - // 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()) + + BLOCKTYPE ClickedBlock; + NIBBLETYPE ClickedBlockMeta; + BLOCKTYPE EquippedBlock = (BLOCKTYPE)(m_Player->GetEquippedItem().m_ItemType); + NIBBLETYPE EquippedBlockDamage = (NIBBLETYPE)(m_Player->GetEquippedItem().m_ItemDamage); + + World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta); + + //Special slab handler coding + if ( + ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM)) && + ((ClickedBlock == E_BLOCK_STONE_SLAB) || (ClickedBlock == E_BLOCK_WOODEN_SLAB)) && //Is clicked a slab? + ((EquippedBlock == E_BLOCK_STONE_SLAB) || (EquippedBlock == E_BLOCK_WOODEN_SLAB)) && //Is equipped a slab? + ((ClickedBlockMeta & 0x07) == (EquippedBlockDamage & 0x07)) //Is clicked same type of slab as item in hand? + ) { - Handler->OnDestroyedByPlayer(World, m_Player, a_BlockX, a_BlockY, a_BlockZ); - // World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); + //Don't move the coordinates } 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); + //World->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0); } - - - BLOCKTYPE PlaceBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); - if (!BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision()) + else { - // 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); + //On side of block, make sure that placement won't be cancelled if there is a slab there + //No need to combinability checks, client will do that + if ((World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + { + //Is 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 + // Some times the client still places the block O.o + World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); + return; + } + + + BLOCKTYPE PlaceBlock = World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + 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; + } + } } } diff --git a/source/ClientHandle.h b/source/ClientHandle.h index c85257df1..a2e29f9dc 100644 --- a/source/ClientHandle.h +++ b/source/ClientHandle.h @@ -312,7 +312,7 @@ private: 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); + public: 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 From a6f068927a186e70fac62367f766bcf4ab1fed51 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 23 Aug 2013 19:45:11 +0100 Subject: [PATCH 06/14] Fix VSProject path issue --- VC2008/MCServer.vcproj | 1 + 1 file changed, 1 insertion(+) diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index 9688aa981..16737e0ef 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -2017,6 +2017,7 @@ Date: Fri, 23 Aug 2013 20:12:21 +0100 Subject: [PATCH 07/14] Fixed incorrect double slab drops --- source/Blocks/BlockDoubleSlab.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/Blocks/BlockDoubleSlab.h b/source/Blocks/BlockDoubleSlab.h index c91fe64e6..ed6ae9a70 100644 --- a/source/Blocks/BlockDoubleSlab.h +++ b/source/Blocks/BlockDoubleSlab.h @@ -20,8 +20,15 @@ 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)); + 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)); } From 8bb2cab9930f807b8434ca6d75da0377605c84da Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 24 Aug 2013 11:10:30 +0100 Subject: [PATCH 08/14] Fixed final slab bug This bug allowed a double slab to be made below by placing a compatible slab on a "top" slab. The coordinates are always one lower, so now it checks to see if the slab orientation can be made into a double. --- source/ClientHandle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 937aebd1a..8ff93ec1b 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -856,7 +856,7 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c //Special slab handler coding if ( - ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM)) && + (((a_BlockFace == BLOCK_FACE_TOP) && (ClickedBlockMeta == (EquippedBlockDamage & 0x07))) || ((a_BlockFace == BLOCK_FACE_BOTTOM) && (ClickedBlockMeta == (EquippedBlockDamage | 0x08)))) && ((ClickedBlock == E_BLOCK_STONE_SLAB) || (ClickedBlock == E_BLOCK_WOODEN_SLAB)) && //Is clicked a slab? ((EquippedBlock == E_BLOCK_STONE_SLAB) || (EquippedBlock == E_BLOCK_WOODEN_SLAB)) && //Is equipped a slab? ((ClickedBlockMeta & 0x07) == (EquippedBlockDamage & 0x07)) //Is clicked same type of slab as item in hand? From d1cc6d9a9cd76eca7ab98ef5253b29573f8d6959 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 24 Aug 2013 18:46:19 +0100 Subject: [PATCH 09/14] Added comments and fixed a bug Bug was placing slabs between slabs not making a double slab. --- source/Blocks/BlockSlab.h | 76 +++++++++++++++++++-------------------- source/ClientHandle.cpp | 30 +++++++++++----- 2 files changed, 58 insertions(+), 48 deletions(-) diff --git a/source/Blocks/BlockSlab.h b/source/Blocks/BlockSlab.h index 881a85615..6caa3a27a 100644 --- a/source/Blocks/BlockSlab.h +++ b/source/Blocks/BlockSlab.h @@ -18,8 +18,7 @@ public: virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override { - char Count = ((m_BlockType == E_BLOCK_STONE_SLAB) || (m_BlockType == E_BLOCK_WOODEN_SLAB)) ? 1 : 1; - a_Pickups.push_back(cItem(m_BlockType, Count, a_BlockMeta)); + a_Pickups.push_back(cItem(m_BlockType, 1, a_BlockMeta)); } @@ -37,39 +36,54 @@ public: int DoubleType; if (Type == E_BLOCK_STONE_SLAB) { - DoubleType = 43; //Make it a double slab (with old type wood) + DoubleType = 43; // Make it a double slab (with old type wood) } else { - DoubleType = 125; //Make it a wooden double slab (new type) + DoubleType = 125; // Make it a wooden double slab (new type) } + // HandlePlaceBlock wants a cItemHandler pointer thing, so let's give it one cItemHandler * ItemHandler = cItemHandler::GetItemHandler(DoubleType); - switch (a_BlockFace) + // Check if the block at the coordinates is a slab. Eligibility for combining etc. were processed in ClientHandle + BLOCKTYPE IsSlab; + IsSlab = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + if ((IsSlab == E_BLOCK_STONE_SLAB) || (IsSlab == E_BLOCK_WOODEN_SLAB)) { - case BLOCK_FACE_TOP: + // Special handling for non top/bottom clicks + if ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM)) { - if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) + // As with previous, call the function in ClientHandle that places a block when the client sends the packet + // This effectively simulates a client placing a double slab, so it goes through plugins etc. so the slabbing can be cancelled + a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); + } + else + { + // If player cursor is at top half of block + if (a_CursorY > 7) { - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - return false; + // 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 { - a_BlockMeta = Meta & 0x7; break; //Bottom half if on top of non slab block + // 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 + } + + switch (a_BlockFace) + { + // Previous IF condition didn't cancel the event (not a slab at coords), so place slab with correct metas + case BLOCK_FACE_TOP: + { + a_BlockMeta = Meta & 0x7; break; // Bottom half slab block + } case BLOCK_FACE_BOTTOM: { - if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) - { - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - return false; - } - else - { - a_BlockMeta = Meta | 0x8; break; //Bottom half if on top of non slab block - } + a_BlockMeta = Meta | 0x8; break; // Top half slab block } case BLOCK_FACE_EAST: case BLOCK_FACE_NORTH: @@ -78,29 +92,13 @@ public: { if (a_CursorY > 7) { - // Cursor at the top half of the face, place a top half of slab - if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) - { - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - return false; - } - else - { - a_BlockMeta = Meta | 0x8; break; - } + // 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: - if ((a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) - { - a_Player->GetClientHandle()->HandlePlaceBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, *ItemHandler); - return false; - } - else - { - a_BlockMeta = Meta & 0x7; break; - } + // Cursor at bottom half of block, place bottom slab + a_BlockMeta = Meta & 0x7; break; } } } // switch (a_BlockFace) diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 8ff93ec1b..199f43014 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -854,19 +854,29 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta); - //Special slab handler coding + // Special slab handler coding if ( + // If clicked face top: is slab there in the "bottom" position? + // If clicked face bottom: is the slab there in the "top" position? + // This prevents a dblslab forming below if you click the top face of a "top" slab. (((a_BlockFace == BLOCK_FACE_TOP) && (ClickedBlockMeta == (EquippedBlockDamage & 0x07))) || ((a_BlockFace == BLOCK_FACE_BOTTOM) && (ClickedBlockMeta == (EquippedBlockDamage | 0x08)))) && - ((ClickedBlock == E_BLOCK_STONE_SLAB) || (ClickedBlock == E_BLOCK_WOODEN_SLAB)) && //Is clicked a slab? - ((EquippedBlock == E_BLOCK_STONE_SLAB) || (EquippedBlock == E_BLOCK_WOODEN_SLAB)) && //Is equipped a slab? - ((ClickedBlockMeta & 0x07) == (EquippedBlockDamage & 0x07)) //Is clicked same type of slab as item in hand? + + // Is clicked a slab? This is a SLAB handler, not stone or something! + ((ClickedBlock == E_BLOCK_STONE_SLAB) || (ClickedBlock == E_BLOCK_WOODEN_SLAB)) && + + // Is equipped a some type of slab? + // This prevents a bug where, well, you get a dblslab by placing TNT or something not a slab. + ((EquippedBlock == E_BLOCK_STONE_SLAB) || (EquippedBlock == E_BLOCK_WOODEN_SLAB)) && + + // Is equipped slab type same as the slab in the world? After all, we can't combine different slabs! + ((ClickedBlockMeta & 0x07) == (EquippedBlockDamage & 0x07)) ) { - //Don't move the coordinates + // Coordinates at CLICKED block, don't move them anywhere } else { - //Check if the block ignores build collision (water, grass etc.): + // Check if the block ignores build collision (water, grass etc.): cBlockHandler * Handler = cBlockHandler::GetBlockHandler(ClickedBlock); if (Handler->DoesIgnoreBuildCollision()) { @@ -876,8 +886,9 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c else { AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); - //On side of block, make sure that placement won't be cancelled if there is a slab there - //No need to combinability checks, client will do that + + // 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 ((World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_STONE_SLAB) || (World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_WOODEN_SLAB)) { //Is a slab, don't do checks and proceed to double-slabbing @@ -904,7 +915,8 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c } } } - + // Special slab handler coding end + 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)) From 2081b6dfdeff7ee8253c97fc78c1a44191a09871 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 24 Aug 2013 18:54:03 +0100 Subject: [PATCH 10/14] Fixed inconsistent metas and added snow metas --- source/Bindings.cpp | 56 ++++++++++++++++++++---------------- source/BlockID.h | 70 ++++++++++++++++++++++++++------------------- 2 files changed, 73 insertions(+), 53 deletions(-) diff --git a/source/Bindings.cpp b/source/Bindings.cpp index 9d6b6d959..7d51f7a4e 100644 --- a/source/Bindings.cpp +++ b/source/Bindings.cpp @@ -27443,14 +27443,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); @@ -27479,14 +27479,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); @@ -27503,14 +27503,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); @@ -27559,6 +27559,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/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: From 11ca2f96a08f8eaba95a7c8ecc2ddd5f761565f9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 24 Aug 2013 22:00:24 +0100 Subject: [PATCH 11/14] Vines now spread when updated --- source/Blocks/BlockVine.h | 7 +++++++ 1 file changed, 7 insertions(+) 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 { From 3640f2c482b05281bc6c8905961050bc694a1248 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 25 Aug 2013 11:45:47 +0100 Subject: [PATCH 12/14] Redstone fixes [SEE DESC] Fixed pistons not correctly powering down Fixed dispensers not correctly powering down Fixed droppers not correctly power down Fixed TNT not correctly powering up Fixed redstone lamps not correctly powering up Fixed redstone lamps not correctly powering down --- source/Simulator/RedstoneSimulator.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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: { From ebc3d040745d1c1677237cca370535ad65a71091 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 25 Aug 2013 13:40:43 +0100 Subject: [PATCH 13/14] Fixed public thing in ClientHandle --- source/ClientHandle.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/ClientHandle.h b/source/ClientHandle.h index a2e29f9dc..f1a2dbc3d 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 ) @@ -310,9 +313,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) - public: 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 From 55e3fc53f65fe3073a9453a9aa2cb86132a28bc3 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 25 Aug 2013 13:41:02 +0100 Subject: [PATCH 14/14] Fixed iron door opening by hand --- source/Blocks/BlockDoor.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); + } }