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 | |
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 'source')
-rw-r--r-- | source/BlockID.cpp | 56 | ||||
-rw-r--r-- | source/BlockID.h | 1 | ||||
-rw-r--r-- | source/Blocks/BlockFlowerPot.h | 80 | ||||
-rw-r--r-- | source/Blocks/BlockHandler.cpp | 2 | ||||
-rw-r--r-- | source/Items/ItemFlowerPot.h | 25 | ||||
-rw-r--r-- | source/Items/ItemHandler.cpp | 2 |
6 files changed, 141 insertions, 25 deletions
diff --git a/source/BlockID.cpp b/source/BlockID.cpp index 5f7302a85..d2bef02ce 100644 --- a/source/BlockID.cpp +++ b/source/BlockID.cpp @@ -390,31 +390,36 @@ public: g_BlockSpreadLightFalloff[E_BLOCK_WATER] = 2; // Transparent blocks - g_BlockTransparent[E_BLOCK_AIR] = true; - g_BlockTransparent[E_BLOCK_BROWN_MUSHROOM] = true; - g_BlockTransparent[E_BLOCK_CHEST] = true; - g_BlockTransparent[E_BLOCK_COBWEB] = true; - g_BlockTransparent[E_BLOCK_CROPS] = true; - g_BlockTransparent[E_BLOCK_FENCE] = true; - g_BlockTransparent[E_BLOCK_FENCE_GATE] = true; - g_BlockTransparent[E_BLOCK_FIRE] = true; - g_BlockTransparent[E_BLOCK_GLASS] = true; - g_BlockTransparent[E_BLOCK_ICE] = true; - g_BlockTransparent[E_BLOCK_IRON_DOOR] = true; - g_BlockTransparent[E_BLOCK_LEAVES] = true; - g_BlockTransparent[E_BLOCK_RED_MUSHROOM] = true; - g_BlockTransparent[E_BLOCK_RED_ROSE] = true; - g_BlockTransparent[E_BLOCK_SIGN_POST] = true; - g_BlockTransparent[E_BLOCK_SNOW] = true; - g_BlockTransparent[E_BLOCK_TALL_GRASS] = true; - g_BlockTransparent[E_BLOCK_TORCH] = true; - g_BlockTransparent[E_BLOCK_VINES] = true; - g_BlockTransparent[E_BLOCK_WALLSIGN] = true; - g_BlockTransparent[E_BLOCK_WOODEN_DOOR] = true; - g_BlockTransparent[E_BLOCK_YELLOW_FLOWER] = true; - g_BlockTransparent[E_BLOCK_RAIL] = true; - g_BlockTransparent[E_BLOCK_DETECTOR_RAIL] = true; - g_BlockTransparent[E_BLOCK_POWERED_RAIL] = true; + g_BlockTransparent[E_BLOCK_AIR] = true; + g_BlockTransparent[E_BLOCK_BROWN_MUSHROOM] = true; + g_BlockTransparent[E_BLOCK_CHEST] = true; + g_BlockTransparent[E_BLOCK_COBWEB] = true; + g_BlockTransparent[E_BLOCK_CROPS] = true; + g_BlockTransparent[E_BLOCK_DETECTOR_RAIL] = true; + g_BlockTransparent[E_BLOCK_FENCE] = true; + g_BlockTransparent[E_BLOCK_FENCE_GATE] = true; + g_BlockTransparent[E_BLOCK_FIRE] = true; + g_BlockTransparent[E_BLOCK_FLOWER_POT] = true; + g_BlockTransparent[E_BLOCK_GLASS] = true; + g_BlockTransparent[E_BLOCK_ICE] = true; + g_BlockTransparent[E_BLOCK_IRON_DOOR] = true; + g_BlockTransparent[E_BLOCK_LEAVES] = true; + g_BlockTransparent[E_BLOCK_LEVER] = true; + g_BlockTransparent[E_BLOCK_NETHER_BRICK_FENCE] = true; + g_BlockTransparent[E_BLOCK_POWERED_RAIL] = true; + g_BlockTransparent[E_BLOCK_RAIL] = true; + g_BlockTransparent[E_BLOCK_RED_MUSHROOM] = true; + g_BlockTransparent[E_BLOCK_RED_ROSE] = true; + g_BlockTransparent[E_BLOCK_SIGN_POST] = true; + g_BlockTransparent[E_BLOCK_STONE_PRESSURE_PLATE] = true; + g_BlockTransparent[E_BLOCK_SNOW] = true; + g_BlockTransparent[E_BLOCK_TALL_GRASS] = true; + g_BlockTransparent[E_BLOCK_TORCH] = true; + g_BlockTransparent[E_BLOCK_VINES] = true; + g_BlockTransparent[E_BLOCK_WALLSIGN] = true; + g_BlockTransparent[E_BLOCK_WOODEN_DOOR] = true; + g_BlockTransparent[E_BLOCK_WOODEN_PRESSURE_PLATE] = true; + g_BlockTransparent[E_BLOCK_YELLOW_FLOWER] = true; // TODO: Any other transparent blocks? @@ -422,6 +427,7 @@ public: g_BlockOneHitDig[E_BLOCK_BROWN_MUSHROOM] = true; g_BlockOneHitDig[E_BLOCK_CROPS] = true; g_BlockOneHitDig[E_BLOCK_FIRE] = true; + g_BlockOneHitDig[E_BLOCK_FLOWER_POT] = true; g_BlockOneHitDig[E_BLOCK_LOCKED_CHEST] = true; g_BlockOneHitDig[E_BLOCK_REDSTONE_REPEATER_OFF] = true; g_BlockOneHitDig[E_BLOCK_REDSTONE_REPEATER_ON] = true; diff --git a/source/BlockID.h b/source/BlockID.h index f6cf5abaa..ae030e119 100644 --- a/source/BlockID.h +++ b/source/BlockID.h @@ -441,6 +441,7 @@ enum ENUM_ITEM_ID E_ITEM_BOOK_AND_QUILL = 386, E_ITEM_WRITTEN_BOOK = 387, E_ITEM_EMERALD = 388, + E_ITEM_FLOWER_POT = 390, E_ITEM_FIREWORK_ROCKET = 401, E_ITEM_FIREWORK_STAR = 402, E_ITEM_ENCHANTED_BOOK = 403, 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);
diff --git a/source/Items/ItemFlowerPot.h b/source/Items/ItemFlowerPot.h new file mode 100644 index 000000000..fe4b3dd61 --- /dev/null +++ b/source/Items/ItemFlowerPot.h @@ -0,0 +1,25 @@ +
+#pragma once
+
+#include "ItemHandler.h"
+
+class cItemFlowerPotHandler : public cItemHandler
+{
+public:
+ cItemFlowerPotHandler(int a_ItemType)
+ : cItemHandler(a_ItemType)
+ {
+
+ }
+
+ virtual bool IsPlaceable() override
+ {
+ return true;
+ }
+
+ virtual BLOCKTYPE GetBlockType() override
+ {
+ return E_BLOCK_FLOWER_POT;
+ }
+
+};
\ No newline at end of file diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp index c4e6537e2..7a6b82eaa 100644 --- a/source/Items/ItemHandler.cpp +++ b/source/Items/ItemHandler.cpp @@ -28,6 +28,7 @@ #include "ItemSign.h"
#include "ItemBed.h"
#include "ItemSpawnEgg.h"
+#include "ItemFlowerPot.h"
#include "../Blocks/BlockHandler.h"
@@ -71,6 +72,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) case E_ITEM_BED: return new cItemBedHandler(a_ItemType);
case E_ITEM_DYE: return new cItemDyeHandler(a_ItemType);
case E_ITEM_FLINT_AND_STEEL: return new cItemLighterHandler(a_ItemType);
+ case E_ITEM_FLOWER_POT: return new cItemFlowerPotHandler(a_ItemType);
case E_ITEM_LEAVES: return new cItemLeavesHandler(a_ItemType);
case E_ITEM_REDSTONE_DUST: return new cItemRedstoneDustHandler(a_ItemType);
case E_ITEM_REDSTONE_REPEATER: return new cItemRedstoneRepeaterHandler(a_ItemType);
|