Added basic spawn eggs (patch contributed by Luksor)
git-svn-id: http://mc-server.googlecode.com/svn/trunk@973 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
dc7f91c2a1
commit
84da8a2353
@ -1970,6 +1970,10 @@
|
||||
RelativePath="..\source\items\ItemSlab.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\Items\ItemSpawnEgg.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\source\items\ItemSugarcane.h"
|
||||
>
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "ItemFood.h"
|
||||
#include "ItemSign.h"
|
||||
#include "ItemBed.h"
|
||||
#include "ItemSpawnEgg.h"
|
||||
|
||||
#include "../Blocks/BlockHandler.h"
|
||||
|
||||
@ -66,15 +67,18 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemID)
|
||||
{
|
||||
default: return new cItemHandler(a_ItemID);
|
||||
|
||||
// Single item per handler:
|
||||
case E_ITEM_SHEARS: return new cItemShearsHandler(a_ItemID);
|
||||
case E_ITEM_LEAVES: return new cItemLeavesHandler(a_ItemID);
|
||||
case E_ITEM_SAPLING: return new cItemSaplingHandler(a_ItemID);
|
||||
// Single item per handler, alphabetically sorted:
|
||||
case E_ITEM_BED: return new cItemBedHandler(a_ItemID);
|
||||
case E_ITEM_DYE: return new cItemDyeHandler(a_ItemID);
|
||||
case E_ITEM_SUGARCANE: return new cItemSugarcaneHandler(a_ItemID);
|
||||
case E_ITEM_FLINT_AND_STEEL: return new cItemLighterHandler(a_ItemID);
|
||||
case E_ITEM_LEAVES: return new cItemLeavesHandler(a_ItemID);
|
||||
case E_ITEM_REDSTONE_DUST: return new cItemRedstoneDustHandler(a_ItemID);
|
||||
case E_ITEM_REDSTONE_REPEATER: return new cItemRedstoneRepeaterHandler(a_ItemID);
|
||||
case E_ITEM_SAPLING: return new cItemSaplingHandler(a_ItemID);
|
||||
case E_ITEM_SHEARS: return new cItemShearsHandler(a_ItemID);
|
||||
case E_ITEM_SIGN: return new cItemSignHandler(a_ItemID);
|
||||
case E_ITEM_SPAWN_EGG: return new cItemSpawnEggHandler(a_ItemID);
|
||||
case E_ITEM_SUGARCANE: return new cItemSugarcaneHandler(a_ItemID);
|
||||
case E_ITEM_WOOL: return new cItemClothHandler(a_ItemID);
|
||||
|
||||
case E_ITEM_WOODEN_HOE:
|
||||
@ -164,12 +168,6 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemID)
|
||||
{
|
||||
return new cItemFoodHandler(a_ItemID);
|
||||
}
|
||||
|
||||
case E_ITEM_SIGN:
|
||||
return new cItemSignHandler(a_ItemID);
|
||||
|
||||
case E_ITEM_BED:
|
||||
return new cItemBedHandler(a_ItemID);
|
||||
}
|
||||
}
|
||||
|
||||
|
69
source/Items/ItemSpawnEgg.h
Normal file
69
source/Items/ItemSpawnEgg.h
Normal file
@ -0,0 +1,69 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ItemHandler.h"
|
||||
#include "../World.h"
|
||||
#include "../Player.h"
|
||||
|
||||
// Mobs:
|
||||
#include "../Mobs/Chicken.h"
|
||||
#include "../Mobs/Spider.h"
|
||||
#include "../Mobs/Cow.h"
|
||||
#include "../Mobs/Squid.h"
|
||||
#include "../Mobs/Wolf.h"
|
||||
#include "../Mobs/Slime.h"
|
||||
#include "../Mobs/Skeleton.h"
|
||||
#include "../Mobs/Silverfish.h"
|
||||
#include "../Mobs/Pig.h"
|
||||
#include "../Mobs/Sheep.h"
|
||||
#include "../Mobs/Zombie.h"
|
||||
#include "../Mobs/Enderman.h"
|
||||
#include "../Mobs/Creeper.h"
|
||||
#include "../Mobs/Cavespider.h"
|
||||
#include "../Mobs/Ghast.h"
|
||||
#include "../Mobs/Zombiepigman.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class cItemSpawnEggHandler : public cItemHandler
|
||||
{
|
||||
public:
|
||||
cItemSpawnEggHandler(int a_ItemID) :
|
||||
cItemHandler(a_ItemID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_X, int a_Y, int a_Z, char a_Dir) override
|
||||
{
|
||||
if (a_Dir < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
AddDirection(a_X, a_Y, a_Z, a_Dir);
|
||||
|
||||
if (a_Dir == BLOCK_FACE_BOTTOM)
|
||||
{
|
||||
a_Y--;
|
||||
}
|
||||
|
||||
cMonster * Monster = NULL;
|
||||
|
||||
Monster = new cZombie();
|
||||
|
||||
Monster->Initialize(a_World);
|
||||
Monster->TeleportTo(a_X + 0.5, a_Y, a_Z + 0.5);
|
||||
a_World->BroadcastSpawn(*Monster);
|
||||
|
||||
a_Player->UseEquippedItem();
|
||||
return true;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user