summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/curses/CurseHumbleBundle.java
blob: 3ad73f22d8539e3e8aa275d17690736c11b86070 (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
/**
 * 
 */
package darkknight.jewelrycraft.curses;

import java.util.ArrayList;

import darkknight.jewelrycraft.api.Curse;
import darkknight.jewelrycraft.config.ConfigHandler;
import darkknight.jewelrycraft.util.Variables;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.event.world.BlockEvent;

/**
 * @author Sorin
 *
 */
public class CurseHumbleBundle extends Curse {
	protected CurseHumbleBundle(String name, int txtID,
			String texturepack) {
		super(name, txtID, texturepack);
	}

	@Override
	public void entityDropItems(EntityPlayer player, Entity target,
			ArrayList<EntityItem> drops) {
		for (EntityItem item : drops) {
			ItemStack drop = item.getEntityItem().copy();
			target.entityDropItem(drop, 0.5F);
		}
	}

	@Override
	public void onBlockItemsDrop(EntityPlayer player,
			BlockEvent.HarvestDropsEvent event) {
		for (ItemStack item : event.drops) {
			ItemStack drop = item.copy();

			if (drop.getItem() != Item.getItemFromBlock(event.block))
				dropItem(event.world, event.x, event.y, event.z, drop);
		}
	}

	public void dropItem(World world, double x, double y, double z,
			ItemStack stack) {
		EntityItem entityitem =
				new EntityItem(world, x + 0.5D, y + 0.5D, z + 0.5D, stack);
		entityitem.motionX = 0;
		entityitem.motionZ = 0;
		entityitem.motionY = 0.11000000298023224D;
		world.spawnEntityInWorld(entityitem);
	}

	@Override
	public String getDescription() {
		return StatCollector.translateToLocal(
				"curse." + Variables.MODID + ".humblebundle.description");
	}

	@Override
	public String getDisplayName() {
		return StatCollector.translateToLocal(
				"curse." + Variables.MODID + ".humblebundle");
	}

	@Override
	public boolean canCurseBeActivated() {
		return ConfigHandler.CURSE_HUMBLE_BUNDLE;
	}
}