Skip to content

Commit

Permalink
Streamline CraftTweaker integration
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Dec 26, 2024
1 parent 121e7b7 commit 3b3a542
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 186 deletions.
27 changes: 7 additions & 20 deletions docs/crafttweaker/example.zs
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
// --------------
// --- IMPORT ---
// --------------
import mods.harkenscythe.Altar;
mods.harkenscythe.bloodAltar.add(<minecraft:cobblestone>, <minecraft:gravel>, 42);

// -----------
// --- ADD ---
// -----------
// Altar.addBloodAltarRecipe(<input>, <output>, <requiredBlood>);
// Altar.addSoulAltarRecipe(<input>, <output>, <requiredSouls>);
// --------------
Altar.addBloodAltarRecipe(<minecraft:cobblestone>, <minecraft:gravel>, 42);
Altar.addSoulAltarRecipe(<minecraft:gravel>, <minecraft:sand>, 69);
mods.harkenscythe.bloodAltar.removeByInput(<minecraft:glass_bottle>);
mods.harkenscythe.bloodAltar.removeByOutput(<harkenscythe:bloodweave_cloth>);

// --------------
// --- REMOVE ---
// --------------
// Altar.removeBloodAltarRecipe(<input>, <output>, <requiredBlood>);
// Altar.removeSoulAltarRecipe(<input>, <output>, <requiredSouls>);
// --------------
Altar.removeBloodAltarRecipe(<minecraft:glass_bottle>, <minecraft:dragon_breath>, 40);
Altar.removeSoulAltarRecipe(<minecraft:cake>, <harkenscythe:soul_cake>, 10);
mods.harkenscythe.soulAltar.add(<minecraft:gravel>, <minecraft:sand>, 69);

mods.harkenscythe.soulAltar.removeByInput(<minecraft:cookie>);
mods.harkenscythe.soulAltar.removeByOutput(<harkenscythe:soul_cake>);
Original file line number Diff line number Diff line change
@@ -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());
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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());
}
}
}
Loading

0 comments on commit 3b3a542

Please sign in to comment.