Jump to content

[1.14.4] Modifying an ItemStack with a custom crafting recipe?


Recommended Posts

Posted (edited)

I have a class for an Item (in this case it extends ArmorItem) with some boolean values. I want to have a recipe that will switch these boolean values, and it depends on the actual Items in the recipe. The main Item is something like a piece of armor, the other is some item that will change the properties of the armor (through the use of the booleans) but keep everything else: durability, enchantments, ect.

I am realizing the class will only be instantiated once for all ItemStacks of this Item, so I suppose I would need to store the information in the ItemStack NBT data or something, but I still need to do something when the crafting takes place.

 

I'm fairly certain the json recipes won't do anything like this, so I need to have it in code. How can this be done?

In the future, for Minecraft 1.16+, I would like to use the smithing table in sort of the same way where the item is upgraded but I don't want another Item, the Item will be the same because there will be many variations and they won't be that much different.

Edited by Invilis
Posted (edited)

That's good, but not quite there yet. I need some way to tell what Item I am using in the recipe because it will have a specific effect. Using getContainerItem I can change the resulting Item but I need the change to depend on what the secondary Item was.

 

The only thing I can think of is to make a custom crafting table block, that way I could have complete control over the ItemStacks involved, at least that's my theory. A game theory.

Edited by Invilis
Posted

I believe you'll need to subclass net.minecraft.item.crafting.SpecialRecipe to create a special crafting recipe (look at ArmorDyeRecipe)

 

Then you need to register a recipe serializer for said SpecialRecipe.

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.