1
0

Added flower pots

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1107 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
luksor111@gmail.com 2012-12-27 01:01:16 +00:00
parent b026dc3034
commit ffcfa7c89b
7 changed files with 149 additions and 25 deletions

View File

@ -1810,6 +1810,10 @@
RelativePath="..\source\blocks\BlockFlower.h" RelativePath="..\source\blocks\BlockFlower.h"
> >
</File> </File>
<File
RelativePath="..\source\Blocks\BlockFlowerPot.h"
>
</File>
<File <File
RelativePath="..\source\blocks\BlockFluid.h" RelativePath="..\source\blocks\BlockFluid.h"
> >
@ -1994,6 +1998,10 @@
RelativePath="..\source\items\ItemDye.h" RelativePath="..\source\items\ItemDye.h"
> >
</File> </File>
<File
RelativePath="..\source\Items\ItemFlowerPot.h"
>
</File>
<File <File
RelativePath="..\source\items\ItemFood.h" RelativePath="..\source\items\ItemFood.h"
> >

View File

@ -390,31 +390,36 @@ public:
g_BlockSpreadLightFalloff[E_BLOCK_WATER] = 2; g_BlockSpreadLightFalloff[E_BLOCK_WATER] = 2;
// Transparent blocks // Transparent blocks
g_BlockTransparent[E_BLOCK_AIR] = true; g_BlockTransparent[E_BLOCK_AIR] = true;
g_BlockTransparent[E_BLOCK_BROWN_MUSHROOM] = true; g_BlockTransparent[E_BLOCK_BROWN_MUSHROOM] = true;
g_BlockTransparent[E_BLOCK_CHEST] = true; g_BlockTransparent[E_BLOCK_CHEST] = true;
g_BlockTransparent[E_BLOCK_COBWEB] = true; g_BlockTransparent[E_BLOCK_COBWEB] = true;
g_BlockTransparent[E_BLOCK_CROPS] = true; g_BlockTransparent[E_BLOCK_CROPS] = true;
g_BlockTransparent[E_BLOCK_FENCE] = true; g_BlockTransparent[E_BLOCK_DETECTOR_RAIL] = true;
g_BlockTransparent[E_BLOCK_FENCE_GATE] = true; g_BlockTransparent[E_BLOCK_FENCE] = true;
g_BlockTransparent[E_BLOCK_FIRE] = true; g_BlockTransparent[E_BLOCK_FENCE_GATE] = true;
g_BlockTransparent[E_BLOCK_GLASS] = true; g_BlockTransparent[E_BLOCK_FIRE] = true;
g_BlockTransparent[E_BLOCK_ICE] = true; g_BlockTransparent[E_BLOCK_FLOWER_POT] = true;
g_BlockTransparent[E_BLOCK_IRON_DOOR] = true; g_BlockTransparent[E_BLOCK_GLASS] = true;
g_BlockTransparent[E_BLOCK_LEAVES] = true; g_BlockTransparent[E_BLOCK_ICE] = true;
g_BlockTransparent[E_BLOCK_RED_MUSHROOM] = true; g_BlockTransparent[E_BLOCK_IRON_DOOR] = true;
g_BlockTransparent[E_BLOCK_RED_ROSE] = true; g_BlockTransparent[E_BLOCK_LEAVES] = true;
g_BlockTransparent[E_BLOCK_SIGN_POST] = true; g_BlockTransparent[E_BLOCK_LEVER] = true;
g_BlockTransparent[E_BLOCK_SNOW] = true; g_BlockTransparent[E_BLOCK_NETHER_BRICK_FENCE] = true;
g_BlockTransparent[E_BLOCK_TALL_GRASS] = true; g_BlockTransparent[E_BLOCK_POWERED_RAIL] = true;
g_BlockTransparent[E_BLOCK_TORCH] = true; g_BlockTransparent[E_BLOCK_RAIL] = true;
g_BlockTransparent[E_BLOCK_VINES] = true; g_BlockTransparent[E_BLOCK_RED_MUSHROOM] = true;
g_BlockTransparent[E_BLOCK_WALLSIGN] = true; g_BlockTransparent[E_BLOCK_RED_ROSE] = true;
g_BlockTransparent[E_BLOCK_WOODEN_DOOR] = true; g_BlockTransparent[E_BLOCK_SIGN_POST] = true;
g_BlockTransparent[E_BLOCK_YELLOW_FLOWER] = true; g_BlockTransparent[E_BLOCK_STONE_PRESSURE_PLATE] = true;
g_BlockTransparent[E_BLOCK_RAIL] = true; g_BlockTransparent[E_BLOCK_SNOW] = true;
g_BlockTransparent[E_BLOCK_DETECTOR_RAIL] = true; g_BlockTransparent[E_BLOCK_TALL_GRASS] = true;
g_BlockTransparent[E_BLOCK_POWERED_RAIL] = 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? // TODO: Any other transparent blocks?
@ -422,6 +427,7 @@ public:
g_BlockOneHitDig[E_BLOCK_BROWN_MUSHROOM] = true; g_BlockOneHitDig[E_BLOCK_BROWN_MUSHROOM] = true;
g_BlockOneHitDig[E_BLOCK_CROPS] = true; g_BlockOneHitDig[E_BLOCK_CROPS] = true;
g_BlockOneHitDig[E_BLOCK_FIRE] = 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_LOCKED_CHEST] = true;
g_BlockOneHitDig[E_BLOCK_REDSTONE_REPEATER_OFF] = true; g_BlockOneHitDig[E_BLOCK_REDSTONE_REPEATER_OFF] = true;
g_BlockOneHitDig[E_BLOCK_REDSTONE_REPEATER_ON] = true; g_BlockOneHitDig[E_BLOCK_REDSTONE_REPEATER_ON] = true;

