diff --git a/build.gradle b/build.gradle index a14c7589..76e127e0 100644 --- a/build.gradle +++ b/build.gradle @@ -38,7 +38,7 @@ repositories { } dependencies { - compile "vazkii.patchouli:Patchouli:1.0-6.8" + compile "vazkii.patchouli:Patchouli:1.0-10.45" deobfCompile "mezz.jei:jei_1.12.2:4.13.1.220" deobfCompile "com.azanor.baubles:Baubles:1.12-1.5.2" diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 2d1ee89f..b3a197e4 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -14,6 +14,7 @@ import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.NBTBase; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -28,6 +29,7 @@ import net.minecraft.world.gen.ChunkProviderServer; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.crafting.IngredientNBT; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.items.IItemHandlerModifiable; @@ -221,4 +223,20 @@ public final class Helper { } }, () -> null); } + + public static Ingredient nbtIng(ItemStack stack) { + return new IngredientNBTPublic(stack); + } + + public static Ingredient blockIng(Block block) { + return Ingredient.fromStacks(new ItemStack(block)); + } + + private static class IngredientNBTPublic extends IngredientNBT { + + //Why is this protected in the original class, we will never know + public IngredientNBTPublic(ItemStack stack) { + super(stack); + } + } } diff --git a/src/main/java/de/ellpeck/naturesaura/api/recipes/AltarRecipe.java b/src/main/java/de/ellpeck/naturesaura/api/recipes/AltarRecipe.java index 0b41e6cf..a04862ad 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/recipes/AltarRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/api/recipes/AltarRecipe.java @@ -1,20 +1,20 @@ package de.ellpeck.naturesaura.api.recipes; import de.ellpeck.naturesaura.api.NaturesAuraAPI; -import net.minecraft.block.Block; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; public class AltarRecipe { public final ResourceLocation name; - public final ItemStack input; + public final Ingredient input; public final ItemStack output; - public final Block catalyst; + public final Ingredient catalyst; public final int aura; public final int time; - public AltarRecipe(ResourceLocation name, ItemStack input, ItemStack output, Block catalyst, int aura, int time) { + public AltarRecipe(ResourceLocation name, Ingredient input, ItemStack output, Ingredient catalyst, int aura, int time) { this.name = name; this.input = input; this.output = output; @@ -23,10 +23,6 @@ public class AltarRecipe { this.time = time; } - public boolean matches(ItemStack found) { - return ItemStack.areItemsEqual(this.input, found) && ItemStack.areItemStackShareTagsEqual(this.input, found); - } - public AltarRecipe register() { NaturesAuraAPI.ALTAR_RECIPES.put(this.name, this); return this; diff --git a/src/main/java/de/ellpeck/naturesaura/api/recipes/TreeRitualRecipe.java b/src/main/java/de/ellpeck/naturesaura/api/recipes/TreeRitualRecipe.java index 1f7690f8..7d1c16be 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/recipes/TreeRitualRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/api/recipes/TreeRitualRecipe.java @@ -2,28 +2,25 @@ package de.ellpeck.naturesaura.api.recipes; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; public class TreeRitualRecipe { public final ResourceLocation name; - public final ItemStack saplingType; - public final ItemStack[] items; + public final Ingredient saplingType; + public final Ingredient[] ingredients; public final ItemStack result; public final int time; - public TreeRitualRecipe(ResourceLocation name, ItemStack saplingType, ItemStack result, int time, ItemStack... items) { + public TreeRitualRecipe(ResourceLocation name, Ingredient saplingType, ItemStack result, int time, Ingredient... ingredients) { this.name = name; this.saplingType = saplingType; - this.items = items; + this.ingredients = ingredients; this.result = result; this.time = time; } - public boolean matches(ItemStack expected, ItemStack found) { - return ItemStack.areItemsEqual(expected, found) && ItemStack.areItemStackShareTagsEqual(expected, found); - } - public TreeRitualRecipe register() { NaturesAuraAPI.TREE_RITUAL_RECIPES.put(this.name, this); return this; diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java index 87a2407b..08cbfb9b 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockWoodStand.java @@ -11,6 +11,7 @@ import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; @@ -50,8 +51,8 @@ public class BlockWoodStand extends BlockContainerImpl { ItemStack saplingStack = sapling.getBlock().getItem(world, pos, sapling); if (!saplingStack.isEmpty()) { for (TreeRitualRecipe recipe : NaturesAuraAPI.TREE_RITUAL_RECIPES.values()) { - if (Helper.areItemsEqual(saplingStack, recipe.saplingType, true)) { - List required = new ArrayList<>(Arrays.asList(recipe.items)); + if (recipe.saplingType.apply(saplingStack)) { + List required = new ArrayList<>(Arrays.asList(recipe.ingredients)); MutableObject toPick = new MutableObject<>(); boolean fine = Multiblocks.TREE_RITUAL.forEach(pos, 'W', (tilePos, matcher) -> { @@ -61,8 +62,8 @@ public class BlockWoodStand extends BlockContainerImpl { ItemStack stack = stand.items.getStackInSlot(0); if (!stack.isEmpty()) { for (int i = required.size() - 1; i >= 0; i--) { - ItemStack req = required.get(i); - if (recipe.matches(req, stack)) { + Ingredient req = required.get(i); + if (req.apply(stack)) { required.remove(i); if (toPick.getValue() == null) { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java index 8379273e..719938b5 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityNatureAltar.java @@ -14,6 +14,7 @@ import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; @@ -115,7 +116,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { this.currentRecipe = getRecipeForInput(stack); } } else { - if (stack.isEmpty() || !this.currentRecipe.matches(stack)) { + if (stack.isEmpty() || !this.currentRecipe.input.apply(stack)) { this.currentRecipe = null; this.timer = 0; } else if (this.hasCatalyst(this.currentRecipe.catalyst)) { @@ -180,21 +181,23 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { private static AltarRecipe getRecipeForInput(ItemStack input) { for (AltarRecipe recipe : NaturesAuraAPI.ALTAR_RECIPES.values()) { - if (recipe.matches(input)) { + if (recipe.input.apply(input)) { return recipe; } } return null; } - private boolean hasCatalyst(Block block) { - if (block == null) + private boolean hasCatalyst(Ingredient catalyst) { + if (catalyst == Ingredient.EMPTY) return true; for (int x = -2; x <= 2; x += 4) { for (int z = -2; z <= 2; z += 4) { - IBlockState state = this.world.getBlockState(this.pos.add(x, 1, z)); - if (state.getBlock() == block) + BlockPos offset = this.pos.add(x, 1, z); + IBlockState state = this.world.getBlockState(offset); + ItemStack stack = state.getBlock().getItem(this.world, offset, state); + if (catalyst.apply(stack)) return true; } } @@ -205,7 +208,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { public void writeNBT(NBTTagCompound compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) { - compound.setTag("items", this.items.serializeNBT()); + compound.setTag("ingredients", this.items.serializeNBT()); compound.setBoolean("fine", this.structureFine); this.container.writeNBT(compound); } @@ -221,7 +224,7 @@ public class TileEntityNatureAltar extends TileEntityImpl implements ITickable { public void readNBT(NBTTagCompound compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) { - this.items.deserializeNBT(compound.getCompoundTag("items")); + this.items.deserializeNBT(compound.getCompoundTag("ingredients")); this.structureFine = compound.getBoolean("fine"); this.container.readNBT(compound); } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java index 624d7120..484f936d 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityOfferingTable.java @@ -12,7 +12,7 @@ public class TileEntityOfferingTable extends TileEntityImpl { public void writeNBT(NBTTagCompound compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) { - compound.setTag("items", this.items.serializeNBT()); + compound.setTag("ingredients", this.items.serializeNBT()); } } @@ -20,7 +20,7 @@ public class TileEntityOfferingTable extends TileEntityImpl { public void readNBT(NBTTagCompound compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) { - this.items.deserializeNBT(compound.getCompoundTag("items")); + this.items.deserializeNBT(compound.getCompoundTag("ingredients")); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java index ef1adfd1..005cc352 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityPlacer.java @@ -149,13 +149,13 @@ public class TileEntityPlacer extends TileEntityImpl implements ITickable { public void readNBT(NBTTagCompound compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) - this.handler.deserializeNBT(compound.getCompoundTag("items")); + this.handler.deserializeNBT(compound.getCompoundTag("ingredients")); } @Override public void writeNBT(NBTTagCompound compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) - compound.setTag("items", this.handler.serializeNBT()); + compound.setTag("ingredients", this.handler.serializeNBT()); } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java index 7d764320..fc2d58a8 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityWoodStand.java @@ -12,6 +12,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -145,15 +146,15 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { return false; } if (this.timer < this.recipe.time / 2) { - List required = new ArrayList<>(Arrays.asList(this.recipe.items)); + List required = new ArrayList<>(Arrays.asList(this.recipe.ingredients)); boolean fine = Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'W', (pos, matcher) -> { TileEntity tile = this.world.getTileEntity(pos); if (tile instanceof TileEntityWoodStand) { ItemStack stack = ((TileEntityWoodStand) tile).items.getStackInSlot(0); if (!stack.isEmpty()) { for (int i = required.size() - 1; i >= 0; i--) { - ItemStack req = required.get(i); - if (this.recipe.matches(req, stack)) { + Ingredient req = required.get(i); + if (req.apply(stack)) { required.remove(i); return true; } @@ -172,7 +173,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { public void writeNBT(NBTTagCompound compound, SaveType type) { super.writeNBT(compound, type); if (type != SaveType.BLOCK) - compound.setTag("items", this.items.serializeNBT()); + compound.setTag("ingredients", this.items.serializeNBT()); if (type == SaveType.TILE) { if (this.ritualPos != null && this.recipe != null) { @@ -187,7 +188,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickable { public void readNBT(NBTTagCompound compound, SaveType type) { super.readNBT(compound, type); if (type != SaveType.BLOCK) - this.items.deserializeNBT(compound.getCompoundTag("items")); + this.items.deserializeNBT(compound.getCompoundTag("ingredients")); if (type == SaveType.TILE) { if (compound.hasKey("recipe")) { diff --git a/src/main/java/de/ellpeck/naturesaura/compat/crafttweaker/AltarTweaker.java b/src/main/java/de/ellpeck/naturesaura/compat/crafttweaker/AltarTweaker.java index 3943ce40..58a1ab34 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/crafttweaker/AltarTweaker.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/crafttweaker/AltarTweaker.java @@ -10,8 +10,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 net.minecraft.block.Block; -import net.minecraft.init.Blocks; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -27,12 +26,11 @@ public final class AltarTweaker { @ZenMethod public static void addRecipe(String name, IItemStack input, IItemStack output, IItemStack catalyst, int aura, int time) { CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> { - Block block = Block.getBlockFromItem(InputHelper.toStack(catalyst).getItem()); ResourceLocation res = new ResourceLocation(name); return new Add(Collections.singletonMap(res, new AltarRecipe(res, - InputHelper.toStack(input), + Helper.nbtIng(InputHelper.toStack(input)), InputHelper.toStack(output), - block == Blocks.AIR ? null : block, + Ingredient.fromStacks(InputHelper.toStack(catalyst)), aura, time))); }); } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/crafttweaker/TreeRitualTweaker.java b/src/main/java/de/ellpeck/naturesaura/compat/crafttweaker/TreeRitualTweaker.java index f07655b8..03720cc0 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/crafttweaker/TreeRitualTweaker.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/crafttweaker/TreeRitualTweaker.java @@ -10,10 +10,12 @@ import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -27,10 +29,10 @@ public final class TreeRitualTweaker { CraftTweakerCompat.SCHEDULED_ACTIONS.add(() -> { ResourceLocation res = new ResourceLocation(name); return new Add(Collections.singletonMap(res, new TreeRitualRecipe(res, - InputHelper.toStack(saplingType), + Ingredient.fromStacks(InputHelper.toStack(saplingType)), InputHelper.toStack(result), time, - InputHelper.toStacks(items) + Arrays.stream(items).map(item -> Helper.nbtIng(InputHelper.toStack(item))).toArray(Ingredient[]::new) ))); }); } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarCategory.java index f2a4a699..2d039cd6 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarCategory.java @@ -1,9 +1,9 @@ package de.ellpeck.naturesaura.compat.jei.altar; import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.api.recipes.AltarRecipe; import de.ellpeck.naturesaura.blocks.ModBlocks; import de.ellpeck.naturesaura.compat.jei.JEINaturesAuraPlugin; -import de.ellpeck.naturesaura.api.recipes.AltarRecipe; import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; @@ -12,8 +12,12 @@ import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; +import java.util.Arrays; +import java.util.Collections; + public class AltarCategory implements IRecipeCategory { private final IDrawable background; @@ -48,10 +52,11 @@ public class AltarCategory implements IRecipeCategory { IGuiItemStackGroup group = recipeLayout.getItemStacks(); AltarRecipe recipe = recipeWrapper.recipe; group.init(0, true, 0, 18); - group.set(0, recipe.input); + group.set(0, Arrays.asList(recipe.input.getMatchingStacks())); group.init(1, false, 56, 18); group.set(1, recipe.output); group.init(2, true, 26, 18); - group.set(2, recipe.catalyst == null ? this.altar : new ItemStack(recipe.catalyst)); + group.set(2, recipe.catalyst == Ingredient.EMPTY ? + Collections.singletonList(this.altar) : Arrays.asList(recipe.catalyst.getMatchingStacks())); } } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarWrapper.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarWrapper.java index b0be40b1..7d5c81e5 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarWrapper.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/altar/AltarWrapper.java @@ -1,12 +1,12 @@ package de.ellpeck.naturesaura.compat.jei.altar; +import com.google.common.collect.ImmutableList; import de.ellpeck.naturesaura.api.recipes.AltarRecipe; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.item.ItemStack; - -import java.util.Arrays; +import net.minecraft.item.crafting.Ingredient; public class AltarWrapper implements IRecipeWrapper { @@ -18,7 +18,11 @@ public class AltarWrapper implements IRecipeWrapper { @Override public void getIngredients(IIngredients ingredients) { - ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(this.recipe.input, new ItemStack(this.recipe.catalyst))); + ImmutableList.Builder builder = ImmutableList.builder(); + builder.add(this.recipe.input.getMatchingStacks()); + if (this.recipe.catalyst != Ingredient.EMPTY) + builder.add(this.recipe.catalyst.getMatchingStacks()); + ingredients.setInputs(VanillaTypes.ITEM, builder.build()); ingredients.setOutput(VanillaTypes.ITEM, this.recipe.output); } } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualCategory.java index e5a95d60..cefee019 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualCategory.java @@ -1,8 +1,8 @@ package de.ellpeck.naturesaura.compat.jei.treeritual; import de.ellpeck.naturesaura.NaturesAura; -import de.ellpeck.naturesaura.compat.jei.JEINaturesAuraPlugin; import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; +import de.ellpeck.naturesaura.compat.jei.JEINaturesAuraPlugin; import mezz.jei.api.IGuiHelper; import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IGuiItemStackGroup; @@ -12,6 +12,8 @@ import mezz.jei.api.recipe.IRecipeCategory; import net.minecraft.client.resources.I18n; import net.minecraft.util.ResourceLocation; +import java.util.Arrays; + public class TreeRitualCategory implements IRecipeCategory { private final IDrawable background; @@ -46,15 +48,15 @@ public class TreeRitualCategory implements IRecipeCategory { TreeRitualRecipe recipe = recipeWrapper.recipe; group.init(0, true, 34, 34); - group.set(0, recipe.saplingType); + group.set(0, Arrays.asList(recipe.saplingType.getMatchingStacks())); group.init(1, true, 124, 34); group.set(1, recipe.result); int[][] positions = new int[][]{{35, 1}, {35, 69}, {1, 35}, {69, 35}, {12, 12}, {58, 58}, {58, 12}, {12, 58}}; - for (int i = 0; i < recipe.items.length; i++) { + for (int i = 0; i < recipe.ingredients.length; i++) { group.init(i + 2, true, positions[i][0] - 1, positions[i][1] - 1); - group.set(i + 2, recipe.items[i]); + group.set(i + 2, Arrays.asList(recipe.ingredients[i].getMatchingStacks())); } } } diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualWrapper.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualWrapper.java index fe1e6b86..e834e3b1 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualWrapper.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/treeritual/TreeRitualWrapper.java @@ -1,14 +1,12 @@ package de.ellpeck.naturesaura.compat.jei.treeritual; +import com.google.common.collect.ImmutableList; import de.ellpeck.naturesaura.api.recipes.TreeRitualRecipe; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IRecipeWrapper; import net.minecraft.item.ItemStack; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import net.minecraft.item.crafting.Ingredient; public class TreeRitualWrapper implements IRecipeWrapper { @@ -20,9 +18,11 @@ public class TreeRitualWrapper implements IRecipeWrapper { @Override public void getIngredients(IIngredients ingredients) { - List inputs = new ArrayList<>(Arrays.asList(this.recipe.items)); - inputs.add(this.recipe.saplingType); - ingredients.setInputs(VanillaTypes.ITEM, inputs); + ImmutableList.Builder builder = ImmutableList.builder(); + for (Ingredient ing : this.recipe.ingredients) + builder.add(ing.getMatchingStacks()); + builder.add(this.recipe.saplingType.getMatchingStacks()); + ingredients.setInputs(VanillaTypes.ITEM, builder.build()); ingredients.setOutput(VanillaTypes.ITEM, this.recipe.result); } } 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 6a2a50ed..4b12d8cd 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorAltar.java @@ -2,7 +2,7 @@ package de.ellpeck.naturesaura.compat.patchouli; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.recipes.AltarRecipe; -import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; import vazkii.patchouli.api.IComponentProcessor; import vazkii.patchouli.api.IVariableProvider; @@ -22,12 +22,12 @@ public class ProcessorAltar implements IComponentProcessor { public String process(String key) { switch (key) { case "input": - return PatchouliAPI.instance.serializeItemStack(this.recipe.input); + return PatchouliAPI.instance.serializeIngredient(this.recipe.input); case "output": return PatchouliAPI.instance.serializeItemStack(this.recipe.output); case "catalyst": - if (this.recipe.catalyst != null) - return PatchouliAPI.instance.serializeItemStack(new ItemStack(this.recipe.catalyst)); + if (this.recipe.catalyst != Ingredient.EMPTY) + return PatchouliAPI.instance.serializeIngredient(this.recipe.catalyst); else return null; case "name": @@ -39,6 +39,6 @@ public class ProcessorAltar implements IComponentProcessor { @Override public boolean allowRender(String group) { - return group.isEmpty() || group.equals(this.recipe.catalyst == null ? "altar" : "catalyst"); + return group.isEmpty() || group.equals(this.recipe.catalyst == Ingredient.EMPTY ? "altar" : "catalyst"); } } 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 9f975bc2..4a0da84d 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/patchouli/ProcessorTreeRitual.java @@ -21,8 +21,8 @@ public class ProcessorTreeRitual implements IComponentProcessor { public String process(String key) { if (key.startsWith("input")) { int id = Integer.parseInt(key.substring(5)) - 1; - if (this.recipe.items.length > id) - return PatchouliAPI.instance.serializeItemStack(this.recipe.items[id]); + if (this.recipe.ingredients.length > id) + return PatchouliAPI.instance.serializeIngredient(this.recipe.ingredients[id]); else return null; } else { @@ -30,7 +30,7 @@ public class ProcessorTreeRitual implements IComponentProcessor { case "output": return PatchouliAPI.instance.serializeItemStack(this.recipe.result); case "sapling": - return PatchouliAPI.instance.serializeItemStack(this.recipe.saplingType); + return PatchouliAPI.instance.serializeIngredient(this.recipe.saplingType); case "name": return this.recipe.result.getDisplayName(); default: diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemShockwaveCreator.java b/src/main/java/de/ellpeck/naturesaura/items/ItemShockwaveCreator.java index 59781ab8..94aff282 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ItemShockwaveCreator.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemShockwaveCreator.java @@ -37,7 +37,7 @@ import java.util.List; public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem { - private static final ResourceLocation RES_WORN = new ResourceLocation(NaturesAura.MOD_ID, "textures/items/shockwave_creator_player.png"); + private static final ResourceLocation RES_WORN = new ResourceLocation(NaturesAura.MOD_ID, "textures/ingredients/shockwave_creator_player.png"); public ItemShockwaveCreator() { super("shockwave_creator"); diff --git a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java index 4f8fcd3a..9d0fcb08 100644 --- a/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java +++ b/src/main/java/de/ellpeck/naturesaura/recipes/ModRecipes.java @@ -1,5 +1,6 @@ package de.ellpeck.naturesaura.recipes; +import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.recipes.AltarRecipe; @@ -10,67 +11,69 @@ import de.ellpeck.naturesaura.items.ModItems; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; public final class ModRecipes { public static void init() { new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "eye"), - new ItemStack(Blocks.SAPLING), new ItemStack(ModItems.EYE), 250, - new ItemStack(Items.SPIDER_EYE), - new ItemStack(Items.GOLD_INGOT), - new ItemStack(ModItems.GOLD_LEAF), - new ItemStack(ModItems.GOLD_LEAF)).register(); + Ingredient.fromStacks(new ItemStack(Blocks.SAPLING)), new ItemStack(ModItems.EYE), 250, + Ingredient.fromItem(Items.SPIDER_EYE), + Ingredient.fromItem(Items.GOLD_INGOT), + Ingredient.fromItem(ModItems.GOLD_LEAF), + Ingredient.fromItem(ModItems.GOLD_LEAF)).register(); new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "nature_altar"), - new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.NATURE_ALTAR), 500, - new ItemStack(Blocks.STONE), - new ItemStack(Blocks.STONE), - new ItemStack(Blocks.STONE), - new ItemStack(ModItems.GOLD_LEAF), - new ItemStack(Items.GOLD_INGOT), - ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), NaturesAuraAPI.TYPE_OVERWORLD)).register(); + Helper.blockIng(Blocks.SAPLING), new ItemStack(ModBlocks.NATURE_ALTAR), 500, + Helper.blockIng(Blocks.STONE), + Helper.blockIng(Blocks.STONE), + Helper.blockIng(Blocks.STONE), + Ingredient.fromItem(ModItems.GOLD_LEAF), + Ingredient.fromItem(Items.GOLD_INGOT), + Helper.nbtIng(ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), NaturesAuraAPI.TYPE_OVERWORLD))).register(); new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "ancient_sapling"), - new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.ANCIENT_SAPLING), 200, - new ItemStack(Blocks.SAPLING), - new ItemStack(Blocks.YELLOW_FLOWER), - new ItemStack(Blocks.RED_FLOWER), - new ItemStack(Items.WHEAT_SEEDS), - new ItemStack(Items.REEDS), - new ItemStack(ModItems.GOLD_LEAF)).register(); + Helper.blockIng(Blocks.SAPLING), new ItemStack(ModBlocks.ANCIENT_SAPLING), 200, + Helper.blockIng(Blocks.SAPLING), + Helper.blockIng(Blocks.YELLOW_FLOWER), + Helper.blockIng(Blocks.RED_FLOWER), + Ingredient.fromItem(Items.WHEAT_SEEDS), + Ingredient.fromItem(Items.REEDS), + Ingredient.fromItem(ModItems.GOLD_LEAF)).register(); new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "furnace_heater"), - new ItemStack(Blocks.SAPLING), new ItemStack(ModBlocks.FURNACE_HEATER), 600, - new ItemStack(ModBlocks.INFUSED_STONE), - new ItemStack(ModBlocks.INFUSED_STONE), - new ItemStack(ModItems.INFUSED_IRON), - new ItemStack(ModItems.INFUSED_IRON), - new ItemStack(Items.FIRE_CHARGE), - new ItemStack(Items.FLINT), - new ItemStack(Blocks.MAGMA), - ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), NaturesAuraAPI.TYPE_NETHER)).register(); + Helper.blockIng(Blocks.SAPLING), new ItemStack(ModBlocks.FURNACE_HEATER), 600, + Helper.blockIng(ModBlocks.INFUSED_STONE), + Helper.blockIng(ModBlocks.INFUSED_STONE), + Ingredient.fromItem(ModItems.INFUSED_IRON), + Ingredient.fromItem(ModItems.INFUSED_IRON), + Ingredient.fromItem(Items.FIRE_CHARGE), + Ingredient.fromItem(Items.FLINT), + Helper.blockIng(Blocks.MAGMA), + Helper.nbtIng(ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), NaturesAuraAPI.TYPE_NETHER))).register(); new TreeRitualRecipe(new ResourceLocation(NaturesAura.MOD_ID, "conversion_catalyst"), - new ItemStack(Blocks.SAPLING, 1, 3), new ItemStack(ModBlocks.CONVERSION_CATALYST), 600, - new ItemStack(Blocks.STONEBRICK, 1, 1), - new ItemStack(ModBlocks.INFUSED_STONE), - new ItemStack(Items.BREWING_STAND), - new ItemStack(Items.GOLD_INGOT), - new ItemStack(ModItems.GOLD_LEAF), - new ItemStack(Blocks.GLOWSTONE)).register(); + Ingredient.fromStacks(new ItemStack(Blocks.SAPLING, 1, 3)), new ItemStack(ModBlocks.CONVERSION_CATALYST), 600, + Ingredient.fromStacks(new ItemStack(Blocks.STONEBRICK, 1, 1)), + Helper.blockIng(ModBlocks.INFUSED_STONE), + Ingredient.fromItem(Items.BREWING_STAND), + Ingredient.fromItem(Items.GOLD_INGOT), + Ingredient.fromItem(ModItems.GOLD_LEAF), + Helper.blockIng(Blocks.GLOWSTONE)).register(); new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "infused_iron"), - new ItemStack(Items.IRON_INGOT), new ItemStack(ModItems.INFUSED_IRON), - null, 300, 80).register(); + Ingredient.fromItem(Items.IRON_INGOT), new ItemStack(ModItems.INFUSED_IRON), + Ingredient.EMPTY, 300, 80).register(); new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "infused_iron_block"), - new ItemStack(Blocks.IRON_BLOCK), new ItemStack(ModBlocks.INFUSED_IRON), - null, 2700, 700).register(); + Helper.blockIng(Blocks.IRON_BLOCK), new ItemStack(ModBlocks.INFUSED_IRON), + Ingredient.EMPTY, 2700, 700).register(); new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "infused_stone"), - new ItemStack(Blocks.STONE), new ItemStack(ModBlocks.INFUSED_STONE), - null, 150, 40).register(); + Helper.blockIng(Blocks.STONE), new ItemStack(ModBlocks.INFUSED_STONE), + Ingredient.EMPTY, 150, 40).register(); new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "chorus"), - ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), NaturesAuraAPI.TYPE_END), new ItemStack(Items.DRAGON_BREATH), - ModBlocks.CONVERSION_CATALYST, 350, 80).register(); + Helper.nbtIng(ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), NaturesAuraAPI.TYPE_END)), + new ItemStack(Items.DRAGON_BREATH), + Helper.blockIng(ModBlocks.CONVERSION_CATALYST), 350, 80).register(); new AltarRecipe(new ResourceLocation(NaturesAura.MOD_ID, "leather"), - new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER), - ModBlocks.CONVERSION_CATALYST, 400, 50).register(); + Ingredient.fromItem(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER), + Helper.blockIng(ModBlocks.CONVERSION_CATALYST), 400, 50).register(); } }