2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityFishingHook.java
|
|
|
|
+++ b/net/minecraft/server/EntityFishingHook.java
|
2014-11-25 22:32:16 +01:00
|
|
|
@@ -3,6 +3,12 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
import java.util.Iterator;
|
2014-11-25 22:32:16 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+import org.bukkit.entity.Fish;
|
|
|
|
+import org.bukkit.event.player.PlayerFishEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class EntityFishingHook extends Entity {
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
private static final DataWatcherObject<Integer> c = DataWatcher.a(EntityFishingHook.class, DataWatcherRegistry.b);
|
|
|
|
@@ -193,6 +199,7 @@
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (movingobjectposition != null) {
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event
|
|
|
|
if (movingobjectposition.entity != null) {
|
2014-11-25 22:32:16 +01:00
|
|
|
this.hooked = movingobjectposition.entity;
|
2016-02-29 22:32:46 +01:00
|
|
|
this.getDataWatcher().set(EntityFishingHook.c, Integer.valueOf(this.hooked.getId() + 1));
|
|
|
|
@@ -266,6 +273,10 @@
|
|
|
|
if (this.au <= 0) {
|
|
|
|
this.av = 0;
|
|
|
|
this.aw = 0;
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
double d10;
|
|
|
|
@@ -278,6 +289,13 @@
|
|
|
|
if (this.aw > 0) {
|
|
|
|
this.aw -= l;
|
|
|
|
if (this.aw <= 0) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.BITE);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
|
|
|
+ if (playerFishEvent.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
this.motY -= 0.20000000298023224D;
|
|
|
|
this.a(SoundEffects.G, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
|
|
|
|
f2 = (float) MathHelper.floor(this.getBoundingBox().b);
|
|
|
|
@@ -391,6 +409,14 @@
|
|
|
|
this.k();
|
|
|
|
this.world.broadcastEntityEffect(this, (byte) 31);
|
|
|
|
i = this.hooked instanceof EntityItem ? 3 : 5;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), this.hooked.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
|
|
|
+
|
|
|
|
+ if (playerFishEvent.isCancelled()) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
} else if (this.au > 0) {
|
|
|
|
LootTableInfo.a loottableinfo_a = new LootTableInfo.a((WorldServer) this.world);
|
|
|
|
|
|
|
|
@@ -400,6 +426,15 @@
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
ItemStack itemstack = (ItemStack) iterator.next();
|
|
|
|
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
|
|
|
|
+ playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (playerFishEvent.isCancelled()) {
|
|
|
|
+ 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;
|
|
|
|
@@ -410,13 +445,25 @@
|
|
|
|
entityitem.motY = d1 * d4 + (double) MathHelper.sqrt(d3) * 0.08D;
|
|
|
|
entityitem.motZ = d2 * d4;
|
|
|
|
this.world.addEntity(entityitem);
|
|
|
|
- this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, this.random.nextInt(6) + 1));
|
|
|
|
+ // CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop()
|
|
|
|
+ if (playerFishEvent.getExpToDrop() > 0) {
|
|
|
|
+ this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, playerFishEvent.getExpToDrop()));
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
i = 1;
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (this.isInGround) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
|
|
|
+
|
|
|
|
+ if (playerFishEvent.isCancelled()) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-02-29 22:32:46 +01:00
|
|
|
i = 2;
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|