nmahdi / FishingRewards

Minecraft 1.20 Plugin using Spigot API to customize fishing rewards.
https://www.spigotmc.org/resources/fishing-rewards.84717/
1 stars 1 forks source link

rewards.yml enchanted book, always produces 4 enchantments #2

Closed leefy-greens closed 4 months ago

leefy-greens commented 4 months ago

With the following (and ONLY the following) in my rewards.yml with FishingRewards 2.1:

EnchantedBook:
    material: 'enchanted_book'
    type: 'item'
    chance: 100
    guaranteed-enchantment-amount: 1
    enchantments:
        - 'depth_strider:1'
        - 'respiration:1'
        - 'aqua_affinity:1'
        - 'thorns:1'
        - 'soul_speed:1'
        - 'looting:1'
        - 'frost_walker:1'
        - 'swift_sneak:1'

When I fish, I always get a book, which is working as intended. The book I get is enchanted, which is working as intended. The book I get always has 4 enchantments, with the above rewards.yml, rather than 1. It's a random selection of the 8 total, but it's always 4 (3+1?). Changing the guaranteed-enchantment-amount to 2 increases the enchantment count to 5 (3+2?), consistently.

It appears there is some base value of 3(?), despite the comment in the rewards.yml of: # guaranteed-enchantment-amount: Determines the number of guaranteed enchantments an item can have. For an example, if an item has 5 guaranteed enchantments, but the amount is set to 2, it will pick 2 enchantments randomly and apply them. which doesn't appear to be true, at the moment. Or there is some other bug affecting the count of returned enchantments.

Additionally: Also, with 7 or 8 enchantments in the list, the returned number of enchantments with guaranteed-enchantment-amount: 1 is 4. However, with 5 or 6 enchantments in the list, the returned number of enchantments with guaranteed-enchantment-amount: 1 is 3.

That seems to indicate some kind of undocumented calculation based on half the total list, possibly?

nmahdi commented 4 months ago

It seems there is an issue with calculating the amount of enchants, I'll try and work on a fix ASAP. I'm currently sick unfortunately so I'm not sure when I'll be able to. Sorry for the inconvenience

nmahdi commented 4 months ago

After reviewing the code, the fix was very simple, I uploaded an updated version on spigot. Let me know if that fixes the issues. https://www.spigotmc.org/resources/fishing-rewards.84717/

leefy-greens commented 4 months ago

Thanks, I will test it today.

leefy-greens commented 4 months ago

Version 2.2 is better, and has resolved my issue. Thanks!