2011-12-28 21:36:02 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
public class ItemBow extends Item {
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public static final String[] a = new String[] { "bow_pull_0", "bow_pull_1", "bow_pull_2"};
|
|
|
|
|
2011-12-28 21:36:02 +01:00
|
|
|
public ItemBow(int i) {
|
|
|
|
super(i);
|
|
|
|
this.maxStackSize = 1;
|
|
|
|
this.setMaxDurability(384);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(CreativeModeTab.j);
|
2011-12-28 21:36:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(ItemStack itemstack, World world, EntityHuman entityhuman, int i) {
|
|
|
|
boolean flag = entityhuman.abilities.canInstantlyBuild || EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_INFINITE.id, itemstack) > 0;
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (flag || entityhuman.inventory.e(Item.ARROW.id)) {
|
2012-12-20 05:03:52 +01:00
|
|
|
int j = this.c_(itemstack) - i;
|
2011-12-28 21:36:02 +01:00
|
|
|
float f = (float) j / 20.0F;
|
|
|
|
|
|
|
|
f = (f * f + f * 2.0F) / 3.0F;
|
|
|
|
if ((double) f < 0.1D) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (f > 1.0F) {
|
|
|
|
f = 1.0F;
|
|
|
|
}
|
|
|
|
|
|
|
|
EntityArrow entityarrow = new EntityArrow(world, entityhuman, f * 2.0F);
|
|
|
|
|
|
|
|
if (f == 1.0F) {
|
2013-03-13 23:33:27 +01:00
|
|
|
entityarrow.a(true);
|
2011-12-28 21:36:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int k = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_DAMAGE.id, itemstack);
|
|
|
|
|
|
|
|
if (k > 0) {
|
2012-10-25 05:53:23 +02:00
|
|
|
entityarrow.b(entityarrow.c() + (double) k * 0.5D + 0.5D);
|
2011-12-28 21:36:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int l = EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK.id, itemstack);
|
|
|
|
|
|
|
|
if (l > 0) {
|
2012-07-29 09:33:13 +02:00
|
|
|
entityarrow.a(l);
|
2011-12-28 21:36:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (EnchantmentManager.getEnchantmentLevel(Enchantment.ARROW_FIRE.id, itemstack) > 0) {
|
|
|
|
entityarrow.setOnFire(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
// CraftBukkit start
|
2012-07-22 08:18:00 +02:00
|
|
|
org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(entityhuman, itemstack, entityarrow, f);
|
2011-12-28 21:36:02 +01:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
event.getProjectile().remove();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (event.getProjectile() == entityarrow.getBukkitEntity()) {
|
|
|
|
world.addEntity(entityarrow);
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
itemstack.damage(1, entityhuman);
|
2013-03-13 23:33:27 +01:00
|
|
|
world.makeSound(entityhuman, "random.bow", 1.0F, 1.0F / (e.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
|
2012-07-29 09:33:13 +02:00
|
|
|
if (flag) {
|
|
|
|
entityarrow.fromPlayer = 2;
|
2011-12-28 21:36:02 +01:00
|
|
|
} else {
|
2012-07-29 09:33:13 +02:00
|
|
|
entityhuman.inventory.d(Item.ARROW.id);
|
2011-12-28 21:36:02 +01:00
|
|
|
}
|
2012-07-29 09:33:13 +02:00
|
|
|
// CraftBukkit - moved addEntity up
|
2011-12-28 21:36:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack b(ItemStack itemstack, World world, EntityHuman entityhuman) {
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
|
2012-12-20 05:03:52 +01:00
|
|
|
public int c_(ItemStack itemstack) {
|
2011-12-28 21:36:02 +01:00
|
|
|
return 72000;
|
|
|
|
}
|
|
|
|
|
2012-12-20 05:03:52 +01:00
|
|
|
public EnumAnimation b_(ItemStack itemstack) {
|
2013-03-13 23:33:27 +01:00
|
|
|
return EnumAnimation.BOW;
|
2011-12-28 21:36:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
|
2012-07-29 09:33:13 +02:00
|
|
|
if (entityhuman.abilities.canInstantlyBuild || entityhuman.inventory.e(Item.ARROW.id)) {
|
2012-12-20 05:03:52 +01:00
|
|
|
entityhuman.a(itemstack, this.c_(itemstack));
|
2011-12-28 21:36:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
|
2012-10-28 07:28:53 +01:00
|
|
|
public int c() {
|
2011-12-28 21:36:02 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|