Share this post

Link to post

Share on other sites

I'm not entirely sure but you might be able to qualify the NBT by treating the ingredient at a conditional ingredient. If you want conditional ingredients, you'll need to create an IIngredientFactory and specify it in _factories.json. In the IIngredientFactory, you can use CraftingHelper.processConditions to check if the conditions are met. If they are, return an Ingredient instance for the specified item; if they aren't, return Ingredient.EMPTY (an Ingredient that never matches any ItemStack). You can see an example implementation by Choonster here.

Share this post

Link to post

Share on other sites

You'll need to create a copy of IngredientNBT and override Ingredient#apply to perform a partial NBT match instead of a full NBT match.

You'll then need to create an implementation of IIngredientFactory that creates an instance of the Ingredient class from the provided JSON object; you can use CraftingHelper.getItemStack to parse an ItemStack from JSON.

Register this factory by adding the fully-qualified name to your _factories.json file; you can see an example here.

The name you specify for the factory in _factories.json is the name you'll use in the type property of the ingredients in your recipe files.

Edit: You might want to use an NBTPredicate for the NBT matching rather than storing a full ItemStack.

2 hours ago, jabelar said:

I'm not entirely sure but you might be able to qualify the NBT by treating the ingredient at a conditional ingredient. If you want conditional ingredients, you'll need to create an IIngredientFactory and specify it in _factories.json. In the IIngredientFactory, you can use CraftingHelper.processConditions to check if the conditions are met. If they are, return an Ingredient instance for the specified item; if they aren't, return Ingredient.EMPTY (an Ingredient that never matches any ItemStack). You can see an example implementation by Choonster here.

Alternatively, maybe you need to make a custom IRecipe.

This isn't really what the OP is looking for, since the conditions are only evaluated once when the recipe is loaded.

Share this post

Link to post

Share on other sites

Enchantments are managed by a Forge registry, so the numeric IDs are automatically assigned per-save and shouldn't be used. Use the registry name in the JSON instead and store the Enchantment instance in the Ingredient for matching.

Hi there,
I want to use my custom 3D Models I created, but I don't understand how to render and bake custom 3D OBJ Models, or if it is even possible.
Here is what I got so far:
public class BakeHandler {
public BakeHandler() {
OBJLoader.INSTANCE.addDomain(HelicopterMod.MOD_ID);
}
@SubscribeEvent
public void onModelBake(ModelBakeEvent event)
{
try
{
IUnbakedModel model = OBJLoader.INSTANCE.loadModel(new ResourceLocation(HelicopterMod.MOD_ID, "models/entity/helicopter_tris.obj"));
//model.bake(bakery, spriteGetter, sprite, format);
} catch (Exception e)
{
e.printStackTrace();
}
}
}
I simply don't know where to continue now, as I don't find any currently working example or explanation.
Does anyone of you guys know an example I can look at, or a good explanation on how to use OBJ models for entities?
Would appreciate any help

How do you create a multi project work-space in Eclipse?
I want to build a mod that has an optional dependency and a mandatory dependency.
I recently learned basic java code and how to make simple mods with new recipes, tools, blocks, armor, ore gen, that sort of stuff...
Now I want to learn how to use API's and call items from other mods but every time I try to import other mods into my work space I have issues.
How Do I set up a multi project work space?