mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-25 14:44:32 +00:00
ModTweaker2 Rework
- Revised base classes for IUndoableAction - Reordered lots of code, so stuck actions should be less frequent - Added wildcard support to many "remove" methods - Started working on exist & duplicate checks
This commit is contained in:
1 parent
f5034b04d8
commit
da33cc6fab
112 files changed
+4596
-3522
No files matched your search
@@ -3,15 +3,17 @@ package modtweaker2.mods.railcraft.handlers;
|
||||
import static modtweaker2.helpers.InputHelper.toObjects;
|
||||
import static modtweaker2.helpers.InputHelper.toShapedObjects;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import mods.railcraft.api.crafting.RailcraftCraftingManager;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.railcraft.RailcraftHelper;
|
||||
import modtweaker2.utils.BaseCraftingAddition;
|
||||
import modtweaker2.utils.BaseCraftingRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
@@ -19,42 +21,42 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@ZenClass("mods.railcraft.Rolling")
|
||||
public class RollingMachine {
|
||||
|
||||
public static final String name = "Railcraft Rolling Machine";
|
||||
|
||||
@ZenMethod
|
||||
public static void addShaped(IItemStack output, IIngredient[][] ingredients) {
|
||||
MineTweakerAPI.apply(new Add(false, toStack(output), toShapedObjects(ingredients)));
|
||||
MineTweakerAPI.apply(new Add(new ShapedOreRecipe(toStack(output), toShapedObjects(ingredients))));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addShapeless(IItemStack output, IIngredient[] ingredients) {
|
||||
MineTweakerAPI.apply(new Add(true, toStack(output), toObjects(ingredients)));
|
||||
MineTweakerAPI.apply(new Add(new ShapelessOreRecipe(toStack(output), toObjects(ingredients))));
|
||||
}
|
||||
|
||||
private static class Add extends BaseCraftingAddition {
|
||||
public Add(boolean shapeless, ItemStack output, Object... recipe) {
|
||||
super("Rolling Machine", shapeless, RailcraftHelper.rolling, output, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyShaped() {
|
||||
RailcraftHelper.rolling.add(new ShapedOreRecipe(output, recipe));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyShapeless() {
|
||||
RailcraftHelper.rolling.add(new ShapelessOreRecipe(output, recipe));
|
||||
public Add(IRecipe recipe) {
|
||||
super(RollingMachine.name, RailcraftHelper.rolling);
|
||||
recipes.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(output)));
|
||||
public static void removeRecipe(IIngredient ingredient) {
|
||||
List<IRecipe> recipes = BaseCraftingRemoval.getRecipes(RailcraftHelper.rolling, ingredient);
|
||||
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipes found for %s. Command ignored!", RollingMachine.name, ingredient.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseCraftingRemoval {
|
||||
public Remove(ItemStack stack) {
|
||||
super("Rolling Machine", RailcraftHelper.rolling, stack);
|
||||
public Remove(List<IRecipe> recipes) {
|
||||
super(RollingMachine.name, RailcraftHelper.rolling, recipes);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user