View File

@ -441,6 +441,7 @@ enum ENUM_ITEM_ID
E_ITEM_BOOK_AND_QUILL = 386, E_ITEM_BOOK_AND_QUILL = 386,
E_ITEM_WRITTEN_BOOK = 387, E_ITEM_WRITTEN_BOOK = 387,
E_ITEM_EMERALD = 388, E_ITEM_EMERALD = 388,
E_ITEM_FLOWER_POT = 390,
E_ITEM_FIREWORK_ROCKET = 401, E_ITEM_FIREWORK_ROCKET = 401,
E_ITEM_FIREWORK_STAR = 402, E_ITEM_FIREWORK_STAR = 402,
E_ITEM_ENCHANTED_BOOK = 403, E_ITEM_ENCHANTED_BOOK = 403,

View File

@ -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;
}
} ;

View File

@ -50,6 +50,7 @@
#include "BlockGlass.h" #include "BlockGlass.h"
#include "BlockEnderchest.h" #include "BlockEnderchest.h"
#include "BlockFenceGate.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_FARMLAND: return new cBlockFarmlandHandler;
case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType); case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
case E_BLOCK_FIRE: return new cBlockFireHandler (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_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
case E_BLOCK_GLOWSTONE: return new cBlockGlowstoneHandler (a_BlockType); case E_BLOCK_GLOWSTONE: return new cBlockGlowstoneHandler (a_BlockType);
case E_BLOCK_GOLD_ORE: return new cBlockOreHandler (a_BlockType); case E_BLOCK_GOLD_ORE: return new cBlockOreHandler (a_BlockType);

View File

@ -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;
}
};

View File

@ -28,6 +28,7 @@
#include "ItemSign.h" #include "ItemSign.h"
#include "ItemBed.h" #include "ItemBed.h"
#include "ItemSpawnEgg.h" #include "ItemSpawnEgg.h"
#include "ItemFlowerPot.h"
#include "../Blocks/BlockHandler.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_BED: return new cItemBedHandler(a_ItemType);
case E_ITEM_DYE: return new cItemDyeHandler(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_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_LEAVES: return new cItemLeavesHandler(a_ItemType);
case E_ITEM_REDSTONE_DUST: return new cItemRedstoneDustHandler(a_ItemType); case E_ITEM_REDSTONE_DUST: return new cItemRedstoneDustHandler(a_ItemType);
case E_ITEM_REDSTONE_REPEATER: return new cItemRedstoneRepeaterHandler(a_ItemType); case E_ITEM_REDSTONE_REPEATER: return new cItemRedstoneRepeaterHandler(a_ItemType);