1.15.2 Can we modify the max durability of an item? & 1 Other question

Discussion in 'Spigot Plugin Development' started by iCodinqs, Jan 12, 2020.

  1. Hello Spigot!

    So I am currently in the process of creating a plugin that will add custom items into the game, more or less.

    I am wondering if it's possible to set the max durability for a diamond pickaxe up to somewhere like 2000?

    If not, I'll need to go ahead and create a custom durability system for what I aim to achieve, unless there's a more easier way to go about it, so please do suggest! :)

    For the other question, is it also possible to modify the speed at which a pickaxe can mine at from the Attributes? If it isn't, what ways could I go about achieving this?
  2. I not know about setting max durations. But you may add addUnsafeEnchantment with value Durability 10 or more.
    Code (Text):
    item.addUnsafeEnchantment(Enchantment.DURABILITY, 100);
  3. I do know about this method, though I am aiming to do this without using any enchantments
  4. you can change mining speed only by making your own mining system (sending own block break animation packets instead of vanilla, by giving high mining fatigue effect) other way the speed would only change serverside, but not clientside
  5. Personally I think going down that route would be very unviable for myself, since I am a solo developer, would take me months to figure all of that out and get a version of it working for clients from 1.13 up to 1.15.

    I think the easy way would probably be to use enchantments for this method, but have them hidden and make the pickaxe not glow, then modify how the enchantments are displayed on the item and have the item glow if the user enchants it
    • Agree Agree x 1
  6. For the durability:
    You can create a virtual durability via NBT data.
    Dura: 2000
    MaxDura: 2000

    Then set the item durability to the equivalent percentage of your custom durability.

    For the mining speed:
    You can give someone a potion effect as soon as he starts mining (silent).
    Other than that you'd need your own mining system with block damage packets.
    (shouldn't take too long when using ProtocolLib)
  7. Yeah I was thinking about doing it this way with the durability, I do know that it used to be possible to change the max durability via reflections and NMS, though I am not sure if thats the case anymore.

    That could be a feasible alternative to the enchantment (the potion effect).

    I will take a look into the block damage packets more deeply and see what I can come with from that, thanks!