Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • My items have durability but it only takes one off of the whole durability
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
Triphion

My items have durability but it only takes one off of the whole durability

By Triphion, September 5, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Triphion    0

Triphion

Triphion    0

  • Creeper Killer
  • Triphion
  • Members
  • 0
  • 110 posts
Posted September 5, 2017 (edited)

As the title implies, the items i have made has durability that shows, but it only takes durability the first time i use them. Not too sure why it only takes one off of the whole durability so i would like some guidance on this topic. Thanks in advance! ^^

 

Code - https://gist.github.com/triphion/9cfa3a8011eb74d90df02255f8643825

Edited September 5, 2017 by Triphion
  • Quote

Share this post


Link to post
Share on other sites

Triphion    0

Triphion

Triphion    0

  • Creeper Killer
  • Triphion
  • Members
  • 0
  • 110 posts
Posted September 5, 2017

Edit: I fixed it, looked into what setdamage did and realized that it actually didn't remove durability but actually just set the durability to a certain number. 

  • Quote

Share this post


Link to post
Share on other sites

Choonster    1651

Choonster

Choonster    1651

  • Reality Controller
  • Choonster
  • Forge Modder
  • 1651
  • 5097 posts
Posted September 5, 2017

Item#setDamage sets the ItemStack's damage to the specified amount. You call it with 1, so it sets the ItemStack's damage to 1.

 

The method you want is ItemStack#damageItem, which increments the ItemStack's damage by the specified amount. Calling with 1 will add 1 to the damage.

 

Side note: Don't use Item#setDamage directly, use ItemStack#setItemDamage when you want to set the ItemStack's damage instead.

  • Quote

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Gubipe
      Minecraft.getMinecraft().thePlayer.swingItem(); wont attack

      By Gubipe · Posted 44 minutes ago

      I am making the two mods with the same functionality. One is 1.16.4 and the other is 1.8.9. The current one is 1.8.9 and then I shall try to port it over to 1.16.4
    • poopoodice
      Minecraft.getMinecraft().thePlayer.swingItem(); wont attack

      By poopoodice · Posted 1 hour ago

      It's for animation only. Btw what version are you using?
    • TheDonkey_King
      I just started modding minecraft and I thought i had finished modding it but Titanium mod isn't loading properly. Can someone help me fix this?

      By TheDonkey_King · Posted 1 hour ago

      What file?
    • BIGDog8808
      HELP! WORLD WONT WORK

      By BIGDog8808 · Posted 1 hour ago

      so is there anyway that i can copy the world and use it with forge  
    • mightymoy
      Cant craft items in modded server

      By mightymoy · Posted 1 hour ago

      we arent using Opti fine anymore and no specific reason we had just picked 1.16.1 
  • Topics

    • Gubipe
      2
      Minecraft.getMinecraft().thePlayer.swingItem(); wont attack

      By Gubipe
      Started 3 hours ago

    • TheDonkey_King
      4
      I just started modding minecraft and I thought i had finished modding it but Titanium mod isn't loading properly. Can someone help me fix this?

      By TheDonkey_King
      Started 7 hours ago

    • BIGDog8808
      10
      HELP! WORLD WONT WORK

      By BIGDog8808
      Started 8 hours ago

    • mightymoy
      8
      Cant craft items in modded server

      By mightymoy
      Started Yesterday at 03:00 AM

    • tinyborisYT
      2
      [1.12.2] Crash at Launch, No clue why

      By tinyborisYT
      Started 2 hours ago

  • Who's Online (See full list)

    • TheDonkey_King
    • Caffeinated Pinkie
    • Gubipe
    • RafaMv
    • Veiro
    • LexManos
    • Frog :)
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • My items have durability but it only takes one off of the whole durability
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community