summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/api/Curse.java
blob: 7f22b3eff143b8693ffecfb1d09d1162449be5cf (plain)
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
package darkknight.jewelrycraft.api;

import java.util.ArrayList;
import java.util.Random;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderHandEvent;
import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingHealEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
import net.minecraftforge.event.world.BlockEvent;

public abstract class Curse {
	protected int textureID, ticksActive;
	protected String name, description, texturePackName;

	protected Random rand = new Random();

	private static ArrayList<Curse> curses = new ArrayList<>();
	public static ArrayList<Curse> availableCurses = new ArrayList<>();

	/**
	 * @param name
	 *            The name of the curse
	 * @param txtID
	 *            The texture ID of it
	 * @param texturepack
	 *            The texturepack location
	 */
	protected Curse(String name, int txtID, String texturepack) {
		this.name = name;
		this.texturePackName = texturepack;
		this.textureID = txtID;
		this.ticksActive = 0;
		curses.add(this);
		availableCurses.add(this);
	}

	/**
	 * @return The name of the curse
	 */
	public String getName() {
		return name;
	}

	public abstract String getDisplayName();

	/**
	 * @return The description of the curse
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * @param desc
	 *            description of the curse
	 * @return The class
	 */
	public Curse setDescription(String desc) {
		description = desc;
		return this;
	}

	/**
	 * @return the texture pack ID
	 */
	public String getTexturePack() {
		return texturePackName;
	}

	/**
	 * @return The texture ID
	 */
	public int getTextureID() {
		return textureID;
	}

	/**
	 * This runs every tick
	 * 
	 * @param world
	 *            The worldthe player is in
	 * @param player
	 *            The cursed player
	 */
	public void action(World world, EntityPlayer player) {
		ticksActive++;
	}

	public int getTicksActive() {
		return ticksActive;
	}

	public void setTicksActive(int ticksActive) {
		this.ticksActive = ticksActive;
	}

	/**
	 * This runs when the player dies
	 * 
	 * @param world
	 *            The world the player is in
	 * @param player
	 *            The cursed player
	 * @param event
	 *            The thing that killed the player
	 */
	public void playerDeathAction(World world, EntityPlayer player, LivingDeathEvent event) {
		// Do nothing
	}

	/**
	 * This runs when the player is healed
	 * 
	 * @param world
	 *            The world the player is in
	 * @param player
	 *            The cursed player
	 * @param event
	 *            The event that the player is healing from
	 */
	public void playerHealAction(World world, EntityPlayer player, LivingHealEvent event) {
		// Do nothing
	}

	/**
	 * This runs when an entity is killed (whether by a player or other causes)
	 * 
	 * @param world
	 *            The world the player is in
	 * @param target
	 *            The entity that died
	 * @param player
	 *            The cursed player
	 */
	public void entityDeathAction(World world, EntityLivingBase target, EntityPlayer player) {
		// Do nothing
	}

	/**
	 * This runs when the player respawns
	 * 
	 * @param world
	 *            The world the player is in
	 * @param player
	 *            The cursed player
	 */
	public void respawnAction(World world, EntityPlayer player) {
		// Do nothing
	}

	/**
	 * This runs when a player gets attacked by anything but another player
	 * 
	 * @param world
	 *            The world the player is in
	 * @param player
	 *            The cursed player
	 * @param event
	 *            The event that attacked the player
	 * @param attacker
	 *            The entity that attacked the player
	 */
	public void attackedAction(World world, EntityPlayer player, LivingAttackEvent event, Entity attacker) {
		// Do nothing
	}

	/**
	 * This runs when an entity is attacked by a player (this includes other
	 * players)
	 * 
	 * @param event
	 * 
	 * @param world
	 *            The world the player is in
	 * @param player
	 *            The player that caused the damage
	 * @param target
	 *            The entity damaged
	 */
	public void attackedByPlayerAction(LivingAttackEvent event, World world, EntityPlayer player, Entity target) {
		// Do nothing
	}

	/**
	 * This runs when an entity is attacked by a player (this includes other
	 * players). This can cancel the damaging event.
	 * 
	 * @param event
	 * 
	 * @param world
	 *            The world the player is in
	 * @param player
	 *            The player that caused the damage
	 * @param target
	 *            The entity damaged
	 * @return Whether or not to cancel the event
	 */
	public boolean attackedByPlayerActionCancelable(LivingAttackEvent event, World world, EntityPlayer player,
			Entity target) {
		return false;
	}

