2011-09-22 00:54:31 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
public class ItemFood extends Item {
|
|
|
|
|
|
|
|
public final int a;
|
2011-11-20 09:01:14 +01:00
|
|
|
private final int b;
|
2012-07-29 09:33:13 +02:00
|
|
|
private final float c;
|
|
|
|
private final boolean bY;
|
|
|
|
private boolean bZ;
|
|
|
|
private int ca;
|
|
|
|
private int cb;
|
|
|
|
private int cc;
|
|
|
|
private float cd;
|
2011-09-22 00:54:31 +02:00
|
|
|
|
|
|
|
public ItemFood(int i, int j, float f, boolean flag) {
|
|
|
|
super(i);
|
|
|
|
this.a = 32;
|
2011-11-20 09:01:14 +01:00
|
|
|
this.b = j;
|
2012-07-29 09:33:13 +02:00
|
|
|
this.bY = flag;
|
|
|
|
this.c = f;
|
|
|
|
this.a(CreativeModeTab.h);
|
2011-09-22 00:54:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ItemFood(int i, int j, boolean flag) {
|
|
|
|
this(i, j, 0.6F, flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack b(ItemStack itemstack, World world, EntityHuman entityhuman) {
|
|
|
|
--itemstack.count;
|
|
|
|
// CraftBukkit start
|
2011-09-26 20:17:32 +02:00
|
|
|
int oldFoodLevel = entityhuman.getFoodData().foodLevel;
|
|
|
|
|
2012-05-18 04:17:23 +02:00
|
|
|
org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, this.getNutrition() + oldFoodLevel);
|
2011-09-22 00:54:31 +02:00
|
|
|
|
|
|
|
if (!event.isCancelled()) {
|
2012-01-14 21:03:48 +01:00
|
|
|
entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, this.getSaturationModifier());
|
2011-09-22 00:54:31 +02:00
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2012-05-18 04:17:23 +02:00
|
|
|
world.makeSound(entityhuman, "random.burp", 0.5F, world.random.nextFloat() * 0.1F + 0.9F);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.c(itemstack, world, entityhuman);
|
2011-09-22 00:54:31 +02:00
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
protected void c(ItemStack itemstack, World world, EntityHuman entityhuman) {
|
|
|
|
if (!world.isStatic && this.ca > 0 && world.random.nextFloat() < this.cd) {
|
|
|
|
entityhuman.addEffect(new MobEffect(this.ca, this.cb * 20, this.cc));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public int a(ItemStack itemstack) {
|
2011-09-22 00:54:31 +02:00
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public EnumAnimation b(ItemStack itemstack) {
|
2011-09-22 00:54:31 +02:00
|
|
|
return EnumAnimation.b;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (entityhuman.e(this.bZ)) {
|
|
|
|
entityhuman.a(itemstack, this.a(itemstack));
|
2011-09-22 00:54:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public int getNutrition() {
|
2011-11-20 09:01:14 +01:00
|
|
|
return this.b;
|
2011-09-22 00:54:31 +02:00
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
public float getSaturationModifier() {
|
2012-07-29 09:33:13 +02:00
|
|
|
return this.c;
|
2011-09-22 00:54:31 +02:00
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean h() {
|
|
|
|
return this.bY;
|
2011-09-22 00:54:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ItemFood a(int i, int j, int k, float f) {
|
2012-07-29 09:33:13 +02:00
|
|
|
this.ca = i;
|
|
|
|
this.cb = j;
|
|
|
|
this.cc = k;
|
|
|
|
this.cd = f;
|
2011-09-22 00:54:31 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public ItemFood i() {
|
|
|
|
this.bZ = true;
|
2011-09-22 00:54:31 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|