mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-01 12:41:50 +01:00
117 lines
6.1 KiB
Diff
117 lines
6.1 KiB
Diff
--- a/net/minecraft/server/EntityFishingHook.java
|
|
+++ b/net/minecraft/server/EntityFishingHook.java
|
|
@@ -2,6 +2,11 @@
|
|
|
|
import java.util.Iterator;
|
|
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 {
|
|
|
|
@@ -261,6 +266,7 @@
|
|
}
|
|
|
|
if (movingobjectposition != null && movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.MISS) {
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event
|
|
if (movingobjectposition.type == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
|
|
this.hooked = movingobjectposition.entity;
|
|
this.s();
|
|
@@ -293,6 +299,10 @@
|
|
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();
|
|
}
|
|
@@ -328,6 +338,13 @@
|
|
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));
|
|
this.a(SoundEffects.H, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
|
|
double d3 = this.getBoundingBox().b + 0.5D;
|
|
@@ -384,6 +401,14 @@
|
|
int i = 0;
|
|
|
|
if (this.hooked != null) {
|
|
+ // 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
|
|
this.k();
|
|
this.world.broadcastEntityEffect(this, (byte) 31);
|
|
i = this.hooked instanceof EntityItem ? 3 : 5;
|
|
@@ -396,6 +421,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);
|
|
+
|
|
+ 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;
|
|
@@ -406,7 +440,11 @@
|
|
entityitem.motY = d1 * 0.1D + (double) MathHelper.sqrt(d3) * 0.08D;
|
|
entityitem.motZ = d2 * 0.1D;
|
|
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
|
|
Item item = itemstack.getItem();
|
|
|
|
if (item == Items.FISH || item == Items.COOKED_FISH) {
|
|
@@ -418,8 +456,25 @@
|
|
}
|
|
|
|
if (this.isInGround) {
|
|
+ // 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
|
|
i = 2;
|
|
}
|
|
+ // 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
|
|
|
|
this.die();
|
|
return i;
|