	/**
	 * This runs when an item is dropped by an entity
	 * 
	 * @param player
	 *            The cursed player
	 * @param target
	 *            The entity that drops the item
	 * @param drops
	 *            An array list containing the dropped items
	 */
	public void entityDropItems(EntityPlayer player, Entity target, ArrayList<EntityItem> drops) {
		// Do nothing
	}

	/**
	 * This is for rendering special things on the player in 3rd person (meaning you
	 * won't see this render); This will also render in the inventory.
	 * 
	 * @param player
	 *            The cursed player
	 * @param event
	 *            The event used for this
	 */
	@SideOnly(Side.CLIENT)
	public void playerRender(EntityPlayer player, RenderPlayerEvent.Specials.Post event) {
		// Do nothing
	}

	/**
	 * This is for rendering special things on the player in 1st and 3rd person, but
	 * not in the player inventory.
	 * 
	 * @param player
	 *            The cursed player
	 * @param event
	 *            The event used for this
	 */
	@SideOnly(Side.CLIENT)
	public void playerHandRender(EntityPlayer player, RenderHandEvent event) {
		// Do nothing
	}

	/**
	 * This runs when a block drops an item (such as breaking a block and dropping
	 * itself, or breaking like a Diamond ore and dropping diamonds)
	 * 
	 * @param player
	 *            The cursed player
	 * @param event
	 *            The BlockEvent that triggers this
	 */
	public void onBlockItemsDrop(EntityPlayer player, BlockEvent.HarvestDropsEvent event) {
		// Do nothing
	}

	/**
	 * This runs when a block is destroyed
	 * 
	 * @param player
	 *            The cursed player
	 * @param event
	 *            The BlockEvent that runs this
	 */
	public void onBlockDestroyed(EntityPlayer player, BlockEvent.BreakEvent event) {
		// Do nothing
	}

	/**
	 * This determines if the player can toss an item or not (with Q)
	 * 
	 * @return True if the player can no longer toss items; False if he can. (by
	 *         default false)
	 */
	public boolean itemToss() {
		return false;
	}

	/**
	 * This controls whether a curse can be activated or not (makes it easy to do
	 * things like disable certain curses if in hardcore)
	 * 
	 * @param world
	 *            The world the player is in
	 * @return True for curses to be used; False otherwise (by default true)
	 */
	public boolean canCurseBeActivated(World world) {
		return canCurseBeActivated();
	}

	/**
	 * This controls whether a curse can be activated or not (makes it easy to do
	 * things like disable certain curses if in hardcore)
	 * 
	 * @return True for curses to be used; False otherwise (by default true)
	 */
	public boolean canCurseBeActivated() {
		return true;
	}

	/**
	 * This is the list of all curses
	 * 
	 * @return The list of registered curses
	 */
	public static ArrayList<Curse> getCurseList() {
		return curses;
	}

	/**
	 * This is the weight of the curse when it chooses it. The lower the value, the
	 * less it gets chosen; the higher the value, the higher the chance of it
	 * getting picked.
	 * 
	 * @param world
	 *            The world the player is currently in
	 * @param player
	 *            The cursed player
	 * @param random
	 *            A random class
	 * @return The weight of the curse (by default 10)
	 */
	public int weight(World world, EntityPlayer player, Random random) {
		return 10;
	}

	/*
	 * This stat is used to determine the chance of certain actions happening
	 */
	public int luck() {
		return 0;
	}

	/**
	 * This event is called whenever the player attempts to sleep.
	 * 
	 * @param worldObj
	 *            the world
	 * @param player
	 *            the cursed player
	 * @param event
	 *            the sleeping event
	 */
	public void playerSleepAction(World worldObj, EntityPlayer player, PlayerSleepInBedEvent event) {

	}

	public void onEntityHurt(World worldObj, EntityPlayer player, LivingHurtEvent event) {
		// TODO Auto-generated method stub
		
	}

	public void onPlayerHurt(World worldObj, EntityPlayer player, LivingHurtEvent event) {
		// TODO Auto-generated method stub
		
	}
}