Skip to content

Instantly share code, notes, and snippets.

@LexManos
Last active September 30, 2018 13:45
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LexManos/2a11d4f7aa9d680d861dae4faf9dcfa6 to your computer and use it in GitHub Desktop.
Save LexManos/2a11d4f7aa9d680d861dae4faf9dcfa6 to your computer and use it in GitHub Desktop.
1.12 Recipe enhancements
Basic loading.
To be done on ServerInit. This means things will load multiple times on the client.
Benifits:
Allows us to just nuke the custom recipes every server init
Allows us to have save leve overrides.
Primes us for syncing recipe types/contents S->C {Not gunna happen in 1.12, but I expect Mojang to work twards this in 1.13+}
Cons:
Increases single player server load time. No known stats at the moment but shouldn't be TO bad
Loading Process:
BootStrap: Vanilla loads their internal recipes, we'll freeze this registry and revert to it at the beginning of ServerInit
Gather Factories:
Gather a list of IRecipe, and Ingredient factories.
Loop through all mod jars/directories and load /assets/MODID/recipes/_factories.json
Names will automatically be prefixed with modid domains. Error if name contains : to dissallow overriding other's factories
Gather Constants:
Done as a second pass to allow modders to depend on other mods ingredient factories
Loop through all mods, loading /assets/MODID/recipes/_constants.json
Add to a central dictionary as modid:name, so mods can't overlap eachother. Again, error if people try to overwrite other's
Load jsons from Mod Jars:
Loop through all mods, loading /assets/MODID/recipes/[!_factories && !_constants].json
Register to central regirsty as modid:jsonFileName like vanilla does
Fire RegistryEvent.Register<IRecipe>:
Fire code event to allow people to create recipes in code?
Loading from modpack/config folder?
Check Forge config for a 'recipes_folder', or explicitly check GameDir/custom_recipes and load all recipes there.
Loads from all asset domains, automatically skipping the ones that do not match a loaded modid.
This should behave the same as loading from a single jar file.
Should we add a global FACTORIES/CONSTANTS json?
Loading from world folder?
Same as loading from modpacks folder but happens afterwords so that worlds override both modpacks and jars.
Conditions:
Simple conditions to determine if we should load the recipe, or set the constant.
All entries must return true.
Allow custom condition types defined in FACTORIES?
Types to add:
mod_loaded: modid
item_exists: itemname
not: [conditions] -- Inverts a condition, can be nested
or: condition1, condition2
[
{
"conditions": [
{
"type": "mod_loaded",
"mod": "minecraft"
}
],
"name" : "PLANKS",
"ingredient" : {
"type" : "ore_dict",
"ore" : "planks"
}
},
{
"conditions": [
{
"type": "mod_loaded",
"mod": "xycraft"
}
],
"name": "PLANKS",
"ingredient" : {
"item" : "xycraft:planks"
}
},
{
"name": "OAK_OR_SPRUCE",
"ingredient": [
{
"item": "minecraft:log",
"data" : 0
},
{
"item": "minecraft:log",
"data" : 2
}
],
},
{
"name": "MIXED",
"ingredient": [
{
"type": "ore_dict",
"ore": "stick"
},
{
"item": "minecraft:torch"
}
]
},
{
"name": "PigEgg",
"ingredient": {
"type": "itemstack_nbt",
"item": "minecraft:mobegg",
"nbt": {
"entityId": "pig"
}
}
}
]
{
"ingredients" : {
"ore_dict": "net.minecraftforge.oredict.OreIngredientFactory",
"itemstack_nbt": "net.minecraftforge.util.NBTIngredientFactory",
},
"recipes" : {
"shapeless_ore" : "net.minecraftforge.oredict.ShapelessOreRecipeFactory",
"shaped_ore" : "net.minecraftforge.oredict.ShapedOreRecipeFactory"
}
}
{
"conditions": [
{
"type": "mod_loaded",
"mod": "minecraft"
}
],
"type": "minecraft:crafting_shaped",
"group": "random_things",
"pattern": [
"###",
"XXX"
],
"key": {
"#": {
"item": "#PLANKS"
},
"X": [
{
"item": "#PLANKS"
},
{
"item": "#MIXED",
},
{
"item": "minecraft:planks",
"data": 2
}
]
},
"result": {
"item": "minecraft:bed",
"data": 15
}
}
@Gaelan
Copy link

Gaelan commented Jun 14, 2017

The new constant system feels kind of redundant with oredict. Would it be possible to replace oredict with a "global" namespace for constants? Then mods could just add their wood blocks to global:LogWood in their constants.json.

@Alpvax
Copy link

Alpvax commented Jun 14, 2017

@Gaelan That just results in a json configurable oredict. I'm not sure that is beneficial.

Having runtime condition factories would be useful, they could be added as ingredients in json for more advanced modpack configuration.

@TechnicianLP
Copy link

TechnicianLP commented Jun 15, 2017

can it be made possible to specify multiple Recipes in one json? ie replace the top JsonObject witn an JsonArray, which then in return contains multiple JsonObjects (which have to be given a individual name manually)

@Dhranios
Copy link

I actually made a different recipes format as well; perhaps you could look into it, it may be of use to you too.
https://github.com/FVbico/MinecraftData/tree/master/minecraft/assets/server/recipes

@KitsuneAlex
Copy link

alright, RegistryEvent you are my friend

@TehenoPengin
Copy link

Thanks for leaving RegistryEvent option :P

@LexManos
Copy link
Author

Don't expect it as of 1.13, Its only in because I know people will bitch if its removed directly.
This is a first round of the json format. Its not perfect but its functional for 99% of use cases.

@MCOfficer
Copy link

MCOfficer commented Nov 5, 2017

i might be a bit late, but is there a way to set the amount of results? (e.g pumpkin -> pumpkin seeds)

@SkyBlade1978
Copy link

Is there any update on the correct procedure for removing a vanilla recipe in 1.12?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment