2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/EntityFishingHook.java
|
|
|
|
+++ b/net/minecraft/server/EntityFishingHook.java
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -2,6 +2,11 @@
|
|
|
|
|
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
|
2016-11-17 02:41:03 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
public class EntityFishingHook extends Entity {
|
|
|
|
|
2016-12-20 21:00:00 +01:00
|
|
|
@@ -261,6 +266,7 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-11-23 12:50:37 +01:00
|
|
|
if (movingobjectposition != null && movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.MISS) {
|
2016-11-28 02:47:01 +01:00
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event
|
2016-11-23 12:50:37 +01:00
|
|
|
if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
|
|
|
|
this.hooked = movingobjectposition.entity;
|
|
|
|
this.s();
|
2016-12-20 21:00:00 +01:00
|
|
|
@@ -293,6 +299,10 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
if (this.g <= 0) {
|
|
|
|
this.h = 0;
|
|
|
|
this.at = 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 {
|
|
|
|
this.motY -= 0.2D * (double) this.random.nextFloat() * (double) this.random.nextFloat();
|
|
|
|
}
|
2016-12-20 21:00:00 +01:00
|
|
|
@@ -328,6 +338,13 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
worldserver.a(EnumParticle.WATER_WAKE, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D, new int[0]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
+ // 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 = (double) (-0.4F * MathHelper.a(this.random, 0.6F, 1.0F));
|
2017-05-14 04:00:00 +02:00
|
|
|
this.a(SoundEffects.K, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
|
2016-11-17 02:41:03 +01:00
|
|
|
double d3 = this.getBoundingBox().b + 0.5D;
|
2016-12-20 21:00:00 +01:00
|
|
|
@@ -384,6 +401,14 @@
|
2016-03-15 14:26:45 +01:00
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if (this.hooked != null) {
|
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-03-15 14:26:45 +01:00
|
|
|
this.k();
|
|
|
|
this.world.broadcastEntityEffect(this, (byte) 31);
|
|
|
|
i = this.hooked instanceof EntityItem ? 3 : 5;
|
2016-12-20 21:00:00 +01:00
|
|
|
@@ -396,6 +421,15 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
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;
|
2016-12-20 21:00:00 +01:00
|
|
|
@@ -406,7 +440,11 @@
|
2016-06-09 03:43:49 +02:00
|
|
|
entityitem.motY = d1 * 0.1D + (double) MathHelper.sqrt(d3) * 0.08D;
|
|
|
|
entityitem.motZ = d2 * 0.1D;
|
2016-02-29 22:32:46 +01:00
|
|
|
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()));
|
|
|
|
+ }
|
2016-11-17 02:41:03 +01:00
|
|
|
+ // CraftBukkit end
|
2016-12-20 21:00:00 +01:00
|
|
|
Item item = itemstack.getItem();
|
2016-02-29 22:32:46 +01:00
|
|
|
|
2016-12-20 21:00:00 +01:00
|
|
|
if (item == Items.FISH || item == Items.COOKED_FISH) {
|
|
|
|
@@ -418,8 +456,25 @@
|
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
|
|
|
}
|
2016-03-05 05:46:56 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (i == 0) {
|
|
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
|
|
|
|
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
|
|
|
+ if (playerFishEvent.isCancelled()) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2016-03-05 05:46:56 +01:00
|
|
|
this.die();
|
2016-11-17 02:41:03 +01:00
|
|
|
return i;
|