summaryrefslogtreecommitdiffstats
path: root/source/Items/ItemSpawnEgg.h
blob: 76b74232834348fd6d70e5e93efe27a67e411636 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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;
	}
} ;