Aura Cascade support!

This commit is contained in:
jaredlll08 2015-02-23 14:42:40 +02:00
parent d35d9b1f69
commit aeb42cd64e
14 changed files with 320 additions and 1 deletions

View file

@ -1,3 +1,3 @@
mc_version=1.7.10 mc_version=1.7.10
forge_version=10.13.2.1286 forge_version=10.13.2.1291
mod_version=0.3.0 mod_version=0.3.0

Binary file not shown.

View file

@ -6,6 +6,7 @@ import minetweaker.MineTweakerImplementationAPI;
import minetweaker.MineTweakerImplementationAPI.ReloadEvent; import minetweaker.MineTweakerImplementationAPI.ReloadEvent;
import minetweaker.util.IEventHandler; import minetweaker.util.IEventHandler;
import modtweaker2.mods.appeng.AppliedEnergistics; import modtweaker2.mods.appeng.AppliedEnergistics;
import modtweaker2.mods.auracascade.AuraCascade;
import modtweaker2.mods.botania.Botania; import modtweaker2.mods.botania.Botania;
import modtweaker2.mods.chisel.Chisel; import modtweaker2.mods.chisel.Chisel;
import modtweaker2.mods.exnihilo.ExNihilo; import modtweaker2.mods.exnihilo.ExNihilo;
@ -80,6 +81,7 @@ public class ModTweaker2 {
TweakerPlugin.register("ThermalExpansion", ThermalExpansion.class); TweakerPlugin.register("ThermalExpansion", ThermalExpansion.class);
TweakerPlugin.register("Forestry", Forestry.class); TweakerPlugin.register("Forestry", Forestry.class);
TweakerPlugin.register("chisel", Chisel.class); TweakerPlugin.register("chisel", Chisel.class);
TweakerPlugin.register("aura", AuraCascade.class);
MinecraftForge.EVENT_BUS.register(new modtweaker2.EventHandler()); MinecraftForge.EVENT_BUS.register(new modtweaker2.EventHandler());
if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import minetweaker.MineTweakerAPI; import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack; import minetweaker.api.item.IItemStack;
import modtweaker2.mods.auracascade.aura.IAuraStack;
import modtweaker2.util.BaseListAddition; import modtweaker2.util.BaseListAddition;
import modtweaker2.util.BaseListRemoval; import modtweaker2.util.BaseListRemoval;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -0,0 +1,16 @@
package modtweaker2.mods.auracascade;
import minetweaker.MineTweakerAPI;
import modtweaker2.mods.auracascade.aura.AuraBracketHandler;
import modtweaker2.mods.auracascade.handlers.Pylon;
import modtweaker2.mods.mekanism.gas.GasBracketHandler;
import pixlepix.auracascade.block.tile.AngelSteelTile;
import pixlepix.auracascade.data.recipe.PylonRecipeRegistry;
public class AuraCascade {
public AuraCascade(){
MineTweakerAPI.registerBracketHandler(new AuraBracketHandler());
MineTweakerAPI.registerClass(Pylon.class);
}
}

View file

@ -0,0 +1,28 @@
package modtweaker2.mods.auracascade;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import minetweaker.api.item.IIngredient;
import modtweaker2.mods.auracascade.aura.IAuraStack;
import modtweaker2.mods.mekanism.gas.IGasStack;
import pixlepix.auracascade.data.AuraQuantity;
import pixlepix.auracascade.data.EnumAura;
public class AuraCascadeHelper {
public static AuraQuantity toAura(IAuraStack iStack) {
if (iStack == null) {
return null;
} else return new AuraQuantity(EnumAura.valueOf(iStack.getName()), iStack.getAmount());
}
// public static GasStack[] toGases(IIngredient[] input) {
// return toGases((IGasStack[]) input);
// }
//
// public static GasStack[] toGases(IGasStack[] iStack) {
// GasStack[] stack = new GasStack[iStack.length];
// for (int i = 0; i < stack.length; i++)
// stack[i] = toGas(iStack[i]);
// return stack;
// }
}

View file

@ -0,0 +1,87 @@
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;
import minetweaker.api.item.IngredientAny;
import pixlepix.auracascade.data.AuraQuantity;
import pixlepix.auracascade.data.EnumAura;
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
import stanhebben.zenscript.expression.ExpressionCallStatic;
import stanhebben.zenscript.expression.ExpressionString;
import stanhebben.zenscript.expression.partial.IPartialExpression;
import stanhebben.zenscript.parser.Token;
import stanhebben.zenscript.symbols.IZenSymbol;
import stanhebben.zenscript.type.natives.IJavaMethod;
import stanhebben.zenscript.util.ZenPosition;
@BracketHandler(priority = 100)
public class AuraBracketHandler implements IBracketHandler {
public static IAuraStack getAura(String name) {
EnumAura aura = EnumAura.valueOf(name);
if (aura != null) {
return new MCAuraStack(new AuraQuantity(aura, 1));
} else {
return null;
}
}
private final IZenSymbol symbolAny;
private final IJavaMethod method;
public AuraBracketHandler() {
symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE");
method = MineTweakerAPI.getJavaMethod(AuraBracketHandler.class, "getAura", String.class);
}
@Override
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens) {
// any symbol
if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) {
return symbolAny;
}
if (tokens.size() > 2) {
if (tokens.get(0).getValue().equals("aura") && tokens.get(1).getValue().equals(":")) {
return find(environment, tokens, 2, tokens.size());
}
}
return null;
}
private IZenSymbol find(IEnvironmentGlobal environment, List<Token> tokens, int startIndex, int endIndex) {
StringBuilder valueBuilder = new StringBuilder();
// }
for (EnumAura a : EnumAura.values()) {
for (int i = startIndex; i < endIndex; i++) {
Token token = tokens.get(i);
if (a.name().equals(token.getValue())) {
return new AuraReferenceSymbol(environment, token.getValue());
}
}
}
return null;
}
private class AuraReferenceSymbol implements IZenSymbol {
private final IEnvironmentGlobal environment;
private final String name;
public AuraReferenceSymbol(IEnvironmentGlobal environment, String name) {
this.environment = environment;
this.name = name;
}
@Override
public IPartialExpression instance(ZenPosition position) {
return new ExpressionCallStatic(position, environment, method, new ExpressionString(position, name));
}
}
}

