Set RepairCost nbt to 0 permanently for all items

Discussion in 'Plugin Requests' started by souperdudeman, Feb 28, 2020.

Thread Status:
Not open for further replies.
  1. Offline


    Plugin category: Mechanics
    Minecraft version: 1.15.2/Latest
    Suggested name: No Repair Cost

    What I want:

    Change the nbt data tag for RepairCost on all enchantable/repairable items to 0.
    - When the RepairCost for an enchantable/repairable item increases, set it back to 0.
    - Ablility to configure which items have their RepairCosts automatically kept at 0.

    Ideas for commands: No commands needed for this plugin. All configuration will hopefully be completed in a plugin config file.

    Ideas for permissions: No permissions needed. Functionality will be applied to all players universally.

    When I'd like it by: I'd be happy if I ever got it!
  2. Offline


    I started work on this, and boy was this more complex than I thought it would be, but I'm nearly done. Just a few more things to fix.
    souperdudeman likes this.
  3. Offline


    holy god thats crazy. I 100% expected nobody to respond to this! THanK YoU So mUCH
  4. Offline


    Let there be plugin!

    I changed it a bit, you add items to the config to based on what items you want to cost experience.
    For example,
    In this case, a diamond sword would cost experience to enchant.

    This is the formatting for all of the items

    Keep in mind that if another plugin of yours does rely on the anvil's behavior I cannot promise it will still work. Due to the way I had to do this. TECHNICAL STUFF INCOMING!

    Minecraft won't actually let you set the experience cost to zero like you'd expect, when the experience cost is zero, the item cannot be taken out of the anvil. So, what I ended up having to do is canceling the action before the player takes the item out of the slot, clearing the anvil, then putting the item on the player's cursor, or in their inventory if they shift-clicked. Because I was canceling the action the anvil was never actually playing sound or breaking, so I had to implement that as well.
    TLDR: I rewrote the anvil functionality

    Hopefully, this satisfies your needs, and if you find an issue, I'd be more than happy to take a look. I can't promise I'll be able to fix it, this is the first plugin I've made outside of messing around purposes.

    Last edited: Feb 29, 2020
    souperdudeman likes this.
  5. Offline

    Machine Maker

    @MacroMew did you find a way to do this using NBT tags or did you just listen for anvil-related events and set repair costs that way?

    EDIT: Nvm, I decided to actually read your whole post.
    souperdudeman likes this.
  6. Offline


    souperdudeman likes this.
  7. Offline


    @MacroMew I've made a mistake in that I was not specific enough with my proposal. The "{RepairCost: ~}" nbt tag specifies the amout of enchantment levels to add to the base cost of an enchantment using the anvil whether that be repairing a bow, adding an enchantment via book, or combining two enchanted bows. Every time an item is used in an anvil, the "{RepairCost: ~}" increases, which means the next time I try to add an enchanted book to that Item, it is much more expensive than when I added the first book. What I am looking for is a plugin that will change any RepairCost nbt that is greater than 0, back to 0. As an example, I place a normal crossbow into an anvil with an unbreaking I book and it costs 1 level. After enchanting, the nbt data of the crossbow is this: "tag: {RepairCost: 1} ....". Now if add another unbreaking I book to the crossbow in the anvil, the cost is 3 levels. With the plugin, after adding the first unbreaking I book, the "tag: {RepairCost: 1}" on the crossbow is changed to "tag {RepairCost: 0}". In this way, no matter how many times the crossbow has been used in an anvil, the cost of adding an unbreaking I book will remain 1 experience level. With the current plugin, all anvil experience costs are set to 0 levels, whereas with the proposed plugin, all anvil expereince costs would remain at their base cost and would not get more expensive the more an item is used in an anvil. I"m sorry for being so vague initially and thank you so much for spending your time helping me!! I will be happy to elaborate if further information is needed.
    Last edited: Mar 1, 2020
  8. Offline


    Ok, I believe I understand now, I read No Repair Cost, and I thought you wanted everything to be free. This is much simpler, and I should be able to do this quickly.

    To make sure I understand, I'll provide an example of how I believe it should function.

    Let's say that you have a half damaged Iron Sword, you repair that sword, costing two levels increasing the future repair cost of the item. The nbt tag that adds onto the cost is then set back down to 0.

    Then let's say you add unbreaking one to the sword. This costs 2 levels. Then you combine it with another unbreaking one book to give it unbreaking 2. This costs 4 levels because it isn't the enchantment cost it is the repair cost.

    Is that accurate to your request?

    Edit: Ok, since you've liked the post here is the finished plugin. If you find any bugs, I'd be happy to look into them.

    Last edited: Mar 2, 2020
    souperdudeman likes this.
  9. Offline


    Yes this is sounding accurate. Whenever the RepairCost nbt tag is increased by the anvil, I would like the plugin to change the increased RepairCost back to 0 so that the next time said item is used in the anvil, the experience level price remains at its base cost.

    The new version of the plugin still has anvil usage as free. While it does change nbt data for repair costs back to 0, it also does the unwanted action of making all anvil activities cost 0 experience levels. Preferably, the only action of the plugin would be to change nbt data for repaircost for values greater than 0, back to 0.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Mar 3, 2020
  10. Offline


    @souperdudeman Did you make sure to delete the other plugin before installing the new one because if you didn't then it wouldn't change anything and the old one would still function.

    Delete the first two plugins that I gave you, and replace it with this one. If it doesn't work, I have no idea. It works perfectly on my test server just as you described. The anvil repair costs experience, but it stays at its base level. Unless the item is enchanted.

Thread Status:
Not open for further replies.

Share This Page