Solved Indestructible Items

Discussion in 'Spigot Plugin Development' started by LazerShadow, Nov 18, 2015.

  1. What would be the best approach to making an item indestructible? Meaning when you break a block or shoot a bow the durability bar doesn't change.
     
    • Like Like x 1
  2. The only easy way is to simply cancel the event that is called where ItemStacks take durability damage (don't recall its name) and update the player's Inventory every time so the durability bar doesn't keep going down. It'll probably flicker though.
     
  3. You can use the event PlayerItemDamageEvent, you can use this event to get the damage dealt to the tool and some more information and just cancel it. More info on the javadocs by clicking here.
     
    • Winner Winner x 3
    • Agree Agree x 1
  4. I got into a discussion with someone about it this before.

    Code (Java):

      public static class Spigot
      {
      public void setUnbreakable(boolean unbreakable)
      {
      throw new UnsupportedOperationException("Not supported yet.");
      }

      public boolean isUnbreakable()
      {
      throw new UnsupportedOperationException("Not supported yet.");
      }
      }

    Another pointed out to use CraftMetaItem... as it's functions are available, but take a look at the damage method for ItemStack source:

    Code (Java):

      public void damage(int i, EntityLiving entityliving)
      {
      if (((!(entityliving instanceof EntityHuman)) || (!((EntityHuman)entityliving).abilities.canInstantlyBuild)) &&
      (e()) &&
      (isDamaged(i, entityliving.bc(), entityliving)))
      {
      entityliving.b(this);
      this.count -= 1;
      if ((entityliving instanceof EntityHuman))
      {
      EntityHuman entityhuman = (EntityHuman)entityliving;

      entityhuman.b(StatisticList.BREAK_ITEM_COUNT[Item.getId(this.item)]);
      if ((this.count == 0) && ((getItem() instanceof ItemBow))) {
      entityhuman.ca();
      }
      }
      if (this.count < 0) {
      this.count = 0;
      }
      if ((this.count == 0) && ((entityliving instanceof EntityHuman))) {
      CraftEventFactory.callPlayerItemBreakEvent((EntityHuman)entityliving, this);
      }
      this.damage = 0;
      }
      }

    As you can see, there is no mention of preventing the breaking of an item, nothing about the Unbreakable tag.

    If you evalute the PlayerInteractManager (in the case that the Unbreakable method was called before or outside the NMS ItemStack's damage method) where the BlockBreakEvent is called, there is nothing mentioned of the Unbreakable tag, same as above except for in a boolean method which doesn't help the case. Hence the normal Bukkit ItemMeta saying the operation is unsupported.
     
  5. Did you completely ignore my post?
     
  6. Your post is irrelevant if you use the spigot api.
    https://hub.spigotmc.org/stash/proj...reakable-and-setUnbreakable-to-ItemMeta.patch

    ofc though should expect nothing good from someone who wrote a wrapper class for YamlConfiguration, and its not even a half decent one at that.

    edit: y argue with yourself

     
    #7 not2excel, Nov 18, 2015
    Last edited: Nov 18, 2015
    • Winner Winner x 2
  7. Your post is irrevelant since it completely depends on the API's implementation in the server jar itself, fucktard. If I made an API and added code to make it to where anyone can fly at any time they want, it doesn't matter if it isn't in the server itself. There's no need to be rude for absolutely no reason. If you look at the damn source, there is no where that showns that it works. Although given I've not tested it, so let me do that to confirm if it actually works or not.

    Your ignorance level makes me want to commit suicide.
     
  8. konsolas

    Supporter

    It works on Spigot servers.

    If you're using craftbukkit you should commit suicide.
     
  9. Lel. I linked to Spigot server source. Anyways, it does work. I wasn't implying it it DIDN'T work. But from the source, I couldn't see any implementation that it did work. Had I known about this earlier, I could've used it in so many cases...
     
  10. 1. You linked the API, not the implementation.
    2. Unfortunately, the methods are implemented.
     
  11. #1. Both of what I linked was using JD-GUI to view the Spigot server source.
    #2. That was already posted farther up, and I've already stated that they work.
     
  12. konsolas

    Supporter

    Why?

    @Raino was attempting to explain to you why what you're saying is wrong, so that with any luck, you'll learn from it. Trying to argue that you have any techincal/moral/correct basis for being wrong won't help anyone. Learn and move on, please.
     
  13. You guys do not read, do you? I did not once say that it is not, in any way, shape, or form, possible to use ItemMeta#spigot() to make the ItemStack unbreakable. I linked various code to show that I was very sure it wasn't supported, as browsing through some of the Spigot server source does not show any implementation. I then tested it and said it DOES work. So even if I had said that it wasn't possible, that statement would be me saying I'm wrong, as it completely contradicts what I would've said, had I said it.

    Why use JD-GUI? Why not? It's easier to start a program from my desktop or Start Menu, double click the Spigot server jar, and view source. Navigating through what Spigot provides with BuildTools with Eclipse is somewhat difficult, as there are many folders, and it creates unnecessary tabs when I have a lot open in Eclipse, keeping what I'm viewing and what I'm typing in two different locations. Also, I know that importing the Spigot server source itself into Eclipse only contains about 10% of the NMS classes. I think the rest of them are in another location, wherever the Minecraft server jar itself gets decompiled and saved.

    Raino was not explaining anything. He was only repeating what I, and himself, had already said.