1.17.1 how to implement a reduction in the strength of the tool

Discussion in 'Spigot Plugin Development' started by Kurasava, Sep 19, 2021.

  1. I'm making a plugin that will expand the functionality of scissors, and I need to make sure that when using scissors on a chicken, along with the loss of feathers, the strength of the scissors decreases
  2. By scissors do you mean shears? I have two different answers depending on the latter.
  3. ItemStack#setDurabilty(int)- may be?
  4. shears
  5. setDurability is deprecated.
    "durability is now part of ItemMeta. To avoid confusion and misuse, getItemMeta(), setItemMeta(ItemMeta) and Damageable.setDamage(int) should be used instead. This is because any call to this method will be overwritten by subsequent setting of ItemMeta which was created before this call."

    Example code from my own plugin:
    Code (Text):
                ItemStack ironSword = new ItemStack(Material.IRON_SWORD, 1);
                //Explicit cast item meta to be of type Damageable
                final Damageable ironSwordItemMeta = (Damageable) ironSword.getItemMeta();
                //Setting the amount of durability I want to take from max durability
    Apologies if this doesn't make much sense, I'm very tired.

    What I would do is get the current damage to durability upon use of the item with getDamage and store as an integer, then set the damage to be current damage +1 or however much you want per use of the item.

    Hope that made a least a little bit of sense.
    • Agree Agree x 1