Jump to content

How to deal with items that can take more than 65536 damage


[NoOneButNo]

Recommended Posts

Explanation: Items that can take more than 65536 damage (let's say a custom shield with 240000 durability) will 'break' when reaching that damage. By break, it means that it will simply vanish without playing the item sound break or whatever. To replicate this 'issue', simple create an item (no need for a code because this basically works with items that can be damaged. This can be easily replicated. armor or shield would be the best as they can easily be damaged or use override the hitEntity of an ItemSword and damage it by more than 65536) that has a durability of more than 65536 damage and damage it until the damage of the item reaches 65536. After 'reaching' it, it will disappear like a thin air.

 

 

Link to comment
Share on other sites

Yes, that's supposed to happen. Any item stack that gets damage of that amount is considered empty.

 

The code for ItemStack.isEmpty() method is:

    public boolean isEmpty()
    {
        if (this == EMPTY)
        {
            return true;
        }
        else if (this.getItemRaw() != null && this.getItemRaw() != Item.getItemFromBlock(Blocks.AIR))
        {
            if (this.stackSize <= 0)
            {
                return true;
            }
            else
            {
                return this.itemDamage < -32768 || this.itemDamage > 65535;
            }
        }
        else
        {
            return true;
        }
    }

 

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

my first instinct was to close the tab (gah, another guy wants to make overpowered gear), but on the second thought, the answer is applicable to many questions, so i'll get to typing...

 

yes, it can be done. no, you can't go above 64k, don't try to fight that limit directly. but sure, solutions exist - are we programmers or silverfish?

 

first of all, sometimes you don't need to reach the original goal, the "that-s-it" solution. in many cases the "that-s-mostly-it" solution is good enough. and it tends to take 4x-20x less time. let's define the task - let's say your task is " item with 240k durability". would it be ok for it to mostly act as if it had 240k durability? meaning, if you give it 60k durability and have it take damage 1/4 of the time, that's functionally similar to having 240k durability. and it takes minutes to implement.

 

another way (which would be suitable for more complicated variation of what you need), is to give your item 100 durability, keep the actual value elsewhere (in nbt for example or cache+worldsave), and keep the durability set to percentage of the current value compared to the maximum value. with this solution, the value does not necessarily need to be the durability. all that is left to do is make a handler for tooltip event and add one line that explains things.

Link to comment
Share on other sites

You have to use NBT for numbers that large.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.