Repository: PaperMC/Paper
File: paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFishHook.java (Java)

Code before:
    }

    @Override
    public void setTimeUntilBite(final int ticks) {
        com.google.common.base.Preconditions.checkArgument(ticks >= 1, "Cannot set time until bite to less than 1 (%s<1)", ticks);
        final FishingHook hook = this.getHandle();

        // Reset the fish angle hook only when this call "enters" the fish into the lure stage.
        final boolean alreadyInLuringPhase = hook.timeUntilHooked > 0 && hook.timeUntilLured <= 0;
        if (!alreadyInLuringPhase) {
            hook.fishAngle = net.minecraft.util.Mth.nextFloat(hook.random, hook.minLureAngle, hook.maxLureAngle);
            hook.timeUntilLured = 0;
        }

        hook.timeUntilHooked = ticks;
    }

    @Override
    public void resetFishingState() {
        final FishingHook hook = this.getHandle();
        hook.resetTimeUntilLured();
        hook.timeUntilHooked = 0; // Reset time until hooked, will be repopulated once lured time is ticked down.
    }

    @Override
    public int retrieve(EquipmentSlot slot, ItemStack itemStack) {
        Preconditions.checkArgument(slot != null, "Equipment slot cannot be null");
        Preconditions.checkArgument(itemStack != null, "ItemStack cannot be null");
        return getHandle().retrieve(CraftEquipmentSlot.getHand(slot), CraftItemStack.asNMSCopy(itemStack));
    }
}


Review comment (suggestion):
a few things now i see this...
- This accept any item (dont throw issues) maybe can be good include a precondition for that?
- This accept any EquipmentSlot causing later the CraftEquipmentSlot.getHand throws a issue then is good add the same check here for avoid that

Code after:
        return this.getHandle().timeUntilHooked;
    }

    @Override
    public void setTimeUntilBite(final int ticks) {
        com.google.common.base.Preconditions.checkArgument(ticks >= 1, "Cannot set time until bite to less than 1 (%s<1)", ticks);
        final FishingHook hook = this.getHandle();

        // Reset the fish angle hook only when this call "enters" the fish into the lure stage.
        final boolean alreadyInLuringPhase = hook.timeUntilHooked > 0 && hook.timeUntilLured <= 0;
        if (!alreadyInLuringPhase) {
            hook.fishAngle = net.minecraft.util.Mth.nextFloat(hook.random, hook.minLureAngle, hook.maxLureAngle);
            hook.timeUntilLured = 0;
        }

        hook.timeUntilHooked = ticks;
    }

    @Override
    public void resetFishingState() {
        final FishingHook hook = this.getHandle();
        hook.resetTimeUntilLured();
        hook.timeUntilHooked = 0; // Reset time until hooked, will be repopulated once lured time is ticked down.
    }

    @Override
    public int retrieve(EquipmentSlot slot) {
        Preconditions.checkArgument(slot == EquipmentSlot.HAND || slot == EquipmentSlot.OFF_HAND, "Equipment slot must be HAND or OFF_HAND");
        final FishingHook fishingHook = getHandle();
        final Player playerOwner = fishingHook.getPlayerOwner();
        Preconditions.checkState(playerOwner != null, "Player owner cannot be null");

        final InteractionHand hand = CraftEquipmentSlot.getHand(slot);
        final ItemStack itemInHand = playerOwner.getItemInHand(hand);
        Preconditions.checkState(itemInHand.is(Items.FISHING_ROD), "Item in slot is not a FISHING_ROD");

        return fishingHook.retrieve(itemInHand, hand);
    }
}