Solved How do you damage an item before drop?

Discussion in 'Plugin Development' started by phondeux, Nov 9, 2012.

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

    phondeux

    I'm writing a plugin in which mobs like Zombies or Skeletons will drop what they're wearing in a damaged state ... I've got the drop figured out but can't get how to make the item damaged. Any suggestions?
     
  2. Offline

    cman1885

    If you're spawning an item entity it takes from an itemstack, no (I could be wrong)? So just use the constructor for an itemstack which applies durability.
     
  3. Offline

    gomeow

  4. Offline

    phondeux

    It's a short, but what does the number mean? How much of the range is valid? Is it 1 for almost destroyed and 100 for undamaged .. .1000 for undamaged?

    I'm messing around with my code and will post here what I find out.

    Code:
    ItemStack eqBoots = new ItemStack(getBoots(theEnt).getType(), 1, (short) 5);
    theMob.getWorld().dropItemNaturally(theMob.getLocation(), eqBoots);
    Why doesn't this drop damaged boots? Is the value too low?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  5. Offline

    phondeux

    I upped the value but items still don't drop damaged. The constructor suggests (Item, Quantity, Durability) but no matter what value I throw into Durability the items drop undamaged. :(
     
  6. Offline

    cman1885

    Does theEnt have boots on? Is that part of your code firing?
     
  7. Offline

    phondeux

    Yes, theEnt is wearing boots.
     
  8. Offline

    phondeux

    Apparently durability values are here; http://www.minecraftwiki.net/wiki/Item_Durability

    It still doesn't explain why the following two lines don't work at all;
    Code:
    ItemStack eqBoots = new ItemStack(getBoots(theEnt).getType(), 1, (short) 5);
    theMob.getWorld().dropItemNaturally(theMob.getLocation(), eqBoots);
     
  9. Since you've looked at this wiki page http://www.minecraftwiki.net/wiki/Item_Durability I would guess that you understand how durability works.

    But here's an awnser to your question anyway:
    Durability counts up, 0 = undamaged, 1500 = heavily damaged diamondpick
     
    phondeux likes this.
  10. Offline

    phondeux

    I did see, thanks!

    The problem is, using my code I increased the number to 50 for all iron equipment, then outfitted a bunch of zombies with iron gear. I then killed them and expected the durability to be at least 50 on each item but all were untouched.

    I'm assuming something is wrong with how I'm creating the damage but don't know what.

    My code does in fact work, I found I hadn't been pushing the correct version out to the server! Thank you everyone for your help!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
Thread Status:
Not open for further replies.

Share This Page