summaryrefslogtreecommitdiffstats
path: root/source/Items/ItemSpawnEgg.h
blob: 974129d6f483f28b7b6dceeb6b58e2b0f7faf161 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184

#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"
#include "../Mobs/Villager.h"
#include "../Mobs/Ocelot.h"
#include "../Mobs/Mooshroom.h"
#include "../Mobs/Magmacube.h"
#include "../Mobs/Blaze.h"





class cItemSpawnEggHandler : public cItemHandler
{
public:
	cItemSpawnEggHandler(int a_ItemType) :
		cItemHandler(a_ItemType)
	{

	}


	virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
	{
		if (a_Dir < 0)
		{
			return false;
		}
		
		AddDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir);

		if (a_Dir == BLOCK_FACE_BOTTOM)
		{
			a_BlockY--;
		}

		cMonster * Monster = NULL;

		switch (a_Item->m_ItemDamage)
		{
			case E_META_SPAWN_EGG_BLAZE:
			{
				Monster = new cBlaze();
				break;
			}
			case E_META_SPAWN_EGG_CAVE_SPIDER:
			{
				Monster = new cCavespider();
				break;
			}
			case E_META_SPAWN_EGG_CHICKEN:
			{
				Monster = new cChicken();
				break;
			}
			case E_META_SPAWN_EGG_COW:
			{
				Monster = new cCow();
				break;
			}
			case E_META_SPAWN_EGG_CREEPER:
			{
				Monster = new cCreeper();
				break;
			}
			case E_META_SPAWN_EGG_ENDERMAN:
			{
				Monster = new cEnderman();
				break;
			}
			case E_META_SPAWN_EGG_GHAST:
			{
				Monster = new cGhast();
				break;
			}
			case E_META_SPAWN_EGG_MAGMA_CUBE:
			{
				Monster = new cMagmacube();
				break;
			}
			case E_META_SPAWN_EGG_MOOSHROOM:
			{
				Monster = new cMooshroom();
				break;
			}
			case E_META_SPAWN_EGG_OCELOT:
			{
				Monster = new cOcelot();
				break;
			}
			case E_META_SPAWN_EGG_PIG:
			{
				Monster = new cPig();
				break;
			}
			case E_META_SPAWN_EGG_SHEEP:
			{
				Monster = new cSheep();
				break;
			}
			case E_META_SPAWN_EGG_SILVERFISH:
			{
				Monster = new cSilverfish();
				break;
			}
			case E_META_SPAWN_EGG_SKELETON:
			{
				Monster = new cSkeleton();
				break;
			}
			case E_META_SPAWN_EGG_SLIME:
			{
				Monster = new cSlime();
				break;
			}
			case E_META_SPAWN_EGG_SPIDER:
			{
				Monster = new cSpider();
				break;
			}
			case E_META_SPAWN_EGG_SQUID:
			{
				Monster = new cSquid();
				break;
			}
			case E_META_SPAWN_EGG_VILLAGER:
			{
				Monster = new cVillager();
				break;
			}
			case E_META_SPAWN_EGG_WOLF:
			{
				Monster = new cWolf();
				break;
			}
			case E_META_SPAWN_EGG_ZOMBIE:
			{
				Monster = new cZombie();
				break;
			}
			case E_META_SPAWN_EGG_ZOMBIE_PIGMAN:
			{
				Monster = new cZombiepigman();
				break;
			}
			default:
			{
				return false;
			}
		}
		Monster->Initialize(a_World);
		Monster->TeleportTo(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5);
		a_World->BroadcastSpawn(*Monster);

		a_Player->UseEquippedItem();
		return true;
	}
} ;