Jump to content

Recommended Posts

Posted (edited)

Is setting hasContainerItem() and getContainerItem() not enough to keep an item in the table on latest forge versions? Found posts for previous versions where it worked in older versions. I have an ItemTool extended class that I want to stay in the table and just have some damage after crafting. Thanks for any help!

 

Item Class:

  Reveal hidden contents

 

ItemTool Extension Class:

  Reveal hidden contents

 

Edited by DimensionsInTime
Posted

Whoops, missed that new method. Fixed. Thanks. The hammer item still disappears on crafting. Recipe is a shapeless where a stack of another item is given when you place the hammer and a block/item in the table. In the hook code I see it checks for container and returns the stack if not empty, has max damage, etc. Looks as if this is called on crafting, so is that the right place to return the stack to keep it in the table?

 

Recipes:

  Reveal hidden contents

 

Posted (edited)

Solved. I was making it harder than it was I guess. 

@Override
public ItemStack getContainerItem(@Nonnull ItemStack stack){
	return stack.getItemDamage() < stack.getMaxDamage() ? new ItemStack(stack.getItem(), 1,stack.getItemDamage() + 10) : ItemStack.EMPTY;
}

 

Works great.

Edited by DimensionsInTime
code format

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.