From 073bcd0361ff1634bcb3c7c8f075592500997b55 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 5 Aug 2013 10:43:43 +0200 Subject: Added the Carpet block. --- source/Blocks/BlockCarpet.h | 54 ++++++++++++++++++++++++ source/Blocks/BlockChest.h | 1 + source/Blocks/BlockDropSpenser.h | 2 + source/Blocks/BlockHandler.cpp | 89 ++++++++++++++++++++-------------------- 4 files changed, 102 insertions(+), 44 deletions(-) create mode 100644 source/Blocks/BlockCarpet.h (limited to 'source/Blocks') diff --git a/source/Blocks/BlockCarpet.h b/source/Blocks/BlockCarpet.h new file mode 100644 index 000000000..f70ff45b6 --- /dev/null +++ b/source/Blocks/BlockCarpet.h @@ -0,0 +1,54 @@ + +// BlockCarpet.h + +// Declares the cBlockCarpetHandler class representing the handler for the carpet block + + + + +#pragma once + + + + + +class cBlockCarpetHandler : + public cBlockHandler +{ +public: + cBlockCarpetHandler(BLOCKTYPE a_BlockType); + + virtual const char * GetStepSound(void) override + { + return "step.cloth"; + } + + + virtual bool GetPlacementBlockTypeMeta( + cWorld * a_World, cPlayer * a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, + int a_CursorX, int a_CursorY, int a_CursorZ, + BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta + ) override + { + a_BlockType = m_BlockType; + a_BlockMeta = a_Player->GetEquippedItem().m_ItemDamage & 0x0f; + return true; + } + + + virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override + { + a_Pickups.push_back(cItem(E_BLOCK_CARPET, 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)); + } +} ; + + + + diff --git a/source/Blocks/BlockChest.h b/source/Blocks/BlockChest.h index 1975e11b2..8164942a3 100644 --- a/source/Blocks/BlockChest.h +++ b/source/Blocks/BlockChest.h @@ -3,6 +3,7 @@ #include "BlockEntity.h" #include "../World.h" +#include "../BlockArea.h" #include "../Player.h" diff --git a/source/Blocks/BlockDropSpenser.h b/source/Blocks/BlockDropSpenser.h index cfb607a7b..e5572da8a 100644 --- a/source/Blocks/BlockDropSpenser.h +++ b/source/Blocks/BlockDropSpenser.h @@ -5,6 +5,8 @@ #pragma once +#include "../Piston.h" + diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 550a6795c..8978f4d46 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -5,59 +5,60 @@ #include "../World.h" #include "../Root.h" #include "../PluginManager.h" -#include "BlockSand.h" -#include "BlockGravel.h" -#include "BlockDoor.h" -#include "BlockFire.h" -#include "BlockRedstone.h" -#include "BlockRedstoneTorch.h" -#include "BlockRedstoneRepeater.h" -#include "BlockPiston.h" -#include "BlockWorkbench.h" -#include "BlockEntity.h" -#include "BlockVine.h" -#include "BlockTallGrass.h" -#include "BlockSnow.h" +#include "BlockBed.h" +#include "BlockBrewingStand.h" +#include "BlockCactus.h" +#include "BlockCarpet.h" +#include "BlockCauldron.h" +#include "BlockChest.h" #include "BlockCloth.h" -#include "BlockSlab.h" +#include "BlockCobWeb.h" +#include "BlockCrops.h" +#include "BlockDeadBush.h" #include "BlockDirt.h" -#include "BlockTorch.h" -#include "BlockWood.h" -#include "BlockLeaves.h" -#include "BlockSapling.h" +#include "BlockDoor.h" +#include "BlockDropSpenser.h" +#include "BlockEnderchest.h" +#include "BlockEntity.h" +#include "BlockFarmland.h" +#include "BlockFenceGate.h" +#include "BlockFire.h" +#include "BlockFlower.h" +#include "BlockFlowerPot.h" #include "BlockFluid.h" -#include "BlockChest.h" #include "BlockFurnace.h" -#include "BlockDropSpenser.h" -#include "BlockStairs.h" +#include "BlockGlass.h" +#include "BlockGlowstone.h" +#include "BlockGravel.h" +#include "BlockHopper.h" +#include "BlockIce.h" #include "BlockLadder.h" +#include "BlockLeaves.h" #include "BlockLever.h" -#include "BlockSign.h" -#include "BlockCrops.h" -#include "BlockSugarcane.h" -#include "BlockFlower.h" -#include "BlockMushroom.h" -#include "BlockCactus.h" -#include "BlockStems.h" -#include "BlockGlowstone.h" -#include "BlockStone.h" #include "BlockMelon.h" -#include "BlockIce.h" -#include "BlockOre.h" -#include "BlockNote.h" -#include "BlockBed.h" -#include "BlockFarmland.h" +#include "BlockMushroom.h" #include "BlockMycelium.h" +#include "BlockNote.h" +#include "BlockOre.h" +#include "BlockPiston.h" #include "BlockRail.h" -#include "BlockGlass.h" -#include "BlockEnderchest.h" -#include "BlockFenceGate.h" -#include "BlockFlowerPot.h" -#include "BlockCauldron.h" -#include "BlockBrewingStand.h" -#include "BlockCobWeb.h" -#include "BlockDeadBush.h" -#include "BlockHopper.h" +#include "BlockRedstone.h" +#include "BlockRedstoneRepeater.h" +#include "BlockRedstoneTorch.h" +#include "BlockSand.h" +#include "BlockSapling.h" +#include "BlockSign.h" +#include "BlockSlab.h" +#include "BlockSnow.h" +#include "BlockStairs.h" +#include "BlockStems.h" +#include "BlockStone.h" +#include "BlockSugarcane.h" +#include "BlockTallGrass.h" +#include "BlockTorch.h" +#include "BlockVine.h" +#include "BlockWood.h" +#include "BlockWorkbench.h" -- cgit v1.2.3