2011-07-03 06:28:29 +02:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2013-03-25 05:22:32 +01:00
|
|
|
import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit
|
2011-07-03 06:28:29 +02:00
|
|
|
|
|
|
|
public class ItemFishingRod extends Item {
|
|
|
|
|
|
|
|
public ItemFishingRod(int i) {
|
|
|
|
super(i);
|
2012-01-14 21:03:48 +01:00
|
|
|
this.setMaxDurability(64);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.d(1);
|
|
|
|
this.a(CreativeModeTab.i);
|
2011-07-03 06:28:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
|
|
|
|
if (entityhuman.hookedFish != null) {
|
2012-10-25 05:53:23 +02:00
|
|
|
int i = entityhuman.hookedFish.c();
|
2011-07-03 06:28:29 +02:00
|
|
|
|
|
|
|
itemstack.damage(i, entityhuman);
|
2013-07-01 13:03:00 +02:00
|
|
|
entityhuman.aR();
|
2011-07-03 06:28:29 +02:00
|
|
|
} else {
|
|
|
|
// CraftBukkit start
|
2013-03-13 06:34:01 +01:00
|
|
|
EntityFishingHook hook = new EntityFishingHook(world, entityhuman);
|
2013-03-25 05:22:32 +01:00
|
|
|
PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.Fish) hook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
|
2011-07-03 06:28:29 +02:00
|
|
|
world.getServer().getPluginManager().callEvent(playerFishEvent);
|
|
|
|
|
|
|
|
if (playerFishEvent.isCancelled()) {
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2013-07-01 13:03:00 +02:00
|
|
|
world.makeSound(entityhuman, "random.bow", 0.5F, 0.4F / (f.nextFloat() * 0.4F + 0.8F));
|
2011-07-03 06:28:29 +02:00
|
|
|
if (!world.isStatic) {
|
2013-03-13 06:34:01 +01:00
|
|
|
world.addEntity(hook); // CraftBukkit - moved creation up
|
2011-07-03 06:28:29 +02:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
entityhuman.aR();
|
2011-07-03 06:28:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
}
|