Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing PlayerItemMend's repairAmount doens't change repair:experience ratio #7449

Closed
rafaelsms opened this issue Feb 6, 2022 · 2 comments · Fixed by #7382
Closed

Changing PlayerItemMend's repairAmount doens't change repair:experience ratio #7449

rafaelsms opened this issue Feb 6, 2022 · 2 comments · Fixed by #7382
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to.

Comments

@rafaelsms
Copy link

rafaelsms commented Feb 6, 2022

Expected behavior

Changing the event's repairAmount would change the experience to repair amount ratio.

For example, given an experience orb with value 10, this event would have repairAmount = 20: if I change it to 10, I expect it to consume the same 10 experience but changing the repair amount.

Observed/Actual behavior

No matter what the value of repairAmount given, NMS' recursion on repairPlayerItems (on Experience Orb entity) will always give the same repair amount, making this event a bit useless.

For instance, if I set repairAmount to 2 no matter what the initial value is, it would consume 1 experience from the orb, and recursion would call the event again until all the experience is consumed on the same 2:1 ratio.

Paper version

This server is running Paper version git-Paper-187 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) (Git: 0cc2503)

Other

public class MendingNerfListener implements Listener {

    private final @NotNull JavaPlugin plugin;

    public MendingNerfListener(@NotNull JavaPlugin plugin) {
        this.plugin = plugin;
    }

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    private void nerfMending(PlayerItemMendEvent event) {
        plugin.getServer()
              .sendMessage(Component.text("id = %d experience = %d, repair amount = %d, item = %s with %d".formatted(
                      event.getExperienceOrb().getEntityId(),
                      event.getExperienceOrb().getExperience(),
                      event.getRepairAmount(),
                      event.getItem().getType().name(),
                      ((Damageable) event.getItem().getItemMeta()).getDamage())));
        //if (!plugin.getConfiguration().isMendingNerfed()) {
        if (false) { // replace with true for normal behaviour
            return;
        }
        event.setRepairAmount(Math.min(event.getRepairAmount(), 2));
    }

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    private void checkNerf(PlayerItemMendEvent event) {
        plugin.getServer()
              .sendMessage(Component.text("=> id = %d experience = %d, repair amount = %d, item = %s with %d".formatted(
                      event.getExperienceOrb().getEntityId(),
                      event.getExperienceOrb().getExperience(),
                      event.getRepairAmount(),
                      event.getItem().getType().name(),
                      ((Damageable) event.getItem().getItemMeta()).getDamage())));
    }
}

Edit: I noticed how my understanding of Mending was wrong and updated the issue accordingly (I believe it stills needs changing)

@rafaelsms rafaelsms added status: needs triage type: bug Something doesn't work as it was intended to. labels Feb 6, 2022
@rafaelsms rafaelsms changed the title Changing PlayerItemMend's repaired amount loops until all items are repaired Changing PlayerItemMend's repairAmount doesn't work properly Feb 17, 2022
@rafaelsms rafaelsms changed the title Changing PlayerItemMend's repairAmount doesn't work properly Changing PlayerItemMend's repairAmount doens't change repair:experience ratio Feb 20, 2022
@Machine-Maker
Copy link
Member

@rafaelsms does this PR fix your issue? It lets you set the durabilityToXp function to whatever you want inside the event.

@Machine-Maker Machine-Maker added the resolution: awaiting response Additional information is required from the issue reporter label Mar 17, 2022
@rafaelsms
Copy link
Author

@rafaelsms does this PR fix your issue? It lets you set the durabilityToXp function to whatever you want inside the event.

Yes it does fix it! Thank you

@Machine-Maker Machine-Maker added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. and removed resolution: awaiting response Additional information is required from the issue reporter status: needs triage labels Mar 18, 2022
@github-project-automation github-project-automation bot moved this to ✅ Accepted in Issues: Bugs Apr 6, 2023
@github-project-automation github-project-automation bot moved this from ✅ Accepted to Done in Issues: Bugs May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants