diff --git a/src/main/java/com/blamejared/compat/tconstruct/Casting.java b/src/main/java/com/blamejared/compat/tconstruct/Casting.java index 306e7fc..740bed8 100644 --- a/src/main/java/com/blamejared/compat/tconstruct/Casting.java +++ b/src/main/java/com/blamejared/compat/tconstruct/Casting.java @@ -6,12 +6,14 @@ import com.blamejared.mtlib.helpers.*; import com.blamejared.mtlib.utils.BaseAction; import crafttweaker.CraftTweakerAPI; import crafttweaker.annotations.*; -import crafttweaker.api.item.IItemStack; +import crafttweaker.api.item.*; import crafttweaker.api.liquid.ILiquidStack; +import crafttweaker.api.minecraft.CraftTweakerMC; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.oredict.OreDictionary; import slimeknights.mantle.util.RecipeMatch; import slimeknights.tconstruct.library.TinkerRegistry; import slimeknights.tconstruct.library.events.TinkerRegisterEvent; @@ -20,6 +22,7 @@ import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.*; import java.util.*; +import java.util.stream.Collectors; @ZenClass("mods.tconstruct.Casting") @ZenRegister @@ -39,15 +42,15 @@ public class Casting { } @ZenMethod - public static void addTableRecipe(IItemStack output, IItemStack cast, ILiquidStack fluid, int amount, @Optional boolean consumeCast, @Optional int time) { + public static void addTableRecipe(IItemStack output, IIngredient cast, ILiquidStack fluid, int amount, @Optional boolean consumeCast, @Optional int time) { init(); - ModTweaker.LATE_ADDITIONS.add(new Add(InputHelper.toStack(output), InputHelper.toStack(cast), InputHelper.toFluid(fluid), amount, true, consumeCast, time)); + ModTweaker.LATE_ADDITIONS.add(new Add(InputHelper.toStack(output), cast, InputHelper.toFluid(fluid), amount, true, consumeCast, time)); } @ZenMethod - public static void addBasinRecipe(IItemStack output, IItemStack cast, ILiquidStack fluid, int amount, @Optional boolean consumeCast, @Optional int time) { + public static void addBasinRecipe(IItemStack output, IIngredient cast, ILiquidStack fluid, int amount, @Optional boolean consumeCast, @Optional int time) { init(); - ModTweaker.LATE_ADDITIONS.add(new Add(InputHelper.toStack(output), InputHelper.toStack(cast), InputHelper.toFluid(fluid), amount, false, consumeCast, time)); + ModTweaker.LATE_ADDITIONS.add(new Add(InputHelper.toStack(output), cast, InputHelper.toFluid(fluid), amount, false, consumeCast, time)); } @ZenMethod @@ -140,14 +143,15 @@ public class Casting { private static class Add extends BaseAction { - private ItemStack output, cast; + private ItemStack output; + IIngredient cast; private FluidStack fluid; private int amount; private boolean table; private boolean consumeCast; private int time; - public Add(ItemStack output, ItemStack cast, FluidStack fluid, int amount, boolean table, boolean consumeCast, int time) { + public Add(ItemStack output, IIngredient cast, FluidStack fluid, int amount, boolean table, boolean consumeCast, int time) { super("Casting"); this.output = output; this.cast = cast; @@ -161,8 +165,18 @@ public class Casting { @Override public void apply() { RecipeMatch rm = null; - if(cast != ItemStack.EMPTY) { - rm = RecipeMatch.ofNBT(cast); + if(cast != null) { + List validCasts = cast.getItems().stream().map(CraftTweakerMC::getItemStack).collect(Collectors.toList()); + if(validCasts.isEmpty()) + CraftTweakerAPI.logInfo("Could not find matching items for " + cast.toString() + ". Substituting empty cast for recipe with output " + output.getDisplayName()); + else if(validCasts.size() == 1) //Keep compat to old handler + if(validCasts.get(0).getMetadata() == OreDictionary.WILDCARD_VALUE) { + rm = RecipeMatch.of(validCasts, output.getCount()); + } else { + rm = RecipeMatch.ofNBT(validCasts.get(0), output.getCount()); + } + else + rm = RecipeMatch.of(validCasts, output.getCount()); } if(table) TinkerRegistry.registerTableCasting(new CastingRecipeTweaker(output, rm, new FluidStack(fluid, amount), time, consumeCast, false)); diff --git a/src/main/java/com/blamejared/compat/tconstruct/Drying.java b/src/main/java/com/blamejared/compat/tconstruct/Drying.java index 31a087c..8fda98f 100644 --- a/src/main/java/com/blamejared/compat/tconstruct/Drying.java +++ b/src/main/java/com/blamejared/compat/tconstruct/Drying.java @@ -6,18 +6,20 @@ import com.blamejared.mtlib.helpers.*; import com.blamejared.mtlib.utils.BaseAction; import crafttweaker.CraftTweakerAPI; import crafttweaker.annotations.*; -import crafttweaker.api.item.IItemStack; +import crafttweaker.api.item.*; +import crafttweaker.api.minecraft.CraftTweakerMC; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import slimeknights.mantle.util.RecipeMatch; -import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.*; import slimeknights.tconstruct.library.events.TinkerRegisterEvent; import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.*; import java.util.*; +import java.util.stream.Collectors; @ZenClass("mods.tconstruct.Drying") @ZenRegister @@ -35,9 +37,9 @@ public class Drying { } @ZenMethod - public static void addRecipe(IItemStack output, IItemStack input, int time) { + public static void addRecipe(IItemStack output, IIngredient input, int time) { init(); - ModTweaker.LATE_ADDITIONS.add(new Add(InputHelper.toStack(output), InputHelper.toStack(input), time)); + ModTweaker.LATE_ADDITIONS.add(new Add(InputHelper.toStack(output), input, time)); } @ZenMethod @@ -48,19 +50,24 @@ public class Drying { private static class Add extends BaseAction { - private ItemStack output, input; - private int time; + private final ItemStack output; + private final IIngredient ingredient; + private final int time; - public Add(ItemStack output, ItemStack input, int time) { + public Add(ItemStack output, IIngredient input, int time) { super("Drying"); this.output = output; - this.input = input; + this.ingredient = input; this.time = time; } @Override public void apply() { - TinkerRegistry.addDryingRecipe(new DryingRecipeTweaker(new RecipeMatch.Item(input, 1), output, time)); + List validIngredients = ingredient.getItems().stream().map(CraftTweakerMC::getItemStack).collect(Collectors.toList()); + if(validIngredients.isEmpty()) + CraftTweakerAPI.logInfo("Could not find matching items for " + ingredient.toString() + ". Ignoring " + name + " recipe for " + output.getDisplayName()); + else + TinkerRegistry.addDryingRecipe(new DryingRecipeTweaker(RecipeMatch.of(validIngredients), output, time)); } @Override diff --git a/src/main/java/com/blamejared/compat/tconstruct/Melting.java b/src/main/java/com/blamejared/compat/tconstruct/Melting.java index 39a2698..f3985c5 100644 --- a/src/main/java/com/blamejared/compat/tconstruct/Melting.java +++ b/src/main/java/com/blamejared/compat/tconstruct/Melting.java @@ -8,8 +8,9 @@ import com.google.common.collect.*; import crafttweaker.CraftTweakerAPI; import crafttweaker.annotations.*; import crafttweaker.api.entity.IEntityDefinition; -import crafttweaker.api.item.IItemStack; +import crafttweaker.api.item.*; import crafttweaker.api.liquid.ILiquidStack; +import crafttweaker.api.minecraft.CraftTweakerMC; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraftforge.common.MinecraftForge; @@ -19,10 +20,12 @@ import net.minecraftforge.fml.common.registry.EntityEntry; import slimeknights.mantle.util.RecipeMatch; import slimeknights.tconstruct.library.TinkerRegistry; import slimeknights.tconstruct.library.events.TinkerRegisterEvent; +import slimeknights.tconstruct.library.smeltery.MeltingRecipe; import stanhebben.zenscript.annotations.Optional; import stanhebben.zenscript.annotations.*; import java.util.*; +import java.util.stream.Collectors; @ZenClass("mods.tconstruct.Melting") @ZenRegister @@ -42,9 +45,9 @@ public class Melting { } @ZenMethod - public static void addRecipe(ILiquidStack output, IItemStack input, @Optional int temp) { + public static void addRecipe(ILiquidStack output, IIngredient input, @Optional int temp) { init(); - ModTweaker.LATE_ADDITIONS.add(new Melting.Add(InputHelper.toFluid(output), InputHelper.toStack(input), temp)); + ModTweaker.LATE_ADDITIONS.add(new Melting.Add(InputHelper.toFluid(output), input, temp)); } @@ -68,23 +71,28 @@ public class Melting { private static class Add extends BaseAction { - private FluidStack output; - private ItemStack input; - private int temp; + private final FluidStack output; + private final IIngredient ingredient; + private final int temp; - public Add(FluidStack output, ItemStack input, int temp) { + public Add(FluidStack output, IIngredient ingredient, int temp) { super("Melting"); this.output = output; - this.input = input; this.temp = temp; + this.ingredient = ingredient; } @Override public void apply() { - if(temp != 0) - TinkerRegistry.registerMelting(new MeltingRecipeTweaker(RecipeMatch.of(input, output.amount), output, temp)); - else - TinkerRegistry.registerMelting(new MeltingRecipeTweaker(RecipeMatch.of(input, output.amount), output)); + List validIngredients = ingredient.getItems().stream().map(CraftTweakerMC::getItemStack).collect(Collectors.toList()); + if(validIngredients.isEmpty()) + CraftTweakerAPI.logInfo("Could not find matching items for " + ingredient.toString() + ". Ignoring Melting recipe for " + output.getLocalizedName()); + + else if(temp == 0) { + TinkerRegistry.registerMelting(new MeltingRecipeTweaker(RecipeMatch.of(validIngredients, output.amount), output)); + } else { + TinkerRegistry.registerMelting(new MeltingRecipeTweaker(RecipeMatch.of(validIngredients, output.amount), output, temp)); + } } @Override