2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/projectile/EntityFishingHook.java
|
|
|
|
+++ b/net/minecraft/world/entity/projectile/EntityFishingHook.java
|
|
|
|
@@ -45,6 +45,12 @@
|
|
|
|
import net.minecraft.world.phys.MovingObjectPositionEntity;
|
|
|
|
import net.minecraft.world.phys.Vec3D;
|
2021-03-08 22:47:33 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.entity.Player;
|
2018-07-15 02:00:00 +02:00
|
|
|
+import org.bukkit.entity.FishHook;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.player.PlayerFishEvent;
|
|
|
|
+// CraftBukkit end
|
2021-03-08 22:47:33 +01:00
|
|
|
+
|
2020-06-25 02:00:00 +02:00
|
|
|
public class EntityFishingHook extends IProjectile {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
private final Random syncronizedRandom;
|
|
|
|
@@ -65,6 +71,12 @@
|
|
|
|
private final int luck;
|
|
|
|
private final int lureSpeed;
|
2020-11-06 08:49:15 +01:00
|
|
|
|
|
|
|
+ // CraftBukkit start - Extra variables to enable modification of fishing wait time, values are minecraft defaults
|
|
|
|
+ public int minWaitTime = 100;
|
|
|
|
+ public int maxWaitTime = 600;
|
|
|
|
+ public boolean applyLure = true;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
+
|
2021-06-11 07:00:00 +02:00
|
|
|
private EntityFishingHook(EntityTypes<? extends EntityFishingHook> entitytypes, World world, int i, int j) {
|
|
|
|
super(entitytypes, world);
|
|
|
|
this.syncronizedRandom = new Random();
|
|
|
|
@@ -259,7 +271,7 @@
|
|
|
|
private void l() {
|
2021-05-09 08:51:44 +02:00
|
|
|
MovingObjectPosition movingobjectposition = ProjectileHelper.a((Entity) this, this::a);
|
|
|
|
|
|
|
|
- this.a(movingobjectposition);
|
|
|
|
+ this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -306,6 +318,10 @@
|
|
|
|
this.timeUntilLured = 0;
|
|
|
|
this.timeUntilHooked = 0;
|
|
|
|
this.getDataWatcher().set(EntityFishingHook.DATA_BITING, false);
|
2016-11-17 02:41:03 +01:00
|
|
|
+ // CraftBukkit start
|
2020-06-25 02:00:00 +02:00
|
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.level.getServer().getPluginManager().callEvent(playerFishEvent);
|
2016-11-17 02:41:03 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
} else {
|
|
|
|
float f;
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -339,6 +355,13 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
worldserver.a(Particles.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D);
|
2016-11-17 02:41:03 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
+ // CraftBukkit start
|
2020-06-25 02:00:00 +02:00
|
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.BITE);
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.level.getServer().getPluginManager().callEvent(playerFishEvent);
|
2016-11-17 02:41:03 +01:00
|
|
|
+ if (playerFishEvent.isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-06-11 07:00:00 +02:00
|
|
|
this.playSound(SoundEffects.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
|
2020-06-25 02:00:00 +02:00
|
|
|
double d3 = this.locY() + 0.5D;
|
2019-04-23 04:00:00 +02:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -375,8 +398,10 @@
|
|
|
|
this.timeUntilHooked = MathHelper.nextInt(this.random, 20, 80);
|
2020-11-06 08:49:15 +01:00
|
|
|
}
|
|
|
|
} else {
|
2021-06-11 07:00:00 +02:00
|
|
|
- this.timeUntilLured = MathHelper.nextInt(this.random, 100, 600);
|
|
|
|
- this.timeUntilLured -= this.lureSpeed * 20 * 5;
|
2020-11-06 08:49:15 +01:00
|
|
|
+ // CraftBukkit start - logic to modify fishing wait time
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.timeUntilLured = MathHelper.nextInt(this.random, this.minWaitTime, this.maxWaitTime);
|
|
|
|
+ this.timeUntilLured -= (this.applyLure) ? this.lureSpeed * 20 * 5 : 0;
|
2020-11-06 08:49:15 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -443,6 +468,14 @@
|
2016-03-15 14:26:45 +01:00
|
|
|
int i = 0;
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
if (this.hookedIn != null) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2021-06-11 07:00:00 +02:00
|
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), this.hookedIn.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
|
|
|
|
+ this.level.getServer().getPluginManager().callEvent(playerFishEvent);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ if (playerFishEvent.isCancelled()) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-06-11 07:00:00 +02:00
|
|
|
this.reel(this.hookedIn);
|
|
|
|
CriterionTriggers.FISHING_ROD_HOOKED.a((EntityPlayer) entityhuman, itemstack, this, (Collection) Collections.emptyList());
|
|
|
|
this.level.broadcastEntityEffect(this, (byte) 31);
|
|
|
|
@@ -458,6 +491,15 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
while (iterator.hasNext()) {
|
2018-07-15 02:00:00 +02:00
|
|
|
ItemStack itemstack1 = (ItemStack) iterator.next();
|
2021-06-11 07:00:00 +02:00
|
|
|
EntityItem entityitem = new EntityItem(this.level, this.locX(), this.locY(), this.locZ(), itemstack1);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit start
|
2020-06-25 02:00:00 +02:00
|
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), entityitem.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1);
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.level.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
|
2020-06-25 02:00:00 +02:00
|
|
|
double d0 = entityhuman.locX() - this.locX();
|
|
|
|
double d1 = entityhuman.locY() - this.locY();
|
|
|
|
double d2 = entityhuman.locZ() - this.locZ();
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -465,7 +507,11 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
|
|
|
|
entityitem.setMot(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
|
2021-06-11 07:00:00 +02:00
|
|
|
this.level.addEntity(entityitem);
|
|
|
|
- entityhuman.level.addEntity(new EntityExperienceOrb(entityhuman.level, entityhuman.locX(), entityhuman.locY() + 0.5D, entityhuman.locZ() + 0.5D, this.random.nextInt(6) + 1));
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop()
|
|
|
|
+ if (playerFishEvent.getExpToDrop() > 0) {
|
2021-06-11 07:00:00 +02:00
|
|
|
+ entityhuman.level.addEntity(new EntityExperienceOrb(entityhuman.level, entityhuman.locX(), entityhuman.locY() + 0.5D, entityhuman.locZ() + 0.5D, playerFishEvent.getExpToDrop()));
|
2016-02-29 22:32:46 +01:00
|
|
|
+ }
|
2016-11-17 02:41:03 +01:00
|
|
|
+ // CraftBukkit end
|
2021-06-11 07:00:00 +02:00
|
|
|
if (itemstack1.a((Tag) TagsItem.FISHES)) {
|
2020-06-25 02:00:00 +02:00
|
|
|
entityhuman.a(StatisticList.FISH_CAUGHT, 1);
|
2018-07-15 02:00:00 +02:00
|
|
|
}
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -475,8 +521,25 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
if (this.onGround) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2020-06-25 02:00:00 +02:00
|
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.level.getServer().getPluginManager().callEvent(playerFishEvent);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ 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) {
|
2020-06-25 02:00:00 +02:00
|
|
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.REEL_IN);
|
2021-06-11 07:00:00 +02:00
|
|
|
+ this.level.getServer().getPluginManager().callEvent(playerFishEvent);
|
2016-03-05 05:46:56 +01:00
|
|
|
+ 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;
|