From 1337c48f419b2d2e3b8e9220db4a8de404d91a7c Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 22 Sep 2020 18:03:56 +0200 Subject: [PATCH] fixed patchouli --- .../compat/patchouli/PatchouliCompat.java | 13 +++++++++---- .../compat/patchouli/ProcessorAltar.java | 4 ++-- .../compat/patchouli/ProcessorAnimalSpawner.java | 2 +- .../compat/patchouli/ProcessorOffering.java | 4 ++-- .../compat/patchouli/ProcessorTreeRitual.java | 4 ++-- .../assets/naturesaura/models/item/book.json | 2 +- .../naturesaura/models/item/color_changer.json | 2 +- .../models/item/color_changer_fill_mode.json | 2 +- .../models/item/color_changer_filled.json | 2 +- 9 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java index aefb83dd..85245420 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/PatchouliCompat.java @@ -18,6 +18,7 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.inventory.IInventory; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipeType; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.RecipeManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.text.StringTextComponent; @@ -31,14 +32,13 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.DeferredWorkQueue; import net.minecraftforge.fml.client.gui.GuiUtils; import vazkii.patchouli.api.BookDrawScreenEvent; +import vazkii.patchouli.api.IVariable; import vazkii.patchouli.api.PatchouliAPI; import java.time.LocalDateTime; import java.time.Month; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; +import java.util.stream.Collectors; public class PatchouliCompat implements ICompat { @@ -66,6 +66,11 @@ public class PatchouliCompat implements ICompat { return (T) manager.getRecipe(pre).orElse(null); } + public static IVariable ingredientVariable(Ingredient ingredient) { + return IVariable.wrapList(Arrays.stream(ingredient.getMatchingStacks()) + .map(IVariable::from).collect(Collectors.toList())); + } + @Override public void setup() { DeferredWorkQueue.runLater(() -> { diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java index 6741fccb..3be2f7a2 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java @@ -25,12 +25,12 @@ public class ProcessorAltar implements IComponentProcessor { return null; switch (key) { case "input": - return IVariable.from(this.recipe.input); + return PatchouliCompat.ingredientVariable(this.recipe.input); case "output": return IVariable.from(this.recipe.output); case "catalyst": if (this.recipe.catalyst != Ingredient.EMPTY) - return IVariable.from(this.recipe.catalyst); + return PatchouliCompat.ingredientVariable(this.recipe.catalyst); else return null; case "type": diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java index 5a979ad7..6c73a3a0 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAnimalSpawner.java @@ -25,7 +25,7 @@ public class ProcessorAnimalSpawner implements IComponentProcessor { if (key.startsWith("input")) { int id = Integer.parseInt(key.substring(5)) - 1; if (this.recipe.ingredients.length > id) - return IVariable.from(this.recipe.ingredients[id]); + return PatchouliCompat.ingredientVariable(this.recipe.ingredients[id]); else return null; } else { diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorOffering.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorOffering.java index e1f1c00f..43906942 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorOffering.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorOffering.java @@ -22,11 +22,11 @@ public class ProcessorOffering implements IComponentProcessor { return null; switch (key) { case "input": - return IVariable.from(this.recipe.input); + return PatchouliCompat.ingredientVariable(this.recipe.input); case "output": return IVariable.from(this.recipe.output); case "start": - return IVariable.from(this.recipe.startItem); + return PatchouliCompat.ingredientVariable(this.recipe.startItem); case "name": return IVariable.wrap(this.recipe.output.getDisplayName().getString()); default: diff --git a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java index 90514c56..1c5f9260 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java @@ -23,7 +23,7 @@ public class ProcessorTreeRitual implements IComponentProcessor { if (key.startsWith("input")) { int id = Integer.parseInt(key.substring(5)) - 1; if (this.recipe.ingredients.length > id) - return IVariable.from(this.recipe.ingredients[id]); + return PatchouliCompat.ingredientVariable(this.recipe.ingredients[id]); else return null; } else { @@ -31,7 +31,7 @@ public class ProcessorTreeRitual implements IComponentProcessor { case "output": return IVariable.from(this.recipe.result); case "sapling": - return IVariable.from(this.recipe.saplingType); + return PatchouliCompat.ingredientVariable(this.recipe.saplingType); case "name": return IVariable.wrap(this.recipe.result.getDisplayName().getString()); default: diff --git a/src/main/resources/assets/naturesaura/models/item/book.json b/src/main/resources/assets/naturesaura/models/item/book.json index f85844f4..6d67ff2a 100644 --- a/src/main/resources/assets/naturesaura/models/item/book.json +++ b/src/main/resources/assets/naturesaura/models/item/book.json @@ -1,5 +1,5 @@ { - "parent": "item/generated", + "parent": "minecraft:item/generated", "textures": { "layer0": "naturesaura:item/book" } diff --git a/src/main/resources/assets/naturesaura/models/item/color_changer.json b/src/main/resources/assets/naturesaura/models/item/color_changer.json index c528a9a1..83f8aa52 100644 --- a/src/main/resources/assets/naturesaura/models/item/color_changer.json +++ b/src/main/resources/assets/naturesaura/models/item/color_changer.json @@ -1,5 +1,5 @@ { - "parent": "item/generated", + "parent": "minecraft:item/generated", "textures": { "layer0": "naturesaura:item/color_changer" }, diff --git a/src/main/resources/assets/naturesaura/models/item/color_changer_fill_mode.json b/src/main/resources/assets/naturesaura/models/item/color_changer_fill_mode.json index 957fb74a..7c068fff 100644 --- a/src/main/resources/assets/naturesaura/models/item/color_changer_fill_mode.json +++ b/src/main/resources/assets/naturesaura/models/item/color_changer_fill_mode.json @@ -1,5 +1,5 @@ { - "parent": "item/generated", + "parent": "minecraft:item/generated", "textures": { "layer0": "naturesaura:item/color_changer_fill_mode", "layer1": "naturesaura:item/color_changer_fill_mode_overlay" diff --git a/src/main/resources/assets/naturesaura/models/item/color_changer_filled.json b/src/main/resources/assets/naturesaura/models/item/color_changer_filled.json index 23e8337d..4eb43ac7 100644 --- a/src/main/resources/assets/naturesaura/models/item/color_changer_filled.json +++ b/src/main/resources/assets/naturesaura/models/item/color_changer_filled.json @@ -1,5 +1,5 @@ { - "parent": "item/generated", + "parent": "minecraft:item/generated", "textures": { "layer0": "naturesaura:item/color_changer", "layer1": "naturesaura:item/color_changer_overlay"