Jump to content

Recommended Posts

Posted

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.

Posted
3 minutes ago, Cerezo said:

see Botania's Mortar and Pestle

You know Botania's code is open source, right? If you don't here's it's GitHub page.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted

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.

Posted

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

Have you ever want the new operator to return a type that you didn't ask for? Well, now you can!

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

Posted
10 minutes ago, Vinyarion said:

returning the original ItemStack

I'm saying I can't find any docs on ItemStack usage, so I'm not using it at all. imacatlol's comment helped. The tool will not recieve damage, by the way.

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

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