This closes #17 and closes #58, I tested and it worked using the script given

Also changes like all packages
inb4 "jared changes a package name in ModTweaker2 breaking compatability
with everything" drama tweet.
This commit is contained in:
jaredlll08 committed 2015-02-20 23:57:32 +02:00
1 parent 4fd2551072
commit ec562b62ea
187 files changed
+977 -991

No files matched your search

@@ -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;
}
}
}