mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-21 04:42:20 +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
@@ -2,8 +2,6 @@ package modtweaker2.mods.auracascade.aura;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import minetweaker.IBracketHandler;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.annotations.BracketHandler;
|
||||
@@ -56,8 +54,8 @@ public class AuraBracketHandler implements IBracketHandler {
|
||||
}
|
||||
|
||||
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
|
||||
StringBuilder valueBuilder = new StringBuilder();
|
||||
// }
|
||||
//StringBuilder valueBuilder = new StringBuilder();
|
||||
|
||||
for (EnumAura a : EnumAura.values()) {
|
||||
for (int i = startIndex; i < endIndex; i++) {
|
||||
Token token = tokens.get(i);
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package modtweaker2.mods.auracascade.aura;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import pixlepix.auracascade.data.EnumAura;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.MineTweakerImplementationAPI;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.api.server.ICommandFunction;
|
||||
import modtweaker2.ModTweaker2;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import pixlepix.auracascade.data.EnumAura;
|
||||
|
||||
public class AuraLogger implements ICommandFunction {
|
||||
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
package modtweaker2.mods.auracascade.handlers;
|
||||
|
||||
import static modtweaker2.helpers.InputHelper.toIItemStack;
|
||||
import static modtweaker2.helpers.InputHelper.toStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.helpers.InputHelper;
|
||||
import modtweaker2.helpers.LogHelper;
|
||||
import modtweaker2.mods.auracascade.AuraCascadeHelper;
|
||||
import modtweaker2.mods.auracascade.aura.IAuraStack;
|
||||
import modtweaker2.utils.BaseListAddition;
|
||||
import modtweaker2.utils.BaseListRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import pixlepix.auracascade.data.recipe.PylonRecipe;
|
||||
import pixlepix.auracascade.data.recipe.PylonRecipeComponent;
|
||||
import pixlepix.auracascade.data.recipe.PylonRecipeRegistry;
|
||||
@@ -19,7 +23,11 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
@ZenClass("mods.auraCascade.Pylon")
|
||||
public class Pylon {
|
||||
|
||||
protected static final String name = "Aura Cascade Pylon";
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack ouput, IAuraStack stack, IItemStack input) {
|
||||
addRecipe(ouput, stack, input, stack, input, stack, input, stack, input);
|
||||
@@ -27,37 +35,53 @@ public class Pylon {
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack ouput, IAuraStack aura1, IItemStack input1, IAuraStack aura2, IItemStack input2, IAuraStack aura3, IItemStack input3, IAuraStack aura4, IItemStack input4) {
|
||||
MineTweakerAPI.apply(new Add(new PylonRecipe(toStack(ouput), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input1)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura2), toStack(input2)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura3), toStack(input3)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input4)))));
|
||||
List<PylonRecipe> recipes = new LinkedList<PylonRecipe>();
|
||||
|
||||
recipes.add(new PylonRecipe(toStack(ouput), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input1)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura2), toStack(input2)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura3), toStack(input3)), new PylonRecipeComponent(AuraCascadeHelper.toAura(aura1), toStack(input4))));
|
||||
|
||||
MineTweakerAPI.apply(new Add(recipes));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition {
|
||||
private static class Add extends BaseListAddition<PylonRecipe> {
|
||||
|
||||
public Add(PylonRecipe recipe) {
|
||||
super(PylonRecipeRegistry.recipes, recipe);
|
||||
public Add(List<PylonRecipe> recipes) {
|
||||
super(Pylon.name, PylonRecipeRegistry.recipes, recipes);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(PylonRecipe recipe) {
|
||||
return InputHelper.getStackDescription(recipe.result);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack ouput) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(ouput)));
|
||||
public static void removeRecipe(IIngredient output) {
|
||||
List<PylonRecipe> recipes = new LinkedList<PylonRecipe>();
|
||||
|
||||
for (PylonRecipe r : PylonRecipeRegistry.recipes) {
|
||||
if (output.matches(toIItemStack(r.result))) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we found the recipes and apply the action
|
||||
if(!recipes.isEmpty()) {
|
||||
MineTweakerAPI.apply(new Remove(recipes));
|
||||
} else {
|
||||
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Pylon.name, output.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval {
|
||||
public Remove(ItemStack stack) {
|
||||
super(PylonRecipeRegistry.recipes, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (PylonRecipe r : PylonRecipeRegistry.recipes) {
|
||||
if (r.result.isItemEqual(stack)) {
|
||||
recipes.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
super.apply();
|
||||
private static class Remove extends BaseListRemoval<PylonRecipe> {
|
||||
public Remove(List<PylonRecipe> recipes) {
|
||||
super(Pylon.name, PylonRecipeRegistry.recipes, recipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRecipeInfo(PylonRecipe recipe) {
|
||||
return InputHelper.getStackDescription(recipe.result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user