Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted
comment_402395

Hello,

 

I'm new to the Forge modding community and I have been working on a small project for a couple days, and I have been able to troubleshoot every issue I had until now. Simply put, I need an item to use as a reusable crafting ingredient (see Botania's Mortar and Pestle). My original idea was for the item to have itself as containerItem, but as it turns out, that (obviously) isn't a possibility.

 

Looking for help on the internet, all similar threads I have found are, at least, dated 2017 and make use of the hasContainerItem() and getContainerItem() methods, which have since been deprecated. The comments on the Deprecated tag point me to an "ItemStack sensitive version", which I haven't been able to find. Also, the Forge docs don't mention ItemStack and, apart from this, I haven't been able to find any documentation on it.

 

I would be very thankful.If any of you could point me to either ItemStack documentation or the right methods to use for my problem.

 

Thanks in advance.

comment_402399

Sadly, almost all of the documentation (even the JavaDocs in the code) is horribly outdated or lacking, as you mentioned.

For your case, the "ItemStack sensitive version" comment refers to the hasContainerItem and getContainerItem in IForgeItem, which Item implements. Basically, just add an ItemStack parameter to the deprecated versions and it will override the new versions.

I'm eager to learn and am prone to mistakes. Don't hesitate to tell me how I can improve.

comment_402438
7 minutes ago, Vinyarion said:

Are you saying you are returning the original ItemStack reference in the getContainerItem method? I'm pretty sure you have to return a new/copy ItemStack, not just the same reference

Depends on what you're doing.

If you're using a tool as an "ingredient" and want to damage the tool, yes, you return the same stack that was passed in (after calling AttemptDamage on it).

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.

comment_402446
33 minutes ago, Cerezo said:

I can't find any docs on ItemStack usage

ItemStack is a vanilla class. It represents a (enchant-able, stack-able, damage-able) form of an Item (which is a prototypical singleton).

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.