diff --git a/build.gradle b/build.gradle index 4c4d395..1523c5b 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "0.9.1" +version = "0.9.2" group= "modtweaker" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "ModTweaker~2" diff --git a/libs/CTMLib-1.2.0-7-deobf.jar b/libs/CTMLib-1.2.0-7-deobf.jar new file mode 100644 index 0000000..9489f4c Binary files /dev/null and b/libs/CTMLib-1.2.0-7-deobf.jar differ diff --git a/libs/Chisel2_DEV-2.3.5.0064ec3-deobf.jar b/libs/Chisel2_DEV-2.5.0.148-deobf.jar similarity index 65% rename from libs/Chisel2_DEV-2.3.5.0064ec3-deobf.jar rename to libs/Chisel2_DEV-2.5.0.148-deobf.jar index f248e27..89f073e 100644 Binary files a/libs/Chisel2_DEV-2.3.5.0064ec3-deobf.jar and b/libs/Chisel2_DEV-2.5.0.148-deobf.jar differ diff --git a/libs/Railcraft_1.7.10-9.4.0.0-dev.jar b/libs/Railcraft_1.7.10-9.6.1.0-dev.jar similarity index 59% rename from libs/Railcraft_1.7.10-9.4.0.0-dev.jar rename to libs/Railcraft_1.7.10-9.6.1.0-dev.jar index d77da66..c942231 100644 Binary files a/libs/Railcraft_1.7.10-9.4.0.0-dev.jar and b/libs/Railcraft_1.7.10-9.6.1.0-dev.jar differ diff --git a/src/main/java/modtweaker2/ModProps.java b/src/main/java/modtweaker2/ModProps.java index 1326aba..f62ccbe 100644 --- a/src/main/java/modtweaker2/ModProps.java +++ b/src/main/java/modtweaker2/ModProps.java @@ -4,6 +4,6 @@ public class ModProps { public static final String NAME = "Mod Tweaker 2", name = NAME; public static final String MODID = "modtweaker2", modid = MODID; - public static final String VERSION = "0.9.1", version = VERSION; + public static final String VERSION = "0.9.2", version = VERSION; public static final String DEPENDENCIES = "required-after:MineTweaker3", dependencies = DEPENDENCIES; } diff --git a/src/main/java/modtweaker2/helpers/LogHelper.java b/src/main/java/modtweaker2/helpers/LogHelper.java index 14d74ba..9991ae4 100644 --- a/src/main/java/modtweaker2/helpers/LogHelper.java +++ b/src/main/java/modtweaker2/helpers/LogHelper.java @@ -1,6 +1,7 @@ package modtweaker2.helpers; import java.util.Arrays; +import java.util.LinkedList; import java.util.List; import mekanism.api.gas.GasStack; @@ -9,6 +10,8 @@ import minetweaker.MineTweakerImplementationAPI; import minetweaker.api.player.IPlayer; import minetweaker.mc1710.item.MCItemStack; import modtweaker2.mods.mekanism.gas.MCGasStack; +import modtweaker2.mods.thaumcraft.aspect.AspectStack; +import modtweaker2.mods.thaumcraft.aspect.MCAspectStack; import modtweaker2.utils.TweakerPlugin; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; @@ -19,6 +22,8 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; public class LogHelper { public static void logPrinted(IPlayer player) { @@ -66,6 +71,14 @@ public class LogHelper { return new MCItemStack(new ItemStack((Block)object, 1, 0)).toString(); } else if (TweakerPlugin.isLoaded("Mekanism") && object instanceof GasStack) { return new MCGasStack((GasStack)object).toString(); + } else if (TweakerPlugin.isLoaded("Thaumcraft") && object instanceof AspectStack) { + return new MCAspectStack((AspectStack)object).toString(); + } else if(TweakerPlugin.isLoaded("Thaumcraft") && object instanceof AspectList) { + List stacks = new LinkedList(); + for(Aspect a : ((AspectList)object).getAspects()) { + stacks.add(new AspectStack(a, ((AspectList)object).getAmount(a))); + } + return(getListDescription(stacks)); } else if (object instanceof String) { // Check if string specifies an oredict entry List ores = OreDictionary.getOres((String)object); @@ -75,6 +88,10 @@ public class LogHelper { } else { return "\"" + (String)object + "\""; } + } else if (object instanceof List) { + return getListDescription((List)object); + } else if(object instanceof Object[]) { + return getListDescription(Arrays.asList((Object[])object)); } else if (object != null) { return "\"" + object.toString() + "\""; } else { diff --git a/src/main/java/modtweaker2/mods/appeng/handlers/Inscriber.java b/src/main/java/modtweaker2/mods/appeng/handlers/Inscriber.java index 694aee8..9fd7256 100644 --- a/src/main/java/modtweaker2/mods/appeng/handlers/Inscriber.java +++ b/src/main/java/modtweaker2/mods/appeng/handlers/Inscriber.java @@ -31,7 +31,7 @@ public class Inscriber { @ZenMethod public static void addRecipe(IItemStack[] imprintable, IItemStack plateA, IItemStack plateB, IItemStack out, String type) { - if(imprintable == null || out == null || (!type.equals("Press") || !type.equals("Inscribe"))) { + if(imprintable == null || out == null || (!type.equals("Press") && !type.equals("Inscribe"))) { LogHelper.logError(String.format("Required parameters missing for %s Recipe.", Inscriber.name)); return; } diff --git a/src/main/java/modtweaker2/mods/railcraft/RailcraftHelper.java b/src/main/java/modtweaker2/mods/railcraft/RailcraftHelper.java index a4a3c31..8f829f7 100644 --- a/src/main/java/modtweaker2/mods/railcraft/RailcraftHelper.java +++ b/src/main/java/modtweaker2/mods/railcraft/RailcraftHelper.java @@ -1,14 +1,17 @@ package modtweaker2.mods.railcraft; +import java.util.ArrayList; import java.util.List; import mods.railcraft.api.crafting.IBlastFurnaceRecipe; import mods.railcraft.api.crafting.ICokeOvenRecipe; import mods.railcraft.api.crafting.IRockCrusherRecipe; import mods.railcraft.api.crafting.RailcraftCraftingManager; +import mods.railcraft.common.util.crafting.BlastFurnaceCraftingManager; import mods.railcraft.common.util.crafting.BlastFurnaceCraftingManager.BlastFurnaceRecipe; import mods.railcraft.common.util.crafting.CokeOvenCraftingManager.CokeOvenRecipe; import mods.railcraft.common.util.crafting.RockCrusherCraftingManager.CrusherRecipe; +import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.ReflectionHelper; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -19,13 +22,18 @@ public class RailcraftHelper { public static List oven = null; public static List crusher = null; public static List rolling = null; + public static List fuels = null; static { try { furnace = RailcraftCraftingManager.blastFurnace.getRecipes(); oven = RailcraftCraftingManager.cokeOven.getRecipes(); crusher = RailcraftCraftingManager.rockCrusher.getRecipes(); rolling = RailcraftCraftingManager.rollingMachine.getRecipeList(); - } catch (Exception e) {} + + fuels = new ArrayList(RailcraftCraftingManager.blastFurnace.getFuels()); + ReflectionHelper.setPrivateValue(BlastFurnaceCraftingManager.class, RailcraftCraftingManager.blastFurnace, "fuels", fuels); + + } catch (Exception e) { LogHelper.logError("Error in RailcraftHelper", e); } } private RailcraftHelper() {} diff --git a/src/main/java/modtweaker2/mods/railcraft/handlers/BlastFurnace.java b/src/main/java/modtweaker2/mods/railcraft/handlers/BlastFurnace.java index 6fdea70..c64e4f5 100644 --- a/src/main/java/modtweaker2/mods/railcraft/handlers/BlastFurnace.java +++ b/src/main/java/modtweaker2/mods/railcraft/handlers/BlastFurnace.java @@ -11,10 +11,14 @@ import minetweaker.MineTweakerAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import mods.railcraft.api.crafting.IBlastFurnaceRecipe; +import modtweaker2.helpers.InputHelper; import modtweaker2.helpers.LogHelper; +import modtweaker2.helpers.StackHelper; import modtweaker2.mods.railcraft.RailcraftHelper; import modtweaker2.utils.BaseListAddition; import modtweaker2.utils.BaseListRemoval; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntityFurnace; import stanhebben.zenscript.annotations.ZenClass; import stanhebben.zenscript.annotations.ZenMethod; @@ -22,9 +26,17 @@ import stanhebben.zenscript.annotations.ZenMethod; public class BlastFurnace { public static final String name = "Railcraft Blast Furnace"; + public static final String nameFuel = "Railcraft Blast Furnace (Fuel)"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, int cookTime, IItemStack output) { + if(input == null || output == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } + MineTweakerAPI.apply(new Add(RailcraftHelper.getBlastFurnaceRecipe(toStack(input), matchDamage, matchNBT, cookTime, toStack(output)))); } @@ -40,9 +52,16 @@ public class BlastFurnace { return LogHelper.getStackDescription(recipe.getOutput()); } } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @ZenMethod public static void removeRecipe(IIngredient output) { + if(output == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } + List recipes = new LinkedList(); for (IBlastFurnaceRecipe r : RailcraftHelper.furnace) { @@ -69,4 +88,79 @@ public class BlastFurnace { return LogHelper.getStackDescription(recipe.getOutput()); } } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void addFuel(IIngredient itemInput) { + if(itemInput == null) { + LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); + return; + } + + List fuels = new LinkedList(); + + for(IItemStack item : itemInput.getItems()) { + + boolean match = false; + + for(ItemStack fuel : RailcraftHelper.fuels) { + if(StackHelper.matches(item, InputHelper.toIItemStack(fuel))) { + match = true; + break; + } + } + + if(!match && TileEntityFurnace.isItemFuel(InputHelper.toStack(item))) { + fuels.add(InputHelper.toStack(item)); + } + } + + if(!fuels.isEmpty()) { + MineTweakerAPI.apply(new AddFuels(fuels)); + } else { + LogHelper.logWarning(String.format("No %s added.", nameFuel)); + } + } + + private static class AddFuels extends BaseListAddition { + public AddFuels(List fuels) { + super(BlastFurnace.nameFuel, RailcraftHelper.fuels, fuels); + } + + @Override + protected String getRecipeInfo(ItemStack recipe) { + return LogHelper.getStackDescription(recipe); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + private static void removeFuel(IIngredient itemInput) { + List fuels = new LinkedList(); + + for(ItemStack fuel : RailcraftHelper.fuels) { + if(StackHelper.matches(itemInput, InputHelper.toIItemStack(fuel))) { + fuels.add(fuel); + } + } + + if(!fuels.isEmpty()) { + MineTweakerAPI.apply(new RemoveFuels(fuels)); + } else { + LogHelper.logWarning(String.format("No %s found for argument %s.", nameFuel, itemInput.toString())); + } + } + + private static class RemoveFuels extends BaseListRemoval { + public RemoveFuels(List fuels) { + super(BlastFurnace.nameFuel, RailcraftHelper.fuels, fuels); + } + + @Override + protected String getRecipeInfo(ItemStack recipe) { + return LogHelper.getStackDescription(recipe); + } + } } diff --git a/src/main/java/modtweaker2/mods/railcraft/handlers/CokeOven.java b/src/main/java/modtweaker2/mods/railcraft/handlers/CokeOven.java index ea051d6..5ff8859 100644 --- a/src/main/java/modtweaker2/mods/railcraft/handlers/CokeOven.java +++ b/src/main/java/modtweaker2/mods/railcraft/handlers/CokeOven.java @@ -28,6 +28,8 @@ public class CokeOven { public static final String name = "Railcraft Coke Oven"; + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /** * Adds a recipe for the Coke Oven * diff --git a/src/main/java/modtweaker2/mods/railcraft/handlers/RockCrusher.java b/src/main/java/modtweaker2/mods/railcraft/handlers/RockCrusher.java index ebb1a9f..3116017 100644 --- a/src/main/java/modtweaker2/mods/railcraft/handlers/RockCrusher.java +++ b/src/main/java/modtweaker2/mods/railcraft/handlers/RockCrusher.java @@ -23,6 +23,8 @@ public class RockCrusher { public static final String name = "Railcraft Rock Crusher"; + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + @ZenMethod public static void addRecipe(IItemStack input, boolean matchDamage, boolean matchNBT, IItemStack[] output, double[] chances) { IRockCrusherRecipe recipe = RailcraftHelper.getRockCrusherRecipe(toStack(input), matchDamage, matchNBT); diff --git a/src/main/java/modtweaker2/mods/railcraft/handlers/RollingMachine.java b/src/main/java/modtweaker2/mods/railcraft/handlers/RollingMachine.java index fa51768..bf45c75 100644 --- a/src/main/java/modtweaker2/mods/railcraft/handlers/RollingMachine.java +++ b/src/main/java/modtweaker2/mods/railcraft/handlers/RollingMachine.java @@ -24,6 +24,8 @@ public class RollingMachine { public static final String name = "Railcraft Rolling Machine"; + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + @ZenMethod public static void addShaped(IItemStack output, IIngredient[][] ingredients) { MineTweakerAPI.apply(new Add(new ShapedOreRecipe(toStack(output), toShapedObjects(ingredients)))); diff --git a/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java b/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java index 2e183fa..1425a46 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java @@ -1,16 +1,19 @@ package modtweaker2.mods.thaumcraft; import minetweaker.MineTweakerAPI; +import modtweaker2.mods.thaumcraft.aspect.AspectBracketHandler; import modtweaker2.mods.thaumcraft.handlers.Arcane; import modtweaker2.mods.thaumcraft.handlers.Aspects; import modtweaker2.mods.thaumcraft.handlers.Crucible; import modtweaker2.mods.thaumcraft.handlers.Infusion; import modtweaker2.mods.thaumcraft.handlers.Loot; import modtweaker2.mods.thaumcraft.handlers.Research; +import modtweaker2.mods.thaumcraft.handlers.Test; import modtweaker2.mods.thaumcraft.handlers.Warp; public class Thaumcraft { public Thaumcraft() { + MineTweakerAPI.registerBracketHandler(new AspectBracketHandler()); MineTweakerAPI.registerClass(Arcane.class); MineTweakerAPI.registerClass(Aspects.class); MineTweakerAPI.registerClass(Crucible.class); @@ -18,6 +21,5 @@ public class Thaumcraft { MineTweakerAPI.registerClass(Research.class); MineTweakerAPI.registerClass(Warp.class); MineTweakerAPI.registerClass(Loot.class); - } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java b/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java index 90d21dc..383a597 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java @@ -4,7 +4,12 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import minetweaker.api.item.IItemStack; +import modtweaker2.helpers.LogHelper; import modtweaker2.helpers.ReflectionHelper; +import modtweaker2.mods.thaumcraft.aspect.AspectStack; +import modtweaker2.mods.thaumcraft.aspect.IAspectStack; +import net.minecraft.item.ItemStack; import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.ThaumcraftApi.EntityTags; import thaumcraft.api.aspects.Aspect; @@ -103,4 +108,30 @@ public class ThaumcraftHelper { } return output; } + + public static AspectStack[] toStacks(IAspectStack[] iStack) { + if (iStack == null) { + return null; + } else { + AspectStack[] output = new AspectStack[iStack.length]; + for (int i = 0; i < iStack.length; i++) { + output[i] = toStack(iStack[i]); + } + + return output; + } + } + + public static AspectStack toStack(IAspectStack iStack) { + if (iStack == null) { + return null; + } else { + Object internal = iStack.getInternal(); + if (!(internal instanceof AspectStack)) { + LogHelper.logError("Not a valid aspect stack: " + iStack); + } + + return (AspectStack) internal; + } + } } diff --git a/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectBracketHandler.java b/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectBracketHandler.java new file mode 100644 index 0000000..456c49f --- /dev/null +++ b/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectBracketHandler.java @@ -0,0 +1,85 @@ +package modtweaker2.mods.thaumcraft.aspect; + +import java.util.List; + +import minetweaker.IBracketHandler; +import minetweaker.MineTweakerAPI; +import minetweaker.annotations.BracketHandler; +import minetweaker.api.item.IngredientAny; +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; +import thaumcraft.api.aspects.Aspect; + +@BracketHandler(priority = 100) +public class AspectBracketHandler implements IBracketHandler { + + private final IZenSymbol symbolAny; + private final IJavaMethod method; + + public AspectBracketHandler() { + this.symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE"); + this.method = MineTweakerAPI.getJavaMethod(AspectBracketHandler.class, "getAspect", String.class); + } + + public static IAspectStack getAspect(String name) { + Aspect aspect = Aspect.getAspect(name.toLowerCase()); + if (aspect != null) { + return new MCAspectStack(new AspectStack(aspect, 1)); + } else { + return null; + } + } + + @Override + public IZenSymbol resolve(IEnvironmentGlobal environment, List tokens) { + if (tokens.size() == 1 && tokens.get(0).getValue().equals("*")) { + return symbolAny; + } + + if (tokens.size() > 2) { + if (tokens.get(0).getValue().equals("aspect") && tokens.get(1).getValue().equals(":")) { + return find(environment, tokens, 2, tokens.size()); + } + } + + return null; + } + + private IZenSymbol find(IEnvironmentGlobal environment, List tokens, int startIndex, int endIndex) { + StringBuilder value = new StringBuilder(); + + for (int i = startIndex; i < endIndex; i++) { + Token token = tokens.get(i); + value.append(token.getValue()); + } + + Aspect aspect = Aspect.getAspect(value.toString().toLowerCase()); + + if(aspect != null) { + return new AspectReferenceSymbol(environment, value.toString()); + } + + return null; + } + + private class AspectReferenceSymbol implements IZenSymbol { + private final IEnvironmentGlobal environment; + private final String name; + + public AspectReferenceSymbol(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)); + } + } +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectStack.java b/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectStack.java new file mode 100644 index 0000000..a12d9cf --- /dev/null +++ b/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectStack.java @@ -0,0 +1,44 @@ +package modtweaker2.mods.thaumcraft.aspect; + +import thaumcraft.api.aspects.Aspect; +import thaumcraft.api.aspects.AspectList; + +public class AspectStack { + public Aspect aspect; + public int amount; + + public AspectStack(Aspect aspect, int amount) { + this.aspect = aspect; + this.amount = amount; + } + + public Aspect getAspect() { + return aspect; + } + + public AspectList getAspectList() { + AspectList aspectList = new AspectList(); + aspectList.add(aspect, amount); + return aspectList; + } + + public static AspectList join(AspectList... aspectLists) { + AspectList result = new AspectList(); + + for(AspectList aspectList : aspectLists) { + result.add(aspectList); + } + + return result; + } + + public static AspectList join(AspectStack... aspectStacks) { + AspectList result = new AspectList(); + + for(AspectStack stack : aspectStacks) { + result.add(stack.getAspectList()); + } + + return result; + } +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/aspect/IAspectDefinition.java b/src/main/java/modtweaker2/mods/thaumcraft/aspect/IAspectDefinition.java new file mode 100644 index 0000000..6beb5a1 --- /dev/null +++ b/src/main/java/modtweaker2/mods/thaumcraft/aspect/IAspectDefinition.java @@ -0,0 +1,5 @@ +package modtweaker2.mods.thaumcraft.aspect; + +public interface IAspectDefinition { + +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/aspect/IAspectStack.java b/src/main/java/modtweaker2/mods/thaumcraft/aspect/IAspectStack.java new file mode 100644 index 0000000..842fc05 --- /dev/null +++ b/src/main/java/modtweaker2/mods/thaumcraft/aspect/IAspectStack.java @@ -0,0 +1,32 @@ +package modtweaker2.mods.thaumcraft.aspect; + +import java.util.List; + +import minetweaker.api.item.IIngredient; +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.aspect.IAspectStack") +public interface IAspectStack extends IIngredient { + + @ZenGetter("definition") + public abstract IAspectDefinition getDefinition(); + + @ZenGetter("name") + public abstract String getName(); + + @ZenGetter("displayName") + public abstract String getDisplayName(); + + @ZenOperator(OperatorType.MUL) + @ZenMethod + public abstract IAspectStack amount(int amount); + + @ZenMethod + public abstract IAspectStack withAmount(int amount); + + public abstract List getAspects(); +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectDefinition.java b/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectDefinition.java new file mode 100644 index 0000000..e476cb8 --- /dev/null +++ b/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectDefinition.java @@ -0,0 +1,11 @@ +package modtweaker2.mods.thaumcraft.aspect; + + + +public class MCAspectDefinition implements IAspectDefinition { + + public MCAspectDefinition(AspectStack stack) { + // TODO Auto-generated constructor stub + } + +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectStack.java b/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectStack.java new file mode 100644 index 0000000..8df48bf --- /dev/null +++ b/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectStack.java @@ -0,0 +1,183 @@ +package modtweaker2.mods.thaumcraft.aspect; + +import java.util.Collections; +import java.util.List; + +import minetweaker.api.item.IIngredient; +import minetweaker.api.item.IItemCondition; +import minetweaker.api.item.IItemStack; +import minetweaker.api.item.IItemTransformer; +import minetweaker.api.item.IngredientOr; +import minetweaker.api.liquid.ILiquidStack; +import minetweaker.api.minecraft.MineTweakerMC; +import minetweaker.api.player.IPlayer; +import net.minecraft.item.ItemStack; +import thaumcraft.api.aspects.AspectList; + + +public class MCAspectStack implements IAspectStack { + + private final AspectStack stack; + private final List aspects; + + public MCAspectStack(AspectStack stack) { + if(stack == null) throw new IllegalArgumentException("stack cannot be null"); + + this.stack = stack; + this.aspects = Collections.singletonList(this); + } + + @Override + public IItemStack applyTransform(IItemStack arg0, IPlayer arg1) { + return null; + } + + @Override + public boolean contains(IIngredient ingredient) { + if(ingredient instanceof MCAspectStack) { + List aspects = ((MCAspectStack)ingredient).getAspects(); + + if((aspects == null) || (aspects.size() != 1)) { + return false; + } + + return matches(aspects.get(0)); + } else { + List iitems = ingredient.getItems(); + if ((iitems == null) || (iitems.size() != 1)) { + return false; + } + return matches((IItemStack)iitems.get(0)); + } + } + + @Override + public int getAmount() { + return this.stack.amount; + } + + @Override + public Object getInternal() { + return this.stack; + } + + @Override + public List getItems() { + return null; + } + + @Override + public List getAspects() { + return this.aspects; + } + + @Override + public List getLiquids() { + return Collections.emptyList(); + } + + @Override + public String getMark() { + return null; + } + + @Override + public boolean hasTransformers() { + return false; + } + + @Override + public IIngredient marked(String arg0) { + return null; + } + + @Override + public boolean matches(IItemStack item) { + ItemStack internal = MineTweakerMC.getItemStack(item); + + if(internal != null) { + AspectList itemAspectList = new AspectList(internal); + + if(itemAspectList.aspects.keySet().contains(stack.aspect.getTag())) { + return true; + } + } + + return false; + } + + public boolean matches(IAspectStack aspect) { + if(aspect != null) { + Object internal = aspect.getInternal(); + + if(internal != null && internal instanceof AspectStack) { + if(this.stack.aspect.getTag().equals(((AspectStack)internal).aspect.getTag())) { + return true; + } + } + } + + return false; + } + + @Override + public boolean matches(ILiquidStack arg0) { + return false; + } + + @Override + public IIngredient only(IItemCondition arg0) { + // TODO Auto-generated method stub + return null; + } + + @Override + public IIngredient or(IIngredient ingredient) { + return new IngredientOr(this, ingredient); + } + + @Override + public IIngredient transform(IItemTransformer arg0) { + // TODO Auto-generated method stub + return null; + } + + @Override + public IAspectDefinition getDefinition() { + return new MCAspectDefinition(stack); + } + + @Override + public String getName() { + return this.stack.aspect.getTag(); + } + + @Override + public String getDisplayName() { + return this.stack.aspect.getName(); + } + + @Override + public IAspectStack amount(int amount) { + return withAmount(amount); + } + + @Override + public IAspectStack withAmount(int amount) { + AspectStack result = new AspectStack(this.stack.aspect, amount); + return new MCAspectStack(result); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + + sb.append("'); + + if(stack.amount > 1) { + sb.append(" * ").append(stack.amount); + } + + return sb.toString(); + } +} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/commands/AspectLogger.java b/src/main/java/modtweaker2/mods/thaumcraft/commands/AspectLogger.java index 0abd25d..490c08a 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/commands/AspectLogger.java +++ b/src/main/java/modtweaker2/mods/thaumcraft/commands/AspectLogger.java @@ -1,7 +1,5 @@ package modtweaker2.mods.thaumcraft.commands; -import java.util.ArrayList; - import minetweaker.MineTweakerAPI; import minetweaker.MineTweakerImplementationAPI; import minetweaker.api.player.IPlayer; @@ -12,21 +10,15 @@ public class AspectLogger implements ICommandFunction{ @Override public void execute(String[] arguments, IPlayer player) { - ArrayList aspects = new ArrayList(); - aspects.addAll(Aspect.getPrimalAspects()); - aspects.addAll(Aspect.getCompoundAspects()); - System.out.println("Aspects: " + aspects.size()); - for (Aspect set : aspects) { - if (!set.isPrimal()) { - System.out.println("Aspect:[ AspectName: " + set.getName() + ", description" + set.getLocalizedDescription() + ", Components:[" + set.getComponents()[0].getName() + ", " + set.getComponents()[1].getName() + "]\n"); - MineTweakerAPI.logCommand("Aspect:[ AspectName: " + set.getName() + ", description" + set.getLocalizedDescription() + ", Components:[" + set.getComponents()[0].getName() + ", " + set.getComponents()[1].getName() + "]\n"); - } else { - System.out.println("Aspect:[ AspectName: " + set.getName() + ", description" + set.getLocalizedDescription() + ", ]\n"); - MineTweakerAPI.logCommand("Aspect:[ AspectName: " + set.getName() + ", description" + set.getLocalizedDescription() + ", ]\n"); - - } - } - + + for(Aspect aspect : Aspect.getPrimalAspects()) { + MineTweakerAPI.logCommand(" // " + aspect.getLocalizedDescription()); + } + + for(Aspect aspect : Aspect.getCompoundAspects()) { + MineTweakerAPI.logCommand(" // " + aspect.getLocalizedDescription() + " [, ]"); + } + if (player != null) { player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); }