Jump to content

Recommended Posts

Posted (edited)

I do not seem to understand how im supposed to give my item i've done durability. I've tried the setmaxdamage method aswell as stack.damageitem method, but when i do the stack.damageitem method it just gives me error saying that it isn't existing or something. So then i try to add Itemstack Stack in the upper session where the Player PlayerIn is an all that, but that doesn't work either. I just can't figure out what im supposed to have to succesfully get this to work. 

 

My item class - https://pastebin.com/1b3jg52a

Edited by Triphion
Posted
public ActionResult<ItemStack> onItemRightClick(Itemstack Stack, World worldIn, EntityPlayer playerIn, EnumHand handIn) {

 

I believe Itemstack should be ItemStack. Not sure if that's specifically the problem, but it certainly can't be helping :)

Posted (edited)
18 minutes ago, diesieben07 said:

This makes no sense, please clarify.

Well, i have been looking all over the internet and on every one of those durability posts there is ItemStack Stack in the onitemrightclick method, but when i did the onitemrightclick method, it wasn't mentioned in the method at all. 

Edited by Triphion
Posted

But what should i do? When i add ItemStack Stack successfully it says that i need to remove @Override but then it's not working since it needs to be overriding. So i have no idea what i should add or remove. I tried removing that new itemstack after both "SUCCESS" and "FAIL", but it says that it has to have some sort of statement after which i have no idea what sort of statement it should be. 

Posted (edited)

And if i want to add durability it should be what exactly? The item? Or null? Because i want to add a durability of like 1000 on this staff and i do not know when this applies. 

Edited by Triphion
Posted
22 minutes ago, diesieben07 said:

If you want to add durability, you need to add durability to the stack held by the player and then pass that to the ActionResult.

And the method for that is setmaxdamage? And also, how would i pass it on to the actionresult and register it so that on item rightclick it removes 1 from the durability?

Posted (edited)
5 minutes ago, diesieben07 said:

If you do not know how to pass something to a constructor you need to go and learn basic Java.

I do not see that necessary since this seems to be a very simple matter since its only one thing i want to do and i feel like you already know how to do this. It would be much easier if you could just tell me a method which i can implement into the code such as "Stack.damageitem" or something. Or what needs to be replaced with what method. 

5 minutes ago, diesieben07 said:

What do you want to register?

How much damage it removes on itemrightclick and also that it actually removes durability. 

Edited by Triphion
Posted (edited)
@Override
    public ActionResult<ItemStack> onItemRightClick(Itemstack Stack, World worldIn, EntityPlayer playerIn, EnumHand handIn)

This doesn't look right. Do you get a complaint about the Override? If so, then you need to revise the method profile until the complaint goes away. I know, Eclipse will always suggest that you cut the Override, but that's because Eclipse is too stupid to know if it really belongs there. If it does, then you need to keep it there and make it work, that's what the annotation is for -- to irritate you until you fix the broken method profile.

 

I suggest copying the profile of the method you're overriding.

 

return new ActionResult(EnumActionResult.SUCCESS, new ItemStack(this));

Why are you returning a new stack? What's wrong with the one you were given (and to which you added damage)? You should set some breakpoints around your code and then step through it and into method calls and out to the surrounding vanilla code to see how your result is used. Only then will you see what's happening and why.

Edited by jeffryfisher

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.