some changes to crafttweaker compat, including removing the domain from recipe names

Closes #43
This commit is contained in:
Ellpeck 2019-03-31 10:21:59 +02:00
parent 1c3c8221bd
commit c21afadced
12 changed files with 46 additions and 25 deletions

View file

@ -1,13 +1,23 @@
# Editing Nature's Aura recipes with CraftTweaker
A few notes that apply for most of the recipe types:
- If you don't know how the CraftTweaker syntax works, [read up on it](https://docs.blamejared.com/en/#Getting_Started/) first.
- `name` is the name of a recipe. For most recipes, the name is important as recipes are referenced by name in the Book of Natural Aura. When replacing an existing recipe, make sure to give it the same name as the original recipe. All recipes are prefixed with `naturesaura:`, and crafting recipes get their name from their [json files](https://github.com/Ellpeck/NaturesAura/tree/master/src/main/resources/assets/naturesaura/recipes) and other recipes get their name from their [registration call](https://github.com/Ellpeck/NaturesAura/blob/master/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java). To see which recipes are referenced where, you can also see the [Patchouli documentation](https://github.com/Ellpeck/NaturesAura/tree/master/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries).
- `IIngredient` is any kind of ingredient, meaning either an OreDictionary entry or an item
- `IItemStack` is an item
- `name` is the name of a recipe. Read on for more information about this.
- `aura` is the amount of Aura required and represents the total amount required for the completion of the recipe (for reference, 1,000,000 is the default amount of Aura present in the world and 2,000,000 is the amount that is required for the Environmental Eye's bar to fill up fully)
- `time` is the time processes take in ticks
- For most removal recipes, `output` is the output of the recipe that should be removed. All recipes with the given outupt will be removed.
## On the Importance of Recipe Names
When replacing an existing recipe with a new one, the `name` variable of the recipe matters greatly, both for Nature's Aura's custom recipe types and for [vanilla crafting recipes](https://crafttweaker.readthedocs.io/en/latest/#Vanilla/Recipes/Crafting/Recipes_Crafting_Table/), if the replacement recipe should be displayed correctly in the Book of Natural Aura in place of the original recipe.
__The replacement recipe that is added for any given item inside of Nature's Aura needs to be named after the item id of the item that is being crafted.__
As an example, the following piece of code will remove the existing recipe of the Imperceptible Builder and replace it with a new one. Checking its Book of Natural Aura entry will then also display the new recipe correctly without errors.
```
recipes.remove(<naturesaura:placer>);
recipes.addShapeless("placer", <naturesaura:placer>, <naturesaura:infused_iron>, <minecraft:piston>);
```
Note that the name of the recipe is supplied as `placer` because the item id of the Imperceptible Builder is `naturesaura:placer`. Not doing this would lead to the Book of Natural Aura not displaying the new recipe.
_When adding a new recipe without replacing an existing one, the name of the newly added recipe does not matter._
## Natural Altar
`mods.naturesaura.Altar.addRecipe(String name, IIngredient input, IItemStack output, IIngredient catalyst, int aura, int time)`

View file

@ -38,7 +38,7 @@ repositories {
}
dependencies {
compile "vazkii.patchouli:Patchouli:1.0-18.93"
compile "vazkii.patchouli:Patchouli:1.0-19.96"
deobfCompile "mezz.jei:jei_1.12.2:4.14.4.267"
deobfCompile "com.azanor.baubles:Baubles:1.12-1.5.2"

View file

@ -4,18 +4,17 @@ import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat;
import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public final class Compat {
public static final String CRAFT_TWEAKER = "crafttweaker";
public static boolean baubles;
public static boolean craftTweaker;
public static boolean mtLib;
public static void preInit() {
baubles = Loader.isModLoaded("baubles");
craftTweaker = Loader.isModLoaded("crafttweaker");
craftTweaker = Loader.isModLoaded(CRAFT_TWEAKER);
mtLib = Loader.isModLoaded("mtlib");
if (baubles)

View file

@ -12,6 +12,7 @@ import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
import de.ellpeck.naturesaura.compat.Compat;
import net.minecraft.util.ResourceLocation;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ -27,7 +28,7 @@ public final class AltarTweaker {
@ZenMethod
public static void addRecipe(String name, IIngredient input, IItemStack output, IIngredient catalyst, int aura, int time) {
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
ResourceLocation res = new ResourceLocation(name);
ResourceLocation res = new ResourceLocation(Compat.CRAFT_TWEAKER, name);
return new Add(Collections.singletonMap(res, new AltarRecipe(res,
CraftTweakerMC.getIngredient(input),
InputHelper.toStack(output),

View file

@ -8,6 +8,7 @@ import crafttweaker.api.minecraft.CraftTweakerMC;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.AnimalSpawnerRecipe;
import de.ellpeck.naturesaura.compat.Compat;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import stanhebben.zenscript.annotations.ZenClass;
@ -24,7 +25,7 @@ public final class AnimalSpawnerTweaker {
@ZenMethod
public static void addRecipe(String name, String entity, int aura, int time, IIngredient[] ingredients) {
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
ResourceLocation res = new ResourceLocation(name);
ResourceLocation res = new ResourceLocation(Compat.CRAFT_TWEAKER, name);
return new Add(Collections.singletonMap(res, new AnimalSpawnerRecipe(res, new ResourceLocation(entity), aura, time,
Arrays.stream(ingredients).map(CraftTweakerMC::getIngredient).toArray(Ingredient[]::new)
)));

View file

@ -13,6 +13,7 @@ import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
import de.ellpeck.naturesaura.api.recipes.ing.AmountIngredient;
import de.ellpeck.naturesaura.compat.Compat;
import net.minecraft.util.ResourceLocation;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ -28,7 +29,7 @@ public final class OfferingTweaker {
@ZenMethod
public static void addRecipe(String name, IIngredient input, int inputAmount, IIngredient startItem, IItemStack output) {
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
ResourceLocation res = new ResourceLocation(name);
ResourceLocation res = new ResourceLocation(Compat.CRAFT_TWEAKER, name);
return new Add(Collections.singletonMap(res, new OfferingRecipe(res,
new AmountIngredient(CraftTweakerMC.getIngredient(input), inputAmount),
CraftTweakerMC.getIngredient(startItem),

View file

@ -12,6 +12,7 @@ import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
import de.ellpeck.naturesaura.compat.Compat;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import stanhebben.zenscript.annotations.ZenClass;
@ -29,7 +30,7 @@ public final class TreeRitualTweaker {
@ZenMethod
public static void addRecipe(String name, IIngredient saplingType, IItemStack result, int time, IIngredient[] items) {
CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> {
ResourceLocation res = new ResourceLocation(name);
ResourceLocation res = new ResourceLocation(Compat.CRAFT_TWEAKER, name);
return new Add(Collections.singletonMap(res, new TreeRitualRecipe(res,
CraftTweakerMC.getIngredient(saplingType),
InputHelper.toStack(result),

View file

@ -3,14 +3,13 @@ package de.ellpeck.naturesaura.compat.patchouli;
import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.multiblock.Matcher;
import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.events.ClientEvents;
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler;
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler.FancyInfo;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.MinecraftForge;
@ -24,6 +23,7 @@ import vazkii.patchouli.api.PatchouliAPI;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.Collections;
import java.util.Map;
public final class PatchouliCompat {
@ -101,4 +101,12 @@ public final class PatchouliCompat {
}
PatchouliAPI.instance.registerMultiblock(name, PatchouliAPI.instance.makeMultiblock(pattern, rawMatchers));
}
public static <T> T getRecipe(Map<ResourceLocation, T> recipes, String name) {
ResourceLocation res = new ResourceLocation(name);
T recipe = recipes.get(res);
if (recipe == null)
recipe = recipes.get(new ResourceLocation(Compat.CRAFT_TWEAKER, res.getPath()));
return recipe;
}
}

View file

@ -3,7 +3,6 @@ package de.ellpeck.naturesaura.compat.patchouli;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.AltarRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import vazkii.patchouli.api.IComponentProcessor;
import vazkii.patchouli.api.IVariableProvider;
import vazkii.patchouli.api.PatchouliAPI;
@ -14,12 +13,13 @@ public class ProcessorAltar implements IComponentProcessor {
@Override
public void setup(IVariableProvider<String> provider) {
ResourceLocation res = new ResourceLocation(provider.get("recipe"));
this.recipe = NaturesAuraAPI.ALTAR_RECIPES.get(res);
this.recipe = PatchouliCompat.getRecipe(NaturesAuraAPI.ALTAR_RECIPES, provider.get("recipe"));
}
@Override
public String process(String key) {
if (this.recipe == null)
return null;
switch (key) {
case "input":
return PatchouliAPI.instance.serializeIngredient(this.recipe.input);

View file

@ -6,7 +6,6 @@ import net.minecraft.client.resources.I18n;
import net.minecraft.init.Items;
import net.minecraft.item.ItemMonsterPlacer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import vazkii.patchouli.api.IComponentProcessor;
@ -19,12 +18,13 @@ public class ProcessorAnimalSpawner implements IComponentProcessor {
@Override
public void setup(IVariableProvider<String> provider) {
ResourceLocation res = new ResourceLocation(provider.get("recipe"));
this.recipe = NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES.get(res);
this.recipe = PatchouliCompat.getRecipe(NaturesAuraAPI.ANIMAL_SPAWNER_RECIPES, provider.get("recipe"));
}
@Override
public String process(String key) {
if (this.recipe == null)
return null;
if (key.startsWith("input")) {
int id = Integer.parseInt(key.substring(5)) - 1;
if (this.recipe.ingredients.length > id)

View file

@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.compat.patchouli;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.OfferingRecipe;
import net.minecraft.util.ResourceLocation;
import vazkii.patchouli.api.IComponentProcessor;
import vazkii.patchouli.api.IVariableProvider;
import vazkii.patchouli.api.PatchouliAPI;
@ -13,12 +12,13 @@ public class ProcessorOffering implements IComponentProcessor {
@Override
public void setup(IVariableProvider<String> provider) {
ResourceLocation res = new ResourceLocation(provider.get("recipe"));
this.recipe = NaturesAuraAPI.OFFERING_RECIPES.get(res);
this.recipe = PatchouliCompat.getRecipe(NaturesAuraAPI.OFFERING_RECIPES, provider.get("recipe"));
}
@Override
public String process(String key) {
if (this.recipe == null)
return null;
switch (key) {
case "input":
return PatchouliAPI.instance.serializeIngredient(this.recipe.input);

View file

@ -2,7 +2,6 @@ package de.ellpeck.naturesaura.compat.patchouli;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe;
import net.minecraft.util.ResourceLocation;
import vazkii.patchouli.api.IComponentProcessor;
import vazkii.patchouli.api.IVariableProvider;
import vazkii.patchouli.api.PatchouliAPI;
@ -13,12 +12,13 @@ public class ProcessorTreeRitual implements IComponentProcessor {
@Override
public void setup(IVariableProvider<String> provider) {
ResourceLocation res = new ResourceLocation(provider.get("recipe"));
this.recipe = NaturesAuraAPI.TREE_RITUAL_RECIPES.get(res);
this.recipe = PatchouliCompat.getRecipe(NaturesAuraAPI.TREE_RITUAL_RECIPES, provider.get("recipe"));
}
@Override
public String process(String key) {
if (this.recipe == null)
return null;
if (key.startsWith("input")) {
int id = Integer.parseInt(key.substring(5)) - 1;
if (this.recipe.ingredients.length > id)