Jump to content

DelviousCrafts

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by DelviousCrafts

  1. Thanks for the reply!! I did attempt what you suggested... Attempted exactly as suggested: return (ItemStack.is(TagKeyReference)); requiring a implimentation of: public static final TagKey<Item> TagKeyReference = ItemTags.create(new ResourceLocation("modName", "anyCustomTag")); (with proper imports of course) As well as return (itemStack.is(anyCustomTag)); and return (ItemStack.is("anyCustomTag")); All of which returned an error of: non-static method cannot be referenced from a static context. It seems that the ItemStack.is is from a static boolean in vanilla minecraft code which can't be referenced by the non-static field required by AbstractContainerMenu Supplier. (as otherwise it goes way wonkey with a mess of errors, but just to be sure I did attempt to make this static as well.) Also attempted as: public final TagKey<Item> ItemTagReference = ItemTags.create(new ResourceLocation("modName", "anyCustomTag")); to remove this "static" field just to be sure along with all methods of return listed above. All of which returned the same error as above. Also, correct me if I'm wrong, but as I understand it stack.getItem() is referencing the ItemStack that you're attempting to provide to the slot, therefore I'm not calling Item.is(TagKey<Item>), I'm already referencing ItemStack.is(TagKey<Item>) with the stack.getItem().is code. stack.getItem() is found in the SlotItemHandler of Forge being called by the customSlots reference of new SlotItemHandler which, according to the Forge code, references an itemStack, not an Item direct.
  2. I've built a GUI for an item object that I'm trying to limit the items you can insert into it to specific forge tags using the simplified .is(anyCustomTag) method. I have the container built and working with no issues. The issue I'm running into is when I change from the functioning placeholder: return (Items.STICK == stack.getItem()); to return (stack.getItem().is(anyCustomTag)); for a boolean of true or false as to weather the slot can accept the item in the code. It errors out saying cannot find symbol, and symbol variable is anyCustomTag. I know it's a simple matter of missing imports as I completed this successfully with this exact same method once before by adding a specific set of imports and then my computer froze causing me to loose all my work. I can't for the life of me remember what imports I used to get this working correctly and it's driving me crazy and eclipse doesn't give me auto imports for .is() functionality as it seems to be to common a word for it to find the imports to use or something. current imports in working code with placeholder: return (Items.STICK == stack.getItem()); are: I've poured through forge tags documentation attempting to resolve myself, studying out of the documentation thoroughly. Forge documentation states that Tag-holding registry objects contain a method called #is in either their registry object or state-aware class to check whether the object belongs to a certain tag. From this I concluded that importing ForgeRegistries (with obvious file structure proceeding it) would work. It did not. Then tried importing Item (from minecraft.world.item (as it's my understanding this is the state-aware class)) with no success. I've also scoured the internet. It seems use for the .is() function is not very commonly used considering most people (understandably) don't want to limit what items can be placed into a slot, so not much luck. Imports I've tried: I then attempted a different method of creating a new comparison approach creating a new direct registry in the beginning of the class using: I then began to dig through forge's 1.18.x code on GitHub, looking through literally every class for mention of "boolean is" with the find functionality of my internet browser, and couldn't find it anywhere in the GitHub repository. Plenty of "boolean isSomething" but no plain old "boolean is". Truly I have made (in my opinion) a more than valiant attempt at resolving this on my own with no results. At this point I'm ready to throw in the towel. Someone please assist with what import I'm missing for my class to work, or how I need to adjust the code for it to function as desired. Full code if it helps (erroring code color is changed to yellow for an easier find):
×
×
  • Create New...

Important Information

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