From 7502690157df43ab5fe2964d610395794d7568e6 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sat, 23 Jan 2021 12:23:32 +1100 Subject: [PATCH] #571: Expand the FishHook API By: Parker Hawke --- .../main/java/org/bukkit/entity/FishHook.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/entity/FishHook.java b/paper-api/src/main/java/org/bukkit/entity/FishHook.java index 7069de3081..d1b3753031 100644 --- a/paper-api/src/main/java/org/bukkit/entity/FishHook.java +++ b/paper-api/src/main/java/org/bukkit/entity/FishHook.java @@ -1,5 +1,8 @@ package org.bukkit.entity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + /** * Represents a fishing hook. */ @@ -98,4 +101,65 @@ public interface FishHook extends Projectile { */ @Deprecated public void setBiteChance(double chance) throws IllegalArgumentException; + + /** + * Check whether or not this fish hook is in open water. + *

+ * Open water is defined by a 5x4x5 area of water, air and lily pads. If in + * open water, treasure items may be caught. + * + * @return true if in open water, false otherwise + */ + public boolean isInOpenWater(); + + /** + * Get the entity hooked by this fish hook. + * + * @return the hooked entity. null if none + */ + @Nullable + public Entity getHookedEntity(); + + /** + * Set the entity hooked by this fish hook. + * + * @param entity the entity to set, or null to unhook + */ + public void setHookedEntity(@Nullable Entity entity); + + /** + * Pull the hooked entity to the caster of this fish hook. If no entity is + * hooked, this method has no effect. + * + * @return true if pulled, false if no entity is hooked + */ + public boolean pullHookedEntity(); + + /** + * Get the current state of this fish hook. + * + * @return the fish hook state + */ + @NotNull + public HookState getState(); + + /** + * Represents a state in which a fishing hook may be. + */ + public enum HookState { + + /** + * The fishing hook has been cast and is either in the air or resting + * against a block on the ground. + */ + UNHOOKED, + /** + * The fishing hook has hooked an entity. + */ + HOOKED_ENTITY, + /** + * The fishing hook is bobbing in the water, waiting for a bite. + */ + BOBBING; + } }