From 1cbb38fb028dd0dd6f515b22a40f2fd813f63432 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 13 Sep 2013 20:17:39 +0100 Subject: Removed place on top and side preventions --- source/Blocks/BlockBed.h | 6 ------ source/Blocks/BlockCactus.h | 6 ------ source/Blocks/BlockCrops.h | 6 ------ source/Blocks/BlockDeadBush.h | 12 ------------ source/Blocks/BlockDoor.h | 6 ------ source/Blocks/BlockFlower.h | 12 ------------ source/Blocks/BlockLever.h | 6 ------ source/Blocks/BlockMushroom.h | 12 ------------ source/Blocks/BlockRedstone.h | 11 ----------- source/Blocks/BlockRedstoneRepeater.h | 12 ------------ source/Blocks/BlockSapling.h | 12 ------------ source/Blocks/BlockSign.h | 6 ------ source/Blocks/BlockSugarcane.h | 6 ------ 13 files changed, 113 deletions(-) diff --git a/source/Blocks/BlockBed.h b/source/Blocks/BlockBed.h index 0bf1cfc0f..8a289b22c 100644 --- a/source/Blocks/BlockBed.h +++ b/source/Blocks/BlockBed.h @@ -37,12 +37,6 @@ public: } - virtual bool DoesAllowBlockOnTop() override - { - return false; - } - - // Bed specific helper functions static NIBBLETYPE RotationToMetaData(double a_Rotation) { diff --git a/source/Blocks/BlockCactus.h b/source/Blocks/BlockCactus.h index 1d123bc0a..4147ad473 100644 --- a/source/Blocks/BlockCactus.h +++ b/source/Blocks/BlockCactus.h @@ -63,12 +63,6 @@ public: return true; } - - - virtual bool CanBePlacedOnSide(void) override - { - return false; - } void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override diff --git a/source/Blocks/BlockCrops.h b/source/Blocks/BlockCrops.h index 4bc76fd50..9e19b14ec 100644 --- a/source/Blocks/BlockCrops.h +++ b/source/Blocks/BlockCrops.h @@ -20,12 +20,6 @@ public: } - virtual bool DoesAllowBlockOnTop() override - { - return false; - } - - virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_Meta) override { MTRand rand; diff --git a/source/Blocks/BlockDeadBush.h b/source/Blocks/BlockDeadBush.h index 379e8e5df..14617d006 100644 --- a/source/Blocks/BlockDeadBush.h +++ b/source/Blocks/BlockDeadBush.h @@ -28,18 +28,6 @@ public: { return (a_RelY > 0) && (a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ) == E_BLOCK_SAND); } - - - virtual bool DoesAllowBlockOnTop(void) override - { - return false; - } - - - virtual bool CanBePlacedOnSide() override - { - return false; - } } ; diff --git a/source/Blocks/BlockDoor.h b/source/Blocks/BlockDoor.h index 4978fee38..7304056be 100644 --- a/source/Blocks/BlockDoor.h +++ b/source/Blocks/BlockDoor.h @@ -68,12 +68,6 @@ public: } - virtual bool CanBePlacedOnSide(void) override - { - return false; - } - - 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)); diff --git a/source/Blocks/BlockFlower.h b/source/Blocks/BlockFlower.h index 952901ba5..421e2d5d8 100644 --- a/source/Blocks/BlockFlower.h +++ b/source/Blocks/BlockFlower.h @@ -30,18 +30,6 @@ public: } - virtual bool DoesAllowBlockOnTop(void) override - { - return true; - } - - - virtual bool CanBePlacedOnSide(void) override - { - return false; - } - - virtual const char * GetStepSound(void) override { return "step.grass"; diff --git a/source/Blocks/BlockLever.h b/source/Blocks/BlockLever.h index 362cf563e..ddf48297c 100644 --- a/source/Blocks/BlockLever.h +++ b/source/Blocks/BlockLever.h @@ -42,12 +42,6 @@ public: a_BlockMeta = cRedstoneSimulator::LeverDirectionToMetaData(a_BlockFace); return true; } - - - virtual bool DoesAllowBlockOnTop(void) override - { - return false; - } virtual const char * GetStepSound(void) override diff --git a/source/Blocks/BlockMushroom.h b/source/Blocks/BlockMushroom.h index b3b23e2ba..2846a6317 100644 --- a/source/Blocks/BlockMushroom.h +++ b/source/Blocks/BlockMushroom.h @@ -46,18 +46,6 @@ public: } return true; } - - - virtual bool DoesAllowBlockOnTop(void) override - { - return false; - } - - - virtual bool CanBePlacedOnSide(void) override - { - return false; - } virtual const char * GetStepSound(void) override diff --git a/source/Blocks/BlockRedstone.h b/source/Blocks/BlockRedstone.h index ae0466937..f28f3f2d6 100644 --- a/source/Blocks/BlockRedstone.h +++ b/source/Blocks/BlockRedstone.h @@ -16,11 +16,6 @@ public: virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override; - virtual bool DoesAllowBlockOnTop(void) override - { - return false; - } - virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { @@ -33,12 +28,6 @@ public: // Reset meta to 0 a_Pickups.push_back(cItem(E_ITEM_REDSTONE_DUST, 1)); } - - - virtual bool CanBePlacedOnSide(void) override - { - return false; - } } ; diff --git a/source/Blocks/BlockRedstoneRepeater.h b/source/Blocks/BlockRedstoneRepeater.h index f3e250963..24250ab86 100644 --- a/source/Blocks/BlockRedstoneRepeater.h +++ b/source/Blocks/BlockRedstoneRepeater.h @@ -32,23 +32,11 @@ public: } - virtual bool DoesAllowBlockOnTop(void) override - { - return false; - } - - 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)); } - - virtual bool CanBePlacedOnSide(void) override - { - return false; - } - virtual const char * GetStepSound(void) override { return "step.wood"; diff --git a/source/Blocks/BlockSapling.h b/source/Blocks/BlockSapling.h index 17ef4984f..fff2fa88b 100644 --- a/source/Blocks/BlockSapling.h +++ b/source/Blocks/BlockSapling.h @@ -29,12 +29,6 @@ public: { return (a_RelY > 0) && IsBlockTypeOfDirt(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)); } - - - virtual bool DoesAllowBlockOnTop(void) override - { - return false; - } void OnUpdate(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override @@ -50,12 +44,6 @@ public: a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta | 0x08); } } - - - virtual bool CanBePlacedOnSide() override - { - return false; - } virtual const char * GetStepSound(void) override diff --git a/source/Blocks/BlockSign.h b/source/Blocks/BlockSign.h index e6426180f..7fbe61893 100644 --- a/source/Blocks/BlockSign.h +++ b/source/Blocks/BlockSign.h @@ -23,12 +23,6 @@ public: { a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0)); } - - - virtual bool DoesAllowBlockOnTop(void) override - { - return false; - } virtual const char * GetStepSound(void) override diff --git a/source/Blocks/BlockSugarcane.h b/source/Blocks/BlockSugarcane.h index 9d66d6be6..28a60df80 100644 --- a/source/Blocks/BlockSugarcane.h +++ b/source/Blocks/BlockSugarcane.h @@ -77,12 +77,6 @@ public: { a_World->GrowSugarcane(a_BlockX, a_BlockY, a_BlockZ, 1); } - - - virtual bool CanBePlacedOnSide() override - { - return false; - } virtual const char * GetStepSound(void) override -- cgit v1.2.3 From 4cdf776759fe3790716ae17f5b4d69038bf69942 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 13 Sep 2013 21:08:36 +0100 Subject: Removed torch top placement prevention --- source/Blocks/BlockTorch.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source/Blocks/BlockTorch.h b/source/Blocks/BlockTorch.h index 3a50cab77..dfa4bce83 100644 --- a/source/Blocks/BlockTorch.h +++ b/source/Blocks/BlockTorch.h @@ -100,12 +100,6 @@ public: } - virtual bool DoesAllowBlockOnTop(void) override - { - return true; - } - - static bool CanBePlacedOn(BLOCKTYPE a_BlockType, char a_Direction) { if ( g_BlockIsSolid[a_BlockType] ) { -- cgit v1.2.3 From 411f0b5fa415565cb9625f61730ec94c08f7d530 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 15 Sep 2013 12:18:14 +0100 Subject: Removed leftover DoesAllowBlockOnTop --- source/Blocks/BlockHandler.cpp | 9 --------- source/Blocks/BlockHandler.h | 5 +---- source/ClientHandle.cpp | 9 --------- 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 5134c1103..6d5394a9b 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -404,15 +404,6 @@ bool cBlockHandler::DoesIgnoreBuildCollision(void) -bool cBlockHandler::DoesAllowBlockOnTop(void) -{ - return true; -} - - - - - bool cBlockHandler::CanBePlacedOnSide(void) { return true; diff --git a/source/Blocks/BlockHandler.h b/source/Blocks/BlockHandler.h index 228ce174b..c1df7e934 100644 --- a/source/Blocks/BlockHandler.h +++ b/source/Blocks/BlockHandler.h @@ -83,10 +83,7 @@ public: NOTE: This call doesn't actually place the block */ // virtual bool CanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir); - - /// Called when the player tries to place a block on top of this block (Only if he aims directly on this block); return false to disallow - virtual bool DoesAllowBlockOnTop(void); - + /// Called to check whether this block supports a rclk action. If it returns true, OnUse() is called virtual bool IsUseable(void); diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index 3d819ee18..f915fd7ae 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -908,15 +908,6 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c } 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? -- cgit v1.2.3 From a8cb2bd90e07ad6be815fc456638d2699463d68f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 15 Sep 2013 12:20:13 +0100 Subject: Removed leftover CanBePlacedOnSide --- source/Blocks/BlockHandler.cpp | 9 --------- source/Blocks/BlockHandler.h | 3 --- source/ClientHandle.cpp | 7 ------- 3 files changed, 19 deletions(-) diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 6d5394a9b..4aaf47306 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -404,15 +404,6 @@ bool cBlockHandler::DoesIgnoreBuildCollision(void) -bool cBlockHandler::CanBePlacedOnSide(void) -{ - return true; -} - - - - - bool cBlockHandler::DoesDropOnUnsuitable(void) { return true; diff --git a/source/Blocks/BlockHandler.h b/source/Blocks/BlockHandler.h index c1df7e934..0487505ee 100644 --- a/source/Blocks/BlockHandler.h +++ b/source/Blocks/BlockHandler.h @@ -96,9 +96,6 @@ public: For example blocks placed "on" snow will be placed at the same position. So: Snow ignores Build collision */ virtual bool DoesIgnoreBuildCollision(void); - - /// Indicates this block can be placed on the side of other blocks. Default: true - virtual bool CanBePlacedOnSide(void); /// Does this block drop if it gets destroyed by an unsuitable situation? Default: true virtual bool DoesDropOnUnsuitable(void); diff --git a/source/ClientHandle.cpp b/source/ClientHandle.cpp index f915fd7ae..b0f18a4c0 100644 --- a/source/ClientHandle.cpp +++ b/source/ClientHandle.cpp @@ -929,13 +929,6 @@ void cClientHandle::HandlePlaceBlock(int a_BlockX, int a_BlockY, int a_BlockZ, c cBlockHandler * NewBlock = BlockHandler(BlockType); - if ((a_BlockFace != BLOCK_FACE_TOP) && !NewBlock->CanBePlacedOnSide()) - { - // Cannot be placed on the side of an other block - World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); - return; - } - if (cRoot::Get()->GetPluginManager()->CallHookPlayerPlacingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, BlockType, BlockMeta)) { // A plugin doesn't agree with placing the block, revert the block on the client: -- cgit v1.2.3 From fc3d5ff5a6090eb447e31966faa77f75bd1b5c06 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 15 Sep 2013 15:55:35 +0100 Subject: Torches work properly Also fixed a naming inconsistency concerning quartz stairs. --- source/BlockID.cpp | 105 +++++++++++++++++++++++++++++------------ source/BlockID.h | 4 +- source/Blocks/BlockHandler.cpp | 2 +- source/Blocks/BlockTorch.h | 97 +++++++++++++++++++++++++++---------- 4 files changed, 149 insertions(+), 59 deletions(-) diff --git a/source/BlockID.cpp b/source/BlockID.cpp index b53507f17..3e1b86f3a 100644 --- a/source/BlockID.cpp +++ b/source/BlockID.cpp @@ -21,6 +21,7 @@ bool g_BlockPistonBreakable[256]; bool g_BlockIsSnowable[256]; bool g_BlockRequiresSpecialTool[256]; bool g_BlockIsSolid[256]; +bool g_BlockIsTorchPlaceable[256]; @@ -523,6 +524,7 @@ public: memset(g_BlockTransparent, 0x00, sizeof(g_BlockTransparent)); memset(g_BlockOneHitDig, 0x00, sizeof(g_BlockOneHitDig)); memset(g_BlockPistonBreakable, 0x00, sizeof(g_BlockPistonBreakable)); + memset(g_BlockIsTorchPlaceable, 0x00, sizeof(g_BlockIsTorchPlaceable)); // Setting bools to true must be done manually, see http://forum.mc-server.org/showthread.php?tid=629&pid=5415#pid5415 for (int i = 0; i < ARRAYCOUNT(g_BlockIsSnowable); i++) @@ -754,66 +756,109 @@ public: g_BlockRequiresSpecialTool[E_BLOCK_VINES] = true; // Nonsolid Blocks: + g_BlockIsSolid[E_BLOCK_ACTIVATOR_RAIL] = false; g_BlockIsSolid[E_BLOCK_AIR] = false; - g_BlockIsSolid[E_BLOCK_BED] = false; - g_BlockIsSolid[E_BLOCK_BIRCH_WOOD_STAIRS] = false; - g_BlockIsSolid[E_BLOCK_BRICK_STAIRS] = false; g_BlockIsSolid[E_BLOCK_BROWN_MUSHROOM] = false; - g_BlockIsSolid[E_BLOCK_CACTUS] = false; - g_BlockIsSolid[E_BLOCK_CAKE] = false; - g_BlockIsSolid[E_BLOCK_CHEST] = false; - g_BlockIsSolid[E_BLOCK_COBBLESTONE_STAIRS] = false; + g_BlockIsSolid[E_BLOCK_CARROTS] = false; + g_BlockIsSolid[E_BLOCK_COBWEB] = false; g_BlockIsSolid[E_BLOCK_CROPS] = false; - g_BlockIsSolid[E_BLOCK_ENCHANTMENT_TABLE] = false; + g_BlockIsSolid[E_BLOCK_DETECTOR_RAIL] = false; g_BlockIsSolid[E_BLOCK_END_PORTAL] = false; - g_BlockIsSolid[E_BLOCK_END_PORTAL_FRAME] = false; - g_BlockIsSolid[E_BLOCK_FARMLAND] = false; - g_BlockIsSolid[E_BLOCK_FENCE] = false; g_BlockIsSolid[E_BLOCK_FIRE] = false; - g_BlockIsSolid[E_BLOCK_GLASS] = false; - g_BlockIsSolid[E_BLOCK_IRON_DOOR] = false; - g_BlockIsSolid[E_BLOCK_JUNGLE_WOOD_STAIRS] = false; - g_BlockIsSolid[E_BLOCK_LADDER] = false; + g_BlockIsSolid[E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE] = false; g_BlockIsSolid[E_BLOCK_LAVA] = false; - g_BlockIsSolid[E_BLOCK_LEAVES] = false; g_BlockIsSolid[E_BLOCK_LEVER] = false; - g_BlockIsSolid[E_BLOCK_LOCKED_CHEST] = false; - g_BlockIsSolid[E_BLOCK_NETHER_BRICK_STAIRS] = false; + g_BlockIsSolid[E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE] = false; + g_BlockIsSolid[E_BLOCK_MELON_STEM] = false; g_BlockIsSolid[E_BLOCK_NETHER_PORTAL] = false; - g_BlockIsSolid[E_BLOCK_PISTON] = false; - g_BlockIsSolid[E_BLOCK_PISTON_EXTENSION] = false; - g_BlockIsSolid[E_BLOCK_RAIL] = true; - g_BlockIsSolid[E_BLOCK_REDSTONE_REPEATER_OFF] = false; - g_BlockIsSolid[E_BLOCK_REDSTONE_REPEATER_ON] = false; + g_BlockIsSolid[E_BLOCK_PISTON_MOVED_BLOCK] = false; + g_BlockIsSolid[E_BLOCK_POTATOES] = false; + g_BlockIsSolid[E_BLOCK_PUMPKIN_STEM] = false; + g_BlockIsSolid[E_BLOCK_RAIL] = false; g_BlockIsSolid[E_BLOCK_REDSTONE_TORCH_OFF] = false; g_BlockIsSolid[E_BLOCK_REDSTONE_TORCH_ON] = false; g_BlockIsSolid[E_BLOCK_REDSTONE_WIRE] = false; g_BlockIsSolid[E_BLOCK_RED_MUSHROOM] = false; g_BlockIsSolid[E_BLOCK_RED_ROSE] = false; g_BlockIsSolid[E_BLOCK_REEDS] = false; - g_BlockIsSolid[E_BLOCK_SANDSTONE_STAIRS] = false; g_BlockIsSolid[E_BLOCK_SAPLING] = false; g_BlockIsSolid[E_BLOCK_SIGN_POST] = false; g_BlockIsSolid[E_BLOCK_SNOW] = false; - g_BlockIsSolid[E_BLOCK_SPRUCE_WOOD_STAIRS] = false; g_BlockIsSolid[E_BLOCK_STATIONARY_LAVA] = false; g_BlockIsSolid[E_BLOCK_STATIONARY_WATER] = false; - g_BlockIsSolid[E_BLOCK_STONE_BRICK_STAIRS] = false; g_BlockIsSolid[E_BLOCK_STONE_BUTTON] = false; g_BlockIsSolid[E_BLOCK_STONE_PRESSURE_PLATE] = false; - g_BlockIsSolid[E_BLOCK_STONE_SLAB] = false; g_BlockIsSolid[E_BLOCK_TALL_GRASS] = false; - g_BlockIsSolid[E_BLOCK_TNT] = false; g_BlockIsSolid[E_BLOCK_TORCH] = false; - g_BlockIsSolid[E_BLOCK_TRAPDOOR] = false; + g_BlockIsSolid[E_BLOCK_TRIPWIRE] = false; g_BlockIsSolid[E_BLOCK_VINES] = false; g_BlockIsSolid[E_BLOCK_WALLSIGN] = false; g_BlockIsSolid[E_BLOCK_WATER] = false; g_BlockIsSolid[E_BLOCK_WOODEN_BUTTON] = false; - g_BlockIsSolid[E_BLOCK_WOODEN_DOOR] = false; g_BlockIsSolid[E_BLOCK_WOODEN_PRESSURE_PLATE] = false; g_BlockIsSolid[E_BLOCK_WOODEN_SLAB] = false; g_BlockIsSolid[E_BLOCK_YELLOW_FLOWER] = false; + + // Torch placeable + g_BlockIsTorchPlaceable[E_BLOCK_BEDROCK] = true; + g_BlockIsTorchPlaceable[E_BLOCK_BLOCK_OF_COAL] = true; + g_BlockIsTorchPlaceable[E_BLOCK_BLOCK_OF_REDSTONE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_BOOKCASE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_BRICK] = true; + g_BlockIsTorchPlaceable[E_BLOCK_CLAY] = true; + g_BlockIsTorchPlaceable[E_BLOCK_COAL_ORE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_COBBLESTONE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_COMMAND_BLOCK] = true; + g_BlockIsTorchPlaceable[E_BLOCK_CRAFTING_TABLE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_DIAMOND_BLOCK] = true; + g_BlockIsTorchPlaceable[E_BLOCK_DIAMOND_ORE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_DIRT] = true; + g_BlockIsTorchPlaceable[E_BLOCK_DISPENSER] = true; + g_BlockIsTorchPlaceable[E_BLOCK_DOUBLE_STONE_SLAB] = true; + g_BlockIsTorchPlaceable[E_BLOCK_DOUBLE_WOODEN_SLAB] = true; + g_BlockIsTorchPlaceable[E_BLOCK_DROPPER] = true; + g_BlockIsTorchPlaceable[E_BLOCK_EMERALD_BLOCK] = true; + g_BlockIsTorchPlaceable[E_BLOCK_EMERALD_ORE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_END_STONE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_FURNACE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_GLOWSTONE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_GOLD_BLOCK] = true; + g_BlockIsTorchPlaceable[E_BLOCK_GOLD_ORE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_GRASS] = true; + g_BlockIsTorchPlaceable[E_BLOCK_GRAVEL] = true; + g_BlockIsTorchPlaceable[E_BLOCK_HARDENED_CLAY] = true; + g_BlockIsTorchPlaceable[E_BLOCK_HAY_BALE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_HUGE_BROWN_MUSHROOM] = true; + g_BlockIsTorchPlaceable[E_BLOCK_HUGE_RED_MUSHROOM] = true; + g_BlockIsTorchPlaceable[E_BLOCK_IRON_BLOCK] = true; + g_BlockIsTorchPlaceable[E_BLOCK_IRON_ORE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_JACK_O_LANTERN] = true; + g_BlockIsTorchPlaceable[E_BLOCK_JUKEBOX] = true; + g_BlockIsTorchPlaceable[E_BLOCK_LAPIS_BLOCK] = true; + g_BlockIsTorchPlaceable[E_BLOCK_LAPIS_ORE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_LOG] = true; + g_BlockIsTorchPlaceable[E_BLOCK_MELON] = true; + g_BlockIsTorchPlaceable[E_BLOCK_MOSSY_COBBLESTONE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_MYCELIUM] = true; + g_BlockIsTorchPlaceable[E_BLOCK_NETHERRACK] = true; + g_BlockIsTorchPlaceable[E_BLOCK_NETHER_BRICK] = true; + g_BlockIsTorchPlaceable[E_BLOCK_NETHER_QUARTZ_ORE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_NOTE_BLOCK] = true; + g_BlockIsTorchPlaceable[E_BLOCK_OBSIDIAN] = true; + g_BlockIsTorchPlaceable[E_BLOCK_PLANKS] = true; + g_BlockIsTorchPlaceable[E_BLOCK_PUMPKIN] = true; + g_BlockIsTorchPlaceable[E_BLOCK_QUARTZ_BLOCK] = true; + g_BlockIsTorchPlaceable[E_BLOCK_REDSTONE_LAMP_OFF] = true; + g_BlockIsTorchPlaceable[E_BLOCK_REDSTONE_LAMP_ON] = true; + g_BlockIsTorchPlaceable[E_BLOCK_REDSTONE_ORE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_REDSTONE_ORE_GLOWING] = true; + g_BlockIsTorchPlaceable[E_BLOCK_SANDSTONE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_SAND] = true; + g_BlockIsTorchPlaceable[E_BLOCK_SILVERFISH_EGG] = true; + g_BlockIsTorchPlaceable[E_BLOCK_SPONGE] = true; + g_BlockIsTorchPlaceable[E_BLOCK_STAINED_CLAY] = true; + g_BlockIsTorchPlaceable[E_BLOCK_WOOL] = true; + g_BlockIsTorchPlaceable[E_BLOCK_STONE] = true; } } BlockPropertiesInitializer; diff --git a/source/BlockID.h b/source/BlockID.h index 40da3c651..8f5675b31 100644 --- a/source/BlockID.h +++ b/source/BlockID.h @@ -165,7 +165,7 @@ enum ENUM_BLOCK_ID E_BLOCK_NETHER_QUARTZ_ORE = 153, E_BLOCK_HOPPER = 154, E_BLOCK_QUARTZ_BLOCK = 155, - E_BLOCK_QUARTZ_STAIR = 156, + E_BLOCK_QUARTZ_STAIRS = 156, E_BLOCK_ACTIVATOR_RAIL = 157, E_BLOCK_DROPPER = 158, @@ -770,7 +770,7 @@ extern bool g_BlockPistonBreakable[256]; extern bool g_BlockIsSnowable[256]; extern bool g_BlockRequiresSpecialTool[256]; extern bool g_BlockIsSolid[256]; - +extern bool g_BlockIsTorchPlaceable[256]; diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 4aaf47306..9cc1433b6 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -154,7 +154,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler (); case E_BLOCK_PLANKS: return new cBlockWoodHandler (a_BlockType); case E_BLOCK_PUMPKIN_STEM: return new cBlockStemsHandler (a_BlockType); - case E_BLOCK_QUARTZ_STAIR: return new cBlockStairsHandler (a_BlockType); + case E_BLOCK_QUARTZ_STAIRS: return new cBlockStairsHandler (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); diff --git a/source/Blocks/BlockTorch.h b/source/Blocks/BlockTorch.h index dfa4bce83..b9e0dbf27 100644 --- a/source/Blocks/BlockTorch.h +++ b/source/Blocks/BlockTorch.h @@ -24,16 +24,31 @@ public: BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta ) override { - // Find proper placement. Use the player-supplied one as the default, but fix if not okay: - if (!TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace)) + // Find proper placement of torch + + if ((a_BlockFace == BLOCK_FACE_TOP) || (a_BlockFace == BLOCK_FACE_BOTTOM)) { - a_BlockFace = FindSuitableFace(a_World, a_BlockX, a_BlockY, a_BlockZ); - - if (a_BlockFace == BLOCK_FACE_BOTTOM) + a_BlockFace = FindSuitableFace(a_World, a_BlockX, a_BlockY, a_BlockZ); // Top or bottom faces clicked, find a suitable face + if (a_BlockFace == BLOCK_FACE_NONE) { + // Client wouldn't have sent anything anyway, but whatever return false; } } + else + { + // Not top or bottom faces, try to preserve whatever face was clicked + if (!TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace)) + { + // Torch couldn't be placed on whatever face was clicked, last ditch resort - find another face + a_BlockFace = FindSuitableFace(a_World, a_BlockX, a_BlockY, a_BlockZ); + if (a_BlockFace == BLOCK_FACE_NONE) + { + return false; + } + } + } + a_BlockType = m_BlockType; a_BlockMeta = DirectionToMetaData(a_BlockFace); return true; @@ -100,45 +115,58 @@ public: } - static bool CanBePlacedOn(BLOCKTYPE a_BlockType, char a_Direction) + static bool CanBePlacedOn(BLOCKTYPE a_BlockType, char a_BlockFace) { - if ( g_BlockIsSolid[a_BlockType] ) { - return (a_Direction == 0x1); // allow only direction "standing on floor" + if ( !g_BlockIsTorchPlaceable[a_BlockType] ) + { + return (a_BlockFace == BLOCK_FACE_TOP); // Allow placement only when torch upright } - else { - return g_BlockIsSolid[a_BlockType]; + else + { + return true; } } static bool TorchCanBePlacedAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) { - // TODO: If placing a torch from below, check all 4 XZ neighbors, place it on that neighbor instead - // How to propagate that change up? - // Simon: The easiest way is to calculate the position two times, shouldn�t cost much cpu power :) - - if (a_BlockFace == BLOCK_FACE_BOTTOM) - { - return false; - } - AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, true); - return CanBePlacedOn(a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ), a_BlockFace); } - /// Finds a suitable Face for the Torch. Returns BLOCK_FACE_BOTTOM on failure + /// Finds a suitable face to place the torch, returning BLOCK_FACE_NONE on failure static char FindSuitableFace(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) { - for (int i = 1; i <= 5; i++) + // TODO: If placing a torch from below, check all 4 XZ neighbors, place it on that neighbor instead + // How to propagate that change up? + // Simon: The easiest way is to calculate the position two times, shouldn't cost much cpu power :) + + for (int i = 0; i <= 5; i++) { - if (TorchCanBePlacedAt(a_World, a_BlockX, a_BlockY, a_BlockZ, i)) + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, i, true); + BLOCKTYPE BlockInQuestion = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ); + + if ( + ((BlockInQuestion == E_BLOCK_GLASS) || + (BlockInQuestion == E_BLOCK_FENCE) || + (BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE) || + (BlockInQuestion == E_BLOCK_COBBLESTONE_WALL)) && + (i = 1) + ) + { + return i; + } + else if ( g_BlockIsTorchPlaceable[BlockInQuestion] ) { return i; } + else + { + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, i, false); + } } - return BLOCK_FACE_BOTTOM; + return BLOCK_FACE_NONE; } @@ -157,11 +185,28 @@ public: virtual bool CanBeAt(int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override { - // 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); + + AddFaceDirection(a_RelX, a_RelY, a_RelZ, Face, true); + BLOCKTYPE BlockInQuestion; + a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockInQuestion); + + if ((BlockInQuestion == E_BLOCK_GLASS) || (BlockInQuestion == E_BLOCK_FENCE) || (BlockInQuestion == E_BLOCK_NETHER_BRICK_FENCE)) + { + // Torches can be placed on tops of glass and fences, despite them being 'untorcheable' + // No need to check for upright orientation, it was done when the torch was placed + return true; + } + else if ( !g_BlockIsTorchPlaceable[BlockInQuestion] ) + { + return false; + } + else + { + return true; + } } -- cgit v1.2.3 From 30b8300ad38d82f5b402a490bc121bccdbfb323f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 15 Sep 2013 15:56:02 +0100 Subject: Mycelium now has correct placement sound --- source/Blocks/BlockMycelium.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/Blocks/BlockMycelium.h b/source/Blocks/BlockMycelium.h index 0ed7162ac..7f897c72a 100644 --- a/source/Blocks/BlockMycelium.h +++ b/source/Blocks/BlockMycelium.h @@ -20,6 +20,11 @@ public: { a_Pickups.push_back(cItem(E_BLOCK_DIRT, 1, 0)); } + + virtual const char * GetStepSound(void) override + { + return "step.gravel"; + } } ; -- cgit v1.2.3 From 91a13c8e8793109e072a03dc67554ea109ac08e9 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 15 Sep 2013 16:40:09 +0100 Subject: Fixed pistons pulling un-pullables --- source/Piston.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/Piston.cpp b/source/Piston.cpp index f4244d177..b5fda1600 100644 --- a/source/Piston.cpp +++ b/source/Piston.cpp @@ -270,7 +270,13 @@ bool cPiston::CanPull(BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) return false; } } - return CanPush(a_BlockType, a_BlockMeta) || CanBreakPush(a_BlockType, a_BlockMeta); + + if (CanBreakPush(a_BlockType, a_BlockMeta)) + { + return false; // CanBreakPush returns true, but we need false to prevent pulling + } + + return CanPush(a_BlockType, a_BlockMeta); } -- cgit v1.2.3 From 526c769b6a1869af3fd891a6056d8ccb187a6c21 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 15 Sep 2013 16:42:23 +0100 Subject: Possible Linux compile fix --- VC2008/MCServer.vcproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/VC2008/MCServer.vcproj b/VC2008/MCServer.vcproj index 7ffa3c887..82ed37554 100644 --- a/VC2008/MCServer.vcproj +++ b/VC2008/MCServer.vcproj @@ -2147,6 +2147,10 @@ RelativePath="..\source\blocks\BlockPiston.h" > + + -- cgit v1.2.3