Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions paper-api/src/main/java/org/bukkit/entity/FishHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,23 @@ public interface FishHook extends Projectile {
*/
public void setLureAngle(float min, float max);

/**
* Set maximum distance from fish hook to launching projectile source in blocks.
* When exceeded, the fish hook despawns.
* <p>
* The default is 32 blocks.
*
* @param maxDistance maximum distance between fish hook and its source in blocks
*/
public void setMaxFishHookDistance(float maxDistance);

/**
* Get maximum distance from fish hook to launching projectile source in blocks.
*
* @return maximum distance between fish hook and its source in blocks
*/
public float getMaxFishHookDistance();

/**
* Get whether the lure enchantment should be applied to reduce the wait
* time.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/FishingHook.java
+++ b/net/minecraft/world/entity/projectile/FishingHook.java
@@ -71,10 +_,26 @@
@@ -71,10 +_,27 @@
private final int luck;
private final int lureSpeed;

Expand All @@ -14,6 +14,7 @@
+ public boolean applyLure = true;
+ public boolean rainInfluenced = true;
+ public boolean skyInfluenced = true;
+ public float maxFishHookDistance = 32F; // Paper - Add max fish hook distance
+ // CraftBukkit end
+
private FishingHook(final EntityType<? extends FishingHook> type, final Level level, final int luck, final int lureSpeed) {
Expand Down Expand Up @@ -65,7 +66,13 @@
this.currentState = FishingHook.FishHookState.FLYING;
}
}
@@ -262,13 +_,13 @@
@@ -257,18 +_,18 @@
ItemStack selectedItemOffHand = owner.getOffhandItem();
boolean mainHandIsFishing = selectedItem.is(Items.FISHING_ROD);
boolean offHandIsFishing = selectedItemOffHand.is(Items.FISHING_ROD);
- if ((mainHandIsFishing || offHandIsFishing) && this.distanceToSqr(owner) <= 1024.0) {
+ if ((mainHandIsFishing || offHandIsFishing) && this.distanceTo(owner) <= maxFishHookDistance) { // Paper - Add max fish hook distance
return false;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.entity;

import com.google.common.base.Preconditions;
import io.papermc.paper.util.BoundChecker;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -115,6 +116,17 @@ public void setLureAngle(float min, float max) {
this.getHandle().maxLureAngle = max;
}

@Override
public void setMaxFishHookDistance(float maxDistance) {
BoundChecker.requirePositive(maxDistance, "maxDistance");
this.getHandle().maxFishHookDistance = maxDistance;
}

@Override
public float getMaxFishHookDistance() {
return this.getHandle().maxFishHookDistance;
}

@Override
public boolean isSkyInfluenced() {
return this.getHandle().skyInfluenced;
Expand Down
Loading