From 48ccd93426a1130dcec3555638551472484754e2 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 7 Apr 2020 23:28:51 +0100 Subject: [PATCH] Add Terracotta handlers --- src/Blocks/BlockGlazedTerracotta.h | 34 ++++++++++++++++++++++++++++++ src/Blocks/BlockHandler.cpp | 17 +++++++++++++++ src/Blocks/CMakeLists.txt | 1 + 3 files changed, 52 insertions(+) create mode 100644 src/Blocks/BlockGlazedTerracotta.h diff --git a/src/Blocks/BlockGlazedTerracotta.h b/src/Blocks/BlockGlazedTerracotta.h new file mode 100644 index 000000000..380c3c923 --- /dev/null +++ b/src/Blocks/BlockGlazedTerracotta.h @@ -0,0 +1,34 @@ + +#pragma once + +#include "BlockHandler.h" +#include "Mixins.h" + + +class cBlockGlazedTerracottaHandler: + public cClearMetaOnDrop +{ + using super = cClearMetaOnDrop; + +public: + + cBlockGlazedTerracottaHandler(BLOCKTYPE a_BlockType) : super(a_BlockType) + { + } + + virtual bool GetPlacementBlockTypeMeta( + cChunkInterface & a_ChunkInterface, cPlayer & a_Player, + int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, + int a_CursorX, int a_CursorY, int a_CursorZ, + BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta + ) override + { + a_BlockType = m_BlockType; + + // FIXME: Do not use cPiston class for furnace placement! + a_BlockMeta = cBlockPistonHandler::RotationPitchToMetaData(a_Player.GetYaw(), 0); + + return true; + } + +}; diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 4e0188bfb..f690d7448 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -40,6 +40,7 @@ #include "BlockFluid.h" #include "BlockFurnace.h" #include "BlockGlass.h" +#include "BlockGlazedTerracotta.h" #include "BlockGlowstone.h" #include "BlockGrass.h" #include "BlockGravel.h" @@ -203,9 +204,12 @@ static cBlockHandler * CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_BIRCH_FENCE: return new cBlockFenceHandler (a_BlockType); case E_BLOCK_BIRCH_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); case E_BLOCK_BIRCH_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); + case E_BLOCK_BLACK_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); + case E_BLOCK_BLUE_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); case E_BLOCK_BOOKCASE: return new cBlockBookShelfHandler (a_BlockType); case E_BLOCK_BREWING_STAND: return new cBlockBrewingStandHandler (a_BlockType); case E_BLOCK_BRICK_STAIRS: return new cBlockStairsHandler (a_BlockType); + case E_BLOCK_BROWN_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); case E_BLOCK_BROWN_MUSHROOM: return new cBlockMushroomHandler (a_BlockType); case E_BLOCK_CACTUS: return new cBlockCactusHandler (a_BlockType); case E_BLOCK_CAKE: return new cBlockCakeHandler (a_BlockType); @@ -223,6 +227,7 @@ static cBlockHandler * CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_COMMAND_BLOCK: return new cBlockCommandBlockHandler (a_BlockType); case E_BLOCK_CONCRETE_POWDER: return new cBlockConcretePowderHandler (a_BlockType); case E_BLOCK_CROPS: return new cBlockCropsHandler<7> (a_BlockType); // 8 stages of growth + case E_BLOCK_CYAN_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); case E_BLOCK_DARK_OAK_DOOR: return new cBlockDoorHandler (a_BlockType); case E_BLOCK_DARK_OAK_FENCE: return new cBlockFenceHandler (a_BlockType); case E_BLOCK_DARK_OAK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); @@ -252,6 +257,8 @@ static cBlockHandler * CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_GOLD_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_GRASS: return new cBlockGrassHandler (a_BlockType); case E_BLOCK_GRAVEL: return new cBlockGravelHandler (a_BlockType); + case E_BLOCK_GRAY_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); + case E_BLOCK_GREEN_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); case E_BLOCK_HAY_BALE: return new cBlockSidewaysHandler (a_BlockType); case E_BLOCK_HEAD: return new cBlockMobHeadHandler (a_BlockType); case E_BLOCK_HEAVY_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler (a_BlockType); @@ -272,10 +279,14 @@ static cBlockHandler * CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_LAVA: return new cBlockLavaHandler (a_BlockType); case E_BLOCK_LEAVES: return new cBlockLeavesHandler (a_BlockType); case E_BLOCK_LEVER: return new cBlockLeverHandler (a_BlockType); + case E_BLOCK_LIGHT_BLUE_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); + case E_BLOCK_LIGHT_GRAY_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); case E_BLOCK_LIGHT_WEIGHTED_PRESSURE_PLATE: return new cBlockPressurePlateHandler (a_BlockType); case E_BLOCK_LILY_PAD: return new cBlockLilypadHandler (a_BlockType); + case E_BLOCK_LIME_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); case E_BLOCK_LIT_FURNACE: return new cBlockFurnaceHandler (a_BlockType); case E_BLOCK_LOG: return new cBlockSidewaysHandler (a_BlockType); + case E_BLOCK_MAGENTA_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); case E_BLOCK_MELON: return new cBlockMelonHandler (a_BlockType); case E_BLOCK_MELON_STEM: return new cBlockMelonStemHandler (a_BlockType); case E_BLOCK_MOB_SPAWNER: return new cBlockMobSpawnerHandler (a_BlockType); @@ -292,7 +303,9 @@ static cBlockHandler * CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_OAK_DOOR: return new cBlockDoorHandler (a_BlockType); case E_BLOCK_OAK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); case E_BLOCK_OAK_WOOD_STAIRS: return new cBlockStairsHandler (a_BlockType); + case E_BLOCK_ORANGE_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); case E_BLOCK_PACKED_ICE: return new cBlockIceHandler (a_BlockType); + case E_BLOCK_PINK_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); case E_BLOCK_PISTON: return new cBlockPistonHandler (a_BlockType); case E_BLOCK_PISTON_EXTENSION: return new cBlockPistonHeadHandler; case E_BLOCK_PLANKS: return new cBlockPlanksHandler (a_BlockType); @@ -300,6 +313,7 @@ static cBlockHandler * CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_POWERED_RAIL: return new cBlockRailHandler (a_BlockType); case E_BLOCK_PUMPKIN: return new cBlockPumpkinHandler (a_BlockType); case E_BLOCK_PUMPKIN_STEM: return new cBlockPumpkinStemHandler (a_BlockType); + case E_BLOCK_PURPLE_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); case E_BLOCK_PURPUR_DOUBLE_SLAB: return new cBlockDoubleSlabHandler (a_BlockType); case E_BLOCK_PURPUR_SLAB: return new cBlockSlabHandler (a_BlockType); case E_BLOCK_PURPUR_STAIRS: return new cBlockStairsHandler (a_BlockType); @@ -314,6 +328,7 @@ static cBlockHandler * CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_REDSTONE_TORCH_OFF: return new cBlockRedstoneTorchHandler (a_BlockType); case E_BLOCK_REDSTONE_TORCH_ON: return new cBlockRedstoneTorchHandler (a_BlockType); case E_BLOCK_REDSTONE_WIRE: return new cBlockRedstoneHandler (a_BlockType); + case E_BLOCK_RED_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); case E_BLOCK_RED_MUSHROOM: return new cBlockMushroomHandler (a_BlockType); case E_BLOCK_RED_ROSE: return new cBlockFlowerHandler (a_BlockType); case E_BLOCK_RED_SANDSTONE_SLAB: return new cBlockSlabHandler (a_BlockType); @@ -352,12 +367,14 @@ static cBlockHandler * CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_VINES: return new cBlockVineHandler (a_BlockType); case E_BLOCK_WALLSIGN: return new cBlockWallSignHandler (a_BlockType); case E_BLOCK_WATER: return new cBlockFluidHandler (a_BlockType); + case E_BLOCK_WHITE_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); case E_BLOCK_WOODEN_BUTTON: return new cBlockButtonHandler (a_BlockType); case E_BLOCK_WOODEN_PRESSURE_PLATE: return new cBlockPressurePlateHandler (a_BlockType); case E_BLOCK_WOODEN_SLAB: return new cBlockSlabHandler (a_BlockType); case E_BLOCK_WOOL: return new cBlockClothHandler (a_BlockType); case E_BLOCK_WORKBENCH: return new cBlockWorkbenchHandler (a_BlockType); case E_BLOCK_YELLOW_FLOWER: return new cBlockFlowerHandler (a_BlockType); + case E_BLOCK_YELLOW_GLAZED_TERRACOTTA: return new cBlockGlazedTerracottaHandler(a_BlockType); default: return new cBlockHandler(a_BlockType); } diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt index 22789fe1b..fd46f672a 100644 --- a/src/Blocks/CMakeLists.txt +++ b/src/Blocks/CMakeLists.txt @@ -46,6 +46,7 @@ SET (HDRS BlockFluid.h BlockFurnace.h BlockGlass.h + BlockGlazedTerracotta.h BlockGlowstone.h BlockGravel.h BlockHandler.h