mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 20:46:59 +01:00
118 lines
6.2 KiB
Diff
118 lines
6.2 KiB
Diff
--- a/net/minecraft/server/EntityFishingHook.java
|
|
+++ b/net/minecraft/server/EntityFishingHook.java
|
|
@@ -4,6 +4,11 @@
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import javax.annotation.Nullable;
|
|
+// CraftBukkit start
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.entity.FishHook;
|
|
+import org.bukkit.event.player.PlayerFishEvent;
|
|
+// CraftBukkit end
|
|
|
|
public class EntityFishingHook extends Entity {
|
|
|
|
@@ -207,6 +212,7 @@
|
|
}, RayTrace.BlockCollisionOption.COLLIDER, true);
|
|
|
|
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, movingobjectposition); // Craftbukkit - Call event
|
|
if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
|
|
this.hooked = ((MovingObjectPositionEntity) movingobjectposition).getEntity();
|
|
this.n();
|
|
@@ -239,6 +245,10 @@
|
|
if (this.ar <= 0) {
|
|
this.as = 0;
|
|
this.at = 0;
|
|
+ // CraftBukkit start
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
|
|
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
|
+ // CraftBukkit end
|
|
} else {
|
|
this.setMot(this.getMot().add(0.0D, -0.2D * (double) this.random.nextFloat() * (double) this.random.nextFloat(), 0.0D));
|
|
}
|
|
@@ -274,6 +284,13 @@
|
|
worldserver.a(Particles.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D);
|
|
}
|
|
} else {
|
|
+ // CraftBukkit start
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.BITE);
|
|
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
|
+ if (playerFishEvent.isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
Vec3D vec3d = this.getMot();
|
|
|
|
this.setMot(vec3d.x, (double) (-0.4F * MathHelper.a(this.random, 0.6F, 1.0F)), vec3d.z);
|
|
@@ -330,6 +347,14 @@
|
|
int i = 0;
|
|
|
|
if (this.hooked != null) {
|
|
+ // CraftBukkit start
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), this.hooked.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
|
|
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
|
+
|
|
+ if (playerFishEvent.isCancelled()) {
|
|
+ return 0;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
this.reel();
|
|
CriterionTriggers.D.a((EntityPlayer) this.owner, itemstack, this, Collections.emptyList());
|
|
this.world.broadcastEntityEffect(this, (byte) 31);
|
|
@@ -345,6 +370,15 @@
|
|
while (iterator.hasNext()) {
|
|
ItemStack itemstack1 = (ItemStack) iterator.next();
|
|
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack1);
|
|
+ // CraftBukkit start
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), entityitem.getBukkitEntity(), (FishHook) 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;
|
|
@@ -352,7 +386,11 @@
|
|
|
|
entityitem.setMot(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, 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
|
|
if (itemstack1.getItem().a(TagsItem.FISHES)) {
|
|
this.owner.a(StatisticList.FISH_CAUGHT, 1);
|
|
}
|
|
@@ -362,8 +400,25 @@
|
|
}
|
|
|
|
if (this.isInGround) {
|
|
+ // CraftBukkit start
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.owner.getBukkitEntity(), null, (FishHook) 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, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.REEL_IN);
|
|
+ this.world.getServer().getPluginManager().callEvent(playerFishEvent);
|
|
+ if (playerFishEvent.isCancelled()) {
|
|
+ return 0;
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
|
|
this.die();
|
|
return i;
|