-
Notifications
You must be signed in to change notification settings - Fork 14
/
HammerReward.java
64 lines (51 loc) · 1.57 KB
/
HammerReward.java
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
package exnihiloomnia.registries.hammering;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class HammerReward
{
private int base_chance;
private int fortune_modifier; //the effectiveness of Fortune enchantments.
private ItemStack item;
public HammerReward(ItemStack item, int base_chance, int fortune_modifier)
{
this.item = item;
this.base_chance = base_chance;
this.fortune_modifier = fortune_modifier;
}
public void dropReward(EntityPlayer player, BlockPos pos)
{
World world = player.worldObj;
int luck_level = getFortuneModifier();
int chance = base_chance + (fortune_modifier * luck_level);
if (world.rand.nextInt(100) < chance)
{
EntityItem entityitem = new EntityItem(world, pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f, item.copy());
entityitem.motionX = world.rand.nextGaussian() * 0.05F;
entityitem.motionY = (0.2d);
entityitem.motionZ = world.rand.nextGaussian() * 0.05F;
entityitem.setDefaultPickupDelay();
world.spawnEntityInWorld(entityitem);
}
}
public int getBaseChance() {
return base_chance;
}
public void setBaseChance(int base_chance) {
this.base_chance = base_chance;
}
public int getFortuneModifier() {
return fortune_modifier;
}
public void setFortuneModifier(int luck_modifier) {
this.fortune_modifier = luck_modifier;
}
public ItemStack getItem() {
return item;
}
public void setItem(ItemStack item) {
this.item = item;
}
}