From c7125aaa4874adcb8179474fc1a0eb0307abe7d8 Mon Sep 17 00:00:00 2001 From: Zach Brown <1254957+zachbr@users.noreply.github.com> Date: Tue, 1 Mar 2016 13:14:11 -0600 Subject: [PATCH] Configurable fishing time ranges --- .../entity/projectile/FishingHook.java.patch | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch index fda0fd767e..c5b22d1a8a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -41,7 +41,17 @@ private FishingHook(EntityType<? extends FishingHook> type, Level world, int luckBonus, int waitTimeReductionTicks) { super(type, world); this.syncronizedRandom = RandomSource.create(); -@@ -81,7 +99,7 @@ +@@ -75,13 +93,17 @@ + this.currentState = FishingHook.FishHookState.FLYING; + this.luck = Math.max(0, luckBonus); + this.lureSpeed = Math.max(0, waitTimeReductionTicks); ++ // Paper start - Configurable fishing time ranges ++ minWaitTime = world.paperConfig().fishingTimeRange.minimum; ++ maxWaitTime = world.paperConfig().fishingTimeRange.maximum; ++ // Paper end - Configurable fishing time ranges + } + + public FishingHook(EntityType<? extends FishingHook> type, Level world) { this(type, world, 0, 0); } @@ -50,7 +60,7 @@ this(EntityType.FISHING_BOBBER, world, luckBonus, waitTimeReductionTicks); this.setOwner(thrower); float f = thrower.getXRot(); -@@ -149,15 +167,15 @@ +@@ -149,15 +171,15 @@ public void tick() { this.syncronizedRandom.setSeed(this.getUUID().getLeastSignificantBits() ^ this.level().getGameTime()); super.tick(); @@ -69,7 +79,7 @@ return; } } else { -@@ -250,7 +268,7 @@ +@@ -250,7 +272,7 @@ } } @@ -78,7 +88,7 @@ ItemStack itemstack = player.getMainHandItem(); ItemStack itemstack1 = player.getOffhandItem(); boolean flag = itemstack.is(Items.FISHING_ROD); -@@ -259,7 +277,7 @@ +@@ -259,7 +281,7 @@ if (!player.isRemoved() && player.isAlive() && (flag || flag1) && this.distanceToSqr((Entity) player) <= 1024.0D) { return false; } else { @@ -87,7 +97,7 @@ return true; } } -@@ -267,7 +285,7 @@ +@@ -267,7 +289,7 @@ private void checkCollision() { HitResult movingobjectposition = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); @@ -96,7 +106,7 @@ } @Override -@@ -300,11 +318,11 @@ +@@ -300,11 +322,11 @@ int i = 1; BlockPos blockposition1 = pos.above(); @@ -110,7 +120,7 @@ --i; } -@@ -314,6 +332,10 @@ +@@ -314,6 +336,10 @@ this.timeUntilLured = 0; this.timeUntilHooked = 0; this.getEntityData().set(FishingHook.DATA_BITING, false); @@ -121,7 +131,7 @@ } } else { float f; -@@ -347,6 +369,13 @@ +@@ -347,6 +373,13 @@ worldserver.sendParticles(ParticleTypes.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D); } } else { @@ -135,7 +145,7 @@ this.playSound(SoundEvents.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); double d3 = this.getY() + 0.5D; -@@ -379,12 +408,16 @@ +@@ -379,12 +412,16 @@ } if (this.timeUntilLured <= 0) { @@ -151,12 +161,12 @@ - this.timeUntilLured -= this.lureSpeed; + // CraftBukkit start - logic to modify fishing wait time + this.timeUntilLured = Mth.nextInt(this.random, this.minWaitTime, this.maxWaitTime); -+ this.timeUntilLured -= (this.applyLure) ? this.lureSpeed : 0; ++ this.timeUntilLured -= (this.applyLure) ? (this.lureSpeed >= this.maxWaitTime ? this.timeUntilLured - 1 : this.lureSpeed ) : 0; // Paper - Fix Lure infinite loop + // CraftBukkit end } } -@@ -446,12 +479,20 @@ +@@ -446,12 +483,20 @@ public void readAdditionalSaveData(CompoundTag nbt) {} public int retrieve(ItemStack usedItem) { @@ -178,7 +188,7 @@ this.pullEntity(this.hookedIn); CriteriaTriggers.FISHING_ROD_HOOKED.trigger((ServerPlayer) entityhuman, usedItem, this, Collections.emptyList()); this.level().broadcastEntityEvent(this, (byte) 31); -@@ -467,6 +508,15 @@ +@@ -467,6 +512,15 @@ while (iterator.hasNext()) { ItemStack itemstack1 = (ItemStack) iterator.next(); ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemstack1); @@ -194,7 +204,7 @@ double d0 = entityhuman.getX() - this.getX(); double d1 = entityhuman.getY() - this.getY(); double d2 = entityhuman.getZ() - this.getZ(); -@@ -474,7 +524,11 @@ +@@ -474,7 +528,11 @@ entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D); this.level().addFreshEntity(entityitem); @@ -207,7 +217,7 @@ if (itemstack1.is(ItemTags.FISHES)) { entityhuman.awardStat(Stats.FISH_CAUGHT, 1); } -@@ -484,10 +538,27 @@ +@@ -484,10 +542,27 @@ } if (this.onGround()) { @@ -236,7 +246,7 @@ return i; } else { return 0; -@@ -496,7 +567,7 @@ +@@ -496,7 +571,7 @@ @Override public void handleEntityEvent(byte status) { @@ -245,7 +255,7 @@ this.pullEntity(this.hookedIn); } -@@ -520,8 +591,15 @@ +@@ -520,8 +595,15 @@ @Override public void remove(Entity.RemovalReason reason) { @@ -262,7 +272,7 @@ } @Override -@@ -536,7 +614,7 @@ +@@ -536,7 +618,7 @@ } private void updateOwnerInfo(@Nullable FishingHook fishingBobber) { @@ -271,7 +281,7 @@ if (entityhuman != null) { entityhuman.fishing = fishingBobber; -@@ -545,10 +623,10 @@ +@@ -545,10 +627,10 @@ } @Nullable @@ -284,7 +294,7 @@ } @Nullable -@@ -575,7 +653,7 @@ +@@ -575,7 +657,7 @@ int i = packet.getData(); FishingHook.LOGGER.error("Failed to recreate fishing hook on client. {} (id: {}) is not a valid owner.", this.level().getEntity(i), i);