mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-26 15:13:05 +00:00
Also changes like all packages inb4 "jared changes a package name in ModTweaker2 breaking compatability with everything" drama tweet.
This commit is contained in:
1 parent
4fd2551072
commit
ec562b62ea
187 files changed
+977
-991
No files matched your search
@@ -0,0 +1,18 @@
|
||||
package modtweaker2.mods.mariculture;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import modtweaker2.mods.mariculture.handlers.Anvil;
|
||||
import modtweaker2.mods.mariculture.handlers.Casting;
|
||||
import modtweaker2.mods.mariculture.handlers.Crucible;
|
||||
import modtweaker2.mods.mariculture.handlers.Fishing;
|
||||
import modtweaker2.mods.mariculture.handlers.Vat;
|
||||
|
||||
public class Mariculture {
|
||||
public Mariculture() {
|
||||
MineTweakerAPI.registerClass(Anvil.class);
|
||||
MineTweakerAPI.registerClass(Casting.class);
|
||||
MineTweakerAPI.registerClass(Crucible.class);
|
||||
MineTweakerAPI.registerClass(Fishing.class);
|
||||
MineTweakerAPI.registerClass(Vat.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package modtweaker2.mods.mariculture;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import mariculture.api.core.MaricultureHandlers;
|
||||
import mariculture.api.fishery.Fishing;
|
||||
import mariculture.api.fishery.Loot;
|
||||
import mariculture.api.fishery.Loot.Rarity;
|
||||
import modtweaker2.helpers.ReflectionHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class MaricultureHelper {
|
||||
public static Map fuels = null;
|
||||
public static HashMap<Rarity, ArrayList<Loot>> loot = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
fuels = ReflectionHelper.getFinalObject(MaricultureHandlers.crucible, "fuels");
|
||||
loot = ReflectionHelper.getFinalObject(Fishing.fishing, "fishing_loot");
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
private MaricultureHelper() {}
|
||||
|
||||
//Helper for getting the key that is used when adding/removing fuels
|
||||
public static String getKey(Object o) {
|
||||
if (o instanceof String) return (String) o;
|
||||
else if (o instanceof ItemStack) {
|
||||
String name = "";
|
||||
ItemStack stack = (ItemStack) o;
|
||||
if (OreDictionary.getOreIDs(stack).length > 0) {
|
||||
name = OreDictionary.getOreName(OreDictionary.getOreIDs(stack)[0]);
|
||||
} else if (stack.isItemStackDamageable()) {
|
||||
name = Item.itemRegistry.getNameForObject(stack.getItem()) + "|ignore";
|
||||
} else {
|
||||
name = Item.itemRegistry.getNameForObject(stack.getItem()) + "|" + stack.getItemDamage();
|
||||
}
|
||||
|
||||
return name;
|
||||
} else if (o instanceof FluidStack) {
|
||||
return ((FluidStack) o).getFluid().getName();
|
||||
} else return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package modtweaker2.mods.mariculture.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import mariculture.api.core.IAnvilHandler.RecipeAnvil;
|
||||
import mariculture.api.core.MaricultureHandlers;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.mods.mariculture.MaricultureHelper;
|
||||
import modtweaker2.util.BaseMapAddition;
|
||||
import modtweaker2.util.BaseMapRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@ZenClass("mods.mariculture.Anvil")
|
||||
public class Anvil {
|
||||
//Adding a Mariculture Anvil recipe
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack input, IItemStack output, int hits) {
|
||||
MineTweakerAPI.apply(new Add(new RecipeAnvil(toStack(input), toStack(output), hits)));
|
||||
}
|
||||
|
||||
private static class Add extends BaseMapAddition {
|
||||
public Add(RecipeAnvil recipe) {
|
||||
super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes(), MaricultureHelper.getKey(recipe.input), recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return ((RecipeAnvil) recipe).output.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Removing a Mariculture Anvil recipe
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack input) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(input)));
|
||||
}
|
||||
|
||||
private static class Remove extends BaseMapRemoval {
|
||||
public Remove(ItemStack stack) {
|
||||
super("Mariculture Anvil", MaricultureHandlers.anvil.getRecipes(), MaricultureHelper.getKey(stack), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return ((ItemStack) stack).getDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package modtweaker2.mods.mariculture.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toFluid;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import mariculture.api.core.MaricultureHandlers;
|
||||
import mariculture.api.core.RecipeCasting;
|
||||
import mariculture.api.core.RecipeCasting.RecipeNuggetCasting;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import modtweaker2.mods.mariculture.MaricultureHelper;
|
||||
import modtweaker2.util.BaseMapAddition;
|
||||
import modtweaker2.util.BaseMapRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@ZenClass("mods.mariculture.Casting")
|
||||
public class Casting {
|
||||
//Adding Mariculture Casting Recipes
|
||||
@ZenMethod
|
||||
public static void addNuggetRecipe(ILiquidStack input, IItemStack output) {
|
||||
MineTweakerAPI.apply(new Add(new RecipeNuggetCasting(toFluid(input), toStack(output)), MaricultureHandlers.casting.getNuggetRecipes()));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addIngotRecipe(ILiquidStack input, IItemStack output) {
|
||||
MineTweakerAPI.apply(new Add(new RecipeNuggetCasting(toFluid(input), toStack(output)), MaricultureHandlers.casting.getIngotRecipes()));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addBlockRecipe(ILiquidStack input, IItemStack output) {
|
||||
MineTweakerAPI.apply(new Add(new RecipeNuggetCasting(toFluid(input), toStack(output)), MaricultureHandlers.casting.getBlockRecipes()));
|
||||
}
|
||||
|
||||
private static class Add extends BaseMapAddition {
|
||||
public Add(RecipeCasting recipe, HashMap map) {
|
||||
super("Mariculture Casting", map, MaricultureHelper.getKey(recipe.fluid), recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return ((RecipeCasting) recipe).output.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Removing Mariculture Casting Recipes
|
||||
@ZenMethod
|
||||
public static void removeNuggetRecipe(IItemStack input) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(input), MaricultureHandlers.casting.getNuggetRecipes()));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeIngotRecipe(IItemStack input) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(input), MaricultureHandlers.casting.getIngotRecipes()));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeBlockRecipe(IItemStack input) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(input), MaricultureHandlers.casting.getBlockRecipes()));
|
||||
}
|
||||
|
||||
private static class Remove extends BaseMapRemoval {
|
||||
public Remove(ItemStack stack, HashMap map) {
|
||||
super("Mariculture Casting", map, MaricultureHelper.getKey(stack), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return ((ItemStack) stack).getDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package modtweaker2.mods.mariculture.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toFluid;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.helpers.StackHelper.areEqual;
|
||||
import mariculture.api.core.FuelInfo;
|
||||
import mariculture.api.core.MaricultureHandlers;
|
||||
import mariculture.api.core.RecipeSmelter;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import modtweaker2.mods.mariculture.MaricultureHelper;
|
||||
import modtweaker2.util.BaseListAddition;
|
||||
import modtweaker2.util.BaseListRemoval;
|
||||
import modtweaker2.util.BaseMapAddition;
|
||||
import modtweaker2.util.BaseMapRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@ZenClass("mods.mariculture.Crucible")
|
||||
public class Crucible {
|
||||
|
||||
/********************************************** Mariculture Crucible Recipes **********************************************/
|
||||
|
||||
// Adding a Mariculture Crucible recipe
|
||||
@ZenMethod
|
||||
public static void addRecipe(int temp, IItemStack input, ILiquidStack fluid, @Optional IItemStack output, @Optional int chance) {
|
||||
ItemStack out = output != null ? toStack(output) : null;
|
||||
MineTweakerAPI.apply(new AddRecipe(new RecipeSmelter(toStack(input), null, temp, toFluid(fluid), out, chance)));
|
||||
}
|
||||
|
||||
// Passes the list to the base list implementation, and adds the recipe
|
||||
private static class AddRecipe extends BaseListAddition {
|
||||
public AddRecipe(RecipeSmelter recipe) {
|
||||
super("Mariculture Crucible", MaricultureHandlers.crucible.getRecipes(), recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return ((RecipeSmelter) recipe).input.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Removing a Mariculture Crucible recipe
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack input) {
|
||||
MineTweakerAPI.apply(new RemoveRecipe(toStack(input)));
|
||||
}
|
||||
|
||||
// Removes a recipe, apply is never the same for anything, so will always
|
||||
// need to override it
|
||||
private static class RemoveRecipe extends BaseListRemoval {
|
||||
public RemoveRecipe(ItemStack stack) {
|
||||
super("Mariculture Crucible", MaricultureHandlers.crucible.getRecipes(), stack);
|
||||
}
|
||||
|
||||
// Loops through the registry, to find the item that matches, saves that
|
||||
// recipe then removes it
|
||||
@Override
|
||||
public void apply() {
|
||||
|
||||
for (RecipeSmelter r : MaricultureHandlers.crucible.getRecipes()) {
|
||||
if (r != null) {
|
||||
if (r.input != null && stack != null && areEqual(r.input, stack)) {
|
||||
recipe = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (recipe != null)
|
||||
MaricultureHandlers.crucible.getRecipes().remove(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************** Crucible Fuels **********************************************/
|
||||
@ZenMethod
|
||||
public static void addFuel(IItemStack input, int max, int per, int time) {
|
||||
MineTweakerAPI.apply(new AddFuel(toStack(input), new FuelInfo(max, per, time)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addFuel(ILiquidStack input, int max, int per, int time) {
|
||||
MineTweakerAPI.apply(new AddFuel(toFluid(input), new FuelInfo(max, per, time)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addFuel(String input, int max, int per, int time) {
|
||||
MineTweakerAPI.apply(new AddFuel(input, new FuelInfo(max, per, time)));
|
||||
}
|
||||
|
||||
// Passes the list to the base map implementation, and adds the recipe
|
||||
private static class AddFuel extends BaseMapAddition {
|
||||
public AddFuel(Object o, FuelInfo info) {
|
||||
super("Mariculture Crucible Fuel", MaricultureHelper.fuels, MaricultureHelper.getKey(o), info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return (String) key;
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ZenMethod
|
||||
public static void removeFuel(IItemStack fuel) {
|
||||
MineTweakerAPI.apply(new RemoveFuel(fuel));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeFuel(ILiquidStack fuel) {
|
||||
MineTweakerAPI.apply(new RemoveFuel(fuel));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeFuel(String fuel) {
|
||||
MineTweakerAPI.apply(new RemoveFuel(fuel));
|
||||
}
|
||||
|
||||
// Removes a recipe, will always remove the key, so all should be good
|
||||
private static class RemoveFuel extends BaseMapRemoval {
|
||||
public RemoveFuel(Object o) {
|
||||
super("Mariculture Crucible Fuel", MaricultureHelper.fuels, MaricultureHelper.getKey(o), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return (String) key;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package modtweaker2.mods.mariculture.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
import static modtweaker2.helpers.StackHelper.areEqual;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import mariculture.api.fishery.Loot;
|
||||
import mariculture.api.fishery.Loot.Rarity;
|
||||
import mariculture.api.fishery.RodType;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.helpers.ReflectionHelper;
|
||||
import modtweaker2.mods.mariculture.MaricultureHelper;
|
||||
import modtweaker2.util.BaseDescriptionAddition;
|
||||
import modtweaker2.util.BaseDescriptionRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.Optional;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
@ZenClass("mods.mariculture.Fishing")
|
||||
public class Fishing {
|
||||
//HashMap Helper for converting strings to rodtypes, (will personally add a registry to mariculture eventually...)
|
||||
public static HashMap<String, RodType> rodTypes = new HashMap();
|
||||
|
||||
static {
|
||||
rodTypes.put("net", RodType.NET);
|
||||
rodTypes.put("old", RodType.OLD);
|
||||
rodTypes.put("good", RodType.GOOD);
|
||||
rodTypes.put("dire", RodType.DIRE);
|
||||
rodTypes.put("super", RodType.SUPER);
|
||||
rodTypes.put("flux", RodType.FLUX);
|
||||
if (Loader.isModLoaded("AWWayofTime")) {
|
||||
try {
|
||||
rodTypes.put("blood", (RodType) ReflectionHelper.getStaticObject(Class.forName("mariculture.plugins.PluginBloodMagic"), "BLOOD"));
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Adding Fishing Loot
|
||||
@ZenMethod
|
||||
public static void addJunk(IItemStack loot, double chance, @Optional String type, @Optional boolean exact, @Optional int[] dimension) {
|
||||
addLoot(toStack(loot), chance, type, exact, dimension, Rarity.JUNK);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addGood(IItemStack loot, double chance, @Optional String type, @Optional boolean exact, @Optional int[] dimension) {
|
||||
addLoot(toStack(loot), chance, type, exact, dimension, Rarity.GOOD);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRare(IItemStack loot, double chance, @Optional String type, @Optional boolean exact, @Optional int[] dimension) {
|
||||
addLoot(toStack(loot), chance, type, exact, dimension, Rarity.RARE);
|
||||
}
|
||||
|
||||
private static void addLoot(ItemStack stack, double chance, String type, boolean exact, int[] dimension, Rarity rarity) {
|
||||
if (dimension == null || dimension.length == 0) dimension = new int[] { Short.MAX_VALUE };
|
||||
if (type == null) type = "dire";
|
||||
for (int dim : dimension) {
|
||||
MineTweakerAPI.apply(new AddLoot(new Loot(stack, chance, rarity, dim, rodTypes.get(type), exact), rarity.name()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class AddLoot extends BaseDescriptionAddition {
|
||||
private final Loot loot;
|
||||
|
||||
public AddLoot(Loot loot, String description) {
|
||||
super("Fishing Loot - " + description);
|
||||
this.loot = loot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
ArrayList<Loot> list = MaricultureHelper.loot.get(loot.rarity);
|
||||
list.add(loot);
|
||||
MaricultureHelper.loot.put(loot.rarity, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
ArrayList<Loot> list = MaricultureHelper.loot.get(loot.rarity);
|
||||
list.remove(loot);
|
||||
MaricultureHelper.loot.put(loot.rarity, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return loot.loot.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//Removing Fishing Loot, will remove it from every single list
|
||||
@ZenMethod
|
||||
public static void removeLoot(IItemStack loot) {
|
||||
MineTweakerAPI.apply(new RemoveLoot(toStack(loot)));
|
||||
}
|
||||
|
||||
private static class RemoveLoot extends BaseDescriptionRemoval {
|
||||
private HashMap<Rarity, Loot> loot;
|
||||
private final ItemStack stack;
|
||||
|
||||
public RemoveLoot(ItemStack stack) {
|
||||
super("Fishing Loot");
|
||||
this.loot = new HashMap();
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
loot.clear();
|
||||
apply(Rarity.JUNK);
|
||||
apply(Rarity.GOOD);
|
||||
apply(Rarity.RARE);
|
||||
}
|
||||
|
||||
//Performs the apply function on all rarity types
|
||||
public void apply(Rarity rarity) {
|
||||
ArrayList<Loot> list = MaricultureHelper.loot.get(rarity);
|
||||
int preSize = list.size();
|
||||
for (Loot l : list) {
|
||||
if (areEqual(l.loot, stack)) {
|
||||
loot.put(rarity, l);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
list.remove(loot);
|
||||
|
||||
if (list.size() != preSize) MaricultureHelper.loot.put(rarity, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
for (Map.Entry<Rarity, Loot> entry : loot.entrySet()) {
|
||||
undo(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
//Undoes the action on the applicable rarities
|
||||
public void undo(Rarity rarity, Loot l) {
|
||||
ArrayList<Loot> list = MaricultureHelper.loot.get(rarity);
|
||||
list.add(l);
|
||||
MaricultureHelper.loot.put(rarity, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package modtweaker2.mods.mariculture.handlers;
|
||||
|
||||
import mariculture.api.core.MaricultureHandlers;
|
||||
import mariculture.api.core.RecipeVat;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.liquid.ILiquidStack;
|
||||
import modtweaker2.util.BaseListAddition;
|
||||
import modtweaker2.util.BaseListRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.StackHelper.*;
|
||||
|
||||
@ZenClass("mods.mariculture.Vat")
|
||||
public class Vat {
|
||||
// Adding a Mariculture Vat recipe
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, ILiquidStack outputFluid, int time) {
|
||||
addRecipe(fluid1, fluid2, null, outputFluid, null, time);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack outputItem, int time) {
|
||||
addRecipe(fluid1, fluid2, null, null, outputItem, time);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, ILiquidStack outputFluid, IItemStack outputItem, int time) {
|
||||
addRecipe(fluid1, fluid2, null, outputFluid, outputItem, time);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluid1, IItemStack input, ILiquidStack outputFluid, int time) {
|
||||
addRecipe(fluid1, null, input, outputFluid, null, time);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluid1, IItemStack input, IItemStack outputItem, int time) {
|
||||
addRecipe(fluid1, null, input, null, outputItem, time);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluid1, IItemStack input, ILiquidStack outputFluid, IItemStack outputItem, int time) {
|
||||
addRecipe(fluid1, null, input, outputFluid, outputItem, time);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack input, ILiquidStack outputFluid, int time) {
|
||||
addRecipe(fluid1, fluid2, input, outputFluid, null, time);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack input, IItemStack outputItem, int time) {
|
||||
addRecipe(fluid1, fluid2, input, null, outputItem, time);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(ILiquidStack fluid1, ILiquidStack fluid2, IItemStack input, ILiquidStack outputFluid, IItemStack outputItem, int time) {
|
||||
MineTweakerAPI.apply(new Add(new RecipeVat(toStack(input), toFluid(fluid1), toFluid(fluid2), toFluid(outputFluid), toStack(outputItem), time)));
|
||||
}
|
||||
|
||||
// Passes the list to the base list implementation, and adds the recipe
|
||||
private static class Add extends BaseListAddition {
|
||||
public Add(RecipeVat recipe) {
|
||||
super("Mariculture Vat", MaricultureHandlers.vat.getRecipes(), recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
if (((RecipeVat) recipe).outputItem != null)
|
||||
return ((RecipeVat) recipe).outputItem.getDisplayName();
|
||||
else
|
||||
return ((RecipeVat) recipe).outputFluid.getFluid().getLocalizedName();
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Removing a Mariculture Vat recipe
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack outputItem) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(outputItem), null));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(ILiquidStack outputFluid) {
|
||||
MineTweakerAPI.apply(new Remove(null, toFluid(outputFluid)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack outputItem, ILiquidStack outputFluid) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(outputItem), toFluid(outputFluid)));
|
||||
}
|
||||
|
||||
// Removes a recipe, apply is never the same for anything, so will always
|
||||
// need to override it
|
||||
private static class Remove extends BaseListRemoval {
|
||||
private final FluidStack fluid;
|
||||
|
||||
public Remove(ItemStack stack, FluidStack fluid) {
|
||||
super("Mariculture Vat", MaricultureHandlers.vat.getRecipes(), stack);
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
// Loops through the registry, to find the item that matches, saves that
|
||||
// recipe then removes it
|
||||
@Override
|
||||
public void apply() {
|
||||
for (RecipeVat r : MaricultureHandlers.vat.getRecipes()) {
|
||||
if (r != null)
|
||||
if (r.outputItem != null && stack != null && areEqual(r.outputItem, stack)) {
|
||||
if (r.outputFluid == null || (fluid != null && r.outputFluid.isFluidStackIdentical(fluid))) {
|
||||
recipe = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((r.outputFluid != null && fluid != null && r.outputFluid.isFluidStackIdentical(fluid))) {
|
||||
recipe = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (recipe != null)
|
||||
MaricultureHandlers.vat.getRecipes().remove(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return stack != null ? stack.getDisplayName() : fluid.getFluid().getLocalizedName();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user