View file

@ -0,0 +1,19 @@
package modtweaker2.mods.auracascade.aura;
import stanhebben.zenscript.annotations.OperatorType;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
import stanhebben.zenscript.annotations.ZenOperator;
@ZenClass("modtweaker.auraCascade.IAuraDefinition")
public interface IAuraDefinition {
@ZenOperator(OperatorType.MUL)
public IAuraStack asAura(int amount);
@ZenGetter("name")
public String getName();
@ZenGetter("displayName")
public String getDisplayName();
}

View file

@ -0,0 +1,28 @@
package modtweaker2.mods.auracascade.aura;
import stanhebben.zenscript.annotations.OperatorType;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
import stanhebben.zenscript.annotations.ZenMethod;
import stanhebben.zenscript.annotations.ZenOperator;
@ZenClass("modtweaker.auraCascade.IAuraStack")
public interface IAuraStack {
@ZenGetter("definition")
public IAuraDefinition getDefinition();
@ZenGetter("name")
public String getName();
@ZenGetter("displayName")
public String getDisplayName();
@ZenGetter("amount")
public int getAmount();
@ZenOperator(OperatorType.MUL)
@ZenMethod
public IAuraStack withAmount(int amount);
public Object getInternal();
}

View file

@ -0,0 +1,27 @@
package modtweaker2.mods.auracascade.aura;
import pixlepix.auracascade.data.AuraQuantity;
public class MCAuraDefinition implements IAuraDefinition {
private final AuraQuantity aura;
public MCAuraDefinition(AuraQuantity aura) {
this.aura = aura;
}
@Override
public String getName() {
return aura.getType().name;
}
@Override
public String getDisplayName() {
return aura.getType().name;
}
@Override
public IAuraStack asAura(int amount) {
return new MCAuraStack(new AuraQuantity(aura.getType(), aura.getNum()));
}
}

View file

@ -0,0 +1,43 @@
package modtweaker2.mods.auracascade.aura;
import pixlepix.auracascade.data.AuraQuantity;
public class MCAuraStack implements IAuraStack {
private final AuraQuantity aura;
public MCAuraStack(AuraQuantity aura) {
this.aura = aura;
}
@Override
public IAuraDefinition getDefinition() {
return new MCAuraDefinition(aura);
}
@Override
public String getName() {
return aura.getType().name();
}
@Override
public String getDisplayName() {
return aura.getType().name();
}
@Override
public int getAmount() {
return aura.getNum();
}
@Override
public IAuraStack withAmount(int amount) {
AuraQuantity result = new AuraQuantity(aura.getType(), amount);
return new MCAuraStack(result);
}
@Override
public Object getInternal() {
return aura;
}
}

View file

@ -0,0 +1,68 @@
package modtweaker2.mods.auracascade.handlers;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import static modtweaker2.helpers.InputHelper.*;
import modtweaker2.mods.appeng.handlers.Inscriber.Add;
import modtweaker2.mods.auracascade.AuraCascadeHelper;
import modtweaker2.mods.auracascade.aura.IAuraStack;
import modtweaker2.util.BaseListAddition;
import modtweaker2.util.BaseListRemoval;
import pixlepix.auracascade.data.recipe.PylonRecipe;
import pixlepix.auracascade.data.recipe.PylonRecipeComponent;
import pixlepix.auracascade.data.recipe.PylonRecipeRegistry;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
@ZenClass("mods.auraCascade.Pylon")
public class Pylon {
@ZenMethod
public static void addRecipe(IItemStack ouput, IAuraStack stack, IItemStack input) {
addRecipe(ouput, stack, input, stack, input, stack, input, stack, input);
}
@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)))));
}
private static class Add extends BaseListAddition {
public Add(PylonRecipe recipe) {
super(PylonRecipeRegistry.recipes, recipe);
}
}
@ZenMethod
public static void removeRecipe(IItemStack ouput) {
MineTweakerAPI.apply(new Remove(toStack(ouput)));
}
private static class Remove extends BaseListRemoval {
ArrayList<PylonRecipe> recipesToRemove = new ArrayList<PylonRecipe>();
public Remove(ItemStack stack) {
super(PylonRecipeRegistry.recipes, stack);
}
@Override
public void apply() {
for (PylonRecipe r : PylonRecipeRegistry.recipes) {
if (r.result.isItemEqual(stack)) {
recipesToRemove.add(r);
}
}
for (PylonRecipe r : recipesToRemove) {
recipesToRemove.remove(r);
}
}
}
}