fixed patchouli

This commit is contained in:
Ell 2020-09-22 18:03:56 +02:00
parent 572a63fe20
commit 1337c48f41
9 changed files with 20 additions and 15 deletions

View file

@ -18,6 +18,7 @@ import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.item.crafting.RecipeManager; import net.minecraft.item.crafting.RecipeManager;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.StringTextComponent; 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.DeferredWorkQueue;
import net.minecraftforge.fml.client.gui.GuiUtils; import net.minecraftforge.fml.client.gui.GuiUtils;
import vazkii.patchouli.api.BookDrawScreenEvent; import vazkii.patchouli.api.BookDrawScreenEvent;
import vazkii.patchouli.api.IVariable;
import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.api.PatchouliAPI;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.Month; import java.time.Month;
import java.util.Collections; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
import java.util.Map;
import java.util.Optional;
public class PatchouliCompat implements ICompat { public class PatchouliCompat implements ICompat {
@ -66,6 +66,11 @@ public class PatchouliCompat implements ICompat {
return (T) manager.getRecipe(pre).orElse(null); 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 @Override
public void setup() { public void setup() {
DeferredWorkQueue.runLater(() -> { DeferredWorkQueue.runLater(() -> {

View file

@ -25,12 +25,12 @@ public class ProcessorAltar implements IComponentProcessor {
return null; return null;
switch (key) { switch (key) {
case "input": case "input":
return IVariable.from(this.recipe.input); return PatchouliCompat.ingredientVariable(this.recipe.input);
case "output": case "output":
return IVariable.from(this.recipe.output); return IVariable.from(this.recipe.output);
case "catalyst": case "catalyst":
if (this.recipe.catalyst != Ingredient.EMPTY) if (this.recipe.catalyst != Ingredient.EMPTY)
return IVariable.from(this.recipe.catalyst); return PatchouliCompat.ingredientVariable(this.recipe.catalyst);
else else
return null; return null;
case "type": case "type":

View file

@ -25,7 +25,7 @@ public class ProcessorAnimalSpawner implements IComponentProcessor {
if (key.startsWith("input")) { if (key.startsWith("input")) {
int id = Integer.parseInt(key.substring(5)) - 1; int id = Integer.parseInt(key.substring(5)) - 1;
if (this.recipe.ingredients.length > id) if (this.recipe.ingredients.length > id)
return IVariable.from(this.recipe.ingredients[id]); return PatchouliCompat.ingredientVariable(this.recipe.ingredients[id]);
else else
return null; return null;
} else { } else {

View file

@ -22,11 +22,11 @@ public class ProcessorOffering implements IComponentProcessor {
return null; return null;
switch (key) { switch (key) {
case "input": case "input":
return IVariable.from(this.recipe.input); return PatchouliCompat.ingredientVariable(this.recipe.input);
case "output": case "output":
return IVariable.from(this.recipe.output); return IVariable.from(this.recipe.output);
case "start": case "start":
return IVariable.from(this.recipe.startItem); return PatchouliCompat.ingredientVariable(this.recipe.startItem);
case "name": case "name":
return IVariable.wrap(this.recipe.output.getDisplayName().getString()); return IVariable.wrap(this.recipe.output.getDisplayName().getString());
default: default:

View file

@ -23,7 +23,7 @@ public class ProcessorTreeRitual implements IComponentProcessor {
if (key.startsWith("input")) { if (key.startsWith("input")) {
int id = Integer.parseInt(key.substring(5)) - 1; int id = Integer.parseInt(key.substring(5)) - 1;
if (this.recipe.ingredients.length > id) if (this.recipe.ingredients.length > id)
return IVariable.from(this.recipe.ingredients[id]); return PatchouliCompat.ingredientVariable(this.recipe.ingredients[id]);
else else
return null; return null;
} else { } else {
@ -31,7 +31,7 @@ public class ProcessorTreeRitual implements IComponentProcessor {
case "output": case "output":
return IVariable.from(this.recipe.result); return IVariable.from(this.recipe.result);
case "sapling": case "sapling":
return IVariable.from(this.recipe.saplingType); return PatchouliCompat.ingredientVariable(this.recipe.saplingType);
case "name": case "name":
return IVariable.wrap(this.recipe.result.getDisplayName().getString()); return IVariable.wrap(this.recipe.result.getDisplayName().getString());
default: default:

View file

@ -1,5 +1,5 @@
{ {
"parent": "item/generated", "parent": "minecraft:item/generated",
"textures": { "textures": {
"layer0": "naturesaura:item/book" "layer0": "naturesaura:item/book"
} }

View file

@ -1,5 +1,5 @@
{ {
"parent": "item/generated", "parent": "minecraft:item/generated",
"textures": { "textures": {
"layer0": "naturesaura:item/color_changer" "layer0": "naturesaura:item/color_changer"
}, },

View file

@ -1,5 +1,5 @@
{ {
"parent": "item/generated", "parent": "minecraft:item/generated",
"textures": { "textures": {
"layer0": "naturesaura:item/color_changer_fill_mode", "layer0": "naturesaura:item/color_changer_fill_mode",
"layer1": "naturesaura:item/color_changer_fill_mode_overlay" "layer1": "naturesaura:item/color_changer_fill_mode_overlay"

View file

@ -1,5 +1,5 @@
{ {
"parent": "item/generated", "parent": "minecraft:item/generated",
"textures": { "textures": {
"layer0": "naturesaura:item/color_changer", "layer0": "naturesaura:item/color_changer",
"layer1": "naturesaura:item/color_changer_overlay" "layer1": "naturesaura:item/color_changer_overlay"