diff options
author | luksor111@gmail.com <luksor111@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-12-27 02:01:16 +0100 |
---|---|---|
committer | luksor111@gmail.com <luksor111@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-12-27 02:01:16 +0100 |
commit | ffcfa7c89b6428ed3dc30a181c74dddc67f1f1bf (patch) | |
tree | 8ce0af2bbed3a0f396a45e79eea4781f465acbde /source/Blocks | |
parent | Dispensers can spawn mobs (diff) | |
download | cuberite-ffcfa7c89b6428ed3dc30a181c74dddc67f1f1bf.tar cuberite-ffcfa7c89b6428ed3dc30a181c74dddc67f1f1bf.tar.gz cuberite-ffcfa7c89b6428ed3dc30a181c74dddc67f1f1bf.tar.bz2 cuberite-ffcfa7c89b6428ed3dc30a181c74dddc67f1f1bf.tar.lz cuberite-ffcfa7c89b6428ed3dc30a181c74dddc67f1f1bf.tar.xz cuberite-ffcfa7c89b6428ed3dc30a181c74dddc67f1f1bf.tar.zst cuberite-ffcfa7c89b6428ed3dc30a181c74dddc67f1f1bf.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Blocks/BlockFlowerPot.h | 80 | ||||
-rw-r--r-- | source/Blocks/BlockHandler.cpp | 2 |
2 files changed, 82 insertions, 0 deletions
diff --git a/source/Blocks/BlockFlowerPot.h b/source/Blocks/BlockFlowerPot.h new file mode 100644 index 000000000..d5653108d --- /dev/null +++ b/source/Blocks/BlockFlowerPot.h @@ -0,0 +1,80 @@ +
+#pragma once
+
+#include "BlockHandler.h"
+
+
+
+
+
+class cBlockFlowerPotHandler :
+ public cBlockHandler
+{
+public:
+ cBlockFlowerPotHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
+ {
+ a_Pickups.push_back(cItem(E_ITEM_FLOWER_POT, 1, 0));
+ if( a_BlockMeta == 0 ) return;
+ cItem & Plant = cItem(E_ITEM_RED_ROSE, 1, 0);
+ switch( a_BlockMeta )
+ {
+ case 1: Plant = cItem(E_ITEM_RED_ROSE, 1, 0); break;
+ case 2: Plant = cItem(E_ITEM_YELLOW_FLOWER, 1, 0); break;
+ case 3: Plant = cItem(E_ITEM_SAPLING, 1, E_META_SAPLING_APPLE); break;
+ case 4: Plant = cItem(E_ITEM_SAPLING, 1, E_META_SAPLING_CONIFER); break;
+ case 5: Plant = cItem(E_ITEM_SAPLING, 1, E_META_SAPLING_BIRCH); break;
+ case 6: Plant = cItem(E_ITEM_SAPLING, 1, E_META_SAPLING_JUNGLE); break;
+ case 7: Plant = cItem(E_ITEM_RED_MUSHROOM, 1, 0); break;
+ case 8: Plant = cItem(E_ITEM_BROWN_MUSHROOM, 1, 0); break;
+ case 9: Plant = cItem(E_ITEM_CACTUS, 1, 0); break;
+ case 10: Plant = cItem(E_BLOCK_DEAD_BUSH, 1, 0); break;
+ case 11: Plant = cItem(E_BLOCK_TALL_GRASS, 1, E_META_TALL_GRASS_FERN); break;
+ }
+ a_Pickups.push_back(Plant);
+ }
+
+ void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
+ {
+ char Meta = a_World->GetBlockMeta( a_BlockX, a_BlockY, a_BlockZ );
+ if( Meta ) return;
+ switch( a_Player->GetEquippedItem().m_ItemType )
+ {
+ case E_ITEM_RED_ROSE: Meta = 1; break;
+ case E_ITEM_YELLOW_FLOWER: Meta = 2; break;
+ case E_ITEM_SAPLING:
+ {
+ switch( a_Player->GetEquippedItem().m_ItemDamage )
+ {
+ case E_META_SAPLING_APPLE: Meta = 3; break;
+ case E_META_SAPLING_CONIFER: Meta = 4; break;
+ case E_META_SAPLING_BIRCH: Meta = 5; break;
+ case E_META_SAPLING_JUNGLE: Meta = 6; break;
+ }
+ break;
+ }
+ case E_ITEM_RED_MUSHROOM: Meta = 7; break;
+ case E_ITEM_BROWN_MUSHROOM: Meta = 8; break;
+ case E_ITEM_CACTUS: Meta = 9; break;
+ case E_BLOCK_DEAD_BUSH: Meta = 10; break;
+ case E_BLOCK_TALL_GRASS:
+ if( a_Player->GetEquippedItem().m_ItemDamage == E_META_TALL_GRASS_FERN ) Meta = 11; break;
+ }
+ cItem Item(a_Player->GetEquippedItem().m_ItemType, 1);
+ a_Player->GetInventory().RemoveItem(Item);
+ a_World->SetBlockMeta( a_BlockX, a_BlockY, a_BlockZ, Meta );
+ }
+
+ virtual bool IsUseable() override
+ {
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp index 13342117e..a6ada015b 100644 --- a/source/Blocks/BlockHandler.cpp +++ b/source/Blocks/BlockHandler.cpp @@ -50,6 +50,7 @@ #include "BlockGlass.h"
#include "BlockEnderchest.h"
#include "BlockFenceGate.h"
+#include "BlockFlowerPot.h"
@@ -107,6 +108,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType) case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler;
case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType);
+ case E_BLOCK_FLOWER_POT: return new cBlockFlowerPotHandler (a_BlockType);
case E_BLOCK_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
case E_BLOCK_GLOWSTONE: return new cBlockGlowstoneHandler (a_BlockType);
case E_BLOCK_GOLD_ORE: return new cBlockOreHandler (a_BlockType);
|