diff --git a/docs/crafttweaker/example.zs b/docs/crafttweaker/example.zs index c631f96..64d274c 100644 --- a/docs/crafttweaker/example.zs +++ b/docs/crafttweaker/example.zs @@ -1,22 +1,9 @@ -// -------------- -// --- IMPORT --- -// -------------- -import mods.harkenscythe.Altar; +mods.harkenscythe.bloodAltar.add(, , 42); -// ----------- -// --- ADD --- -// ----------- -// Altar.addBloodAltarRecipe(, , ); -// Altar.addSoulAltarRecipe(, , ); -// -------------- -Altar.addBloodAltarRecipe(, , 42); -Altar.addSoulAltarRecipe(, , 69); +mods.harkenscythe.bloodAltar.removeByInput(); +mods.harkenscythe.bloodAltar.removeByOutput(); -// -------------- -// --- REMOVE --- -// -------------- -// Altar.removeBloodAltarRecipe(, , ); -// Altar.removeSoulAltarRecipe(, , ); -// -------------- -Altar.removeBloodAltarRecipe(, , 40); -Altar.removeSoulAltarRecipe(, , 10); +mods.harkenscythe.soulAltar.add(, , 69); + +mods.harkenscythe.soulAltar.removeByInput(); +mods.harkenscythe.soulAltar.removeByOutput(); diff --git a/src/main/java/mod/emt/harkenscythe/compat/crafttweaker/HSCraftTweakerBloodAltarRecipes.java b/src/main/java/mod/emt/harkenscythe/compat/crafttweaker/HSCraftTweakerBloodAltarRecipes.java new file mode 100644 index 0000000..8f06fc7 --- /dev/null +++ b/src/main/java/mod/emt/harkenscythe/compat/crafttweaker/HSCraftTweakerBloodAltarRecipes.java @@ -0,0 +1,104 @@ +package mod.emt.harkenscythe.compat.crafttweaker; + +import crafttweaker.CraftTweakerAPI; +import crafttweaker.IAction; +import crafttweaker.annotations.ZenRegister; +import crafttweaker.api.item.IItemStack; +import crafttweaker.api.minecraft.CraftTweakerMC; +import mod.emt.harkenscythe.init.HSAltarRecipes; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +@SuppressWarnings("unused") +@ZenRegister +@ZenClass("mods.harkenscythe.bloodAltar") +public class HSCraftTweakerBloodAltarRecipes +{ + @ZenMethod + public static void add(IItemStack input, IItemStack output, int requiredBlood) + { + CraftTweakerAPI.apply(new AddAction(input, output, requiredBlood)); + } + + @ZenMethod + public static void removeByOutput(IItemStack output) + { + CraftTweakerAPI.apply(new RemoveByOutputAction(output)); + } + + @ZenMethod + public static void removeByInput(IItemStack output) + { + CraftTweakerAPI.apply(new RemoveByInputAction(output)); + } + + private static class AddAction implements IAction + { + private final IItemStack input; + private final IItemStack output; + private final int requiredBlood; + + public AddAction(IItemStack input, IItemStack output, int requiredBlood) + { + this.input = input; + this.output = output; + this.requiredBlood = requiredBlood; + } + + @Override + public void apply() + { + HSAltarRecipes.addBloodRecipe(CraftTweakerMC.getItemStack(input), CraftTweakerMC.getItemStack(output), requiredBlood); + } + + @Override + public String describe() + { + return String.format("Adding Blood Altar recipe: %s -> %s with %d blood", input.toString(), output.toString(), requiredBlood); + } + } + + private static class RemoveByOutputAction implements IAction + { + private final IItemStack output; + + public RemoveByOutputAction(IItemStack output) + { + this.output = output; + } + + @Override + public void apply() + { + HSAltarRecipes.removeBloodRecipeByOutput(CraftTweakerMC.getItemStack(output)); + } + + @Override + public String describe() + { + return String.format("Removing all Blood Altar recipes with output %s", output.toString()); + } + } + + private static class RemoveByInputAction implements IAction + { + private final IItemStack input; + + public RemoveByInputAction(IItemStack input) + { + this.input = input; + } + + @Override + public void apply() + { + HSAltarRecipes.removeBloodRecipeByInput(CraftTweakerMC.getItemStack(input)); + } + + @Override + public String describe() + { + return String.format("Removing all Blood Altar recipes with input %s", input.toString()); + } + } +} diff --git a/src/main/java/mod/emt/harkenscythe/compat/crafttweaker/HSCraftTweakerPlugin.java b/src/main/java/mod/emt/harkenscythe/compat/crafttweaker/HSCraftTweakerPlugin.java deleted file mode 100644 index 5ff9a52..0000000 --- a/src/main/java/mod/emt/harkenscythe/compat/crafttweaker/HSCraftTweakerPlugin.java +++ /dev/null @@ -1,144 +0,0 @@ -package mod.emt.harkenscythe.compat.crafttweaker; - -import crafttweaker.CraftTweakerAPI; -import crafttweaker.IAction; -import crafttweaker.annotations.ZenRegister; -import crafttweaker.api.item.IItemStack; -import crafttweaker.api.minecraft.CraftTweakerMC; -import mod.emt.harkenscythe.init.HSAltarRecipes; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; - -@SuppressWarnings("unused") -@ZenRegister -@ZenClass("mods.harkenscythe.Altar") -public class HSCraftTweakerPlugin -{ - @ZenMethod - public static void addBloodAltarRecipe(IItemStack input, IItemStack output, int requiredBlood) - { - CraftTweakerAPI.apply(new AddBloodAltarRecipeAction(input, output, requiredBlood)); - } - - @ZenMethod - public static void removeBloodAltarRecipe(IItemStack input, IItemStack output, int requiredBlood) - { - CraftTweakerAPI.apply(new RemoveBloodAltarRecipeAction(input, output, requiredBlood)); - } - - @ZenMethod - public static void addSoulAltarRecipe(IItemStack input, IItemStack output, int requiredSouls) - { - CraftTweakerAPI.apply(new AddSoulAltarRecipeAction(input, output, requiredSouls)); - } - - @ZenMethod - public static void removeSoulAltarRecipe(IItemStack input, IItemStack output, int requiredSouls) - { - CraftTweakerAPI.apply(new RemoveSoulAltarRecipeAction(input, output, requiredSouls)); - } - - private static class AddBloodAltarRecipeAction implements IAction - { - private final IItemStack input; - private final IItemStack output; - private final int requiredBlood; - - public AddBloodAltarRecipeAction(IItemStack input, IItemStack output, int requiredBlood) - { - this.input = input; - this.output = output; - this.requiredBlood = requiredBlood; - } - - @Override - public void apply() - { - HSAltarRecipes.addBloodRecipe(CraftTweakerMC.getItemStack(input), CraftTweakerMC.getItemStack(output), requiredBlood); - } - - @Override - public String describe() - { - return String.format("Adding Blood Altar recipe: %s -> %s with %d blood", input.toString(), output.toString(), requiredBlood); - } - } - - private static class RemoveBloodAltarRecipeAction implements IAction - { - private final IItemStack input; - private final IItemStack output; - private final int requiredBlood; - - public RemoveBloodAltarRecipeAction(IItemStack input, IItemStack output, int requiredBlood) - { - this.input = input; - this.output = output; - this.requiredBlood = requiredBlood; - } - - @Override - public void apply() - { - HSAltarRecipes.removeBloodRecipe(CraftTweakerMC.getItemStack(input), CraftTweakerMC.getItemStack(output), requiredBlood); - } - - @Override - public String describe() - { - return String.format("Removing Blood Altar recipe: %s -> %s with %d blood", input.toString(), output.toString(), requiredBlood); - } - } - - private static class AddSoulAltarRecipeAction implements IAction - { - private final IItemStack input; - private final IItemStack output; - private final int requiredSouls; - - public AddSoulAltarRecipeAction(IItemStack input, IItemStack output, int requiredSouls) - { - this.input = input; - this.output = output; - this.requiredSouls = requiredSouls; - } - - @Override - public void apply() - { - HSAltarRecipes.addSoulRecipe(CraftTweakerMC.getItemStack(input), CraftTweakerMC.getItemStack(output), requiredSouls); - } - - @Override - public String describe() - { - return String.format("Adding Soul Altar recipe: %s -> %s with %d souls", input.toString(), output.toString(), requiredSouls); - } - } - - private static class RemoveSoulAltarRecipeAction implements IAction - { - private final IItemStack input; - private final IItemStack output; - private final int requiredSouls; - - public RemoveSoulAltarRecipeAction(IItemStack input, IItemStack output, int requiredSouls) - { - this.input = input; - this.output = output; - this.requiredSouls = requiredSouls; - } - - @Override - public void apply() - { - HSAltarRecipes.removeSoulRecipe(CraftTweakerMC.getItemStack(input), CraftTweakerMC.getItemStack(output), requiredSouls); - } - - @Override - public String describe() - { - return String.format("Removing Soul Altar recipe: %s -> %s with %d souls", input.toString(), output.toString(), requiredSouls); - } - } -} diff --git a/src/main/java/mod/emt/harkenscythe/compat/crafttweaker/HSCraftTweakerSoulAltarRecipes.java b/src/main/java/mod/emt/harkenscythe/compat/crafttweaker/HSCraftTweakerSoulAltarRecipes.java new file mode 100644 index 0000000..db02228 --- /dev/null +++ b/src/main/java/mod/emt/harkenscythe/compat/crafttweaker/HSCraftTweakerSoulAltarRecipes.java @@ -0,0 +1,104 @@ +package mod.emt.harkenscythe.compat.crafttweaker; + +import crafttweaker.CraftTweakerAPI; +import crafttweaker.IAction; +import crafttweaker.annotations.ZenRegister; +import crafttweaker.api.item.IItemStack; +import crafttweaker.api.minecraft.CraftTweakerMC; +import mod.emt.harkenscythe.init.HSAltarRecipes; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +@SuppressWarnings("unused") +@ZenRegister +@ZenClass("mods.harkenscythe.soulAltar") +public class HSCraftTweakerSoulAltarRecipes +{ + @ZenMethod + public static void add(IItemStack input, IItemStack output, int requiredSouls) + { + CraftTweakerAPI.apply(new AddAction(input, output, requiredSouls)); + } + + @ZenMethod + public static void removeByOutput(IItemStack output) + { + CraftTweakerAPI.apply(new RemoveByOutputAction(output)); + } + + @ZenMethod + public static void removeByInput(IItemStack output) + { + CraftTweakerAPI.apply(new RemoveByInputAction(output)); + } + + private static class AddAction implements IAction + { + private final IItemStack input; + private final IItemStack output; + private final int requiredSouls; + + public AddAction(IItemStack input, IItemStack output, int requiredSouls) + { + this.input = input; + this.output = output; + this.requiredSouls = requiredSouls; + } + + @Override + public void apply() + { + HSAltarRecipes.addSoulRecipe(CraftTweakerMC.getItemStack(input), CraftTweakerMC.getItemStack(output), requiredSouls); + } + + @Override + public String describe() + { + return String.format("Adding Soul Altar recipe: %s -> %s with %d souls", input.toString(), output.toString(), requiredSouls); + } + } + + private static class RemoveByOutputAction implements IAction + { + private final IItemStack output; + + public RemoveByOutputAction(IItemStack output) + { + this.output = output; + } + + @Override + public void apply() + { + HSAltarRecipes.removeSoulRecipeByOutput(CraftTweakerMC.getItemStack(output)); + } + + @Override + public String describe() + { + return String.format("Removing all Soul Altar recipes with output %s", output.toString()); + } + } + + private static class RemoveByInputAction implements IAction + { + private final IItemStack input; + + public RemoveByInputAction(IItemStack input) + { + this.input = input; + } + + @Override + public void apply() + { + HSAltarRecipes.removeSoulRecipeByInput(CraftTweakerMC.getItemStack(input)); + } + + @Override + public String describe() + { + return String.format("Removing all Soul Altar recipes with input %s", input.toString()); + } + } +} diff --git a/src/main/java/mod/emt/harkenscythe/init/HSAltarRecipes.java b/src/main/java/mod/emt/harkenscythe/init/HSAltarRecipes.java index 8569705..e064523 100644 --- a/src/main/java/mod/emt/harkenscythe/init/HSAltarRecipes.java +++ b/src/main/java/mod/emt/harkenscythe/init/HSAltarRecipes.java @@ -66,20 +66,14 @@ public static void addBloodRecipesConfig(String[] strings) } } - public static void removeBloodRecipe(Item input, Item output, int requiredBlood) + public static void removeBloodRecipeByOutput(ItemStack output) { - BLOOD_ALTAR_RECIPE_REMOVALS.add(new HSRecipeBloodAltar(new ItemStack(input), new ItemStack(output), requiredBlood)); + BLOOD_ALTAR_RECIPE_REMOVALS.add(new HSRecipeBloodAltar(ItemStack.EMPTY, output, 0)); } - public static void removeBloodRecipe(ItemStack input, ItemStack output, int requiredBlood) + public static void removeBloodRecipeByInput(ItemStack input) { - BLOOD_ALTAR_RECIPE_REMOVALS.add(new HSRecipeBloodAltar(input, output, requiredBlood)); - } - - public static void removeBloodRecipe(String oreDictName, Item output, int requiredBlood) - { - List ores = OreDictionary.getOres(oreDictName); - for (ItemStack ore : ores) removeBloodRecipe(ore.getItem(), output, requiredBlood); + BLOOD_ALTAR_RECIPE_REMOVALS.add(new HSRecipeBloodAltar(input, ItemStack.EMPTY, 0)); } public static void removeBloodRecipes() @@ -88,7 +82,7 @@ public static void removeBloodRecipes() { for (HSRecipeBloodAltar recipe : BLOOD_ALTAR_RECIPES) { - if (recipe.getInput().getItem() == recipeRemoval.getInput().getItem() && recipe.getOutput().getItem() == recipeRemoval.getOutput().getItem() && recipe.getRequiredBlood() == recipeRemoval.getRequiredBlood()) + if (recipe.getInput().getItem() == recipeRemoval.getInput().getItem() || recipe.getOutput().getItem() == recipeRemoval.getOutput().getItem()) { BLOOD_ALTAR_RECIPES.remove(recipe); return; @@ -179,20 +173,14 @@ public static void addSoulRecipesConfig(String[] strings) } } - public static void removeSoulRecipe(Item input, Item output, int requiredSouls) + public static void removeSoulRecipeByOutput(ItemStack output) { - SOUL_ALTAR_RECIPE_REMOVALS.add(new HSRecipeSoulAltar(new ItemStack(input), new ItemStack(output), requiredSouls)); + SOUL_ALTAR_RECIPE_REMOVALS.add(new HSRecipeSoulAltar(ItemStack.EMPTY, output, 0)); } - public static void removeSoulRecipe(ItemStack input, ItemStack output, int requiredSouls) + public static void removeSoulRecipeByInput(ItemStack input) { - SOUL_ALTAR_RECIPE_REMOVALS.add(new HSRecipeSoulAltar(input, output, requiredSouls)); - } - - public static void removeSoulRecipe(String oreDictName, Item output, int requiredSouls) - { - List ores = OreDictionary.getOres(oreDictName); - for (ItemStack ore : ores) removeSoulRecipe(ore.getItem(), output, requiredSouls); + SOUL_ALTAR_RECIPE_REMOVALS.add(new HSRecipeSoulAltar(input, ItemStack.EMPTY, 0)); } public static void removeSoulRecipes() @@ -201,7 +189,7 @@ public static void removeSoulRecipes() { for (HSRecipeSoulAltar recipe : SOUL_ALTAR_RECIPES) { - if (recipe.getInput().getItem() == recipeRemoval.getInput().getItem() && recipe.getOutput().getItem() == recipeRemoval.getOutput().getItem() && recipe.getRequiredSouls() == recipeRemoval.getRequiredSouls()) + if (recipe.getInput().getItem() == recipeRemoval.getInput().getItem() || recipe.getOutput().getItem() == recipeRemoval.getOutput().getItem()) { SOUL_ALTAR_RECIPES.remove(recipe); return;