summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft
diff options
context:
space:
mode:
authorEvilSeph <evilseph@unaligned.org>2011-07-03 00:28:29 -0400
committerEvilSeph <evilseph@unaligned.org>2011-07-03 03:01:38 -0400
commit3789f61c7e0be89d01ab96b83bc1a784278e6169 (patch)
tree1f6ba257e8166aa76f51bc5996a58c2cd64a221e /src/main/java/net/minecraft
parentaacb95e27564a1495bcdf13342c32dbc4069dccc (diff)
downloadcraftbukkit-3789f61c7e0be89d01ab96b83bc1a784278e6169.tar
craftbukkit-3789f61c7e0be89d01ab96b83bc1a784278e6169.tar.gz
craftbukkit-3789f61c7e0be89d01ab96b83bc1a784278e6169.tar.lz
craftbukkit-3789f61c7e0be89d01ab96b83bc1a784278e6169.tar.xz
craftbukkit-3789f61c7e0be89d01ab96b83bc1a784278e6169.zip
Added PlayerFish event.
Diffstat (limited to 'src/main/java/net/minecraft')
-rw-r--r--src/main/java/net/minecraft/server/EntityFish.java37
-rw-r--r--src/main/java/net/minecraft/server/ItemFishingRod.java38
2 files changed, 75 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/EntityFish.java b/src/main/java/net/minecraft/server/EntityFish.java
index 74bcf35e..ed704a9c 100644
--- a/src/main/java/net/minecraft/server/EntityFish.java
+++ b/src/main/java/net/minecraft/server/EntityFish.java
@@ -6,6 +6,7 @@ import java.util.List;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
import org.bukkit.event.entity.EntityDamageEvent;
+import org.bukkit.event.player.PlayerFishEvent;
// CraftBukkit end
public class EntityFish extends Entity {
@@ -336,6 +337,16 @@ public class EntityFish extends Entity {
byte b0 = 0;
if (this.c != null) {
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) this.owner.getBukkitEntity(), this.c.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
+ this.die();
+ this.owner.hookedFish = null;
+ return 0;
+ }
+ // CraftBukkit end
double d0 = this.owner.locX - this.locX;
double d1 = this.owner.locY - this.locY;
double d2 = this.owner.locZ - this.locZ;
@@ -348,6 +359,16 @@ public class EntityFish extends Entity {
b0 = 3;
} else if (this.k > 0) {
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, new ItemStack(Item.RAW_FISH));
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
+ this.die();
+ this.owner.hookedFish = null;
+ return 0;
+ }
+ // CraftBukkit end
double d5 = this.owner.locX - this.locX;
double d6 = this.owner.locY - this.locY;
double d7 = this.owner.locZ - this.locZ;
@@ -363,9 +384,25 @@ public class EntityFish extends Entity {
}
if (this.h) {
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) this.owner.getBukkitEntity(), null, PlayerFishEvent.State.IN_GROUND);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
+ this.die();
+ this.owner.hookedFish = null;
+ return 0;
+ }
+ // CraftBukkit end
b0 = 2;
}
+ // CraftBukkit start
+ if (b0 == 0) {
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) this.owner.getBukkitEntity(), null, PlayerFishEvent.State.FAILED_ATTEMPT);
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
+ }
+ // CraftBukkit end
this.die();
this.owner.hookedFish = null;
return b0;
diff --git a/src/main/java/net/minecraft/server/ItemFishingRod.java b/src/main/java/net/minecraft/server/ItemFishingRod.java
new file mode 100644
index 00000000..9bcf2e2f
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ItemFishingRod.java
@@ -0,0 +1,38 @@
+package net.minecraft.server;
+
+import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit
+
+public class ItemFishingRod extends Item {
+
+ public ItemFishingRod(int i) {
+ super(i);
+ this.d(64);
+ this.c(1);
+ }
+
+ public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
+ if (entityhuman.hookedFish != null) {
+ int i = entityhuman.hookedFish.h();
+
+ itemstack.damage(i, entityhuman);
+ entityhuman.w();
+ } else {
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null,PlayerFishEvent.State.FISHING);
+ world.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
+ return itemstack;
+ }
+ // CraftBukkit end
+ world.makeSound(entityhuman, "random.bow", 0.5F, 0.4F / (b.nextFloat() * 0.4F + 0.8F));
+ if (!world.isStatic) {
+ world.addEntity(new EntityFish(world, entityhuman));
+ }
+
+ entityhuman.w();
+ }
+
+ return itemstack;
+ }
+}