3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00
Paper/nms-patches/EntityFishingHook.patch
Thinkofdeath 90ac03522a Revert "Remove patch headers"
This reverts commit d6e3dff7d8.
2014-11-28 23:02:15 +00:00

160 Zeilen
9.7 KiB
Diff

--- ../work/decompile-8eb82bde//net/minecraft/server/EntityFishingHook.java 2014-11-28 17:43:43.093707435 +0000
+++ src/main/java/net/minecraft/server/EntityFishingHook.java 2014-11-28 17:38:20.000000000 +0000
@@ -3,6 +3,12 @@
import java.util.Arrays;
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 {
private static final List d = Arrays.asList(new PossibleFishingResult[] { (new PossibleFishingResult(new ItemStack(Items.LEATHER_BOOTS), 10)).a(0.9F), new PossibleFishingResult(new ItemStack(Items.LEATHER), 10), new PossibleFishingResult(new ItemStack(Items.BONE), 10), new PossibleFishingResult(new ItemStack(Items.POTION), 10), new PossibleFishingResult(new ItemStack(Items.STRING), 5), (new PossibleFishingResult(new ItemStack(Items.FISHING_ROD), 2)).a(0.9F), new PossibleFishingResult(new ItemStack(Items.BOWL), 10), new PossibleFishingResult(new ItemStack(Items.STICK), 5), new PossibleFishingResult(new ItemStack(Items.DYE, 10, EnumColor.BLACK.getInvColorIndex()), 1), new PossibleFishingResult(new ItemStack(Blocks.TRIPWIRE_HOOK), 10), new PossibleFishingResult(new ItemStack(Items.ROTTEN_FLESH), 10)});
@@ -168,7 +174,7 @@
MovingObjectPosition movingobjectposition1 = axisalignedbb.a(vec3d, vec3d1);
if (movingobjectposition1 != null) {
- d6 = vec3d.f(movingobjectposition1.pos);
+ d6 = vec3d.distanceSquared(movingobjectposition1.pos); // CraftBukkit - distance efficiency
if (d6 < d5 || d5 == 0.0D) {
entity = entity1;
d5 = d6;
@@ -182,6 +188,7 @@
}
if (movingobjectposition != null) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event
if (movingobjectposition.entity != null) {
if (movingobjectposition.entity.damageEntity(DamageSource.projectile(this, this.owner), 0.0F)) {
this.hooked = movingobjectposition.entity;
@@ -261,8 +268,8 @@
} else {
float f3;
float f4;
- double d11;
float f5;
+ double d11;
double d12;
if (this.av > 0) {
@@ -277,20 +284,20 @@
} else {
this.aw = (float) ((double) this.aw + this.random.nextGaussian() * 4.0D);
f3 = this.aw * 0.017453292F;
- f5 = MathHelper.sin(f3);
- f4 = MathHelper.cos(f3);
- d8 = this.locX + (double) (f5 * (float) this.av * 0.1F);
- d12 = (double) ((float) MathHelper.floor(this.getBoundingBox().b) + 1.0F);
- d11 = this.locZ + (double) (f4 * (float) this.av * 0.1F);
+ f4 = MathHelper.sin(f3);
+ f5 = MathHelper.cos(f3);
+ d8 = this.locX + (double) (f4 * (float) this.av * 0.1F);
+ d11 = (double) ((float) MathHelper.floor(this.getBoundingBox().b) + 1.0F);
+ d12 = this.locZ + (double) (f5 * (float) this.av * 0.1F);
if (this.random.nextFloat() < 0.15F) {
- worldserver.a(EnumParticle.WATER_BUBBLE, d8, d12 - 0.10000000149011612D, d11, 1, (double) f5, 0.1D, (double) f4, 0.0D, new int[0]);
+ worldserver.a(EnumParticle.WATER_BUBBLE, d8, d11 - 0.10000000149011612D, d12, 1, (double) f4, 0.1D, (double) f5, 0.0D, new int[0]);
}
- float f6 = f5 * 0.04F;
- float f7 = f4 * 0.04F;
+ float f6 = f4 * 0.04F;
+ float f7 = f5 * 0.04F;
- worldserver.a(EnumParticle.WATER_WAKE, d8, d12, d11, 0, (double) f7, 0.01D, (double) (-f6), 1.0D, new int[0]);
- worldserver.a(EnumParticle.WATER_WAKE, d8, d12, d11, 0, (double) (-f7), 0.01D, (double) f6, 1.0D, new int[0]);
+ worldserver.a(EnumParticle.WATER_WAKE, d8, d11, d12, 0, (double) f7, 0.01D, (double) (-f6), 1.0D, new int[0]);
+ worldserver.a(EnumParticle.WATER_WAKE, d8, d11, d12, 0, (double) (-f7), 0.01D, (double) f6, 1.0D, new int[0]);
}
} else if (this.au > 0) {
this.au -= k;
@@ -304,12 +311,12 @@
}
if (this.random.nextFloat() < f3) {
- f5 = MathHelper.a(this.random, 0.0F, 360.0F) * 0.017453292F;
- f4 = MathHelper.a(this.random, 25.0F, 60.0F);
- d8 = this.locX + (double) (MathHelper.sin(f5) * f4 * 0.1F);
- d12 = (double) ((float) MathHelper.floor(this.getBoundingBox().b) + 1.0F);
- d11 = this.locZ + (double) (MathHelper.cos(f5) * f4 * 0.1F);
- worldserver.a(EnumParticle.WATER_SPLASH, d8, d12, d11, 2 + this.random.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D, new int[0]);
+ f4 = MathHelper.a(this.random, 0.0F, 360.0F) * 0.017453292F;
+ f5 = MathHelper.a(this.random, 25.0F, 60.0F);
+ d8 = this.locX + (double) (MathHelper.sin(f4) * f5 * 0.1F);
+ d11 = (double) ((float) MathHelper.floor(this.getBoundingBox().b) + 1.0F);
+ d12 = this.locZ + (double) (MathHelper.cos(f4) * f5 * 0.1F);
+ worldserver.a(EnumParticle.WATER_SPLASH, d8, d11, d12, 2 + this.random.nextInt(2), 0.10000000149011612D, 0.0D, 0.10000000149011612D, 0.0D, new int[0]);
}
if (this.au <= 0) {
@@ -374,6 +381,15 @@
byte b0 = 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
+
double d0 = this.owner.locX - this.locX;
double d1 = this.owner.locY - this.locY;
double d2 = this.owner.locZ - this.locZ;
@@ -386,6 +402,16 @@
b0 = 3;
} else if (this.at > 0) {
EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY, this.locZ, this.m());
+ // 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 d5 = this.owner.locX - this.locX;
double d6 = this.owner.locY - this.locY;
double d7 = this.owner.locZ - this.locZ;
@@ -396,13 +422,32 @@
entityitem.motY = d6 * d9 + (double) MathHelper.sqrt(d8) * 0.08D;
entityitem.motZ = d7 * d9;
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 - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop()
+ this.owner.world.addEntity(new EntityExperienceOrb(this.owner.world, this.owner.locX, this.owner.locY + 0.5D, this.owner.locZ + 0.5D, playerFishEvent.getExpToDrop()));
b0 = 1;
}
if (this.aq) {
+ // 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
b0 = 2;
}
+
+ // CraftBukkit start
+ if (b0 == 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();
this.owner.hookedFish = null;