diff --git a/build.gradle b/build.gradle index ab62150..0862086 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import groovy.io.FileType + buildscript { repositories { jcenter() @@ -7,7 +9,7 @@ buildscript { } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT' } } @@ -25,19 +27,24 @@ group= "modtweaker" // http://maven.apache.org/guides/mini/guide-naming-conventi archivesBaseName = "ModTweaker2" minecraft { - version = "${config.minecraft.version}-${config.forge.version}" + version = "${config.forge.version}" runDir = "eclipse" replace "@modVersion@", config.mod.version - mappings = "stable_20" + mappings = "snapshot_20160518" } repositories { - maven { - name = "forestry" - url = "http://maven.ic2.player.to/" - } -} +} +dependencies { + def list = [] + + def dir = new File("libs/") + dir.eachFileRecurse (FileType.FILES) { file -> + list << file + // deobfCompile file.path + } +} processResources { diff --git a/build.properties b/build.properties index 065b026..62edc93 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ -minecraft.version=1.8.9 -forge.version=11.15.0.1701 +minecraft.version=1.10.2 +forge.version=1.10.2-12.18.0.2005-1.10.0 -mod.version=1.0.0 \ No newline at end of file +mod.version=2.0.0 \ No newline at end of file diff --git a/libs/Baubles-deobf.jar b/libs/Baubles-deobf.jar deleted file mode 100644 index addccc7..0000000 Binary files a/libs/Baubles-deobf.jar and /dev/null differ diff --git a/libs/Chisel-MC1.8.9-0.0.2.6-api.jar b/libs/Chisel-MC1.8.9-0.0.2.6-api.jar deleted file mode 100644 index 3d0fbcb..0000000 Binary files a/libs/Chisel-MC1.8.9-0.0.2.6-api.jar and /dev/null differ diff --git a/libs/CraftTweaker-Customized-Dev-Full-1.8.8-3.0.2.jar b/libs/CraftTweaker-Dev-1.9-3.0.9.jar similarity index 67% rename from libs/CraftTweaker-Customized-Dev-Full-1.8.8-3.0.2.jar rename to libs/CraftTweaker-Dev-1.9-3.0.9.jar index 8cf8aa0..1873cf4 100644 Binary files a/libs/CraftTweaker-Customized-Dev-Full-1.8.8-3.0.2.jar and b/libs/CraftTweaker-Dev-1.9-3.0.9.jar differ diff --git a/libs/Mantle-1.9.4-0.10.1.jenkins142.jar b/libs/Mantle-1.9.4-0.10.1.jenkins142.jar new file mode 100644 index 0000000..96df434 Binary files /dev/null and b/libs/Mantle-1.9.4-0.10.1.jenkins142.jar differ diff --git a/libs/TC-deobf.jar b/libs/TC-deobf.jar deleted file mode 100644 index 689b114..0000000 Binary files a/libs/TC-deobf.jar and /dev/null differ diff --git a/libs/TConstruct-1.9.4-2.3.1.jenkins229.jar b/libs/TConstruct-1.9.4-2.3.1.jenkins229.jar new file mode 100644 index 0000000..15aa08a Binary files /dev/null and b/libs/TConstruct-1.9.4-2.3.1.jenkins229.jar differ diff --git a/libs/forestry_1.9.4-5.0.13.158.jar b/libs/forestry_1.9.4-5.0.13.158.jar new file mode 100644 index 0000000..6417ecc Binary files /dev/null and b/libs/forestry_1.9.4-5.0.13.158.jar differ diff --git a/src/main/java/modtweaker2/ClientEvents.java b/src/main/java/modtweaker2/ClientEvents.java index e8d98b7..1268ce8 100644 --- a/src/main/java/modtweaker2/ClientEvents.java +++ b/src/main/java/modtweaker2/ClientEvents.java @@ -1,7 +1,5 @@ package modtweaker2; -import static modtweaker2.helpers.LogHelper.print; - import minetweaker.api.item.IItemStack; import minetweaker.api.minecraft.MineTweakerMC; import minetweaker.api.player.IPlayer; @@ -10,6 +8,8 @@ import net.minecraft.client.settings.GameSettings; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import static modtweaker2.helpers.LogHelper.print; + public class ClientEvents { public static int cooldown; public static boolean active; @@ -17,14 +17,14 @@ public class ClientEvents { @SubscribeEvent public void onDrawTooltip(ItemTooltipEvent event) { - IPlayer player = MineTweakerMC.getIPlayer(event.entityPlayer); + IPlayer player = MineTweakerMC.getIPlayer(event.getEntityPlayer()); if (player != null) { - IItemStack hand = MineTweakerMC.getIItemStack(event.itemStack); + IItemStack hand = MineTweakerMC.getIItemStack(event.getItemStack()); if (hand != null) { if (active) { String print = hand.toString(); - event.toolTip.add(print); + event.getToolTip().add(print); if (GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSprint)) { if (cooldown <= 0) { cooldown = 30; diff --git a/src/main/java/modtweaker2/Commands.java b/src/main/java/modtweaker2/Commands.java index 7aff945..7969737 100644 --- a/src/main/java/modtweaker2/Commands.java +++ b/src/main/java/modtweaker2/Commands.java @@ -4,9 +4,6 @@ import minetweaker.MineTweakerAPI; import minetweaker.api.player.IPlayer; import minetweaker.api.server.ICommandFunction; import modtweaker2.commands.EntityMappingLogger; -import modtweaker2.mods.thaumcraft.commands.AspectLogger; -import modtweaker2.mods.thaumcraft.research.commands.ResearchLogger; -import modtweaker2.utils.TweakerPlugin; public class Commands { @@ -23,11 +20,7 @@ public class Commands { MineTweakerAPI.server.addMineTweakerCommand("entities", new String[] { "/minetweaker entities", " Outputs a list of entities class mapping keys and the entity IDs" }, new EntityMappingLogger()); - if (TweakerPlugin.isLoaded("Thaumcraft")) { - MineTweakerAPI.server.addMineTweakerCommand("research", new String[] { "/minetweaker research", "/minetweaker research [CATEGORY]", " Outputs a list of all category names in the game to the minetweaker log," + " or outputs a list of all research keys in a category to the log." }, new ResearchLogger()); - MineTweakerAPI.server.addMineTweakerCommand("aspectList", new String[] { "/minetweaker aspectList", " Outputs a list of all aspects registered to entities and items" }, new AspectLogger()); - } - + } } diff --git a/src/main/java/modtweaker2/ModProps.java b/src/main/java/modtweaker2/ModProps.java index 54c7d16..36eabc4 100644 --- a/src/main/java/modtweaker2/ModProps.java +++ b/src/main/java/modtweaker2/ModProps.java @@ -5,5 +5,5 @@ 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 = "@modVersion@", version = VERSION; - public static final String DEPENDENCIES = "required-after:crafttweaker;", dependencies = DEPENDENCIES; + public static final String DEPENDENCIES = "required-after:MineTweaker3;", dependencies = DEPENDENCIES; } diff --git a/src/main/java/modtweaker2/ModTweaker2.java b/src/main/java/modtweaker2/ModTweaker2.java index 3a01a59..087d5ea 100644 --- a/src/main/java/modtweaker2/ModTweaker2.java +++ b/src/main/java/modtweaker2/ModTweaker2.java @@ -1,15 +1,11 @@ package modtweaker2; -import java.io.File; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - import minetweaker.MineTweakerImplementationAPI; import minetweaker.MineTweakerImplementationAPI.ReloadEvent; import minetweaker.runtime.providers.ScriptProviderDirectory; import minetweaker.util.IEventHandler; -import modtweaker2.mods.thaumcraft.Thaumcraft; +import modtweaker2.mods.forestry.Forestry; +import modtweaker2.mods.tconstruct.TConstruct; import modtweaker2.proxy.CommonProxy; import modtweaker2.utils.TweakerPlugin; import net.minecraftforge.common.MinecraftForge; @@ -23,6 +19,10 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.relauncher.Side; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.File; @Mod(modid = ModProps.modid, version = ModProps.version, dependencies = ModProps.dependencies) public class ModTweaker2 { @@ -44,7 +44,8 @@ public class ModTweaker2 { @EventHandler public void init(FMLInitializationEvent event) { logger.info("Starting Initialization for " + ModProps.modid); - TweakerPlugin.register("Thaumcraft", Thaumcraft.class); + TweakerPlugin.register("forestry", Forestry.class); + TweakerPlugin.register("tconstruct", TConstruct.class); if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { MinecraftForge.EVENT_BUS.register(new ClientEvents()); diff --git a/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectBracketHandler.java b/src/main/java/modtweaker2/brackets/MaterialBracketHandler.java similarity index 56% rename from src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectBracketHandler.java rename to src/main/java/modtweaker2/brackets/MaterialBracketHandler.java index 456c49f..f419815 100644 --- a/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectBracketHandler.java +++ b/src/main/java/modtweaker2/brackets/MaterialBracketHandler.java @@ -1,11 +1,12 @@ -package modtweaker2.mods.thaumcraft.aspect; - -import java.util.List; +package modtweaker2.brackets; import minetweaker.IBracketHandler; import minetweaker.MineTweakerAPI; import minetweaker.annotations.BracketHandler; import minetweaker.api.item.IngredientAny; +import modtweaker2.brackets.util.IMaterial; +import modtweaker2.brackets.util.MCMaterial; +import slimeknights.tconstruct.library.TinkerRegistry; import stanhebben.zenscript.compiler.IEnvironmentGlobal; import stanhebben.zenscript.expression.ExpressionCallStatic; import stanhebben.zenscript.expression.ExpressionString; @@ -14,36 +15,37 @@ 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; +import java.util.List; + +/** + * Created by Jared on 6/16/2016. + */ @BracketHandler(priority = 100) -public class AspectBracketHandler implements IBracketHandler { +public class MaterialBracketHandler implements IBracketHandler { + + public static IMaterial getMaterial(String name) { + return new MCMaterial(TinkerRegistry.getMaterial(name)); + } 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 MaterialBracketHandler() { + + symbolAny = MineTweakerAPI.getJavaStaticFieldSymbol(IngredientAny.class, "INSTANCE"); + method = MineTweakerAPI.getJavaMethod(MaterialBracketHandler.class, "getMaterial", 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) { + // any symbol 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(":")) { + if (tokens.get(0).getValue().equals("material") && tokens.get(1).getValue().equals(":")) { return find(environment, tokens, 2, tokens.size()); } } @@ -52,27 +54,26 @@ public class AspectBracketHandler implements IBracketHandler { } private IZenSymbol find(IEnvironmentGlobal environment, List tokens, int startIndex, int endIndex) { - StringBuilder value = new StringBuilder(); - + StringBuilder valueBuilder = new StringBuilder(); for (int i = startIndex; i < endIndex; i++) { Token token = tokens.get(i); - value.append(token.getValue()); + valueBuilder.append(token.getValue()); } - - Aspect aspect = Aspect.getAspect(value.toString().toLowerCase()); - - if(aspect != null) { - return new AspectReferenceSymbol(environment, value.toString()); + IMaterial material = getMaterial(valueBuilder.toString()); + if (!material.getName().equals("unknown")) { + MineTweakerAPI.logInfo("Material wasn't null"); + return new MaterialReferenceSymbol(environment, valueBuilder.toString()); } + MineTweakerAPI.logInfo("Material was null"); return null; } - private class AspectReferenceSymbol implements IZenSymbol { + private class MaterialReferenceSymbol implements IZenSymbol { private final IEnvironmentGlobal environment; private final String name; - public AspectReferenceSymbol(IEnvironmentGlobal environment, String name) { + public MaterialReferenceSymbol(IEnvironmentGlobal environment, String name) { this.environment = environment; this.name = name; } diff --git a/src/main/java/modtweaker2/brackets/util/IMaterial.java b/src/main/java/modtweaker2/brackets/util/IMaterial.java new file mode 100644 index 0000000..0a47191 --- /dev/null +++ b/src/main/java/modtweaker2/brackets/util/IMaterial.java @@ -0,0 +1,68 @@ +package modtweaker2.brackets.util; + +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenGetter; +import stanhebben.zenscript.annotations.ZenMethod; +import stanhebben.zenscript.annotations.ZenSetter; + +/** + * Created by Jared on 6/16/2016. + */ +@ZenClass("modtweaker.materials.IMaterial") +public interface IMaterial { + + @ZenGetter + String getName(); + + @ZenMethod + boolean matches(IMaterial var1); + + Object getInternal(); + + @ZenGetter("definition") + IMaterialDefinition getDefinition(); + + @ZenSetter("durabilityHead") + void setDurabilityHead(int durability); + + @ZenGetter("durabilityHead") + int getDurabilityHead(); + + @ZenSetter("miningSpeedHead") + void setMiningSpeedHead(float miningSpeed); + + @ZenGetter("miningSpeedHead") + float getMiningSpeedHead(); + + @ZenSetter("attackHead") + void setAttackHead(float attack); + + @ZenGetter("attackHead") + float getAttackHead(); + + @ZenSetter("harvestLevelHead") + void setHarvestLevelHead(int level); + + @ZenGetter("harvestLevelHead") + int getHarvestLevelHead(); + + + @ZenSetter("durabilityHandle") + void setDurabilityHandle(int durability); + + @ZenGetter("durabilityHandle") + int getDurabilityHandle(); + + @ZenSetter("modifierHandle") + void setModifierHandle(float modifier); + + @ZenGetter("modifierHandle") + float getModifierHandle(); + + @ZenSetter("durabilityExtra") + void setDurabilityExtra(int durability); + + @ZenGetter("durabilityExtra") + int getDurabilityExtra(); + +} diff --git a/src/main/java/modtweaker2/brackets/util/IMaterialDefinition.java b/src/main/java/modtweaker2/brackets/util/IMaterialDefinition.java new file mode 100644 index 0000000..52044e4 --- /dev/null +++ b/src/main/java/modtweaker2/brackets/util/IMaterialDefinition.java @@ -0,0 +1,20 @@ +package modtweaker2.brackets.util; + +import stanhebben.zenscript.annotations.*; + +/** + * Created by Jared on 6/16/2016. + */ +@ZenClass("modtweaker.material.IMaterialDefinition") +public interface IMaterialDefinition { + + @ZenOperator(OperatorType.MUL) + public IMaterial asMaterial(); + + @ZenGetter("name") + public String getName(); + + @ZenGetter("displayName") + public String getDisplayName(); + +} diff --git a/src/main/java/modtweaker2/brackets/util/MCMaterial.java b/src/main/java/modtweaker2/brackets/util/MCMaterial.java new file mode 100644 index 0000000..c8a0231 --- /dev/null +++ b/src/main/java/modtweaker2/brackets/util/MCMaterial.java @@ -0,0 +1,111 @@ +package modtweaker2.brackets.util; + +import minetweaker.MineTweakerAPI; +import modtweaker2.mods.tconstruct.actions.*; +import slimeknights.tconstruct.library.materials.HandleMaterialStats; +import slimeknights.tconstruct.library.materials.HeadMaterialStats; +import slimeknights.tconstruct.library.materials.Material; + +/** + * Created by Jared on 6/16/2016. + */ +public class MCMaterial implements IMaterial { + private final Material material; + + public MCMaterial(Material material) { + this.material = material; + System.out.println("added: " + material.getIdentifier()); + } + + @Override + public String getName() { + return material.getIdentifier(); + } + + @Override + public boolean matches(IMaterial var1) { + return var1.getName().equals(getName()); + } + + @Override + public Object getInternal() { + return material; + } + + @Override + public IMaterialDefinition getDefinition() { + return new MCMaterialDefinition(material); + } + + @Override + public void setDurabilityHead(int durability) { + MineTweakerAPI.apply(new SetDurabilityAction(this, "head", durability)); + } + + @Override + public int getDurabilityHead() { + return ((HeadMaterialStats) material.getStats("head")).durability; + } + + @Override + public void setMiningSpeedHead(float miningSpeed) { + MineTweakerAPI.apply(new SetMiningSpeedAction(this, "head", miningSpeed)); + } + + @Override + public float getMiningSpeedHead() { + return ((HeadMaterialStats) material.getStats("head")).miningspeed; + } + + @Override + public void setAttackHead(float attack) { + MineTweakerAPI.apply(new SetAttackAction(this, "head", attack)); + } + + @Override + public float getAttackHead() { + return ((HeadMaterialStats) material.getStats("head")).attack; + } + + + @Override + public void setHarvestLevelHead(int level) { + MineTweakerAPI.apply(new SetHarvestLevelAction(this, "head", level)); + } + + @Override + public int getHarvestLevelHead() { + return ((HeadMaterialStats) material.getStats("head")).harvestLevel; + } + + @Override + public void setDurabilityHandle(int durability) { + MineTweakerAPI.apply(new SetDurabilityAction(this, "handle", durability)); + } + + @Override + public int getDurabilityHandle() { + return ((HandleMaterialStats) material.getStats("handle")).durability; + } + + @Override + public void setModifierHandle(float modifier) { + MineTweakerAPI.apply(new SetModifierAction(this, "handle", modifier)); + } + + @Override + public float getModifierHandle() { + return ((HandleMaterialStats) material.getStats("handle")).modifier; + } + + @Override + public void setDurabilityExtra(int durability) { + MineTweakerAPI.apply(new SetDurabilityAction(this, "extra", durability)); + } + + @Override + public int getDurabilityExtra() { + return ((HandleMaterialStats) material.getStats("extra")).durability; + } + +} diff --git a/src/main/java/modtweaker2/brackets/util/MCMaterialDefinition.java b/src/main/java/modtweaker2/brackets/util/MCMaterialDefinition.java new file mode 100644 index 0000000..984fc79 --- /dev/null +++ b/src/main/java/modtweaker2/brackets/util/MCMaterialDefinition.java @@ -0,0 +1,30 @@ +package modtweaker2.brackets.util; + +import slimeknights.tconstruct.library.materials.Material; + +/** + * Created by Jared on 6/16/2016. + */ + +public class MCMaterialDefinition implements IMaterialDefinition { + private final Material material; + + public MCMaterialDefinition(Material material) { + this.material = material; + } + + @Override + public IMaterial asMaterial() { + return new MCMaterial(material); + } + + @Override + public String getName() { + return material.getLocalizedName(); + } + + @Override + public String getDisplayName() { + return material.getLocalizedName(); + } +} diff --git a/src/main/java/modtweaker2/commands/EntityMappingLogger.java b/src/main/java/modtweaker2/commands/EntityMappingLogger.java index ed11480..1abe1d0 100644 --- a/src/main/java/modtweaker2/commands/EntityMappingLogger.java +++ b/src/main/java/modtweaker2/commands/EntityMappingLogger.java @@ -1,7 +1,5 @@ package modtweaker2.commands; -import java.util.Set; - import minetweaker.MineTweakerAPI; import minetweaker.MineTweakerImplementationAPI; import minetweaker.api.player.IPlayer; @@ -9,13 +7,15 @@ import minetweaker.api.server.ICommandFunction; import modtweaker2.ModTweaker2; import net.minecraft.entity.EntityList; +import java.util.Set; + public class EntityMappingLogger implements ICommandFunction { @Override public void execute(String[] arguments, IPlayer player) { @SuppressWarnings("unchecked") - Set keys = EntityList.stringToClassMapping.keySet(); + Set keys = EntityList.NAME_TO_CLASS.keySet(); System.out.println("Mob Keys: " + keys.size()); diff --git a/src/main/java/modtweaker2/helpers/ForgeHelper.java b/src/main/java/modtweaker2/helpers/ForgeHelper.java index 88bb687..242190e 100644 --- a/src/main/java/modtweaker2/helpers/ForgeHelper.java +++ b/src/main/java/modtweaker2/helpers/ForgeHelper.java @@ -1,34 +1,27 @@ package modtweaker2.helpers; -import static modtweaker2.helpers.ReflectionHelper.getConstructor; -import static modtweaker2.helpers.ReflectionHelper.getFinalObject; -import static modtweaker2.helpers.ReflectionHelper.getInstance; -import static modtweaker2.helpers.ReflectionHelper.getStaticObject; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; -import net.minecraftforge.common.ChestGenHooks; +import net.minecraft.util.text.translation.I18n; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.relauncher.Side; +import java.util.List; +import java.util.Map; + +import static modtweaker2.helpers.ReflectionHelper.*; + public class ForgeHelper { @SuppressWarnings("rawtypes") public static Map translate = null; @SuppressWarnings("rawtypes") public static List seeds = null; - public static HashMap loot = null; static { try { seeds = getStaticObject(ForgeHooks.class, "seedList"); - loot = getStaticObject(ChestGenHooks.class, "chestInfo"); - translate = getFinalObject(getStaticObject(StatCollector.class, "localizedName", "field_74839_a"), "languageList", "field_74816_c"); + translate = getFinalObject(getStaticObject(I18n.class, "localizedName", "field_74839_a"), "languageList", "field_74816_c"); } catch (Exception e) { } } diff --git a/src/main/java/modtweaker2/helpers/InputHelper.java b/src/main/java/modtweaker2/helpers/InputHelper.java index ab3e192..4bd2139 100644 --- a/src/main/java/modtweaker2/helpers/InputHelper.java +++ b/src/main/java/modtweaker2/helpers/InputHelper.java @@ -1,15 +1,12 @@ package modtweaker2.helpers; -import java.lang.reflect.Array; -import java.util.ArrayList; - import minetweaker.api.entity.IEntity; import minetweaker.api.item.IIngredient; import minetweaker.api.item.IItemStack; import minetweaker.api.liquid.ILiquidStack; import minetweaker.api.oredict.IOreDictEntry; -import minetweaker.mc18.item.MCItemStack; -import minetweaker.mc18.liquid.MCLiquidStack; +import minetweaker.mc19.item.MCItemStack; +import minetweaker.mc19.liquid.MCLiquidStack; import net.minecraft.entity.Entity; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -17,6 +14,9 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import java.lang.reflect.Array; +import java.util.ArrayList; + public class InputHelper { public static boolean isABlock(IItemStack block) { if (!(isABlock(toStack(block)))) { diff --git a/src/main/java/modtweaker2/helpers/LogHelper.java b/src/main/java/modtweaker2/helpers/LogHelper.java index 22bd852..ef7f6fe 100644 --- a/src/main/java/modtweaker2/helpers/LogHelper.java +++ b/src/main/java/modtweaker2/helpers/LogHelper.java @@ -1,18 +1,11 @@ package modtweaker2.helpers; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - import minetweaker.MineTweakerAPI; import minetweaker.MineTweakerImplementationAPI; import minetweaker.api.item.IIngredient; import minetweaker.api.oredict.IOreDictEntry; import minetweaker.api.player.IPlayer; -import minetweaker.mc18.item.MCItemStack; -import modtweaker2.mods.thaumcraft.aspect.AspectStack; -import modtweaker2.mods.thaumcraft.aspect.MCAspectStack; -import modtweaker2.utils.TweakerPlugin; +import minetweaker.mc19.item.MCItemStack; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; @@ -22,8 +15,9 @@ 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; + +import java.util.Arrays; +import java.util.List; public class LogHelper { public static void logPrinted(IPlayer player) { @@ -42,19 +36,19 @@ public class LogHelper { System.out.println(string); MineTweakerAPI.logCommand(string); } - + public static void logError(String message) { MineTweakerAPI.logError("[ModTweaker2] " + message); } - + public static void logError(String message, Throwable exception) { MineTweakerAPI.logError("[ModTweaker2] " + message, exception); } - + public static void logWarning(String message) { MineTweakerAPI.logWarning("[ModTweaker2] " + message); } - + public static void logInfo(String message) { MineTweakerAPI.logInfo("[ModTweaker2] " + message); } @@ -64,35 +58,27 @@ public class LogHelper { */ @SuppressWarnings("rawtypes") public static String getStackDescription(Object object) { - if(object instanceof IIngredient) { - return getStackDescription((IIngredient)object); + if (object instanceof IIngredient) { + return getStackDescription((IIngredient) object); } else if (object instanceof ItemStack) { - return new MCItemStack((ItemStack)object).toString(); + return new MCItemStack((ItemStack) object).toString(); } else if (object instanceof FluidStack) { return getStackDescription((FluidStack) object); } else if (object instanceof Block) { - return new MCItemStack(new ItemStack((Block)object, 1, 0)).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)); + return new MCItemStack(new ItemStack((Block) object, 1, 0)).toString(); } else if (object instanceof String) { // Check if string specifies an oredict entry - List ores = OreDictionary.getOres((String)object); + List ores = OreDictionary.getOres((String) object); - if(!ores.isEmpty()) { - return ""; + if (!ores.isEmpty()) { + return ""; } else { - return "\"" + (String)object + "\""; + return "\"" + (String) object + "\""; } } else if (object instanceof List) { - return getListDescription((List)object); - } else if(object instanceof Object[]) { - return getListDescription(Arrays.asList((Object[])object)); + return getListDescription((List) object); + } else if (object instanceof Object[]) { + return getListDescription(Arrays.asList((Object[]) object)); } else if (object != null) { return "\"" + object.toString() + "\""; } else { @@ -116,49 +102,49 @@ public class LogHelper { public static String getStackDescription(FluidStack stack) { StringBuilder sb = new StringBuilder(); - + sb.append("'); - - if(stack.amount > 1) { + + if (stack.amount > 1) { sb.append(" * ").append(stack.amount); } - + return sb.toString(); } - + public static String getListDescription(List objects) { StringBuilder sb = new StringBuilder(); - - if(objects.isEmpty()) { + + if (objects.isEmpty()) { sb.append("[]"); } else { sb.append('['); - for(Object object : objects) { - if(object instanceof List) { - sb.append(getListDescription((List)object)).append(", "); - } else if(object instanceof Object[]) { - sb.append(getListDescription(Arrays.asList((Object[])object))).append(", "); - } else { + for (Object object : objects) { + if (object instanceof List) { + sb.append(getListDescription((List) object)).append(", "); + } else if (object instanceof Object[]) { + sb.append(getListDescription(Arrays.asList((Object[]) object))).append(", "); + } else { sb.append(getStackDescription(object)).append(", "); } } sb.setLength(sb.length() - 2); sb.append(']'); } - + return sb.toString(); } public static String getCraftingDescription(IRecipe recipe) { - if(recipe instanceof ShapelessOreRecipe) - return LogHelper.getCraftingDescription((ShapelessOreRecipe)recipe); - else if(recipe instanceof ShapedOreRecipe) - return LogHelper.getCraftingDescription((ShapedOreRecipe)recipe); - else if(recipe instanceof ShapelessRecipes) - return LogHelper.getCraftingDescription((ShapelessRecipes)recipe); - else if(recipe instanceof ShapedRecipes) - return LogHelper.getCraftingDescription((ShapedRecipes)recipe); - + if (recipe instanceof ShapelessOreRecipe) + return LogHelper.getCraftingDescription((ShapelessOreRecipe) recipe); + else if (recipe instanceof ShapedOreRecipe) + return LogHelper.getCraftingDescription((ShapedOreRecipe) recipe); + else if (recipe instanceof ShapelessRecipes) + return LogHelper.getCraftingDescription((ShapelessRecipes) recipe); + else if (recipe instanceof ShapedRecipes) + return LogHelper.getCraftingDescription((ShapedRecipes) recipe); + return recipe.toString(); } @@ -173,9 +159,9 @@ public class LogHelper { public static String getCraftingDescription(ShapedOreRecipe recipe) { int height = ReflectionHelper.getObject(recipe, "width"); int width = ReflectionHelper.getObject(recipe, "height"); - + Object[][] recipes = InputHelper.getMultiDimensionalArray(Object.class, recipe.getInput(), height, width); - + return getListDescription(Arrays.asList(recipes)); } diff --git a/src/main/java/modtweaker2/helpers/StringHelper.java b/src/main/java/modtweaker2/helpers/StringHelper.java index 945689e..0fe5a00 100644 --- a/src/main/java/modtweaker2/helpers/StringHelper.java +++ b/src/main/java/modtweaker2/helpers/StringHelper.java @@ -16,7 +16,6 @@ public class StringHelper { public static String join(List list, String conjunction) { StringBuilder sb = new StringBuilder(); - if(conjunction == null) { conjunction = ", "; } diff --git a/src/main/java/modtweaker2/mods/forestry/Forestry.java b/src/main/java/modtweaker2/mods/forestry/Forestry.java new file mode 100644 index 0000000..6ff297b --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/Forestry.java @@ -0,0 +1,22 @@ +package modtweaker2.mods.forestry; + +import minetweaker.MineTweakerAPI; +import modtweaker2.mods.forestry.handlers.Carpenter; +import modtweaker2.mods.forestry.handlers.Centrifuge; +import modtweaker2.mods.forestry.handlers.Fermenter; +import modtweaker2.mods.forestry.handlers.Moistener; +import modtweaker2.mods.forestry.handlers.Squeezer; +import modtweaker2.mods.forestry.handlers.Still; +import modtweaker2.mods.forestry.handlers.ThermionicFabricator; + +public class Forestry { + public Forestry() { + MineTweakerAPI.registerClass(Fermenter.class); + MineTweakerAPI.registerClass(Still.class); + MineTweakerAPI.registerClass(Moistener.class); + MineTweakerAPI.registerClass(Carpenter.class); + MineTweakerAPI.registerClass(Squeezer.class); + MineTweakerAPI.registerClass(Centrifuge.class); + MineTweakerAPI.registerClass(ThermionicFabricator.class); + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/ForestryListAddition.java b/src/main/java/modtweaker2/mods/forestry/ForestryListAddition.java new file mode 100644 index 0000000..517b2e6 --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/ForestryListAddition.java @@ -0,0 +1,54 @@ +package modtweaker2.mods.forestry; + +import forestry.api.recipes.ICraftingProvider; +import forestry.api.recipes.IForestryRecipe; +import modtweaker2.helpers.LogHelper; +import modtweaker2.utils.BaseListAddition; + +import java.util.ArrayList; +import java.util.List; + +public abstract class ForestryListAddition> extends BaseListAddition { + private final C craftingProvider; + + protected ForestryListAddition(String name, C craftingProvider) { + super(name, new ArrayList(craftingProvider.recipes())); + this.craftingProvider = craftingProvider; + } + + protected ForestryListAddition(String name, C craftingProvider, List recipes) { + super(name, new ArrayList(craftingProvider.recipes()), recipes); + this.craftingProvider = craftingProvider; + } + + @Override + protected abstract String getRecipeInfo(T recipe); + + @Override + public final void apply() { + for (T recipe : recipes) { + if (recipe != null) { + if (craftingProvider.addRecipe(recipe)) { + successful.add(recipe); + } else { + LogHelper.logError(String.format("Error adding %s Recipe for %s", name, getRecipeInfo(recipe))); + } + } else { + LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); + } + } + } + + @Override + public final void undo() { + for (T recipe : successful) { + if (recipe != null) { + if (!craftingProvider.removeRecipe(recipe)) { + LogHelper.logError(String.format("Error removing %s Recipe for %s", name, this.getRecipeInfo(recipe))); + } + } else { + LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); + } + } + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/ForestryListRemoval.java b/src/main/java/modtweaker2/mods/forestry/ForestryListRemoval.java new file mode 100644 index 0000000..897f6eb --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/ForestryListRemoval.java @@ -0,0 +1,49 @@ +package modtweaker2.mods.forestry; + +import forestry.api.recipes.ICraftingProvider; +import forestry.api.recipes.IForestryRecipe; +import modtweaker2.helpers.LogHelper; +import modtweaker2.utils.BaseListRemoval; + +import java.util.ArrayList; +import java.util.List; + +public abstract class ForestryListRemoval> extends BaseListRemoval { + private final C craftingProvider; + + public ForestryListRemoval(String name, C craftingProvider, List recipes) { + super(name, new ArrayList(craftingProvider.recipes()), recipes); + this.craftingProvider = craftingProvider; + } + + @Override + protected abstract String getRecipeInfo(T recipe); + + @Override + public final void apply() { + for (T recipe : recipes) { + if (recipe != null) { + if (craftingProvider.removeRecipe(recipe)) { + successful.add(recipe); + } else { + LogHelper.logError(String.format("Error removing %s Recipe for %s", name, getRecipeInfo(recipe))); + } + } else { + LogHelper.logError(String.format("Error removing %s Recipe: null object", name)); + } + } + } + + @Override + public final void undo() { + for (T recipe : successful) { + if (recipe != null) { + if (!craftingProvider.addRecipe(recipe)) { + LogHelper.logError(String.format("Error restoring %s Recipe for %s", name, getRecipeInfo(recipe))); + } + } else { + LogHelper.logError(String.format("Error restoring %s Recipe: null object", name)); + } + } + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java b/src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java new file mode 100644 index 0000000..85bb395 --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Carpenter.java @@ -0,0 +1,138 @@ +package modtweaker2.mods.forestry.handlers; + +import forestry.api.recipes.ICarpenterManager; +import forestry.api.recipes.ICarpenterRecipe; +import forestry.api.recipes.IDescriptiveRecipe; +import forestry.api.recipes.RecipeManagers; +import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IIngredient; +import minetweaker.api.item.IItemStack; +import minetweaker.api.liquid.ILiquidStack; +import modtweaker2.helpers.LogHelper; +import modtweaker2.mods.forestry.ForestryListAddition; +import modtweaker2.mods.forestry.ForestryListRemoval; +import modtweaker2.mods.forestry.recipes.CarpenterRecipe; +import modtweaker2.mods.forestry.recipes.DescriptiveRecipe; +import net.minecraft.item.ItemStack; +import stanhebben.zenscript.annotations.Optional; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +import java.util.LinkedList; +import java.util.List; + +import static modtweaker2.helpers.InputHelper.*; +import static modtweaker2.helpers.StackHelper.matches; + +@ZenClass("mods.forestry.Carpenter") +public class Carpenter { + + public static final String name = "Forestry Carpenter"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a shaped recipe for the Carpenter + * + * @param output recipe output + * @param ingredients recipe ingredients + * @param packagingTime time per crafting operation + * @optionalParam box recipes casting item (optional) + */ + @ZenMethod + public static void addRecipe(IItemStack output, IIngredient[][] ingredients, int packagingTime, @Optional IItemStack box, @Optional IItemStack[] remainingItems) { + if (remainingItems == null) { + remainingItems = new IItemStack[0]; + } + IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), toStacks(remainingItems)); + MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, null, toStack(box), craftRecipe))); + } + + /** + * Adds a shaped recipe for the Carpenter + * + * @param output recipe output + * @param ingredients recipe ingredients + * @param fluidInput recipe fluid amount + * @param packagingTime time per crafting operation + * @optionalParam box recipes casting item (optional) + */ + @ZenMethod + public static void addRecipe(IItemStack output, IIngredient[][] ingredients, ILiquidStack fluidInput, int packagingTime, @Optional IItemStack box, @Optional IItemStack[] remainingItems) { + if (remainingItems == null) { + remainingItems = new IItemStack[0]; + } + IDescriptiveRecipe craftRecipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), toStacks(remainingItems)); + MineTweakerAPI.apply(new Add(new CarpenterRecipe(packagingTime, toFluid(fluidInput), toStack(box), craftRecipe))); + } + + private static IItemStack[][] transform(IItemStack[] arr, int N) { + int M = (arr.length + N - 1) / N; + IItemStack[][] mat = new IItemStack[M][]; + int start = 0; + for (int r = 0; r < M; r++) { + int L = Math.min(N, arr.length - start); + mat[r] = java.util.Arrays.copyOfRange(arr, start, start + L); + start += L; + } + return mat; + } + + private static class Add extends ForestryListAddition { + + public Add(ICarpenterRecipe recipe) { + super(Carpenter.name, RecipeManagers.carpenterManager); + recipes.add(recipe); + } + + @Override + protected String getRecipeInfo(ICarpenterRecipe recipe) { + return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Removes a recipe for the Carpenter + * + * @param output = item output + * @optionalParam liquid = liquid input + */ + @ZenMethod + public static void removeRecipe(IIngredient output, @Optional IIngredient liquid) { + List recipes = new LinkedList(); + + for (ICarpenterRecipe recipe : RecipeManagers.carpenterManager.recipes()) { + if (recipe != null) { + ItemStack recipeResult = recipe.getCraftingGridRecipe().getRecipeOutput(); + if (recipeResult != null && matches(output, toIItemStack(recipeResult))) { + if (liquid != null) { + if (matches(liquid, toILiquidStack(recipe.getFluidResource()))) + recipes.add(recipe); + } else { + recipes.add(recipe); + } + } + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Carpenter.name, output.toString())); + } + } + + private static class Remove extends ForestryListRemoval { + + public Remove(List recipes) { + super(Carpenter.name, RecipeManagers.carpenterManager, recipes); + } + + @Override + protected String getRecipeInfo(ICarpenterRecipe recipe) { + return LogHelper.getStackDescription(recipe.getCraftingGridRecipe().getRecipeOutput()); + } + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java b/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java new file mode 100644 index 0000000..1ca6010 --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Centrifuge.java @@ -0,0 +1,110 @@ +package modtweaker2.mods.forestry.handlers; + +import forestry.api.recipes.ICentrifugeManager; +import forestry.api.recipes.ICentrifugeRecipe; +import forestry.api.recipes.RecipeManagers; +import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IIngredient; +import minetweaker.api.item.IItemStack; +import minetweaker.api.item.WeightedItemStack; +import modtweaker2.helpers.LogHelper; +import modtweaker2.mods.forestry.ForestryListAddition; +import modtweaker2.mods.forestry.ForestryListRemoval; +import modtweaker2.mods.forestry.recipes.CentrifugeRecipe; +import net.minecraft.item.ItemStack; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import static modtweaker2.helpers.InputHelper.toIItemStack; +import static modtweaker2.helpers.InputHelper.toStack; +import static modtweaker2.helpers.StackHelper.matches; + + +@ZenClass("mods.forestry.Centrifuge") +public class Centrifuge { + + public static final String name = "Forestry Centrifuge"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a recipe for the Centrifuge + * + * @param output List of items to produce with associated chance + * @param ingredient item input + * @param timePerItem time per item to process + */ + @ZenMethod + public static void addRecipe(WeightedItemStack[] output, IItemStack ingredient, int timePerItem) { + Map products = new HashMap(); + for (WeightedItemStack product : output) { + products.put(toStack(product.getStack()), product.getChance()); + } + MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(ingredient), products))); + } + + @ZenMethod + @Deprecated + public static void addRecipe(int timePerItem, IItemStack itemInput, IItemStack[] output, int[] chances) { + Map products = new HashMap(); + int i = 0; + for (IItemStack product : output) { + products.put(toStack(product), ((float) chances[i] / 100)); + i++; + } + MineTweakerAPI.apply(new Add(new CentrifugeRecipe(timePerItem, toStack(itemInput), products))); + } + + private static class Add extends ForestryListAddition { + public Add(ICentrifugeRecipe recipe) { + super(Centrifuge.name, RecipeManagers.centrifugeManager); + recipes.add(recipe); + } + + @Override + protected String getRecipeInfo(ICentrifugeRecipe recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Removes a recipe for the Centrifuge + * + * @param input item input + */ + @ZenMethod + public static void removeRecipe(IIngredient input) { + List recipes = new LinkedList(); + + for(ICentrifugeRecipe recipe : RecipeManagers.centrifugeManager.recipes()) { + if(recipe != null && matches(input, toIItemStack(recipe.getInput()))) { + recipes.add(recipe); + } + } + + if(!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Centrifuge.name, input.toString())); + } + } + + private static class Remove extends ForestryListRemoval { + + public Remove(List recipes) { + super(Centrifuge.name, RecipeManagers.centrifugeManager, recipes); + } + + @Override + protected String getRecipeInfo(ICentrifugeRecipe recipe) { + return LogHelper.getStackDescription(recipe.getInput()); + } + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Fermenter.java b/src/main/java/modtweaker2/mods/forestry/handlers/Fermenter.java new file mode 100644 index 0000000..eab5b5f --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Fermenter.java @@ -0,0 +1,171 @@ +package modtweaker2.mods.forestry.handlers; + +import forestry.api.fuels.FermenterFuel; +import forestry.api.fuels.FuelManager; +import forestry.api.recipes.IFermenterManager; +import forestry.api.recipes.IFermenterRecipe; +import forestry.api.recipes.RecipeManagers; +import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IIngredient; +import minetweaker.api.item.IItemStack; +import minetweaker.api.liquid.ILiquidStack; +import modtweaker2.helpers.LogHelper; +import modtweaker2.mods.forestry.ForestryListAddition; +import modtweaker2.mods.forestry.ForestryListRemoval; +import modtweaker2.mods.forestry.recipes.FermenterRecipe; +import modtweaker2.utils.BaseMapAddition; +import modtweaker2.utils.BaseMapRemoval; +import net.minecraft.item.ItemStack; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import static modtweaker2.helpers.InputHelper.*; +import static modtweaker2.helpers.StackHelper.matches; + +@ZenClass("mods.forestry.Fermenter") +public class Fermenter { + + public static final String name = "Forestry Fermenter"; + public static final String nameFuel = name + " (Fuel)"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a fermenter recipe. Amount of fluid output is calculated: fermentationValue * fluidOutputModifier + * Note: the actual consumption of fluid input depends on the fermentation fuel + * + * @param fluidOutput type of fluid produced + * @param resource organic item + * @param fluidInput type of fluid required in input + * @param fermentationValue amount of inputFluid on organic item requires + * @param fluidOutputModifier Output multiplier (this is usually a from the input fluid + */ + @ZenMethod + public static void addRecipe(ILiquidStack fluidOutput, IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier) { + MineTweakerAPI.apply(new Add(new FermenterRecipe(toStack(resource), fermentationValue, fluidOutputModifier, getFluid(fluidOutput), toFluid(fluidInput)))); + } + + @Deprecated + @ZenMethod + public static void addRecipe(IItemStack resource, ILiquidStack fluidInput, int fermentationValue, float fluidOutputModifier, ILiquidStack fluidOutput) { + MineTweakerAPI.apply(new Add(new FermenterRecipe(toStack(resource), fermentationValue, fluidOutputModifier, getFluid(fluidOutput), toFluid(fluidInput)))); + } + + private static class Add extends ForestryListAddition { + public Add(IFermenterRecipe recipe) { + super(Fermenter.name, RecipeManagers.fermenterManager); + recipes.add(recipe); + } + + @Override + public String getRecipeInfo(IFermenterRecipe recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IIngredient input) { + List recipes = new LinkedList(); + + for(IFermenterRecipe recipe : RecipeManagers.fermenterManager.recipes()) { + // check for input items + if(recipe != null && recipe.getResource() != null && matches(input, toIItemStack(recipe.getResource()))) { + recipes.add(recipe); + } + + // check for input liquids + if(recipe != null && recipe.getResource() != null && matches(input, toILiquidStack(recipe.getFluidResource()))) { + recipes.add(recipe); + } + } + + if(!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Fermenter.name, input.toString())); + } + } + + private static class Remove extends ForestryListRemoval { + + public Remove(List recipes) { + super(Fermenter.name, RecipeManagers.fermenterManager, recipes); + } + + @Override + protected String getRecipeInfo(IFermenterRecipe recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds fermenter fuel. + * Note: the actual consumption of fluid input depends on the fermentation fuel + * + * @param item Item that is a valid fuel for the fermenter + * @param fermentPerCycle How much is fermented per work cycle, i.e. how much fluid of the input is consumed. + * @param burnDuration Amount of work cycles a single item of this fuel lasts before expiring. + */ + @ZenMethod + public static void addFuel(IItemStack item, int fermentPerCycle, int burnDuration) { + MineTweakerAPI.apply(new AddFuel(new FermenterFuel(toStack(item), fermentPerCycle, burnDuration))); + } + + private static class AddFuel extends BaseMapAddition { + public AddFuel(FermenterFuel fuelEntry) { + super(Fermenter.nameFuel, FuelManager.fermenterFuel); + recipes.put(fuelEntry.item, fuelEntry); + } + + @Override + public String getRecipeInfo(Entry fuelEntry) { + return LogHelper.getStackDescription(fuelEntry.getKey()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Removes a fermenter fuel. + * + * @param fermenterItem Item that is a valid fuel for the fermenter + */ + @ZenMethod + public static void removeFuel(IIngredient fermenterItem) { + Map fuelItems = new HashMap(); + + for(Entry fuelItem : FuelManager.fermenterFuel.entrySet()) { + if(fuelItem != null && matches(fermenterItem, toIItemStack(fuelItem.getValue().item))) { + fuelItems.put(fuelItem.getKey(), fuelItem.getValue()); + } + } + + if(!fuelItems.isEmpty()) { + MineTweakerAPI.apply(new RemoveFuel(fuelItems)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Fermenter.name, fermenterItem.toString())); + } + } + + private static class RemoveFuel extends BaseMapRemoval { + public RemoveFuel(Map recipes) { + super(Fermenter.nameFuel, FuelManager.fermenterFuel, recipes); + } + + @Override + public String getRecipeInfo(Entry fuelEntry) { + return LogHelper.getStackDescription(fuelEntry.getKey()); + } + } +} + diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Moistener.java b/src/main/java/modtweaker2/mods/forestry/handlers/Moistener.java new file mode 100644 index 0000000..3266756 --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Moistener.java @@ -0,0 +1,163 @@ +package modtweaker2.mods.forestry.handlers; + +import forestry.api.fuels.FuelManager; +import forestry.api.fuels.MoistenerFuel; +import forestry.api.recipes.IMoistenerManager; +import forestry.api.recipes.IMoistenerRecipe; +import forestry.api.recipes.RecipeManagers; +import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IIngredient; +import minetweaker.api.item.IItemStack; +import modtweaker2.helpers.LogHelper; +import modtweaker2.mods.forestry.ForestryListAddition; +import modtweaker2.mods.forestry.ForestryListRemoval; +import modtweaker2.mods.forestry.recipes.MoistenerRecipe; +import modtweaker2.utils.BaseMapAddition; +import modtweaker2.utils.BaseMapRemoval; +import net.minecraft.item.ItemStack; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import static modtweaker2.helpers.InputHelper.toIItemStack; +import static modtweaker2.helpers.InputHelper.toStack; +import static modtweaker2.helpers.StackHelper.matches; + +@ZenClass("mods.forestry.Moistener") +public class Moistener { + + public static final String name = "Forestry Moistener"; + public static final String nameFuel = name + " (Fuel)"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a recipe for the Moistener + * + * @param output recipe output + * @param resource organic item + * @param timePerItem time per item to process + */ + @ZenMethod + public static void addRecipe(IItemStack output, IItemStack resource, int timePerItem) { + MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(resource), toStack(output), timePerItem))); + } + + @Deprecated + @ZenMethod + public static void addRecipe(int timePerItem, IItemStack resource, IItemStack product) { + MineTweakerAPI.apply(new Add(new MoistenerRecipe(toStack(resource), toStack(product), timePerItem))); + } + + private static class Add extends ForestryListAddition { + public Add(IMoistenerRecipe recipe) { + super(Moistener.name, RecipeManagers.moistenerManager); + recipes.add(recipe); + } + + @Override + public String getRecipeInfo(IMoistenerRecipe recipe) { + return LogHelper.getStackDescription(recipe.getProduct()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeRecipe(IIngredient output) { + List recipes = new LinkedList(); + for (IMoistenerRecipe recipe : RecipeManagers.moistenerManager.recipes()) { + if (recipe != null && recipe.getProduct() != null && matches(output, toIItemStack(recipe.getProduct()))) { + recipes.add(recipe); + } + } + + if(!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Moistener.name, output.toString())); + } + } + + private static class Remove extends ForestryListRemoval { + public Remove(List recipes) { + super(Moistener.name, RecipeManagers.moistenerManager, recipes); + } + + @Override + public String getRecipeInfo(IMoistenerRecipe recipe) { + return LogHelper.getStackDescription(recipe.getProduct()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds moistener fuel. + * + * @param item The item to use + * @param product The item that leaves the moistener's working slot (i.e. mouldy wheat, decayed wheat, mulch) + * @param moistenerValue How much this item contributes to the final product of the moistener (i.e. mycelium) + * @param stage What stage this product represents. Resources with lower stage value will be consumed first. (First Stage is 0) + */ + @ZenMethod + public static void addFuel(IItemStack item, IItemStack product, int moistenerValue, int stage) { + if(stage >= 0) { + MineTweakerAPI.apply(new AddFuel(new MoistenerFuel(toStack(item), toStack(product), moistenerValue, stage))); + } else { + LogHelper.logWarning(String.format("No %s Recipe add for %s. Stage parameter must positive!", Moistener.name, item.toString())); + } + } + + private static class AddFuel extends BaseMapAddition { + public AddFuel(MoistenerFuel fuelEntry) { + super(Moistener.nameFuel, FuelManager.moistenerResource); + recipes.put(fuelEntry.item, fuelEntry); + } + + @Override + public String getRecipeInfo(Entry fuelEntry) { + return LogHelper.getStackDescription(fuelEntry.getKey()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Removes a moistener fuel. + * + * @param moistenerItem Item that is a valid fuel for the moistener + */ + @ZenMethod + public static void removeFuel(IIngredient moistenerItem) { + Map fuelItems = new HashMap(); + + for(Entry fuelItem : FuelManager.moistenerResource.entrySet()) { + if(fuelItem != null && matches(moistenerItem, toIItemStack(fuelItem.getValue().item))) { + fuelItems.put(fuelItem.getKey(), fuelItem.getValue()); + } + } + + if(!fuelItems.isEmpty()) { + MineTweakerAPI.apply(new RemoveFuel(fuelItems)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Moistener.name, moistenerItem.toString())); + } + } + + private static class RemoveFuel extends BaseMapRemoval { + public RemoveFuel(Map recipes) { + super(Moistener.nameFuel, FuelManager.moistenerResource, recipes); + } + + @Override + public String getRecipeInfo(Entry fuelEntry) { + return LogHelper.getStackDescription(fuelEntry.getKey()); + } + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Squeezer.java b/src/main/java/modtweaker2/mods/forestry/handlers/Squeezer.java new file mode 100644 index 0000000..8adaf15 --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Squeezer.java @@ -0,0 +1,127 @@ +package modtweaker2.mods.forestry.handlers; + +import forestry.api.recipes.ISqueezerManager; +import forestry.api.recipes.ISqueezerRecipe; +import forestry.api.recipes.RecipeManagers; +import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IIngredient; +import minetweaker.api.item.IItemStack; +import minetweaker.api.item.WeightedItemStack; +import minetweaker.api.liquid.ILiquidStack; +import modtweaker2.helpers.LogHelper; +import modtweaker2.mods.forestry.ForestryListAddition; +import modtweaker2.mods.forestry.ForestryListRemoval; +import modtweaker2.mods.forestry.recipes.SqueezerRecipe; +import stanhebben.zenscript.annotations.Optional; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +import java.util.LinkedList; +import java.util.List; + +import static modtweaker2.helpers.InputHelper.*; +import static modtweaker2.helpers.StackHelper.matches; + +@ZenClass("mods.forestry.Squeezer") +public class Squeezer { + + public static final String name = "Forestry Squeezer"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a recipe without additional item output + * + * @param fluidOutput recipe fluid amount + * @param ingredients recipe ingredients + * @param timePerItem time per crafting operation + */ + @ZenMethod + public static void addRecipe(ILiquidStack fluidOutput, int timePerItem, IItemStack[] ingredients) { + MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(ingredients), toFluid(fluidOutput), null, 0))); + } + + /** + * Adds a recipe with additional item output + * + * @param fluidOutput recipe fluid amount + * @param itemOutput recipe output + * @param ingredients recipe ingredients + * @param timePerItem time per crafting operation + */ + @ZenMethod + public static void addRecipe(ILiquidStack fluidOutput, WeightedItemStack itemOutput, IItemStack[] ingredients, int timePerItem) { + MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(ingredients), toFluid(fluidOutput), toStack(itemOutput.getStack()), itemOutput.getChance()))); + } + + @ZenMethod + @Deprecated + public static void addRecipe(int timePerItem, IItemStack[] resources, ILiquidStack liquid, IItemStack remnants, int chance) { + MineTweakerAPI.apply(new Add(new SqueezerRecipe(timePerItem, toStacks(resources), toFluid(liquid), toStack(remnants), chance))); + } + + private static class Add extends ForestryListAddition { + public Add(ISqueezerRecipe recipe) { + super(Squeezer.name, RecipeManagers.squeezerManager); + recipes.add(recipe); + } + + @Override + public String getRecipeInfo(ISqueezerRecipe recipe) { + return LogHelper.getStackDescription(recipe.getFluidOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Removes a recipe for the Centrifuge + * + * @param liquid liquid output + * @param ingredients list of ingredients + */ + @ZenMethod + public static void removeRecipe(IIngredient liquid, @Optional IIngredient[] ingredients) { + List recipes = new LinkedList(); + + for (ISqueezerRecipe r : RecipeManagers.squeezerManager.recipes()) { + if (r != null && r.getFluidOutput() != null && matches(liquid, toILiquidStack(r.getFluidOutput()))) { + // optional check for ingredients + if (ingredients != null) { + boolean matched = false; + for (int i = 0; i < ingredients.length; i++) { + if ( matches(ingredients[i], toIItemStack(r.getResources()[i])) ) + matched = true; + else { + matched = false; + // if one ingredients doesn't match abort all further checks + break; + } + } + // if some ingredient doesn't match, the last one is false + if (matched) + recipes.add(r); + } else { + recipes.add(r); + } + } + } + + if(!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Squeezer.name, LogHelper.getStackDescription(liquid))); + } + } + + private static class Remove extends ForestryListRemoval { + public Remove(List recipes) { + super(Squeezer.name, RecipeManagers.squeezerManager, recipes); + } + + @Override + public String getRecipeInfo(ISqueezerRecipe recipe) { + return LogHelper.getStackDescription(recipe.getFluidOutput()); + } + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/Still.java b/src/main/java/modtweaker2/mods/forestry/handlers/Still.java new file mode 100644 index 0000000..f27c9b7 --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/handlers/Still.java @@ -0,0 +1,108 @@ +package modtweaker2.mods.forestry.handlers; + +import forestry.api.recipes.IStillManager; +import forestry.api.recipes.IStillRecipe; +import forestry.api.recipes.RecipeManagers; +import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IIngredient; +import minetweaker.api.liquid.ILiquidStack; +import modtweaker2.helpers.LogHelper; +import modtweaker2.mods.forestry.ForestryListAddition; +import modtweaker2.mods.forestry.ForestryListRemoval; +import modtweaker2.mods.forestry.recipes.StillRecipe; +import stanhebben.zenscript.annotations.Optional; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +import java.util.LinkedList; +import java.util.List; + +import static modtweaker2.helpers.InputHelper.toFluid; +import static modtweaker2.helpers.InputHelper.toILiquidStack; +import static modtweaker2.helpers.StackHelper.matches; + +@ZenClass("mods.forestry.Still") +public class Still { + + public static final String name = "Forestry Still"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a recipe for the Still + * + * @param fluidOutput recipe fluid amount + * @param fluidInput recipe fluid input + * @param timePerUnit time per crafting operation + */ + @ZenMethod + public static void addRecipe(ILiquidStack fluidOutput, ILiquidStack fluidInput, int timePerUnit) { + fluidOutput.amount(fluidOutput.getAmount() / 100); + fluidInput.amount(fluidInput.getAmount() / 100); + + MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(fluidInput), toFluid(fluidOutput)))); + } + + @Deprecated + @ZenMethod + public static void addRecipe(int timePerUnit, ILiquidStack input, ILiquidStack output) { + output.amount(output.getAmount() / 100); + input.amount(input.getAmount() / 100); + + MineTweakerAPI.apply(new Add(new StillRecipe(timePerUnit, toFluid(input), toFluid(output)))); + } + + private static class Add extends ForestryListAddition { + public Add(IStillRecipe recipe) { + super("Forestry Still", RecipeManagers.stillManager); + recipes.add(recipe); + } + + @Override + public String getRecipeInfo(IStillRecipe recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Removes a recipe for the Still + * + * @param output = liquid output + * @optionalParam liquid = liquid input + */ + @ZenMethod + public static void removeRecipe(IIngredient output, @Optional ILiquidStack input) { + List recipes = new LinkedList(); + + for (IStillRecipe r : RecipeManagers.stillManager.recipes()) { + if (r != null && r.getOutput() != null && matches(output, toILiquidStack(r.getOutput()))) { + if (input != null) { + if (matches(input, toILiquidStack(r.getInput()))) { + recipes.add(r); + } + } + else + recipes.add(r); + } + } + + if(!recipes.isEmpty()) { + MineTweakerAPI.apply(new Remove(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Still.name, LogHelper.getStackDescription(output))); + } + } + + private static class Remove extends ForestryListRemoval { + public Remove(List recipes) { + super(Still.name, RecipeManagers.stillManager, recipes); + } + + @Override + public String getRecipeInfo(IStillRecipe recipe) { + return LogHelper.getStackDescription(recipe.getOutput()); + } + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/handlers/ThermionicFabricator.java b/src/main/java/modtweaker2/mods/forestry/handlers/ThermionicFabricator.java new file mode 100644 index 0000000..6b0e470 --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/handlers/ThermionicFabricator.java @@ -0,0 +1,187 @@ +package modtweaker2.mods.forestry.handlers; + +import forestry.api.recipes.*; +import minetweaker.MineTweakerAPI; +import minetweaker.api.item.IIngredient; +import minetweaker.api.item.IItemStack; +import minetweaker.api.liquid.ILiquidStack; +import modtweaker2.helpers.LogHelper; +import modtweaker2.mods.forestry.ForestryListAddition; +import modtweaker2.mods.forestry.ForestryListRemoval; +import modtweaker2.mods.forestry.recipes.DescriptiveRecipe; +import modtweaker2.mods.forestry.recipes.FabricatorRecipe; +import modtweaker2.mods.forestry.recipes.FabricatorSmeltingRecipe; +import net.minecraftforge.fluids.FluidRegistry; +import stanhebben.zenscript.annotations.Optional; +import stanhebben.zenscript.annotations.ZenClass; +import stanhebben.zenscript.annotations.ZenMethod; + +import java.util.LinkedList; +import java.util.List; + +import static modtweaker2.helpers.InputHelper.*; +import static modtweaker2.helpers.StackHelper.matches; + +@ZenClass("mods.forestry.ThermionicFabricator") +public class ThermionicFabricator { + + public static final String nameSmelting = "Forestry Thermionic Fabricator (Smelting)"; + public static final String nameCasting = "Forestry Thermionic Fabricator (Casting)"; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a smelting recipe for the Thermionic Fabricator + * + * @param fluidOutput recipe fluid amount + * @param itemInput recipe input input + * @param meltingPoint point at where itemInput melts down + */ + @ZenMethod + public static void addSmelting(int fluidOutput, IItemStack itemInput, int meltingPoint) { + //The machines internal tank accept only liquid glass, therefor this function only accept the amount and hardcode the fluid to glass + MineTweakerAPI.apply(new AddSmelting(new FabricatorSmeltingRecipe(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint))); + } + + @Deprecated + @ZenMethod + public static void addSmelting(IItemStack itemInput, int meltingPoint, int fluidOutput) { + //The machines internal tank accept only liquid glass, therefor this function only accept the amount and hardcode the fluid to glass + MineTweakerAPI.apply(new AddSmelting(new FabricatorSmeltingRecipe(toStack(itemInput), FluidRegistry.getFluidStack("glass", fluidOutput), meltingPoint))); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Adds a casting recipe for the Thermionic Fabricator + * + * @param output recipe output item + * @param ingredients list of input items + * @param fluidInput recipe fluid input + * @param plan recipe plan item + */ + @ZenMethod + public static void addCast(IItemStack output, IIngredient[][] ingredients, int fluidInput, @Optional IItemStack plan, @Optional IItemStack[] remainingItems) { + if (remainingItems == null) { + remainingItems = new IItemStack[0]; + } + IDescriptiveRecipe recipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), toStacks(remainingItems)); + MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), FluidRegistry.getFluidStack("glass", fluidInput), recipe))); + } + + @Deprecated + @ZenMethod + public static void addCast(ILiquidStack fluidInput, IIngredient[][] ingredients, IItemStack plan, IItemStack output, @Optional IItemStack[] remainingItems) { + if (remainingItems == null) { + remainingItems = new IItemStack[0]; + } + IDescriptiveRecipe recipe = new DescriptiveRecipe(3, 3, toShapedObjects(ingredients), toStack(output), toStacks(remainingItems)); + MineTweakerAPI.apply(new AddCast(new FabricatorRecipe(toStack(plan), toFluid(fluidInput), recipe))); + } + + /* + Implements the actions to add a recipe + Since the machine has two crafting Steps, this is a constructors for both + */ + private static class AddSmelting extends ForestryListAddition { + + public AddSmelting(IFabricatorSmeltingRecipe recipe) { + super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager); + recipes.add(recipe); + } + + @Override + public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) { + return LogHelper.getStackDescription(recipe.getResource()); + } + } + + private static class AddCast extends ForestryListAddition { + + public AddCast(IFabricatorRecipe recipe) { + super(ThermionicFabricator.nameCasting, RecipeManagers.fabricatorManager); + recipes.add(recipe); + } + + @Override + public String getRecipeInfo(IFabricatorRecipe recipe) { + return LogHelper.getStackDescription(recipe.getRecipeOutput()); + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + @ZenMethod + public static void removeSmelting(IIngredient itemInput) { + List recipes = new LinkedList(); + + for (IFabricatorSmeltingRecipe r : RecipeManagers.fabricatorSmeltingManager.recipes()) { + if (r != null && r.getResource() != null && matches(itemInput, toIItemStack(r.getResource()))) { + recipes.add(r); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveSmelting(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, itemInput.toString())); + } + } + + @ZenMethod + public static void removeCast(IIngredient product) { + List recipes = new LinkedList(); + + for (IFabricatorRecipe r : RecipeManagers.fabricatorManager.recipes()) { + if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) { + recipes.add(r); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveCasts(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, product.toString())); + } + } + + @Deprecated + @ZenMethod + public static void removeCasts(IIngredient product) { + List recipes = new LinkedList(); + + for (IFabricatorRecipe r : RecipeManagers.fabricatorManager.recipes()) { + if (r != null && r.getRecipeOutput() != null && matches(product, toIItemStack(r.getRecipeOutput()))) { + recipes.add(r); + } + } + + if (!recipes.isEmpty()) { + MineTweakerAPI.apply(new RemoveCasts(recipes)); + } else { + LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", ThermionicFabricator.nameSmelting, product.toString())); + } + } + + private static class RemoveSmelting extends ForestryListRemoval { + public RemoveSmelting(List recipes) { + super(ThermionicFabricator.nameSmelting, RecipeManagers.fabricatorSmeltingManager, recipes); + } + + @Override + public String getRecipeInfo(IFabricatorSmeltingRecipe recipe) { + return LogHelper.getStackDescription(recipe.getResource()); + } + } + + private static class RemoveCasts extends ForestryListRemoval { + public RemoveCasts(List recipes) { + super(ThermionicFabricator.nameCasting, RecipeManagers.fabricatorManager, recipes); + } + + @Override + public String getRecipeInfo(IFabricatorRecipe recipe) { + return LogHelper.getStackDescription(recipe.getRecipeOutput()); + } + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/CarpenterRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/CarpenterRecipe.java new file mode 100644 index 0000000..6f8cf77 --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/recipes/CarpenterRecipe.java @@ -0,0 +1,46 @@ +package modtweaker2.mods.forestry.recipes; + +import forestry.api.recipes.ICarpenterRecipe; +import forestry.api.recipes.IDescriptiveRecipe; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import javax.annotation.Nullable; + +public class CarpenterRecipe implements ICarpenterRecipe { + + private final int packagingTime; + @Nullable + private final FluidStack liquid; + @Nullable + private final ItemStack box; + private final IDescriptiveRecipe internal; + + public CarpenterRecipe(int packagingTime, @Nullable FluidStack liquid, @Nullable ItemStack box, IDescriptiveRecipe internal) { + this.packagingTime = packagingTime; + this.liquid = liquid; + this.box = box; + this.internal = internal; + } + + public int getPackagingTime() { + return packagingTime; + } + + @Override + @Nullable + public ItemStack getBox() { + return box; + } + + @Override + @Nullable + public FluidStack getFluidResource() { + return liquid; + } + + @Override + public IDescriptiveRecipe getCraftingGridRecipe() { + return internal; + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/CentrifugeRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/CentrifugeRecipe.java new file mode 100644 index 0000000..f74370b --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/recipes/CentrifugeRecipe.java @@ -0,0 +1,58 @@ +package modtweaker2.mods.forestry.recipes; + +import com.google.common.collect.ImmutableMap; +import forestry.api.recipes.ICentrifugeRecipe; +import net.minecraft.item.ItemStack; + +import java.util.*; + +public class CentrifugeRecipe implements ICentrifugeRecipe { + + private final int processingTime; + private final ItemStack input; + private final Map outputs; + + public CentrifugeRecipe(int processingTime, ItemStack input, Map outputs) { + this.processingTime = processingTime; + this.input = input; + this.outputs = outputs; + + for (ItemStack item : outputs.keySet()) { + if (item == null) { + throw new IllegalArgumentException("Tried to register a null product of " + input); + } + } + } + + @Override + public ItemStack getInput() { + return input; + } + + @Override + public int getProcessingTime() { + return processingTime; + } + + @Override + public Collection getProducts(Random random) { + List products = new ArrayList(); + + for (Map.Entry entry : this.outputs.entrySet()) { + float probability = entry.getValue(); + + if (probability >= 1.0) { + products.add(entry.getKey().copy()); + } else if (random.nextFloat() < probability) { + products.add(entry.getKey().copy()); + } + } + + return products; + } + + @Override + public Map getAllProducts() { + return ImmutableMap.copyOf(outputs); + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/DescriptiveRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/DescriptiveRecipe.java new file mode 100644 index 0000000..b6dc9c0 --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/recipes/DescriptiveRecipe.java @@ -0,0 +1,62 @@ +package modtweaker2.mods.forestry.recipes; + +import forestry.api.recipes.IDescriptiveRecipe; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; +import net.minecraftforge.oredict.ShapedOreRecipe; + +public class DescriptiveRecipe implements IDescriptiveRecipe { + + private final int width; + private final int height; + private final ShapedOreRecipe recipe; + private final ItemStack[] remainingItems; + + public DescriptiveRecipe(int width, int height, Object[] ingredients, ItemStack output, ItemStack[] remainingItems) { + this.width = width; + this.height = height; + this.recipe = new ShapedOreRecipe(output, ingredients); + this.remainingItems = remainingItems; + } + + @Override + public int getWidth() { + return width; + } + + @Override + public int getHeight() { + return height; + } + + @Override + public ItemStack getRecipeOutput() { + return recipe.getRecipeOutput(); + } + + @Override + public ItemStack[] getRemainingItems(InventoryCrafting inv) { + return remainingItems; + } + + @Override + public Object[] getIngredients() { + return recipe.getInput(); + } + + @Override + public boolean matches(InventoryCrafting inventoryCrafting, World world) { + return recipe.matches(inventoryCrafting, world); + } + + @Override + public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) { + return recipe.getCraftingResult(inventoryCrafting); + } + + @Override + public int getRecipeSize() { + return width * height; + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorRecipe.java new file mode 100644 index 0000000..b335617 --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorRecipe.java @@ -0,0 +1,58 @@ +package modtweaker2.mods.forestry.recipes; + +import forestry.api.recipes.IDescriptiveRecipe; +import forestry.api.recipes.IFabricatorRecipe; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import javax.annotation.Nullable; + +public class FabricatorRecipe implements IFabricatorRecipe { + + private final ItemStack plan; + private final FluidStack molten; + private final IDescriptiveRecipe internal; + + public FabricatorRecipe(ItemStack plan, FluidStack molten, ItemStack result, ItemStack[] remainingItems, Object[] ingredients) { + this(plan, molten, new DescriptiveRecipe(3, 3, ingredients, result, remainingItems)); + } + + public FabricatorRecipe(ItemStack plan, FluidStack molten, IDescriptiveRecipe internal) { + this.plan = plan; + this.molten = molten; + this.internal = internal; + } + + + @Override + public Object[] getIngredients() { + return internal.getIngredients(); + } + + @Override + public int getWidth() { + return internal.getWidth(); + } + + @Override + public int getHeight() { + return internal.getHeight(); + } + + @Override + @Nullable + public ItemStack getPlan() { + return plan; + } + + @Override + public FluidStack getLiquid() { + return molten; + } + + @Override + public ItemStack getRecipeOutput() { + return internal.getRecipeOutput(); + } + +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorSmeltingRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorSmeltingRecipe.java new file mode 100644 index 0000000..4d93a25 --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/recipes/FabricatorSmeltingRecipe.java @@ -0,0 +1,38 @@ +package modtweaker2.mods.forestry.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.recipes.IFabricatorSmeltingRecipe; + +public class FabricatorSmeltingRecipe implements IFabricatorSmeltingRecipe { + private final ItemStack resource; + private final FluidStack product; + private final int meltingPoint; + + public FabricatorSmeltingRecipe(ItemStack resource, FluidStack molten, int meltingPoint) { + if (resource == null) { + throw new IllegalArgumentException("Resource cannot be null"); + } + if (molten == null) { + throw new IllegalArgumentException("Molten cannot be null"); + } + + this.resource = resource; + this.product = molten; + this.meltingPoint = meltingPoint; + } + + public ItemStack getResource() { + return resource; + } + + public FluidStack getProduct() { + return product; + } + + public int getMeltingPoint() { + return meltingPoint; + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/FermenterRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/FermenterRecipe.java new file mode 100644 index 0000000..15a3f7b --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/recipes/FermenterRecipe.java @@ -0,0 +1,68 @@ +package modtweaker2.mods.forestry.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.recipes.IFermenterRecipe; + +public class FermenterRecipe implements IFermenterRecipe { + + private final ItemStack resource; + private final int fermentationValue; + private final float modifier; + private final Fluid output; + private final FluidStack fluidResource; + + public FermenterRecipe(ItemStack resource, int fermentationValue, float modifier, Fluid output, FluidStack fluidResource) { + if (resource == null) { + throw new NullPointerException("Fermenter Resource cannot be null!"); + } + + if (output == null) { + throw new NullPointerException("Fermenter Output cannot be null!"); + } + + if (fluidResource == null) { + throw new NullPointerException("Fermenter Liquid cannot be null!"); + } + + // assume that fermenter recipes want to use Forestry's honey and not the legacy "fluid.honey" + if (fluidResource.getFluid().getName().equals("fluid.honey")) { + fluidResource = new FluidStack(FluidRegistry.getFluid("fluid.for.honey"), fluidResource.amount); + } + + this.resource = resource; + this.fermentationValue = fermentationValue; + this.modifier = modifier; + this.output = output; + this.fluidResource = fluidResource; + } + + @Override + public ItemStack getResource() { + return resource; + } + + @Override + public FluidStack getFluidResource() { + return fluidResource; + } + + @Override + public int getFermentationValue() { + return fermentationValue; + } + + @Override + public float getModifier() { + return modifier; + } + + @Override + public Fluid getOutput() { + return output; + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/MoistenerRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/MoistenerRecipe.java new file mode 100644 index 0000000..5cec8eb --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/recipes/MoistenerRecipe.java @@ -0,0 +1,30 @@ +package modtweaker2.mods.forestry.recipes; + +import net.minecraft.item.ItemStack; + +import forestry.api.recipes.IMoistenerRecipe; + +public class MoistenerRecipe implements IMoistenerRecipe { + + private final int timePerItem; + private final ItemStack resource; + private final ItemStack product; + + public MoistenerRecipe(ItemStack resource, ItemStack product, int timePerItem) { + this.timePerItem = timePerItem; + this.resource = resource; + this.product = product; + } + + public int getTimePerItem() { + return timePerItem; + } + + public ItemStack getResource() { + return resource; + } + + public ItemStack getProduct() { + return product; + } +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/SqueezerRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/SqueezerRecipe.java new file mode 100644 index 0000000..d1f6e82 --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/recipes/SqueezerRecipe.java @@ -0,0 +1,50 @@ +package modtweaker2.mods.forestry.recipes; + +import net.minecraft.item.ItemStack; + +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.recipes.ISqueezerRecipe; + +public class SqueezerRecipe implements ISqueezerRecipe { + + private final int processingTime; + private final ItemStack[] resources; + private final FluidStack fluidOutput; + private final ItemStack remnants; + private final float remnantsChance; + + public SqueezerRecipe(int processingTime, ItemStack[] resources, FluidStack fluidOutput, ItemStack remnants, float remnantsChance) { + this.processingTime = processingTime; + this.resources = resources; + this.fluidOutput = fluidOutput; + this.remnants = remnants; + this.remnantsChance = remnantsChance; + } + + @Override + public ItemStack[] getResources() { + return resources; + } + + @Override + public ItemStack getRemnants() { + return remnants; + } + + @Override + public float getRemnantsChance() { + return remnantsChance; + } + + @Override + public FluidStack getFluidOutput() { + return fluidOutput; + } + + @Override + public int getProcessingTime() { + return processingTime; + } + +} diff --git a/src/main/java/modtweaker2/mods/forestry/recipes/StillRecipe.java b/src/main/java/modtweaker2/mods/forestry/recipes/StillRecipe.java new file mode 100644 index 0000000..9049c6d --- /dev/null +++ b/src/main/java/modtweaker2/mods/forestry/recipes/StillRecipe.java @@ -0,0 +1,38 @@ +package modtweaker2.mods.forestry.recipes; + +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.recipes.IStillRecipe; + +public class StillRecipe implements IStillRecipe { + private final int timePerUnit; + private final FluidStack input; + private final FluidStack output; + + public StillRecipe(int timePerUnit, FluidStack input, FluidStack output) { + this.timePerUnit = timePerUnit; + if (input == null) { + throw new IllegalArgumentException("Still recipes need an input. Input was null."); + } + if (output == null) { + throw new IllegalArgumentException("Still recipes need an output. Output was null."); + } + this.input = input; + this.output = output; + } + + @Override + public int getCyclesPerUnit() { + return timePerUnit; + } + + @Override + public FluidStack getInput() { + return input; + } + + @Override + public FluidStack getOutput() { + return output; + } +} diff --git a/src/main/java/modtweaker2/mods/tconstruct/TConstruct.java b/src/main/java/modtweaker2/mods/tconstruct/TConstruct.java new file mode 100644 index 0000000..010e51f --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/TConstruct.java @@ -0,0 +1,16 @@ +package modtweaker2.mods.tconstruct; + +import minetweaker.MineTweakerAPI; +import modtweaker2.brackets.MaterialBracketHandler; + +public class TConstruct { + public TConstruct() { +// MineTweakerAPI.registerClass(Casting.class); +// MineTweakerAPI.registerClass(Drying.class); +// MineTweakerAPI.registerClass(Smeltery.class); +// MineTweakerAPI.registerClass(Modifiers.class); +// MineTweakerAPI.registerClass(TiCTweaks.class); +// MineTweakerAPI.registerClass(ToolStats.class); + MineTweakerAPI.registerBracketHandler(new MaterialBracketHandler()); + } +} diff --git a/src/main/java/modtweaker2/mods/tconstruct/TConstructHelper.java b/src/main/java/modtweaker2/mods/tconstruct/TConstructHelper.java new file mode 100644 index 0000000..f8bb5bd --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/TConstructHelper.java @@ -0,0 +1,54 @@ +package modtweaker2.mods.tconstruct; + +import modtweaker2.helpers.ReflectionHelper; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; +import slimeknights.tconstruct.library.DryingRecipe; +import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.modifiers.IModifier; +import slimeknights.tconstruct.library.smeltery.AlloyRecipe; +import slimeknights.tconstruct.library.smeltery.CastingRecipe; +import slimeknights.tconstruct.library.smeltery.MeltingRecipe; + +import java.util.ArrayList; +import java.util.List; + +public class TConstructHelper { + public static List alloys = null; + public static List basinCasting = null; + public static List tableCasting = null; + public static List smeltingList = null; + // public static Map temperatureList = null; +// public static Map renderIndex = null; + public static List fuelList = new ArrayList(); + public static List modifiers = new ArrayList(); + public static List modifiers_clone = null; + + static { + try { + alloys = TinkerRegistry.getAlloys(); + smeltingList = TinkerRegistry.getAllMeltingRecipies(); +// temperatureList = tconstruct.library.crafting.Smeltery.getTemperatureList(); +// renderIndex = tconstruct.library.crafting.Smeltery.getRenderIndex(); + basinCasting = TinkerRegistry.getAllBasinCastingRecipes(); + tableCasting = TinkerRegistry.getAllTableCastingRecipes(); + modifiers.addAll(TinkerRegistry.getAllModifiers()); + modifiers_clone = new ArrayList(modifiers); + fuelList.addAll(TinkerRegistry.getSmelteryFuels()); + + } catch (Exception e) { + } + } + + private TConstructHelper() { + } + + //Returns a Drying Recipe, using reflection as the constructor is not visible + public static DryingRecipe getDryingRecipe(ItemStack input, int time, ItemStack output) { + return ReflectionHelper.getInstance(ReflectionHelper.getConstructor(DryingRecipe.class, ItemStack.class, int.class, ItemStack.class), + input, + time, + output); + } + +} diff --git a/src/main/java/modtweaker2/mods/tconstruct/actions/SetAttackAction.java b/src/main/java/modtweaker2/mods/tconstruct/actions/SetAttackAction.java new file mode 100644 index 0000000..bce748d --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/actions/SetAttackAction.java @@ -0,0 +1,65 @@ +package modtweaker2.mods.tconstruct.actions; + +import minetweaker.IUndoableAction; +import modtweaker2.brackets.util.IMaterial; +import slimeknights.tconstruct.library.materials.HeadMaterialStats; +import slimeknights.tconstruct.library.materials.IMaterialStats; +import slimeknights.tconstruct.library.materials.Material; + +/** + * Created by Jared on 6/16/2016. + */ +public class SetAttackAction implements IUndoableAction { + + private final IMaterial material; + private final String stat; + private final float newValue; + private final float oldValue; + + public SetAttackAction(IMaterial material, String stat, float newValue) { + this.material = material; + this.stat = stat; + this.newValue = newValue; + this.oldValue = ((HeadMaterialStats) ((Material) material.getInternal()).getStats("head")).attack; + } + + private static void set(Material material, String stat, float attack) { + IMaterialStats oldStat = material.getStats(stat); + if (oldStat instanceof HeadMaterialStats) { + HeadMaterialStats headStat = (HeadMaterialStats) oldStat; + HeadMaterialStats newHead = new HeadMaterialStats(headStat.durability, headStat.miningspeed, attack, headStat.harvestLevel); + material.addStats(newHead); + } + + } + + @Override + public void apply() { + set((Material) material.getInternal(), stat, newValue); + } + + @Override + public boolean canUndo() { + return true; + } + + @Override + public void undo() { + set((Material) material.getInternal(), stat, oldValue); + } + + @Override + public String describe() { + return "Setting Attack of " + material.getName() + " to " + newValue + " for " + stat; + } + + @Override + public String describeUndo() { + return "Reverting Attack of " + material.getName() + " to " + oldValue + " for " + stat; + } + + @Override + public Object getOverrideKey() { + return null; + } +} diff --git a/src/main/java/modtweaker2/mods/tconstruct/actions/SetDurabilityAction.java b/src/main/java/modtweaker2/mods/tconstruct/actions/SetDurabilityAction.java new file mode 100644 index 0000000..97849d0 --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/actions/SetDurabilityAction.java @@ -0,0 +1,70 @@ +package modtweaker2.mods.tconstruct.actions; + +import minetweaker.IUndoableAction; +import modtweaker2.brackets.util.IMaterial; +import slimeknights.tconstruct.library.materials.*; + +/** + * Created by Jared on 6/16/2016. + */ +public class SetDurabilityAction implements IUndoableAction { + + private final IMaterial material; + private final String stat; + private final int newValue; + private final int oldValue; + + public SetDurabilityAction(IMaterial material, String stat, int newValue) { + this.material = material; + this.stat = stat; + this.newValue = newValue; + this.oldValue = ((HeadMaterialStats) ((Material) material.getInternal()).getStats("head")).durability; + } + + private static void set(Material material, String stat, int durability) { + IMaterialStats oldStat = material.getStats(stat); + if (oldStat instanceof HeadMaterialStats) { + HeadMaterialStats headStat = (HeadMaterialStats) oldStat; + HeadMaterialStats newHead = new HeadMaterialStats(durability, headStat.miningspeed, headStat.attack, headStat.harvestLevel); + material.addStats(newHead); + } else if (oldStat instanceof HandleMaterialStats) { + HandleMaterialStats handleStat = (HandleMaterialStats) oldStat; + HandleMaterialStats newHandle = new HandleMaterialStats(handleStat.modifier, durability); + material.addStats(newHandle); + } else if (oldStat instanceof ExtraMaterialStats) { + ExtraMaterialStats newExtra = new ExtraMaterialStats(durability); + material.addStats(newExtra); + } + + } + + @Override + public void apply() { + set((Material) material.getInternal(), stat, newValue); + } + + @Override + public boolean canUndo() { + return true; + } + + @Override + public void undo() { + set((Material) material.getInternal(),stat, oldValue); + } + + @Override + public String describe() { + return "Setting durability of " + material.getName() + " to " + newValue + " for " + stat; + } + + @Override + public String describeUndo() { + return "Reverting durability of " + material.getName() + " to " + oldValue + " for " + stat; + } + + @Override + public Object getOverrideKey() { + return null; + } +} diff --git a/src/main/java/modtweaker2/mods/tconstruct/actions/SetHarvestLevelAction.java b/src/main/java/modtweaker2/mods/tconstruct/actions/SetHarvestLevelAction.java new file mode 100644 index 0000000..c907700 --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/actions/SetHarvestLevelAction.java @@ -0,0 +1,65 @@ +package modtweaker2.mods.tconstruct.actions; + +import minetweaker.IUndoableAction; +import modtweaker2.brackets.util.IMaterial; +import slimeknights.tconstruct.library.materials.HeadMaterialStats; +import slimeknights.tconstruct.library.materials.IMaterialStats; +import slimeknights.tconstruct.library.materials.Material; + +/** + * Created by Jared on 6/16/2016. + */ +public class SetHarvestLevelAction implements IUndoableAction { + + private final IMaterial material; + private final String stat; + private final int newValue; + private final int oldValue; + + public SetHarvestLevelAction(IMaterial material, String stat, int newValue) { + this.material = material; + this.stat = stat; + this.newValue = newValue; + this.oldValue = ((HeadMaterialStats) ((Material) material.getInternal()).getStats("head")).harvestLevel; + } + + private static void set(Material material, String stat, int level) { + IMaterialStats oldStat = material.getStats(stat); + if (oldStat instanceof HeadMaterialStats) { + HeadMaterialStats headStat = (HeadMaterialStats) oldStat; + HeadMaterialStats newHead = new HeadMaterialStats(headStat.durability, headStat.miningspeed, headStat.attack, level); + material.addStats(newHead); + } + + } + + @Override + public void apply() { + set((Material) material.getInternal(), stat, newValue); + } + + @Override + public boolean canUndo() { + return true; + } + + @Override + public void undo() { + set((Material) material.getInternal(), stat, oldValue); + } + + @Override + public String describe() { + return "Setting durability of " + material.getName() + " to " + newValue + " for " + stat; + } + + @Override + public String describeUndo() { + return "Reverting durability of " + material.getName() + " to " + oldValue + " for " + stat; + } + + @Override + public Object getOverrideKey() { + return null; + } +} diff --git a/src/main/java/modtweaker2/mods/tconstruct/actions/SetMiningSpeedAction.java b/src/main/java/modtweaker2/mods/tconstruct/actions/SetMiningSpeedAction.java new file mode 100644 index 0000000..4f5ed3a --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/actions/SetMiningSpeedAction.java @@ -0,0 +1,65 @@ +package modtweaker2.mods.tconstruct.actions; + +import minetweaker.IUndoableAction; +import modtweaker2.brackets.util.IMaterial; +import slimeknights.tconstruct.library.materials.HeadMaterialStats; +import slimeknights.tconstruct.library.materials.IMaterialStats; +import slimeknights.tconstruct.library.materials.Material; + +/** + * Created by Jared on 6/16/2016. + */ +public class SetMiningSpeedAction implements IUndoableAction { + + private final IMaterial material; + private final String stat; + private final float newValue; + private final float oldValue; + + public SetMiningSpeedAction(IMaterial material, String stat, float newValue) { + this.material = material; + this.stat = stat; + this.newValue = newValue; + this.oldValue = ((HeadMaterialStats) ((Material) material.getInternal()).getStats("head")).miningspeed; + } + + private static void set(Material material, String stat, float miningSpeed) { + IMaterialStats oldStat = material.getStats(stat); + if (oldStat instanceof HeadMaterialStats) { + HeadMaterialStats headStat = (HeadMaterialStats) oldStat; + HeadMaterialStats newHead = new HeadMaterialStats(headStat.durability, miningSpeed, headStat.attack, headStat.harvestLevel); + material.addStats(newHead); + } + + } + + @Override + public void apply() { + set((Material) material.getInternal(), stat, newValue); + } + + @Override + public boolean canUndo() { + return true; + } + + @Override + public void undo() { + set((Material) material.getInternal(), stat, oldValue); + } + + @Override + public String describe() { + return "Setting MiningSpeed of " + material.getName() + " to " + newValue + " for " + stat; + } + + @Override + public String describeUndo() { + return "Reverting MiningSpeed of " + material.getName() + " to " + oldValue + " for " + stat; + } + + @Override + public Object getOverrideKey() { + return null; + } +} diff --git a/src/main/java/modtweaker2/mods/tconstruct/actions/SetModifierAction.java b/src/main/java/modtweaker2/mods/tconstruct/actions/SetModifierAction.java new file mode 100644 index 0000000..cb636bc --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/actions/SetModifierAction.java @@ -0,0 +1,65 @@ +package modtweaker2.mods.tconstruct.actions; + +import minetweaker.IUndoableAction; +import modtweaker2.brackets.util.IMaterial; +import slimeknights.tconstruct.library.materials.HandleMaterialStats; +import slimeknights.tconstruct.library.materials.IMaterialStats; +import slimeknights.tconstruct.library.materials.Material; + +/** + * Created by Jared on 6/16/2016. + */ +public class SetModifierAction implements IUndoableAction { + + private final IMaterial material; + private final String stat; + private final float newValue; + private final float oldValue; + + public SetModifierAction(IMaterial material, String stat, float newValue) { + this.material = material; + this.stat = stat; + this.newValue = newValue; + this.oldValue = ((HandleMaterialStats) ((Material) material.getInternal()).getStats("handle")).modifier; + } + + private static void set(Material material, String stat, float modifier) { + IMaterialStats oldStat = material.getStats(stat); + if (oldStat instanceof HandleMaterialStats) { + HandleMaterialStats handleStat = (HandleMaterialStats) oldStat; + HandleMaterialStats newHandle = new HandleMaterialStats(modifier, handleStat.durability); + material.addStats(newHandle); + } + + } + + @Override + public void apply() { + set((Material) material.getInternal(), stat, newValue); + } + + @Override + public boolean canUndo() { + return true; + } + + @Override + public void undo() { + set((Material) material.getInternal(), stat, oldValue); + } + + @Override + public String describe() { + return "Setting Modifier of " + material.getName() + " to " + newValue + " for " + stat; + } + + @Override + public String describeUndo() { + return "Reverting Modifier of " + material.getName() + " to " + oldValue + " for " + stat; + } + + @Override + public Object getOverrideKey() { + return null; + } +} diff --git a/src/main/java/modtweaker2/mods/tconstruct/commands/MaterialLogger.java b/src/main/java/modtweaker2/mods/tconstruct/commands/MaterialLogger.java new file mode 100644 index 0000000..bd013f1 --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/commands/MaterialLogger.java @@ -0,0 +1,20 @@ +package modtweaker2.mods.tconstruct.commands; + +import minetweaker.MineTweakerAPI; +import minetweaker.api.player.IPlayer; +import minetweaker.api.server.ICommandFunction; +import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.materials.Material; + +import static modtweaker2.helpers.LogHelper.logPrinted; + +public class MaterialLogger implements ICommandFunction { + @Override + public void execute(String[] arguments, IPlayer player) { + MineTweakerAPI.logCommand(TinkerRegistry.getAllMaterials().size() + " Materials:"); + for (Material entry : TinkerRegistry.getAllMaterials()) { + MineTweakerAPI.logCommand(entry.getLocalizedName()); + } + logPrinted(player); + } +} diff --git a/src/main/java/modtweaker2/mods/tconstruct/commands/ModifierLogger.java b/src/main/java/modtweaker2/mods/tconstruct/commands/ModifierLogger.java new file mode 100644 index 0000000..e9f9320 --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/commands/ModifierLogger.java @@ -0,0 +1,21 @@ +package modtweaker2.mods.tconstruct.commands; + +import minetweaker.MineTweakerAPI; +import minetweaker.api.player.IPlayer; +import minetweaker.api.server.ICommandFunction; +import modtweaker2.mods.tconstruct.TConstructHelper; +import slimeknights.tconstruct.library.modifiers.IModifier; + +import static modtweaker2.helpers.LogHelper.logPrinted; + +public class ModifierLogger implements ICommandFunction{ + @Override + public void execute(String[] arguments, IPlayer player) { + MineTweakerAPI.logCommand(TConstructHelper.modifiers.size() + " Tinker's Construct modifiers:"); + for (IModifier modifier : TConstructHelper.modifiers) { + if (!modifier.getIdentifier().equals("")) + MineTweakerAPI.logCommand(modifier.getIdentifier()); + } + logPrinted(player); + } +} diff --git a/src/main/java/modtweaker2/mods/tconstruct/commands/TConstructLogger.java b/src/main/java/modtweaker2/mods/tconstruct/commands/TConstructLogger.java new file mode 100644 index 0000000..ea9f8b3 --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/commands/TConstructLogger.java @@ -0,0 +1,96 @@ +package modtweaker2.mods.tconstruct.commands; + +import minetweaker.MineTweakerAPI; +import minetweaker.MineTweakerImplementationAPI; +import minetweaker.api.player.IPlayer; +import minetweaker.api.server.ICommandFunction; +import modtweaker2.helpers.LogHelper; +import modtweaker2.helpers.StringHelper; +import modtweaker2.mods.tconstruct.TConstructHelper; +import slimeknights.tconstruct.library.DryingRecipe; +import slimeknights.tconstruct.library.TinkerRegistry; +import slimeknights.tconstruct.library.smeltery.AlloyRecipe; +import slimeknights.tconstruct.library.smeltery.CastingRecipe; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +public class TConstructLogger implements ICommandFunction { + private static final List validArguments = new LinkedList(); + + static { + validArguments.add("Casting"); + validArguments.add("Drying"); + validArguments.add("Smeltery"); + } + + @Override + public void execute(String[] arguments, IPlayer player) { + List args = StringHelper.toLowerCase(Arrays.asList(arguments)); + + if (!validArguments.containsAll(args)) { + if (player != null) { + player.sendChat(MineTweakerImplementationAPI.platform.getMessage("Invalid arguments for command. Valid arguments: " + StringHelper.join(validArguments, ", "))); + } + } else { + if (args.isEmpty() || args.contains("Casting")) { + for (CastingRecipe recipe : TConstructHelper.basinCasting) { + MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addBasinRecipe(%s, %s, %s, %s, %d);", + LogHelper.getStackDescription(recipe.getResult()), + LogHelper.getStackDescription(recipe.getFluid()), + LogHelper.getStackDescription(recipe.cast), + recipe.consumesCast(), + recipe.getTime())); + } + + for (CastingRecipe recipe : TConstructHelper.tableCasting) { + MineTweakerAPI.logCommand(String.format("mods.tconstruct.Casting.addTableRecipe(%s, %s, %s, %s, %d);", + LogHelper.getStackDescription(recipe.getResult()), + LogHelper.getStackDescription(recipe.getFluid()), + LogHelper.getStackDescription(recipe.cast), + recipe.consumesCast(), + recipe.getTime())); + } + } + + if (args.isEmpty() || args.contains("Drying")) { + for (DryingRecipe recipe : TinkerRegistry.getAllDryingRecipes()) { + MineTweakerAPI.logCommand(String.format("mods.tconstruct.Drying.addRecipe(%s, %s, %d);", + LogHelper.getStackDescription(recipe.input), + LogHelper.getStackDescription(recipe.getResult()), + recipe.time)); + } + } + +// if(args.isEmpty() || args.contains("Smeltery")) { +// for(MeltingRecipe recipe : TConstructHelper.smeltingList) { +// int temperature = recipe.getTemperature(); +// ItemStack renderItem = TConstructHelper.renderIndex.get(recipe.getKey()); +// +// MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addMelting(%s, %s, %d, %s);", +// LogHelper.getStackDescription(new ItemStack(recipe.getKey().item, 1, recipe.getKey().meta)), +// LogHelper.getStackDescription(recipe.getValue()), +// temperature, +// LogHelper.getStackDescription(renderItem))); +// } + + for (AlloyRecipe recipe : TConstructHelper.alloys) { + MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addAlloy(%s, %s);", + LogHelper.getStackDescription(recipe.getResult()), + LogHelper.getListDescription(recipe.getFluids()))); + } + +// for(FluidStack fuel : TConstructHelper.fuelList) { +// MineTweakerAPI.logCommand(String.format("mods.tconstruct.Smeltery.addFuel(%s, %d, %d);", +// LogHelper.getStackDescription(new FluidStack(fuel.getFluid(), 1)), +// fuel[0], +// fuel.getValue()[1])); +// } + + if (player != null) { + player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir")); + } + } + } +} diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/Casting.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/Casting.java new file mode 100644 index 0000000..70d918c --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/Casting.java @@ -0,0 +1,133 @@ +//package modtweaker2.mods.tconstruct.handlers; +// +//import static modtweaker2.helpers.InputHelper.toFluid; +//import static modtweaker2.helpers.InputHelper.toIItemStack; +//import static modtweaker2.helpers.InputHelper.toILiquidStack; +//import static modtweaker2.helpers.InputHelper.toStack; +//import static modtweaker2.helpers.StackHelper.matches; +// +//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 minetweaker.api.item.IngredientAny; +//import minetweaker.api.liquid.ILiquidStack; +//import modtweaker2.helpers.LogHelper; +//import modtweaker2.mods.tconstruct.TConstructHelper; +//import modtweaker2.utils.BaseListAddition; +//import modtweaker2.utils.BaseListRemoval; +//import stanhebben.zenscript.annotations.Optional; +//import stanhebben.zenscript.annotations.ZenClass; +//import stanhebben.zenscript.annotations.ZenMethod; +//import tconstruct.library.crafting.CastingRecipe; +// +//@ZenClass("mods.tconstruct.Casting") +//public class Casting { +// +// protected static final String name = "TConstruct Casting"; +// +// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// @ZenMethod +// public static void addBasinRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) { +// if(metal == null || output == null) { +// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); +// return; +// } +// +// MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.basinCasting)); +// } +// +// @ZenMethod +// public static void addTableRecipe(IItemStack output, ILiquidStack metal, @Optional IItemStack cast, @Optional boolean consume, int delay) { +// if(metal == null || output == null) { +// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); +// return; +// } +// +// MineTweakerAPI.apply(new Add(new CastingRecipe(toStack(output), toFluid(metal), toStack(cast), consume, delay, null), TConstructHelper.tableCasting)); +// } +// +// //Passes the list to the base list implementation, and adds the recipe +// private static class Add extends BaseListAddition { +// public Add(CastingRecipe recipe, ArrayList list) { +// super(Casting.name, list); +// +// this.recipes.add(recipe); +// } +// +// @Override +// protected String getRecipeInfo(CastingRecipe recipe) { +// return LogHelper.getStackDescription(recipe.output); +// } +// } +// +// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// @ZenMethod +// public static void removeTableRecipe(IIngredient output, @Optional IIngredient material, @Optional IIngredient cast) { +// removeRecipe(output, material, cast, TConstructHelper.tableCasting); +// } +// +// @ZenMethod +// public static void removeBasinRecipe(IIngredient output, @Optional IIngredient material, @Optional IIngredient cast) { +// +// removeRecipe(output, material, cast, TConstructHelper.basinCasting); +// } +// +// public static void removeRecipe(IIngredient output, IIngredient material, IIngredient cast, List list) { +// if(output == null) { +// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); +// return; +// } +// +// if(material == null) { +// material = IngredientAny.INSTANCE; +// } +// +// if(cast == null) { +// cast = IngredientAny.INSTANCE; +// } +// +// List recipes = new LinkedList(); +// +// for(CastingRecipe recipe : list) { +// if(recipe != null) { +// if (!matches(output, toIItemStack(recipe.output))) { +// continue; +// } +// +// if (!matches(material, toILiquidStack(recipe.castingMetal))) { +// continue; +// } +// +// if(!matches(cast, toIItemStack(recipe.cast))) { +// continue; +// } +// +// recipes.add(recipe); +// } +// } +// +// if(!recipes.isEmpty()) { +// MineTweakerAPI.apply(new Remove(list, recipes)); +// } else { +// LogHelper.logWarning(String.format("No %s Recipe found for output %s, material %s and cast %s. Command ignored!", Casting.name, output.toString(), material.toString(), cast.toString())); +// } +// } +// +// // Removes all matching recipes, apply is never the same for anything, so will always need to override it +// private static class Remove extends BaseListRemoval { +// public Remove(List list, List recipes) { +// super(Casting.name, list, recipes); +// } +// +// @Override +// protected String getRecipeInfo(CastingRecipe recipe) { +// return LogHelper.getStackDescription(recipe.output); +// } +// } +//} diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/Drying.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/Drying.java new file mode 100644 index 0000000..0bf7fd1 --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/Drying.java @@ -0,0 +1,82 @@ +//package modtweaker2.mods.tconstruct.handlers; +// +//import static modtweaker2.helpers.InputHelper.toIItemStack; +//import static modtweaker2.helpers.InputHelper.toStack; +// +//import java.util.LinkedList; +//import java.util.List; +// +//import minetweaker.MineTweakerAPI; +//import minetweaker.api.item.IIngredient; +//import minetweaker.api.item.IItemStack; +//import modtweaker2.helpers.LogHelper; +//import modtweaker2.mods.tconstruct.TConstructHelper; +//import modtweaker2.utils.BaseListAddition; +//import modtweaker2.utils.BaseListRemoval; +//import stanhebben.zenscript.annotations.ZenClass; +//import stanhebben.zenscript.annotations.ZenMethod; +//import tconstruct.library.crafting.DryingRackRecipes; +//import tconstruct.library.crafting.DryingRackRecipes.DryingRecipe; +// +//@ZenClass("mods.tconstruct.Drying") +//public class Drying { +// +// protected static final String name = "TConstruct Drying Rack"; +// +// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// @ZenMethod +// public static void addRecipe(IItemStack input, IItemStack output, int time) { +// if(input == null || output == null) { +// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", name)); +// return; +// } +// +// MineTweakerAPI.apply(new Add(TConstructHelper.getDryingRecipe(toStack(input), time, toStack(output)))); +// } +// +// //Passes the list to the base list implementation, and adds the recipe +// private static class Add extends BaseListAddition { +// public Add(DryingRecipe recipe) { +// super(Drying.name, DryingRackRecipes.recipes); +// this.recipes.add(recipe); +// } +// +// @Override +// protected String getRecipeInfo(DryingRecipe recipe) { +// return LogHelper.getStackDescription(recipe.result); +// } +// } +// +// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// //Removing a TConstruct Drying Rack recipe +// @ZenMethod +// public static void removeRecipe(IIngredient ingredient) { +// List recipes = new LinkedList(); +// +// for (DryingRecipe recipe : DryingRackRecipes.recipes) { +// if (recipe != null && recipe.result != null && ingredient.matches(toIItemStack(recipe.result))) { +// recipes.add(recipe); +// } +// } +// +// if(!recipes.isEmpty()) { +// MineTweakerAPI.apply(new Remove(recipes)); +// } else { +// LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Drying.name, ingredient.toString())); +// } +// } +// +// //Removes a recipe, apply is never the same for anything, so will always need to override it +// private static class Remove extends BaseListRemoval { +// public Remove(List list) { +// super(Drying.name, DryingRackRecipes.recipes, list); +// } +// +// @Override +// protected String getRecipeInfo(DryingRecipe recipe) { +// return LogHelper.getStackDescription(recipe.result); +// } +// } +//} diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/Modifiers.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/Modifiers.java new file mode 100644 index 0000000..3c69aee --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/Modifiers.java @@ -0,0 +1,48 @@ +//package modtweaker2.mods.tconstruct.handlers; +// +//import java.util.LinkedList; +//import java.util.List; +// +//import minetweaker.MineTweakerAPI; +//import modtweaker2.helpers.LogHelper; +//import modtweaker2.mods.tconstruct.TConstructHelper; +//import modtweaker2.utils.BaseListRemoval; +//import stanhebben.zenscript.annotations.ZenClass; +//import stanhebben.zenscript.annotations.ZenMethod; +//import tconstruct.library.modifier.ItemModifier; +// +//@ZenClass("mods.tconstruct.Modifiers") +//public class Modifiers { +// +// protected static final String name = "TConstruct Modifier"; +// +// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// @ZenMethod +// public static void remove(String mod) { +// List recipes = new LinkedList(); +// +// for (ItemModifier recipe : TConstructHelper.modifiers) { +// if (recipe.key.equals(mod)) { +// recipes.add(recipe); +// } +// } +// +// if(!recipes.isEmpty()) { +// MineTweakerAPI.apply(new Remove(recipes)); +// } else { +// LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Modifiers.name, mod)); +// } +// } +// +// private static class Remove extends BaseListRemoval{ +// public Remove(List recipes) { +// super(Modifiers.name, TConstructHelper.modifiers, recipes); +// } +// +// @Override +// protected String getRecipeInfo(ItemModifier recipe) { +// return recipe.key; +// } +// } +//} diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java new file mode 100644 index 0000000..1f892f5 --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/Smeltery.java @@ -0,0 +1,298 @@ +//package modtweaker2.mods.tconstruct.handlers; +// +//import static modtweaker2.helpers.InputHelper.isABlock; +//import static modtweaker2.helpers.InputHelper.toFluid; +//import static modtweaker2.helpers.InputHelper.toFluids; +//import static modtweaker2.helpers.InputHelper.toIItemStack; +//import static modtweaker2.helpers.InputHelper.toILiquidStack; +//import static modtweaker2.helpers.InputHelper.toStack; +//import static modtweaker2.helpers.StackHelper.matches; +// +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.HashMap; +//import java.util.LinkedList; +//import java.util.List; +//import java.util.Map; +//import java.util.Map.Entry; +// +//import minetweaker.MineTweakerAPI; +//import minetweaker.api.item.IIngredient; +//import minetweaker.api.item.IItemStack; +//import minetweaker.api.liquid.ILiquidStack; +//import modtweaker2.helpers.LogHelper; +//import modtweaker2.mods.tconstruct.TConstructHelper; +//import modtweaker2.utils.BaseListAddition; +//import modtweaker2.utils.BaseListRemoval; +//import modtweaker2.utils.BaseMapAddition; +//import modtweaker2.utils.BaseMapRemoval; +//import net.minecraft.block.Block; +//import net.minecraft.item.ItemStack; +//import net.minecraftforge.fluids.Fluid; +//import net.minecraftforge.fluids.FluidStack; +//import stanhebben.zenscript.annotations.Optional; +//import stanhebben.zenscript.annotations.ZenClass; +//import stanhebben.zenscript.annotations.ZenMethod; +// +//@ZenClass("mods.tconstruct.Smeltery") +//public class Smeltery { +// +// public static final String nameFuel = "TConstruct Smeltery - Fuel"; +// public static final String nameMelting = "TConstruct Smeltery - Melting"; +// public static final String nameAlloy = "TConstruct Smeltery - Alloy"; +// +// /********************************************** TConstruct Alloy Recipes **********************************************/ +// +// // Adding a TConstruct Alloy recipe +// @ZenMethod +// public static void addAlloy(ILiquidStack output, ILiquidStack[] input) { +// if(input == null || output == null) { +// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameAlloy)); +// return; +// } +// +// MineTweakerAPI.apply(new AddAlloy(new AlloyMix(toFluid(output), new ArrayList(Arrays.asList(toFluids(input)))))); +// } +// +// // Passes the list to the base list implementation, and adds the recipe +// private static class AddAlloy extends BaseListAddition { +// public AddAlloy(AlloyMix recipe) { +// super("TConstruct Smeltery - Alloy", TConstructHelper.alloys); +// this.recipes.add(recipe); +// } +// +// @Override +// protected String getRecipeInfo(AlloyMix recipe) { +// return LogHelper.getStackDescription(recipe.result); +// } +// } +// +// // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// // Removing a TConstruct Alloy recipe +// @ZenMethod +// public static void removeAlloy(IIngredient output) { +// List recipes = new LinkedList(); +// +// for(AlloyMix r : TConstructHelper.alloys) { +// if(r != null && matches(output, toILiquidStack(r.result))) { +// recipes.add(r); +// } +// } +// +// if(!recipes.isEmpty()) { +// MineTweakerAPI.apply(new RemoveAlloy(recipes)); +// } else { +// LogHelper.logError(String.format("No %s recipes found for %s. Command ignored!", nameAlloy, output.toString())); +// } +// +// } +// +// // Removes a recipe, apply is never the same for anything, so will always +// // need to override it +// private static class RemoveAlloy extends BaseListRemoval { +// public RemoveAlloy(List recipes) { +// super(nameAlloy, TConstructHelper.alloys, recipes); +// } +// +// @Override +// protected String getRecipeInfo(AlloyMix recipe) { +// return LogHelper.getStackDescription(recipe.result); +// } +// } +// +// /********************************************** TConstruct Melting Recipes **********************************************/ +// +// // Adding a TConstruct Melting recipe +// @ZenMethod +// public static void addMelting(IIngredient input, ILiquidStack output, int temp, @Optional IItemStack block) { +// +// if(input == null || output == null) { +// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameMelting)); +// return; +// } +// +// List recipes = new LinkedList(); +// +// for(IItemStack in : input.getItems()) { +// if(block == null && !isABlock(toStack(in))) { +// LogHelper.logWarning(String.format("Item %s is not a block and no block renderer is provided for %s recipe. Input ignored!", in.toString(), nameMelting)); +// } else { +// recipes.add(new MeltingRecipe(toStack(in), toFluid(output), temp, block == null ? toStack(in) : toStack(block))); +// } +// } +// +// if(!recipes.isEmpty()) { +// MineTweakerAPI.apply(new AddMelting(recipes)); +// } else { +// LogHelper.logError(String.format("No %s recipes could be added for input %s.", nameMelting, input.toString())); +// } +// } +// +// private static class AddMelting extends BaseListAddition { +// +// public AddMelting(List recipes) { +// super(nameMelting, null, recipes); +// } +// +// @Override +// public void apply() { +// for(MeltingRecipe recipe : recipes) { +// tconstruct.library.crafting.Smeltery.addMelting(recipe.input, recipe.getRendererBlock(), recipe.getRendererMeta(), recipe.temperature, recipe.fluid); +// successful.add(recipe); +// } +// } +// +// @Override +// public void undo() { +// for(MeltingRecipe recipe : successful) { +// TConstructHelper.smeltingList.remove(recipe.meta); +// TConstructHelper.temperatureList.remove(recipe.meta); +// TConstructHelper.renderIndex.remove(recipe.meta); +// } +// } +// +// @Override +// public String getRecipeInfo(MeltingRecipe recipe) { +// return LogHelper.getStackDescription(recipe.input); +// } +// } +// +// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// // Removing a TConstruct Melting recipe +// @ZenMethod +// public static void removeMelting(IIngredient input) { +// List recipes = new LinkedList(); +// +// for(ItemMetaWrapper meta : TConstructHelper.smeltingList.keySet()) { +// ItemStack in = new ItemStack(meta.item, 1, meta.meta); +// if(matches(input, toIItemStack(in))) { +// recipes.add(new MeltingRecipe( +// in, +// TConstructHelper.smeltingList.get(meta), +// TConstructHelper.temperatureList.get(meta), +// TConstructHelper.renderIndex.get(meta))); +// } +// } +// +// if(!recipes.isEmpty()) { +// MineTweakerAPI.apply(new RemoveMelting(recipes)); +// } else { +// LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", nameMelting, input.toString())); +// } +// } +// +// private static class RemoveMelting extends BaseListRemoval { +// +// public RemoveMelting(List recipes) { +// super(nameMelting, null, recipes); +// } +// +// @Override +// public void apply() { +// for(MeltingRecipe recipe : recipes) { +// TConstructHelper.smeltingList.remove(recipe.meta); +// TConstructHelper.temperatureList.remove(recipe.meta); +// TConstructHelper.renderIndex.remove(recipe.meta); +// +// successful.add(recipe); +// } +// } +// +// @Override +// public void undo() { +// for(MeltingRecipe recipe : successful) { +// tconstruct.library.crafting.Smeltery.addMelting(recipe.input, recipe.getRendererBlock(), recipe.getRendererMeta(), recipe.temperature, recipe.fluid); +// } +// } +// +// @Override +// public String getRecipeInfo(MeltingRecipe recipe) { +// return LogHelper.getStackDescription(recipe.input); +// } +// } +// +// protected static class MeltingRecipe { +// public final ItemMetaWrapper meta; +// public final ItemStack input; +// public final FluidStack fluid; +// public final Integer temperature; +// public final ItemStack renderer; +// +// protected MeltingRecipe(ItemStack input, FluidStack fluid, int temperature, ItemStack renderer) { +// this.input = input; +// this.fluid = fluid; +// this.temperature = temperature; +// this.renderer = renderer; +// this.meta = new ItemMetaWrapper(input); +// } +// +// public Block getRendererBlock() { +// return Block.getBlockFromItem(renderer.getItem()); +// } +// +// public int getRendererMeta() { +// return renderer.getItemDamage(); +// } +// } +// +// /********************************************** TConstruct Fuel Recipes **********************************************/ +// +// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// @ZenMethod +// public static void removeFuel(IIngredient input) { +// Map recipes = new HashMap(); +// +// for(Entry fuel : TConstructHelper.fuelList.entrySet()) { +// if(fuel != null && fuel.getKey() != null && matches(input, toILiquidStack(new FluidStack(fuel.getKey(), 1)))) { +// recipes.put(fuel.getKey(), fuel.getValue()); +// } +// } +// +// if(!recipes.isEmpty()) { +// MineTweakerAPI.apply(new RemoveFuel(recipes)); +// } else { +// LogHelper.logWarning(String.format("No %s Recipe for %s found. Command ignored!", Smeltery.nameFuel, input.toString())); +// } +// } +// +// public static class RemoveFuel extends BaseMapRemoval { +// public RemoveFuel(Map recipes) { +// super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes); +// } +// +// @Override +// public String getRecipeInfo(Entry recipe) { +// return LogHelper.getStackDescription(new FluidStack(recipe.getKey(), 1)); +// } +// } +// +// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// @ZenMethod +// public static void addFuel(ILiquidStack liquid, int power, int duration) { +// if(liquid == null) { +// LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameFuel)); +// return; +// } +// +// Map recipes = new HashMap(); +// +// recipes.put(toFluid(liquid).getFluid(), new Integer[] {power, duration}); +// +// MineTweakerAPI.apply(new AddFuel(recipes)); +// } +// +// public static class AddFuel extends BaseMapAddition { +// public AddFuel(Map recipes) { +// super(Smeltery.nameFuel, TConstructHelper.fuelList, recipes); +// } +// +// @Override +// public String getRecipeInfo(Entry recipe) { +// return LogHelper.getStackDescription(new FluidStack(recipe.getKey(), 1)); +// } +// } +//} diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/TiCTweaks.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/TiCTweaks.java new file mode 100644 index 0000000..e25dd89 --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/TiCTweaks.java @@ -0,0 +1,118 @@ +//package modtweaker2.mods.tconstruct.handlers; +// +//import static modtweaker2.helpers.InputHelper.toIItemStack; +//import static modtweaker2.helpers.InputHelper.toStack; +// +//import java.util.LinkedList; +//import java.util.List; +// +//import minetweaker.MineTweakerAPI; +//import minetweaker.api.item.IIngredient; +//import minetweaker.api.item.IItemStack; +//import modtweaker2.helpers.LogHelper; +//import modtweaker2.mods.tconstruct.TConstructHelper; +//import modtweaker2.utils.BaseListAddition; +//import modtweaker2.utils.BaseListRemoval; +//import net.minecraft.item.ItemStack; +//import stanhebben.zenscript.annotations.Optional; +//import stanhebben.zenscript.annotations.ZenClass; +//import stanhebben.zenscript.annotations.ZenMethod; +//import tconstruct.library.crafting.PatternBuilder; +//import tconstruct.library.crafting.PatternBuilder.ItemKey; +// +//@ZenClass("mods.tconstruct.Tweaks") +//public class TiCTweaks { +// +// // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// /** Disabling for 0.5, will do this properly for 0.6 **/ +// // Tweaks for enabling / disabling Patterns +// /* +// * @ZenMethod public static void removePattern(IItemStack stack) { +// * MineTweakerAPI.apply(new DisablePattern(toStack(stack))); } +// * +// * private static class DisablePattern implements IUndoableAction { private +// * String key; private MaterialSet set; private List list; private ItemStack +// * stack; private final ItemStack disable; +// * +// * public DisablePattern(ItemStack disable) { this.disable = disable; } +// * +// * //Loops through the pattern mappings to find an entry with the same +// * material name +// * +// * @Override public void apply() { for (Entry entry : +// * TConstructRegistry.patternPartMapping.entrySet()) { ItemStack check = +// * entry.getValue(); if (check.isItemEqual(disable)) { list = +// * entry.getKey(); stack = entry.getValue(); break; } } +// * +// * TConstructRegistry.patternPartMapping.remove(list); } +// * +// * @Override public boolean canUndo() { return true; } +// * +// * @Override public void undo() { +// * TConstructRegistry.patternPartMapping.put(list, stack); } +// * +// * @Override public String describe() { return +// * "Disabling creation of the pattern for: " + disable.getDisplayName(); } +// * +// * @Override public String describeUndo() { return +// * "Enabling creation of the pattern for: " + disable.getDisplayName(); } +// * +// * @Override public Object getOverrideKey() { return null; } } +// */ +// +// // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// @ZenMethod +// public static void addRepairMaterial(IItemStack stack, String material, int value) { +// ItemStack input = toStack(stack); +// MineTweakerAPI.apply(new Add(PatternBuilder.instance.new ItemKey(input.getItem(), input.getItemDamage(), value, material))); +// } +// +// // Tweaks for setting repair materials +// private static class Add extends BaseListAddition { +// public Add(ItemKey recipe) { +// super("Repair Material", PatternBuilder.instance.materials); +// recipes.add(recipe); +// } +// +// @Override +// protected String getRecipeInfo(ItemKey recipe) { +// return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage)); +// } +// } +// +// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// @ZenMethod +// public static void removeRepairMaterial(IIngredient output, @Optional String material) { +// +// List recipes = new LinkedList(); +// +// for (ItemKey recipe : PatternBuilder.instance.materials) { +// IItemStack clone = toIItemStack(new ItemStack(recipe.item, 1, recipe.damage)); +// if ((material != null && material.equalsIgnoreCase(recipe.key)) || (material == null)) { +// if (output.matches(clone)) { +// recipes.add(recipe); +// } +// } +// } +// +// if(!recipes.isEmpty()) { +// MineTweakerAPI.apply(new Remove(recipes)); +// } +// } +// +// // Removes a recipe, apply is never the same for anything, so will always +// // need to override it +// private static class Remove extends BaseListRemoval { +// public Remove(List recipes) { +// super("Repair Material", PatternBuilder.instance.materials, recipes); +// } +// +// @Override +// protected String getRecipeInfo(ItemKey recipe) { +// return LogHelper.getStackDescription(new ItemStack(recipe.item, 1, recipe.damage)); +// } +// } +//} diff --git a/src/main/java/modtweaker2/mods/tconstruct/handlers/ToolStats.java b/src/main/java/modtweaker2/mods/tconstruct/handlers/ToolStats.java new file mode 100644 index 0000000..ce755d0 --- /dev/null +++ b/src/main/java/modtweaker2/mods/tconstruct/handlers/ToolStats.java @@ -0,0 +1,270 @@ +//package modtweaker2.mods.tconstruct.handlers; +// +//import minetweaker.IUndoableAction; +//import minetweaker.MineTweakerAPI; +//import modtweaker2.helpers.ReflectionHelper; +//import modtweaker2.mods.tconstruct.TConstructHelper; +//import slimeknights.tconstruct.library.TinkerRegistry; +//import slimeknights.tconstruct.library.materials.Material; +//import slimeknights.tconstruct.tools.TinkerMaterials; +//import stanhebben.zenscript.annotations.Optional; +//import stanhebben.zenscript.annotations.ZenClass; +//import stanhebben.zenscript.annotations.ZenMethod; +//import tconstruct.library.TConstructRegistry; +//import tconstruct.library.tools.ArrowMaterial; +//import tconstruct.library.tools.BowMaterial; +//import tconstruct.library.tools.ToolMaterial; +// +//@ZenClass("mods.tconstruct.ToolStats") +//public class ToolStats { +// /** +// * @deprecated +// */ +// @Deprecated +// @ZenMethod +// public static void set(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, String ability) { +// if (name == null) name = material + " "; +// MineTweakerAPI.apply(new SetToolStats(material, "", new Material(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, 0xFFFFFF))); +// } +// +// /** +// * @deprecated +// */ +// @Deprecated +// @ZenMethod +// public static void set(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, int primaryColor) { +// if (name == null) name = material + " "; +// Material m; +// MineTweakerAPI.apply(new SetToolStats(material, "", new ToolMaterial(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, primaryColor))); +// } +// +// @ZenMethod +// public static void setStats(String material, @Optional String name, int level, int durability, int speed, int damage, double handle, int reinforced, double stonebound, String style, int primaryColor) { +// if (name == null) name = material + " "; +// MineTweakerAPI.apply(new SetToolStats(material, "", new ToolMaterial(material, name, level, durability, speed, damage, (float) handle, reinforced, (float) stonebound, style, primaryColor))); +// } +// +// @ZenMethod +// public static void setDisplayName(String material, String name) { +// MineTweakerAPI.apply(new SetToolStats(material, "displayName", name)); +// } +// +// @ZenMethod +// public static void setHarvestLevel(String material, int value) { +// MineTweakerAPI.apply(new SetToolStats(material, "harvestLevel", value)); +// } +// +// @ZenMethod +// public static void setDurability(String material, int value) { +// MineTweakerAPI.apply(new SetToolStats(material, "durability", value)); +// } +// +// @ZenMethod +// public static void setSpeed(String material, int value) { +// MineTweakerAPI.apply(new SetToolStats(material, "miningspeed", value)); +// } +// +// @ZenMethod +// public static void setDamage(String material, int value) { +// MineTweakerAPI.apply(new SetToolStats(material, "attack", value)); +// } +// +// @ZenMethod +// public static void setHandleModifier(String material, double value) { +// MineTweakerAPI.apply(new SetToolStats(material, "handleModifier", (float) value)); +// } +// +// @ZenMethod +// public static void setReinforcedLevel(String material, int value) { +// MineTweakerAPI.apply(new SetToolStats(material, "reinforced", value)); +// } +// +// @ZenMethod +// public static void setStoneboundLevel(String material, double value) { +// MineTweakerAPI.apply(new SetToolStats(material, "stonebound", (float) value)); +// } +// +// @ZenMethod +// public static void setStyle(String material, String name) { +// MineTweakerAPI.apply(new SetToolStats(material, "tipStyle", name)); +// } +// +// @ZenMethod +// public static void setAbility(String material, String name) { +// MineTweakerAPI.apply(new SetToolStats(material, "ability", name)); +// } +// +// //Sets various variables with reflection, making my life partially easier :D +// private static class SetToolStats implements IUndoableAction { +// protected int id; +// protected Object old; +// protected Object fresh; +// protected final String material; +// protected final String field; +// protected final Object value; +// +// public SetToolStats(String material, String field, Object value) { +// this.material = material; +// this.field = field; +// this.value = value; +// } +// +// @Override +// public void apply() { +// old = TConstructRegistry.toolMaterialStrings.get(material); +// id = TConstructHelper.getIDFromString(material); +// if (id != -1 && old != null) { +// if (value instanceof ToolMaterial) { +// fresh = (ToolMaterial) value; +// } else { +// ToolMaterial t = (ToolMaterial) old; +// fresh = new ToolMaterial(t.materialName, t.localizationString, t.harvestLevel, t.durability, t.miningspeed, t.attack, t.handleModifier, t.reinforced, t.stonebound, t.tipStyle, t.primaryColor); +// ReflectionHelper.setPrivateValue(ToolMaterial.class, fresh, field, value); +// } +// +// TConstructRegistry.toolMaterials.put(id, (ToolMaterial) fresh); +// TConstructRegistry.toolMaterialStrings.put(material, (ToolMaterial) fresh); +// } +// } +// +// @Override +// public boolean canUndo() { +// return TConstructRegistry.toolMaterialStrings != null && id != -1 && old != null; +// } +// +// @Override +// public void undo() { +// TConstructRegistry.toolMaterials.put(id, (ToolMaterial) old); +// TConstructRegistry.toolMaterialStrings.put(material, (ToolMaterial) old); +// } +// +// @Override +// public String describe() { +// return "Changing material stats field : + " + field + " for " + material; +// } +// +// @Override +// public String describeUndo() { +// return "Undoing change of material stats field : + " + field + " for " + material; +// } +// +// @Override +// public Object getOverrideKey() { +// return null; +// } +// } +// +// ////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// //Bow Stats +// @ZenMethod +// public static void setBowStats(String material, int durability, int drawspeed, double flightspeed) { +// MineTweakerAPI.apply(new SetBowStats(material, "", new BowMaterial(durability, drawspeed, (float) flightspeed))); +// } +// +// @ZenMethod +// public static void setBowDurability(String material, int value) { +// MineTweakerAPI.apply(new SetBowStats(material, "durability", value)); +// } +// +// @ZenMethod +// public static void setBowDrawspeed(String material, int value) { +// MineTweakerAPI.apply(new SetBowStats(material, "drawspeed", value)); +// } +// +// @ZenMethod +// public static void setBowFlightSpeed(String material, double value) { +// MineTweakerAPI.apply(new SetBowStats(material, "flightSpeedMax", (float) value)); +// } +// +// // Bow Stats +// private static class SetBowStats extends SetToolStats { +// public SetBowStats(String material, String field, Object value) { +// super(material, field, value); +// } +// +// @Override +// public void apply() { +// id = TConstructHelper.getIDFromString(material); +// old = TConstructRegistry.bowMaterials.get(id); +// if (id != -1 && old != null) { +// if (value instanceof BowMaterial) { +// fresh = (BowMaterial) value; +// } else { +// BowMaterial b = (BowMaterial) old; +// fresh = new BowMaterial(b.durability, b.drawspeed, b.flightSpeedMax); +// ReflectionHelper.setPrivateValue(BowMaterial.class, fresh, field, value); +// } +// +// TConstructRegistry.bowMaterials.put(id, (BowMaterial) fresh); +// } +// } +// +// @Override +// public boolean canUndo() { +// return TConstructRegistry.bowMaterials != null && id != -1 && old != null; +// } +// +// @Override +// public void undo() { +// TConstructRegistry.bowMaterials.put(id, (BowMaterial) old); +// } +// } +// +// ////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// //Arrow Stats +// @ZenMethod +// public static void setArrowStats(String material, double mass, double breakChance, double accuracy) { +// MineTweakerAPI.apply(new SetArrowStats(material, "", new ArrowMaterial((float) mass, (float) breakChance, (float) accuracy))); +// } +// +// @ZenMethod +// public static void setArrowMass(String material, double value) { +// MineTweakerAPI.apply(new SetArrowStats(material, "mass", (float) value)); +// } +// +// @ZenMethod +// public static void setArrowBreakChance(String material, double value) { +// MineTweakerAPI.apply(new SetArrowStats(material, "breakChance", (float) value)); +// } +// +// @ZenMethod +// public static void setArrowAccuracy(String material, double value) { +// MineTweakerAPI.apply(new SetArrowStats(material, "accuracy", (float) value)); +// } +// +// // Bow Stats +// private static class SetArrowStats extends SetToolStats { +// public SetArrowStats(String material, String field, Object value) { +// super(material, field, value); +// } +// +// @Override +// public void apply() { +// id = TConstructHelper.getIDFromString(material); +// old = TConstructRegistry.arrowMaterials.get(id); +// if (id != -1 && old != null) { +// if (value instanceof ArrowMaterial) { +// fresh = (ArrowMaterial) value; +// } else { +// ArrowMaterial a = (ArrowMaterial) old; +// fresh = new ArrowMaterial(a.mass, a.breakChance, a.accuracy); +// ReflectionHelper.setPrivateValue(ArrowMaterial.class, fresh, field, value); +// } +// +// TConstructRegistry.arrowMaterials.put(id, (ArrowMaterial) fresh); +// } +// } +// +// @Override +// public boolean canUndo() { +// return TConstructRegistry.arrowMaterials != null && id != -1 && old != null; +// } +// +// @Override +// public void undo() { +// TConstructRegistry.arrowMaterials.put(id, (ArrowMaterial) old); +// } +// } +//} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java b/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java deleted file mode 100644 index 01eb419..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/Thaumcraft.java +++ /dev/null @@ -1,24 +0,0 @@ -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.Warp; - -public class Thaumcraft { - public Thaumcraft() { - MineTweakerAPI.registerBracketHandler(new AspectBracketHandler()); - MineTweakerAPI.registerClass(Arcane.class); - MineTweakerAPI.registerClass(Aspects.class); - MineTweakerAPI.registerClass(Crucible.class); - MineTweakerAPI.registerClass(Infusion.class); - 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 deleted file mode 100644 index 0184c14..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/ThaumcraftHelper.java +++ /dev/null @@ -1,135 +0,0 @@ -package modtweaker2.mods.thaumcraft; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import modtweaker2.helpers.LogHelper; -import modtweaker2.helpers.ReflectionHelper; -import modtweaker2.mods.thaumcraft.aspect.AspectStack; -import modtweaker2.mods.thaumcraft.aspect.IAspectStack; -import thaumcraft.api.ThaumcraftApi; -import thaumcraft.api.ThaumcraftApi.EntityTags; -import thaumcraft.api.aspects.Aspect; -import thaumcraft.api.aspects.AspectList; -import thaumcraft.api.research.ResearchCategories; - -public class ThaumcraftHelper { - public static HashMap warpList; - - static { - try { - warpList = ReflectionHelper.getStaticObject(ThaumcraftApi.class, "warpMap"); - } catch (Exception e) {} - } - - private ThaumcraftHelper() {} - - public static AspectList parseAspects(String aspects) { - return parseAspects(new AspectList(), aspects); - } - - public static AspectList parseAspects(AspectList list, String str) { - AspectList output=new AspectList(); - if (list != null) - for(Aspect aspect : list.getAspectsSortedByAmount()) - { - if(aspect!=null) - output.add(aspect, list.getAmount(aspect)); - } - if (str == null || str.equals("")) return list; - String[] aspects = str.split(","); - for (String aspect : aspects) { - if (aspect.startsWith(" ")) aspect = aspect.replaceFirst(" ", ""); - String[] aspct = aspect.split("\\s+"); - if (aspct.length == 2) output.add(Aspect.aspects.get(aspct[0]), Integer.parseInt(aspct[1])); - } - - return output; - } - - public static AspectList removeAspects(AspectList list, String str) { - AspectList output=new AspectList(); - if (list != null) - for(Aspect aspect : list.getAspectsSortedByAmount()) - { - if(aspect!=null) - output.add(aspect, list.getAmount(aspect)); - } - String[] aspects = str.split(","); - for (String aspect : aspects) { - if (aspect.startsWith(" ")) aspect = aspect.replaceFirst(" ", ""); - String[] aspct = aspect.split("\\s+"); - if (aspct.length == 2) { - output.remove(Aspect.aspects.get(aspct[0]), Integer.parseInt(aspct[1])); - } - } - - return output; - } - - public static String getResearchTab(String key) { - for (String tab : ResearchCategories.researchCategories.keySet()) { - for (String research : ResearchCategories.researchCategories.get(tab).research.keySet()) { - if (research.equals(key)) return tab; - } - } - return null; - } - - public static AspectList getEntityAspects(String name) { - for(EntityTags tag : ThaumcraftApi.scanEntities) - { - if(tag.entityName==name && tag.nbts.length==0) - return tag.aspects; - } - return null; - } - - public static void removeEntityAspects(String name) { - List tags = new ArrayList(ThaumcraftApi.scanEntities); - for(EntityTags tag : tags) - { - if(tag.entityName==name && tag.nbts.length==0) - ThaumcraftApi.scanEntities.remove(tag); - } - } - - public static String aspectsToString(AspectList aspects) - { - System.out.println(aspects); - String output=""; - for(Aspect aspect : aspects.getAspectsSortedByAmount()) - { - if(aspect!=null) - output+=aspect.getName()+" "+aspects.getAmount(aspect)+","; - } - 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/AspectStack.java b/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectStack.java deleted file mode 100644 index a12d9cf..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/aspect/AspectStack.java +++ /dev/null @@ -1,44 +0,0 @@ -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 deleted file mode 100644 index 6beb5a1..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/aspect/IAspectDefinition.java +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index 842fc05..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/aspect/IAspectStack.java +++ /dev/null @@ -1,32 +0,0 @@ -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 deleted file mode 100644 index e476cb8..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectDefinition.java +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 8df48bf..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/aspect/MCAspectStack.java +++ /dev/null @@ -1,183 +0,0 @@ -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 deleted file mode 100644 index 490c08a..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/commands/AspectLogger.java +++ /dev/null @@ -1,26 +0,0 @@ -package modtweaker2.mods.thaumcraft.commands; - -import minetweaker.MineTweakerAPI; -import minetweaker.MineTweakerImplementationAPI; -import minetweaker.api.player.IPlayer; -import minetweaker.api.server.ICommandFunction; -import thaumcraft.api.aspects.Aspect; - -public class AspectLogger implements ICommandFunction{ - - @Override - public void execute(String[] arguments, IPlayer player) { - - 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")); - } - } -} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java deleted file mode 100644 index 09d35df..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Arcane.java +++ /dev/null @@ -1,99 +0,0 @@ -package modtweaker2.mods.thaumcraft.handlers; - -import static modtweaker2.helpers.InputHelper.toIItemStack; -import static modtweaker2.helpers.InputHelper.toObjects; -import static modtweaker2.helpers.InputHelper.toShapedObjects; -import static modtweaker2.helpers.InputHelper.toStack; -import static modtweaker2.helpers.StackHelper.matches; - -import java.util.LinkedList; -import java.util.List; - -import minetweaker.MineTweakerAPI; -import minetweaker.api.item.IIngredient; -import minetweaker.api.item.IItemStack; -import modtweaker2.helpers.LogHelper; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import modtweaker2.utils.BaseListAddition; -import modtweaker2.utils.BaseListRemoval; -import net.minecraft.item.ItemStack; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; -import thaumcraft.api.ThaumcraftApi; -import thaumcraft.api.crafting.IArcaneRecipe; -import thaumcraft.api.crafting.ShapedArcaneRecipe; -import thaumcraft.api.crafting.ShapelessArcaneRecipe; - -@ZenClass("mods.thaumcraft.Arcane") -public class Arcane { - - public static final String name = "Thaumcraft Arcane Worktable"; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void addShaped(String key, IItemStack output, String aspects, IIngredient[][] ingredients) { - MineTweakerAPI.apply(new Add(new ShapedArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toShapedObjects(ingredients)))); - } - - @ZenMethod - public static void addShapeless(String key, IItemStack output, String aspects, IIngredient[] ingredients) { - MineTweakerAPI.apply(new Add(new ShapelessArcaneRecipe(key, toStack(output), ThaumcraftHelper.parseAspects(aspects), toObjects(ingredients)))); - } - - private static class Add extends BaseListAddition { - public Add(IArcaneRecipe recipe) { - super(Arcane.name, ThaumcraftApi.getCraftingRecipes()); - recipes.add(recipe); - } - - @Override - protected String getRecipeInfo(IArcaneRecipe recipe) { - ItemStack stack = recipe.getRecipeOutput(); - - if(stack instanceof ItemStack) - return LogHelper.getStackDescription(stack); - else - return "Unknown output"; - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeRecipe(IIngredient output) { - List recipes = new LinkedList(); - - for(Object o : ThaumcraftApi.getCraftingRecipes()) { - if(o != null && o instanceof IArcaneRecipe) { - IArcaneRecipe recipe = (IArcaneRecipe)o; - - if(recipe.getRecipeOutput() != null && matches(output, toIItemStack(recipe.getRecipeOutput()))) { - recipes.add(recipe); - } - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command Ignored", Arcane.name, output.toString())); - } - } - - private static class Remove extends BaseListRemoval { - public Remove(List recipes) { - super(Arcane.name, ThaumcraftApi.getCraftingRecipes(), recipes); - } - - @Override - protected String getRecipeInfo(IArcaneRecipe recipe) { - ItemStack stack = recipe.getRecipeOutput(); - - if(stack instanceof ItemStack) - return LogHelper.getStackDescription(stack); - else - return "Unknown output"; - } - } -} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java deleted file mode 100644 index 50b9083..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Aspects.java +++ /dev/null @@ -1,236 +0,0 @@ -package modtweaker2.mods.thaumcraft.handlers; - -import static modtweaker2.helpers.InputHelper.toStack; - -import java.util.Arrays; - -import minetweaker.MineTweakerAPI; -import minetweaker.api.item.IItemStack; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import modtweaker2.utils.BaseUndoable; -import net.minecraft.entity.EntityList; -import net.minecraft.item.ItemStack; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; -import thaumcraft.api.ThaumcraftApi; -import thaumcraft.api.ThaumcraftApiHelper; -import thaumcraft.api.aspects.AspectList; - -@ZenClass("mods.thaumcraft.Aspects") -public class Aspects { - /** Add/Remove/Set Aspects for items **/ - @ZenMethod - public static void add(IItemStack stack, String aspects) { - MineTweakerAPI.apply(new Add(toStack(stack), aspects, false)); - } - - @ZenMethod - public static void set(IItemStack stack, String aspects) { - MineTweakerAPI.apply(new Add(toStack(stack), aspects, true)); - } - - // Adds or sets Aspects - private static class Add extends BaseUndoable { - private final ItemStack stack; - private final String aspects; - private final boolean replace; - private AspectList oldList; - private AspectList newList; - - public Add(ItemStack stack, String aspects, boolean replace) { - super("Aspects"); - this.stack = stack; - this.aspects = aspects; - this.replace = replace; - } - - @Override - public void apply() { - oldList = new AspectList(stack); - if (!replace) - newList = ThaumcraftHelper.parseAspects(oldList, aspects); - else - newList = ThaumcraftHelper.parseAspects(aspects); - - ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList); - - success = true; - } - - @Override - public void undo() { - if (oldList == null) { - ThaumcraftApi.objectTags.remove(Arrays.asList(stack.getItem(), stack.getItemDamage())); - } else - ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList); - } - - @Override - public String getRecipeInfo() { - return stack.getDisplayName(); - } - } - - // //////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void remove(IItemStack stack, String aspects) { - - MineTweakerAPI.apply(new Remove(toStack(stack), aspects)); - } - - private static class Remove extends BaseUndoable { - private final ItemStack stack; - private final String aspects; - private AspectList oldList; - private AspectList newList; - - public Remove(ItemStack stack, String aspects) { - super("Aspects"); - this.stack = stack; - this.aspects = aspects; - } - - @Override - public void apply() { - oldList = new AspectList(stack); - if (oldList != null) { - newList = ThaumcraftHelper.removeAspects(oldList, aspects); - ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList); - } - - success = true; - } - - @Override - public boolean canUndo() { - return oldList != null; - } - - @Override - public void undo() { - ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), oldList); - } - - @Override - public String getRecipeInfo() { - return stack.getDisplayName(); - } - } - - /** Add/Remove/Set Aspects for entities **/ - @ZenMethod - public static void addEntity(String entityName, String aspects) { - if (!EntityList.stringToClassMapping.containsKey(entityName)) { - MineTweakerAPI.getLogger().logError("No such entity " + entityName); - return; - } - - MineTweakerAPI.apply(new AddEntity(entityName, aspects, false)); - } - - @ZenMethod - public static void setEntity(String entityName, String aspects) { - if (!EntityList.stringToClassMapping.containsKey(entityName)) { - MineTweakerAPI.getLogger().logError("No such entity " + entityName); - return; - } - - MineTweakerAPI.apply(new AddEntity(entityName, aspects, true)); - } - - // Adds or sets Aspects - private static class AddEntity extends BaseUndoable { - private final String entityName; - private final String aspects; - private final boolean replace; - private AspectList oldList; - private AspectList newList; - - public AddEntity(String entityName, String aspects, boolean replace) { - super("Aspects"); - this.entityName = entityName; - this.aspects = aspects; - this.replace = replace; - } - - @Override - public void apply() { - oldList = ThaumcraftHelper.getEntityAspects(entityName); - if (!replace) - newList = ThaumcraftHelper.parseAspects(oldList, aspects); - else - newList = ThaumcraftHelper.parseAspects(aspects); - ThaumcraftHelper.removeEntityAspects(entityName); - ThaumcraftApi.registerEntityTag(entityName, newList); - - success = true; - } - - @Override - public void undo() { - ThaumcraftHelper.removeEntityAspects(entityName); - if (oldList != null) - ThaumcraftApi.registerEntityTag(entityName, oldList); - } - - @Override - public String getRecipeInfo() { - return entityName; - } - } - - // //////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeEntity(String entityName, String aspects) { - if (!EntityList.stringToClassMapping.containsKey(entityName)) { - MineTweakerAPI.getLogger().logError("No such entity " + entityName); - return; - } - - MineTweakerAPI.apply(new RemoveEntity(entityName, aspects)); - } - - private static class RemoveEntity extends BaseUndoable { - private final String entityName; - private final String aspects; - private AspectList oldList; - private AspectList newList; - - public RemoveEntity(String entityName, String aspects) { - super("Aspects"); - this.entityName = entityName; - this.aspects = aspects; - } - - @Override - public void apply() { - oldList = ThaumcraftHelper.getEntityAspects(entityName); - if (oldList != null) { - newList = ThaumcraftHelper.removeAspects(oldList, aspects); - ThaumcraftHelper.removeEntityAspects(entityName); - ThaumcraftApi.registerEntityTag(entityName, newList); - } - - success = true; - } - - @Override - public boolean canUndo() { - return oldList != null; - } - - @Override - public void undo() { - ThaumcraftHelper.removeEntityAspects(entityName); - ThaumcraftApi.registerEntityTag(entityName, oldList); - } - - @Override - public String getRecipeInfo() { - return entityName; - } - } - -} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java deleted file mode 100644 index bf6da11..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Crucible.java +++ /dev/null @@ -1,77 +0,0 @@ -package modtweaker2.mods.thaumcraft.handlers; - -import static modtweaker2.helpers.InputHelper.toIItemStack; -import static modtweaker2.helpers.InputHelper.toObject; -import static modtweaker2.helpers.InputHelper.toStack; -import static modtweaker2.helpers.StackHelper.matches; - -import java.util.LinkedList; -import java.util.List; - -import minetweaker.MineTweakerAPI; -import minetweaker.api.item.IIngredient; -import minetweaker.api.item.IItemStack; -import modtweaker2.helpers.LogHelper; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import modtweaker2.utils.BaseListAddition; -import modtweaker2.utils.BaseListRemoval; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; -import thaumcraft.api.ThaumcraftApi; -import thaumcraft.api.crafting.CrucibleRecipe; - -@ZenClass("mods.thaumcraft.Crucible") -public class Crucible { - - public static final String name = "Thaumcraft Crucible"; - - @ZenMethod - public static void addRecipe(String key[], IItemStack result, IIngredient catalyst, String aspects) { - MineTweakerAPI.apply(new Add(new CrucibleRecipe(key, toStack(result), toObject(catalyst), ThaumcraftHelper.parseAspects(aspects)))); - } - - private static class Add extends BaseListAddition { - public Add(CrucibleRecipe recipe) { - super(Crucible.name, ThaumcraftApi.getCraftingRecipes()); - recipes.add(recipe); - } - - @Override - protected String getRecipeInfo(CrucibleRecipe recipe) { - return LogHelper.getStackDescription(recipe.getRecipeOutput()); - } - } - - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeRecipe(IIngredient output) { - List recipes = new LinkedList(); - - for (Object o : ThaumcraftApi.getCraftingRecipes()) { - if (o instanceof CrucibleRecipe) { - CrucibleRecipe r = (CrucibleRecipe) o; - if (r.getRecipeOutput() != null && matches(output, toIItemStack(r.getRecipeOutput()))) { - recipes.add(r); - } - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Crucible.name, output.toString())); - } - } - - private static class Remove extends BaseListRemoval { - public Remove(List recipes) { - super(Crucible.name, ThaumcraftApi.getCraftingRecipes(), recipes); - } - - @Override - protected String getRecipeInfo(CrucibleRecipe recipe) { - return LogHelper.getStackDescription(recipe.getRecipeOutput()); - } - } -} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java deleted file mode 100644 index 2920fd1..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Infusion.java +++ /dev/null @@ -1,151 +0,0 @@ -package modtweaker2.mods.thaumcraft.handlers; - -import static modtweaker2.helpers.InputHelper.toIItemStack; -import static modtweaker2.helpers.InputHelper.toStack; -import static modtweaker2.helpers.InputHelper.toStacks; -import static modtweaker2.helpers.StackHelper.matches; - -import java.util.LinkedList; -import java.util.List; - -import minetweaker.MineTweakerAPI; -import minetweaker.api.item.IIngredient; -import minetweaker.api.item.IItemStack; -import modtweaker2.helpers.LogHelper; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import modtweaker2.mods.thaumcraft.recipe.MTInfusionRecipe; -import modtweaker2.utils.BaseListAddition; -import modtweaker2.utils.BaseListRemoval; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.item.ItemStack; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; -import thaumcraft.api.ThaumcraftApi; -import thaumcraft.api.crafting.InfusionEnchantmentRecipe; -import thaumcraft.api.crafting.InfusionRecipe; - -@ZenClass("mods.thaumcraft.Infusion") -public class Infusion { - - public static final String name = "Thaumcraft Infusion"; - public static final String enchName = name + " Enchantment"; - - @ZenMethod - public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability) { - - MineTweakerAPI.apply(new Add(new InfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe)))); - } - - // A version that allows you to specify whether the detection should be - // fuzzy or not - @ZenMethod - public static void addRecipe(String key, IItemStack input, IItemStack[] recipe, String aspects, IItemStack result, int instability, boolean fuzzyCentre, boolean[] fuzzyRecipe) { - MineTweakerAPI.apply(new Add(new MTInfusionRecipe(key, toStack(result), instability, ThaumcraftHelper.parseAspects(aspects), toStack(input), toStacks(recipe), fuzzyCentre, fuzzyRecipe))); - } - - @ZenMethod - public static void addEnchantment(String key, int enchantID, int instability, String aspects, IItemStack[] recipe) { - MineTweakerAPI.apply(new AddEnchant(new InfusionEnchantmentRecipe(key, Enchantment.getEnchantmentById(enchantID), instability, ThaumcraftHelper.parseAspects(aspects), toStacks(recipe)))); - } - - private static class Add extends BaseListAddition { - public Add(InfusionRecipe recipe) { - super(Infusion.name, ThaumcraftApi.getCraftingRecipes()); - recipes.add(recipe); - } - - @Override - protected String getRecipeInfo(InfusionRecipe recipe) { - Object out = ((InfusionRecipe) recipe).getRecipeOutput(); - if (out instanceof ItemStack) { - return ((ItemStack) out).getDisplayName(); - } else - return "Unknown item"; - } - } - - private static class AddEnchant extends BaseListAddition { - public AddEnchant(InfusionEnchantmentRecipe inp) { - super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes()); - recipes.add(inp); - } - - @Override - protected String getRecipeInfo(InfusionEnchantmentRecipe recipe) { - return recipe.getEnchantment().getName(); - } - } - - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeRecipe(IIngredient output) { - List recipes = new LinkedList(); - - for (Object o : ThaumcraftApi.getCraftingRecipes()) { - if (o instanceof InfusionRecipe) { - InfusionRecipe r = (InfusionRecipe) o; - if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && matches(output, toIItemStack((ItemStack)r.getRecipeOutput()))) { - recipes.add(r); - } - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Infusion.name, output.toString())); - } - } - - @ZenMethod - public static void removeEnchant(int id) { - List recipes = new LinkedList(); - Enchantment ench = Enchantment.getEnchantmentById(id); - - for (Object recipe : ThaumcraftApi.getCraftingRecipes()) { - if (recipe instanceof InfusionEnchantmentRecipe) { - InfusionEnchantmentRecipe enchRecipe = (InfusionEnchantmentRecipe) recipe; - if (enchRecipe.getEnchantment() == ench) { - recipes.add(enchRecipe); - } - } - } - - if(!recipes.isEmpty()) { - MineTweakerAPI.apply(new RemoveEnchant(recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", Infusion.enchName + " Enchantment", ench.getName())); - } - } - - private static class Remove extends BaseListRemoval { - public Remove(List recipes) { - super(Infusion.name, ThaumcraftApi.getCraftingRecipes(), recipes); - } - - @Override - protected String getRecipeInfo(InfusionRecipe recipe) { - - Object o = recipe.getRecipeOutput(); - - if(o instanceof ItemStack) { - return LogHelper.getStackDescription((ItemStack)o); - } else { - return "Unknown Item"; - } - } - } - - private static class RemoveEnchant extends BaseListRemoval { - public RemoveEnchant(List recipes) { - super(Infusion.enchName, ThaumcraftApi.getCraftingRecipes(), recipes); - } - - @Override - protected String getRecipeInfo(InfusionEnchantmentRecipe recipe) { - return recipe.getEnchantment().getName(); - } - } -} - diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Loot.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Loot.java deleted file mode 100644 index 00bd29d..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Loot.java +++ /dev/null @@ -1,97 +0,0 @@ -package modtweaker2.mods.thaumcraft.handlers; - -import static modtweaker2.helpers.InputHelper.toIItemStack; -import static modtweaker2.helpers.StackHelper.matches; - -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.utils.BaseListAddition; -import modtweaker2.utils.BaseListRemoval; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; -import thaumcraft.api.internal.WeightedRandomLoot; - -@ZenClass("mods.thaumcraft.Loot") -public class Loot { - - public static final String name = "Thaumcraft LootBag"; - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void addCommonLoot(IItemStack stack, int weight) { - MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagCommon, new WeightedRandomLoot(InputHelper.toStack(stack), weight))); - } - - @ZenMethod - public static void addUncommonLoot(IItemStack stack, int weight) { - MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagUncommon, new WeightedRandomLoot(InputHelper.toStack(stack), weight))); - } - - @ZenMethod - public static void addRareLoot(IItemStack stack, int weight) { - MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagRare, new WeightedRandomLoot(InputHelper.toStack(stack), weight))); - } - - public static class Add extends BaseListAddition { - public Add(List list, WeightedRandomLoot recipe) { - super(Loot.name, list); - recipes.add(recipe); - } - - @Override - protected String getRecipeInfo(WeightedRandomLoot recipe) { - return LogHelper.getStackDescription(recipe.item); - } - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeCommonLoot(IIngredient stack) { - removeLoot(WeightedRandomLoot.lootBagCommon, stack); - } - - @ZenMethod - public static void removeUncommonLoot(IIngredient stack) { - removeLoot(WeightedRandomLoot.lootBagUncommon, stack); - } - - @ZenMethod - public static void removeRareLoot(IIngredient stack) { - removeLoot(WeightedRandomLoot.lootBagRare, stack); - } - - public static void removeLoot(List list, IIngredient ingredient) { - List recipes = new LinkedList(); - - for (WeightedRandomLoot loot : list) { - if (matches(ingredient, toIItemStack(loot.item))) { - recipes.add(loot); - } - } - - if (!recipes.isEmpty()) { - MineTweakerAPI.apply(new Remove(list, recipes)); - } else { - LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored.", Loot.name, ingredient.toString())); - } - } - - public static class Remove extends BaseListRemoval { - public Remove(List list, List recipes) { - super(Loot.name, list, recipes); - } - - @Override - protected String getRecipeInfo(WeightedRandomLoot recipe) { - return LogHelper.getStackDescription(recipe.item); - } - } -} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Research.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Research.java deleted file mode 100644 index 56ff472..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Research.java +++ /dev/null @@ -1,237 +0,0 @@ -package modtweaker2.mods.thaumcraft.handlers; - -import static modtweaker2.helpers.InputHelper.toStack; -import minetweaker.MineTweakerAPI; -import minetweaker.api.item.IItemStack; -import minetweaker.api.player.IPlayer; -import modtweaker2.helpers.InputHelper; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import modtweaker2.mods.thaumcraft.research.AddPage; -import modtweaker2.mods.thaumcraft.research.AddPrereq; -import modtweaker2.mods.thaumcraft.research.AddResearch; -import modtweaker2.mods.thaumcraft.research.AddSibling; -import modtweaker2.mods.thaumcraft.research.AddTab; -import modtweaker2.mods.thaumcraft.research.ClearPages; -import modtweaker2.mods.thaumcraft.research.ClearPrereqs; -import modtweaker2.mods.thaumcraft.research.ClearSiblings; -import modtweaker2.mods.thaumcraft.research.Difficulty; -import modtweaker2.mods.thaumcraft.research.MoveResearch; -import modtweaker2.mods.thaumcraft.research.OrphanResearch; -import modtweaker2.mods.thaumcraft.research.RefreshResearch; -import modtweaker2.mods.thaumcraft.research.RemoveResearch; -import modtweaker2.mods.thaumcraft.research.RemoveTab; -import modtweaker2.mods.thaumcraft.research.SetAspects; -import modtweaker2.mods.thaumcraft.research.SetResearch; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.util.ResourceLocation; -import stanhebben.zenscript.annotations.Optional; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; -import thaumcraft.api.ThaumcraftApiHelper; -import thaumcraft.api.research.ResearchHelper; -import thaumcraft.api.research.ResearchItem; -import thaumcraft.api.research.ResearchPage.PageType; - -@ZenClass("mods.thaumcraft.Research") -public class Research { - private static final ResourceLocation defaultBackground = new ResourceLocation("thaumcraft", "textures/gui/gui_researchback.png"); - - @ZenMethod - public static void addTab(String key, String researchKey, String iconDomain, String iconPath) { - addTab(key,researchKey, iconDomain, iconPath, null, null); - } - - @ZenMethod - public static void addTab(String key,String researchKey, String iconDomain, String iconPath, String backDomain, String backPath) { - ResourceLocation icon = new ResourceLocation(iconDomain, iconPath); - ResourceLocation background; - if (backPath == null) - background = defaultBackground; - else - background = new ResourceLocation(backDomain, backPath); - addTab(key, researchKey, icon, background); - } - - private static void addTab(String key, String researchKey, ResourceLocation icon, ResourceLocation background) { - - MineTweakerAPI.apply(new AddTab(key, researchKey, icon, background)); - } - - @ZenMethod - public static void removeTab(String tab) { - - - MineTweakerAPI.apply(new RemoveTab(tab)); - } - - @ZenMethod - public static void removeResearch(String research) { - - MineTweakerAPI.apply(new RemoveResearch(research)); - } - - @ZenMethod - public static void orphanResearch(String research) { - - MineTweakerAPI.apply(new OrphanResearch(research)); - } - - @ZenMethod - public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, String domain, String path) { - - MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, new ResourceLocation(domain, path)), null, null)); - } - - @ZenMethod - public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, IItemStack item) { - - MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, toStack(item)),null, null)); - } - - @ZenMethod - public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, IItemStack item, IItemStack[] triggers, String[] entTriggers) { - - MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, toStack(item)), InputHelper.toStacks(triggers), entTriggers)); - } - - @ZenMethod - public static void addPage(String key, String unlocalized) { - - MineTweakerAPI.apply(new AddPage(key, PageType.TEXT, unlocalized)); - } - - @ZenMethod - public static void addCraftingPage(String key, IItemStack item) { - - MineTweakerAPI.apply(new AddPage(key, PageType.NORMAL_CRAFTING, toStack(item))); - } - - @ZenMethod - public static void addCruciblePage(String key, IItemStack item) { - - MineTweakerAPI.apply(new AddPage(key, PageType.CRUCIBLE_CRAFTING, toStack(item))); - } - - @ZenMethod - public static void addArcanePage(String key, IItemStack item) { - - MineTweakerAPI.apply(new AddPage(key, PageType.ARCANE_CRAFTING, toStack(item))); - } - - @ZenMethod - public static void addInfusionPage(String key, IItemStack item) { - - MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_CRAFTING, toStack(item))); - } - - @ZenMethod - public static void addEnchantmentPage(String key, int i) { - - MineTweakerAPI.apply(new AddPage(key, PageType.INFUSION_ENCHANTMENT, Enchantment.getEnchantmentById(i))); - } - - @ZenMethod - public static void clearPages(String key) { - - MineTweakerAPI.apply(new ClearPages(key)); - } - - @ZenMethod - public static void addPrereq(String key, String req, @Optional boolean hidden) { - - MineTweakerAPI.apply(new AddPrereq(key, req, hidden)); - } - - @ZenMethod - public static void clearPrereqs(String key) { - - MineTweakerAPI.apply(new ClearPrereqs(key)); - } - - @ZenMethod - public static void addSibling(String key, String sibling) { - - MineTweakerAPI.apply(new AddSibling(key, sibling)); - } - - @ZenMethod - public static void clearSiblings(String key) { - - MineTweakerAPI.apply(new ClearSiblings(key)); - } - - @ZenMethod - public static void setRound(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.ROUND)); - } - - @ZenMethod - public static void setSpikey(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SPIKE)); - } - - @ZenMethod - public static void setStub(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.STUB)); - } - - @ZenMethod - public static void setSecondary(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.SECONDARY)); - } - - @ZenMethod - public static void setVirtual(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.VIRTUAL)); - } - - @ZenMethod - public static void setAutoUnlock(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.AUTO)); - } - - @ZenMethod - public static void setConcealed(String key, boolean flag) { - - MineTweakerAPI.apply(new SetResearch(key, flag, SetType.CONCEAL)); - } - - @ZenMethod - public static void setAspects(String key, String aspects) { - - MineTweakerAPI.apply(new SetAspects(key, ThaumcraftHelper.parseAspects(aspects))); - } - - @ZenMethod - public static void setComplexity(String key, int complexity) { - - MineTweakerAPI.apply(new Difficulty(key, complexity)); - } - - @ZenMethod - public static void refreshResearchRecipe(String key) { - - MineTweakerAPI.apply(new RefreshResearch(key)); - } - - @ZenMethod - public static void moveResearch(String key, String destination, int x, int y) { - - MineTweakerAPI.apply(new MoveResearch(key, destination, x, y)); - } - - @ZenMethod - public static boolean hasResearched(IPlayer player, String key) { - return ResearchHelper.isResearchComplete(player.getName(), key); - } - - public static enum SetType { - AUTO, ROUND, SPIKE, SECONDARY, STUB, VIRTUAL, CONCEAL - } -} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Warp.java b/src/main/java/modtweaker2/mods/thaumcraft/handlers/Warp.java deleted file mode 100644 index fb82247..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/handlers/Warp.java +++ /dev/null @@ -1,231 +0,0 @@ -package modtweaker2.mods.thaumcraft.handlers; - -import static modtweaker2.helpers.InputHelper.toStack; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; - -import minetweaker.IUndoableAction; -import minetweaker.MineTweakerAPI; -import minetweaker.api.item.IItemStack; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import net.minecraft.item.ItemStack; -import stanhebben.zenscript.annotations.ZenClass; -import stanhebben.zenscript.annotations.ZenMethod; -import thaumcraft.api.ThaumcraftApi; - -@ZenClass("mods.thaumcraft.Warp") -public class Warp { - - @ZenMethod - public static void addToResearch(String key, int warp) { - MineTweakerAPI.apply(new Add(key, warp)); - } - - @ZenMethod - public static void addToItem(IItemStack stack, int warp) { - MineTweakerAPI.apply(new Add(toStack(stack), warp)); - } - - private static class Add implements IUndoableAction { - Object target; - int warp; - - public Add(Object targ, int amount) { - target = targ; - warp = amount; - } - - public void apply() { - if (target instanceof String) - ThaumcraftApi.addWarpToResearch((String) target, warp); - else if (target instanceof ItemStack) - ThaumcraftApi.addWarpToItem((ItemStack) target, warp); - } - - public boolean canUndo() { - return ThaumcraftApi.getWarp(target) > 0; - } - - public String describe() { - String desc = "Adding " + warp + " warp to "; - if (target instanceof String) - desc += (String) target; - else if (target instanceof ItemStack) - desc += ((ItemStack) target).getDisplayName(); - return desc; - } - - public void undo() { - if (target instanceof String) - ThaumcraftHelper.warpList.remove(target); - else if (target instanceof ItemStack) - ThaumcraftHelper.warpList.remove(Arrays.asList(((ItemStack) target).getItem(), ((ItemStack) target).getItemDamage())); - } - - public String describeUndo() { - String desc = "Removing warp from "; - if (target instanceof String) - desc += (String) target; - else if (target instanceof ItemStack) - desc += ((ItemStack) target).getDisplayName(); - return desc; - } - - public Object getOverrideKey() { - return null; - } - - } - - // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - @ZenMethod - public static void removeFromResearch(String key) { - MineTweakerAPI.apply(new Remove(key)); - } - - @ZenMethod - public static void removeFromItem(IItemStack stack) { - MineTweakerAPI.apply(new Remove(toStack(stack))); - } - - @ZenMethod - public static void removeAll() { - MineTweakerAPI.apply(new MassRemove(RemoveType.BOTH)); - } - - @ZenMethod - public static void removeAllResearch() { - MineTweakerAPI.apply(new MassRemove(RemoveType.RESEARCH)); - } - - @ZenMethod - public static void removeAllItems() { - MineTweakerAPI.apply(new MassRemove(RemoveType.ITEMS)); - } - - private static class Remove implements IUndoableAction { - Object target; - int warp; - - public Remove(Object targ) { - target = targ; - } - - public void apply() { - if (target instanceof String) - warp = ThaumcraftHelper.warpList.remove(target); - else if (target instanceof ItemStack) - warp = ThaumcraftHelper.warpList.remove(Arrays.asList(((ItemStack) target).getItem(), ((ItemStack) target).getItemDamage())); - } - - public boolean canUndo() { - return warp > 0; - } - - public String describe() { - String desc = "Removing warp from "; - if (target instanceof String) - desc += (String) target; - else if (target instanceof ItemStack) - desc += ((ItemStack) target).getDisplayName(); - return desc; - } - - public void undo() { - if (target instanceof String) - ThaumcraftApi.addWarpToResearch((String) target, warp); - else if (target instanceof ItemStack) - ThaumcraftApi.addWarpToItem((ItemStack) target, warp); - } - - public String describeUndo() { - String desc = "Restoring " + warp + " warp to "; - if (target instanceof String) - desc += (String) target; - else if (target instanceof ItemStack) - desc += ((ItemStack) target).getDisplayName(); - return desc; - } - - public Object getOverrideKey() { - return null; - } - - } - - public static enum RemoveType { - RESEARCH, ITEMS, BOTH - } - - private static class MassRemove implements IUndoableAction { - HashMap oldMap = new HashMap(); - RemoveType type; - - public MassRemove(RemoveType typ) { - type = typ; - } - - public void apply() { - if (type == RemoveType.BOTH) { - for (Object key : ThaumcraftHelper.warpList.keySet()) { - oldMap.put(key, ThaumcraftHelper.warpList.get(key)); - } - ThaumcraftHelper.warpList.clear(); - } else if (type == RemoveType.ITEMS) { - for (Object key : ThaumcraftHelper.warpList.keySet()) { - if (key instanceof List) { - oldMap.put(key, ThaumcraftHelper.warpList.get(key)); - } - } - for (Object key : oldMap.keySet()) { - ThaumcraftHelper.warpList.remove(key); - } - } else if (type == RemoveType.RESEARCH) { - for (Object key : ThaumcraftHelper.warpList.keySet()) { - if (key instanceof String) { - oldMap.put(key, ThaumcraftHelper.warpList.get(key)); - } - } - for (Object key : oldMap.keySet()) { - ThaumcraftHelper.warpList.remove(key); - } - } - } - - public boolean canUndo() { - return oldMap.size() > 0; - } - - public String describe() { - if (type == RemoveType.RESEARCH) - return "Clearing All Research Warp"; - else if (type == RemoveType.ITEMS) - return "Clearing All Item Warp"; - else - return "Clearing All Warp"; - } - - public void undo() { - for (Object key : oldMap.keySet()) { - ThaumcraftHelper.warpList.put(key, oldMap.get(key)); - } - } - - public String describeUndo() { - if (type == RemoveType.RESEARCH) - return "Restoring All Research Warp"; - else if (type == RemoveType.ITEMS) - return "Restoring All Item Warp"; - else - return "Restoring All Warp"; - } - - public Object getOverrideKey() { - return null; - } - - } -} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/recipe/MTInfusionRecipe.java b/src/main/java/modtweaker2/mods/thaumcraft/recipe/MTInfusionRecipe.java deleted file mode 100644 index 48fbf5f..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/recipe/MTInfusionRecipe.java +++ /dev/null @@ -1,65 +0,0 @@ -package modtweaker2.mods.thaumcraft.recipe; - -import java.util.ArrayList; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.oredict.OreDictionary; -import thaumcraft.api.ThaumcraftApiHelper; -import thaumcraft.api.aspects.AspectList; -import thaumcraft.api.crafting.InfusionRecipe; -import thaumcraft.api.research.ResearchHelper; - -public class MTInfusionRecipe extends InfusionRecipe { - private final boolean fuzzyCentre; - private final boolean[] fuzzyRecipe; - - public MTInfusionRecipe(String research, Object output, int inst, AspectList aspects2, ItemStack input, ItemStack[] recipe, boolean fuzzyCentre, boolean[] fuzzyRecipe) { - super(research, output, inst, aspects2, input, recipe); - this.fuzzyCentre = fuzzyCentre; - this.fuzzyRecipe = fuzzyRecipe; - } - -// @Override -// public boolean matches(ArrayList input, ItemStack central, World world, EntityPlayer player) { -// if (getRecipeInput() == null) return false; -// -// if (research.length > 0 && !ResearchHelper.isResearchComplete(player.getName(), research)) { -// return false; -// } -// -// ItemStack i2 = central.copy(); -// ItemStack recInput = (ItemStack)getRecipeInput(); -// if (recInput.getItemDamage() == OreDictionary.WILDCARD_VALUE) { -// i2.setItemDamage(OreDictionary.WILDCARD_VALUE); -// } -// -//// if (!areItemStacksEqual(i2, recInput, fuzzyCentre)) return false; -// -// ArrayList ii = new ArrayList(); -// for (ItemStack is : input) { -// ii.add(is.copy()); -// } -// -// for (int j = 0; j < getComponents().length; j++) { -// ItemStack comp = (ItemStack)getComponents()[j]; -// boolean b = false; -// for (int a = 0; a < ii.size(); a++) { -// i2 = ii.get(a).copy(); -// if (comp.getItemDamage() == OreDictionary.WILDCARD_VALUE) { -// i2.setItemDamage(OreDictionary.WILDCARD_VALUE); -// } -// -// if (areItemStacksEqual(i2, comp, fuzzyRecipe[j])) { -// ii.remove(a); -// b = true; -// break; -// } -// } -// if (!b) return false; -// } -// -// return ii.size() == 0 ? true : false; -// } -} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/AddPage.java b/src/main/java/modtweaker2/mods/thaumcraft/research/AddPage.java deleted file mode 100644 index b8d6867..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/AddPage.java +++ /dev/null @@ -1,126 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import static modtweaker2.helpers.StackHelper.areEqual; -import minetweaker.IUndoableAction; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; -import thaumcraft.api.ThaumcraftApi; -import thaumcraft.api.crafting.CrucibleRecipe; -import thaumcraft.api.crafting.IArcaneRecipe; -import thaumcraft.api.crafting.InfusionEnchantmentRecipe; -import thaumcraft.api.crafting.InfusionRecipe; -import thaumcraft.api.research.ResearchCategories; -import thaumcraft.api.research.ResearchPage; -import thaumcraft.api.research.ResearchPage.PageType; - -public class AddPage implements IUndoableAction { - String key; - String tab; - ResearchPage page; - ResearchPage[] oldPages; - PageType type; - ItemStack target; - Enchantment enchant; - - public AddPage(String res, PageType a, Object b) { - key = res; - tab = ThaumcraftHelper.getResearchTab(key); - type = a; - if (type == PageType.TEXT) page = new ResearchPage((String) b); - else if (type == PageType.INFUSION_ENCHANTMENT) enchant = (Enchantment) b; - if (b instanceof ItemStack) target = (ItemStack) b; - } - - @Override - public void apply() { - if (type == PageType.NORMAL_CRAFTING) { - for (Object craft : CraftingManager.getInstance().getRecipeList()) { - if (craft instanceof IRecipe) { - IRecipe theCraft = (IRecipe) craft; - if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), target)) { - page = new ResearchPage(theCraft); - break; - } - } - } - } else if (type == PageType.ARCANE_CRAFTING) { - for (Object craft : ThaumcraftApi.getCraftingRecipes()) { - if (craft instanceof IArcaneRecipe) { - IArcaneRecipe theCraft = (IArcaneRecipe) craft; - if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), target)) { - page = new ResearchPage(theCraft); - break; - } - } - } - } else if (type == PageType.CRUCIBLE_CRAFTING) { - for (Object craft : ThaumcraftApi.getCraftingRecipes()) { - if (craft instanceof CrucibleRecipe) { - CrucibleRecipe theCraft = (CrucibleRecipe) craft; - if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), target)) { - page = new ResearchPage(theCraft); - break; - } - } - } - } else if (type == PageType.INFUSION_CRAFTING) { - for (Object craft : ThaumcraftApi.getCraftingRecipes()) { - if (craft instanceof InfusionRecipe) { - InfusionRecipe theCraft = (InfusionRecipe) craft; - if (theCraft.getRecipeOutput() != null && theCraft.getRecipeOutput() instanceof ItemStack && areEqual(((ItemStack) (theCraft.getRecipeOutput())), target)) { - page = new ResearchPage(theCraft); - break; - } - } - } - } else if (type == PageType.INFUSION_ENCHANTMENT) { - for (Object craft : ThaumcraftApi.getCraftingRecipes()) { - if (craft instanceof InfusionEnchantmentRecipe) { - InfusionEnchantmentRecipe theCraft = (InfusionEnchantmentRecipe) craft; - if (theCraft.getEnchantment() != null && theCraft.getEnchantment() == enchant) { - page = new ResearchPage(theCraft); - break; - } - } - } - } - if (page == null) return; - oldPages = ResearchCategories.researchCategories.get(tab).research.get(key).getPages(); - if (oldPages == null) oldPages = new ResearchPage[0]; - ResearchPage[] newPages = new ResearchPage[oldPages.length + 1]; - for (int x = 0; x < oldPages.length; x++) { - newPages[x] = oldPages[x]; - } - newPages[oldPages.length] = page; - ResearchCategories.researchCategories.get(tab).research.get(key).setPages(newPages); - } - - @Override - public String describe() { - return "Adding Research Page to " + key; - } - - @Override - public boolean canUndo() { - return oldPages != null; - } - - @Override - public void undo() { - ResearchCategories.researchCategories.get(tab).research.get(key).setPages(oldPages); - } - - @Override - public String describeUndo() { - return "Removing Page from " + key; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/AddPrereq.java b/src/main/java/modtweaker2/mods/thaumcraft/research/AddPrereq.java deleted file mode 100644 index 7a76f7a..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/AddPrereq.java +++ /dev/null @@ -1,70 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import minetweaker.IUndoableAction; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import thaumcraft.api.research.ResearchCategories; - -public class AddPrereq implements IUndoableAction { - String key; - String tab; - String prereq; - String[] oldPrereqs; - boolean hidden; - - public AddPrereq(String res, String req, boolean secret) { - key = res; - tab = ThaumcraftHelper.getResearchTab(key); - prereq = req; - hidden = secret; - } - - @Override - public void apply() { - if (!hidden) { - oldPrereqs = ResearchCategories.researchCategories.get(tab).research.get(key).parents; - if (oldPrereqs == null) oldPrereqs = new String[0]; - String[] newPrereqs = new String[oldPrereqs.length + 1]; - for (int x = 0; x < oldPrereqs.length; x++) { - newPrereqs[x] = oldPrereqs[x]; - } - newPrereqs[oldPrereqs.length] = prereq; - ResearchCategories.researchCategories.get(tab).research.get(key).setParents(newPrereqs); - } else { - oldPrereqs = ResearchCategories.researchCategories.get(tab).research.get(key).parentsHidden; - if (oldPrereqs == null) oldPrereqs = new String[0]; - String[] newPrereqs = new String[oldPrereqs.length + 1]; - for (int x = 0; x < oldPrereqs.length; x++) { - newPrereqs[x] = oldPrereqs[x]; - } - newPrereqs[oldPrereqs.length] = prereq; - ResearchCategories.researchCategories.get(tab).research.get(key).setParentsHidden(newPrereqs); - } - } - - @Override - public String describe() { - return "Adding Prerequisites to " + key; - } - - @Override - public boolean canUndo() { - return oldPrereqs != null; - } - - @Override - public void undo() { - if (!hidden) ResearchCategories.researchCategories.get(tab).research.get(key).setParents(oldPrereqs); - else ResearchCategories.researchCategories.get(tab).research.get(key).setParentsHidden(oldPrereqs); - } - - @Override - public String describeUndo() { - return "Restoring Prerequisites for " + key; - } - - @Override - public String getOverrideKey() { - return null; - } - -} diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/AddResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/AddResearch.java deleted file mode 100644 index 0d0d41a..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/AddResearch.java +++ /dev/null @@ -1,59 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import net.minecraft.item.ItemStack; -import minetweaker.IUndoableAction; -import thaumcraft.api.research.ResearchCategories; -import thaumcraft.api.research.ResearchItem; - -public class AddResearch implements IUndoableAction { - String key; - String tab; - ResearchItem research; - ItemStack[] itemTriggers; - String[] entityTriggers; - - public AddResearch(ResearchItem res, ItemStack[] triggers, String[] entTriggers) { - research = res; - tab = research.category; - key = research.key; - itemTriggers = triggers; - entityTriggers = entTriggers; - } - - @Override - public void apply() { -// if (itemTriggers != null) { -// research = research.settrsetItemTriggers(itemTriggers); -// } -// if (entityTriggers != null) { -// research = research.setEntityTriggers(entityTriggers); -// } - research.registerResearchItem(); - } - - @Override - public String describe() { - return "Registering Research: " + key; - } - - @Override - public boolean canUndo() { - return tab != null && key != null; - } - - @Override - public void undo() { - ResearchCategories.researchCategories.get(tab).research.remove(key); - } - - @Override - public String describeUndo() { - return "Removing Research: " + key; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/AddSibling.java b/src/main/java/modtweaker2/mods/thaumcraft/research/AddSibling.java deleted file mode 100644 index c7fa00f..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/AddSibling.java +++ /dev/null @@ -1,56 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import minetweaker.IUndoableAction; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import thaumcraft.api.research.ResearchCategories; - -public class AddSibling implements IUndoableAction { - String key; - String tab; - String sibling; - String[] oldSiblings; - - public AddSibling(String res, String sib) { - key = res; - tab = ThaumcraftHelper.getResearchTab(key); - sibling = sib; - } - - @Override - public void apply() { - oldSiblings = ResearchCategories.researchCategories.get(tab).research.get(key).siblings; - if (oldSiblings == null) oldSiblings = new String[0]; - String[] newSiblings = new String[oldSiblings.length + 1]; - for (int x = 0; x < oldSiblings.length; x++) { - newSiblings[x] = oldSiblings[x]; - } - newSiblings[oldSiblings.length] = sibling; - ResearchCategories.researchCategories.get(tab).research.get(key).setSiblings(sibling); - } - - @Override - public String describe() { - return "Adding Sibling to " + key; - } - - @Override - public boolean canUndo() { - return oldSiblings != null; - } - - @Override - public void undo() { - ResearchCategories.researchCategories.get(tab).research.get(key).setSiblings(oldSiblings); - } - - @Override - public String describeUndo() { - return "Restoring Siblings for " + key; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/AddTab.java b/src/main/java/modtweaker2/mods/thaumcraft/research/AddTab.java deleted file mode 100644 index fb25839..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/AddTab.java +++ /dev/null @@ -1,50 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import minetweaker.IUndoableAction; -import net.minecraft.util.ResourceLocation; -import thaumcraft.api.research.ResearchCategories; - -public class AddTab implements IUndoableAction { - String key; - String tab; - ResourceLocation icon; - ResourceLocation background; - - public AddTab(String key, String research, ResourceLocation pic, ResourceLocation back) { - this.key = key; - icon = pic; - background = back; - tab = research; - } - - @Override - public void apply() { - ResearchCategories.registerCategory(key, tab, icon, background); - } - - @Override - public String describe() { - return "Registering Research Tab: " + tab; - } - - @Override - public boolean canUndo() { - return true; - } - - @Override - public void undo() { - ResearchCategories.researchCategories.remove(tab); - } - - @Override - public String describeUndo() { - return "Removing Research Tab: " + tab; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPages.java b/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPages.java deleted file mode 100644 index 86a552b..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPages.java +++ /dev/null @@ -1,49 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import minetweaker.IUndoableAction; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import thaumcraft.api.research.ResearchCategories; -import thaumcraft.api.research.ResearchPage; - -public class ClearPages implements IUndoableAction { - String key; - String tab; - ResearchPage[] oldPages; - - public ClearPages(String res) { - key = res; - tab = ThaumcraftHelper.getResearchTab(key); - } - - @Override - public void apply() { - oldPages = ResearchCategories.researchCategories.get(tab).research.get(key).getPages(); - ResearchCategories.researchCategories.get(tab).research.get(key).setPages(new ResearchPage[0]); - } - - @Override - public String describe() { - return "Clearing Research Pages from " + key; - } - - @Override - public boolean canUndo() { - return oldPages != null; - } - - @Override - public void undo() { - ResearchCategories.researchCategories.get(tab).research.get(key).setPages(oldPages); - } - - @Override - public String describeUndo() { - return "Restoring Pages to " + key; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPrereqs.java b/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPrereqs.java deleted file mode 100644 index 5fd9899..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/ClearPrereqs.java +++ /dev/null @@ -1,52 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import minetweaker.IUndoableAction; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import thaumcraft.api.research.ResearchCategories; - -public class ClearPrereqs implements IUndoableAction { - String key; - String tab; - String[] prereqs; - String[] secretPrereqs; - - public ClearPrereqs(String res) { - key = res; - tab = ThaumcraftHelper.getResearchTab(key); - } - - @Override - public void apply() { - prereqs = ResearchCategories.researchCategories.get(tab).research.get(key).parents; - secretPrereqs = ResearchCategories.researchCategories.get(tab).research.get(key).parentsHidden; - ResearchCategories.researchCategories.get(tab).research.get(key).setParents(new String[0]); - ResearchCategories.researchCategories.get(tab).research.get(key).setParentsHidden(new String[0]); - } - - @Override - public String describe() { - return "Clearing Prerequisites for " + key; - } - - @Override - public boolean canUndo() { - return prereqs != null || secretPrereqs != null; - } - - @Override - public void undo() { - if (prereqs != null) ResearchCategories.researchCategories.get(tab).research.get(key).setParents(prereqs); - if (secretPrereqs != null) ResearchCategories.researchCategories.get(tab).research.get(key).setParentsHidden(secretPrereqs); - } - - @Override - public String describeUndo() { - return "Restoring Prerequisites for " + key; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/ClearSiblings.java b/src/main/java/modtweaker2/mods/thaumcraft/research/ClearSiblings.java deleted file mode 100644 index d24b2a3..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/ClearSiblings.java +++ /dev/null @@ -1,48 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import minetweaker.IUndoableAction; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import thaumcraft.api.research.ResearchCategories; - -public class ClearSiblings implements IUndoableAction { - String key; - String tab; - String[] siblings; - - public ClearSiblings(String res) { - key = res; - tab = ThaumcraftHelper.getResearchTab(key); - } - - @Override - public void apply() { - siblings = ResearchCategories.researchCategories.get(tab).research.get(key).siblings; - ResearchCategories.researchCategories.get(tab).research.get(key).setSiblings(new String[0]); - } - - @Override - public String describe() { - return "Clearing Siblings for " + key; - } - - @Override - public boolean canUndo() { - return siblings != null; - } - - @Override - public void undo() { - ResearchCategories.researchCategories.get(tab).research.get(key).setSiblings(siblings); - } - - @Override - public String describeUndo() { - return "Restoring Siblings for " + key; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/Difficulty.java b/src/main/java/modtweaker2/mods/thaumcraft/research/Difficulty.java deleted file mode 100644 index b2bd873..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/Difficulty.java +++ /dev/null @@ -1,69 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import java.lang.reflect.Field; - -import minetweaker.IUndoableAction; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import thaumcraft.api.research.ResearchCategories; -import thaumcraft.api.research.ResearchItem; - -public class Difficulty implements IUndoableAction { - String key; - String tab; - int difficulty; - int oldDif; - boolean applied = false; - - public Difficulty(String res, int dif) { - key = res; - tab = ThaumcraftHelper.getResearchTab(key); - difficulty = dif; - } - - @Override - public void apply() { - ResearchItem research = ResearchCategories.researchCategories.get(tab).research.get(key); - oldDif = research.getComplexity(); - try { - Field complexity = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("complexity"); - complexity.setAccessible(true); - complexity.set(research, difficulty); - applied = true; - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public String describe() { - return "Changing Complexity for " + key; - } - - @Override - public boolean canUndo() { - return applied; - } - - @Override - public void undo() { - try { - ResearchItem research = ResearchCategories.researchCategories.get(tab).research.get(key); - Field complexity = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("complexity"); - complexity.setAccessible(true); - complexity.set(research, oldDif); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public String describeUndo() { - return "Restoring Complexity for " + key; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/MoveResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/MoveResearch.java deleted file mode 100644 index 7339287..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/MoveResearch.java +++ /dev/null @@ -1,97 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import java.lang.reflect.Field; - -import minetweaker.IUndoableAction; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import thaumcraft.api.research.ResearchCategories; -import thaumcraft.api.research.ResearchItem; - -public class MoveResearch implements IUndoableAction { - String key; - String newTab; - int x; - int y; - String oldTab; - int oldX; - int oldY; - boolean moved = false; - - public MoveResearch(String research, String destination, int ex, int wy) { - key = research; - oldTab = ThaumcraftHelper.getResearchTab(key); - newTab = destination; - x = ex; - y = wy; - } - - @Override - public void apply() { - if (oldTab != null) { - ResearchItem research = ResearchCategories.researchCategories.get(oldTab).research.get(key); - oldX = research.displayColumn; - oldY = research.displayRow; - try { - Class res = Class.forName("thaumcraft.api.research.ResearchItem"); - Field ex = res.getField("displayColumn"); - ex.setAccessible(true); - ex.setInt(research, x); - Field wy = res.getField("displayRow"); - wy.setAccessible(true); - wy.setInt(research, y); - Field cat = res.getField("category"); - cat.setAccessible(true); - cat.set(research, newTab); - ResearchCategories.researchCategories.get(oldTab).research.remove(key); - research.registerResearchItem(); - moved = true; - - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - @Override - public String describe() { - return "Moving Research " + key + " to " + newTab; - } - - @Override - public boolean canUndo() { - return moved; - } - - @Override - public void undo() { - ResearchItem research = ResearchCategories.researchCategories.get(oldTab).research.get(key); - try { - Class res = Class.forName("thaumcraft.api.research.ResearchItem"); - Field ex = res.getField("displayColumn"); - ex.setAccessible(true); - ex.setInt(research, oldX); - Field wy = res.getField("displayRow"); - wy.setAccessible(true); - wy.setInt(research, oldY); - Field cat = res.getField("category"); - cat.setAccessible(true); - cat.set(research, oldTab); - ResearchCategories.researchCategories.get(newTab).research.remove(key); - research.registerResearchItem(); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public String describeUndo() { - return "Moving Research " + key + " back to " + oldTab; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/OrphanResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/OrphanResearch.java deleted file mode 100644 index 8089006..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/OrphanResearch.java +++ /dev/null @@ -1,126 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import java.util.ArrayList; -import java.util.HashMap; - -import minetweaker.IUndoableAction; -import thaumcraft.api.research.ResearchCategories; - -public class OrphanResearch implements IUndoableAction { - String key; - HashMap children = new HashMap(); - HashMap secretChildren = new HashMap(); - HashMap siblings = new HashMap(); - - public OrphanResearch(String victim) { - key = victim; - } - - @Override - public void apply() { - for (String tab : ResearchCategories.researchCategories.keySet()) { - for (String research : ResearchCategories.researchCategories.get(tab).research.keySet()) { - String[] prereqs = ResearchCategories.researchCategories.get(tab).research.get(research).parents; - if (prereqs != null) { - for (int x = 0; x < prereqs.length; x++) { - if (prereqs[x] != null && prereqs[x].equals(key)) { - children.put(research, tab); - ArrayList newReqs = new ArrayList(); - for (int y = 0; y < prereqs.length; y++) { - if (y != x) newReqs.add(prereqs[y]); - } - ResearchCategories.researchCategories.get(tab).research.get(research).setParents(newReqs.toArray(new String[prereqs.length - 1])); - break; - } - } - } - prereqs = ResearchCategories.researchCategories.get(tab).research.get(research).parentsHidden; - if (prereqs != null) { - for (int x = 0; x < prereqs.length; x++) { - if (prereqs[x] != null && prereqs[x].equals(key)) { - secretChildren.put(research, tab); - ArrayList newReqs = new ArrayList(); - for (int y = 0; y < prereqs.length; y++) { - if (y != x) newReqs.add(prereqs[y]); - } - ResearchCategories.researchCategories.get(tab).research.get(research).setParentsHidden(newReqs.toArray(new String[prereqs.length - 1])); - break; - } - } - } - prereqs = ResearchCategories.researchCategories.get(tab).research.get(research).siblings; - if (prereqs != null) { - for (int x = 0; x < prereqs.length; x++) { - if (prereqs[x] != null && prereqs[x].equals(key)) { - siblings.put(research, tab); - ArrayList newReqs = new ArrayList(); - for (int y = 0; y < prereqs.length; y++) { - if (y != x) newReqs.add(prereqs[y]); - } - ResearchCategories.researchCategories.get(tab).research.get(research).setSiblings(newReqs.toArray(new String[prereqs.length - 1])); - break; - } - } - } - } - } - } - - @Override - public String describe() { - return "Orphaning Research: " + key; - } - - @Override - public boolean canUndo() { - return children.size() > 0 || secretChildren.size() > 0 || siblings.size() > 0; - } - - @Override - public void undo() { - if (children.size() > 0) { - for (String research : children.keySet()) { - String[] oldPrereqs = ResearchCategories.researchCategories.get(children.get(research)).research.get(research).parents; - String[] newReqs = new String[oldPrereqs.length + 1]; - for (int x = 0; x < oldPrereqs.length; x++) { - newReqs[x] = oldPrereqs[x]; - } - newReqs[oldPrereqs.length] = key; - ResearchCategories.researchCategories.get(children.get(research)).research.get(research).setParents(newReqs); - } - } - if (secretChildren.size() > 0) { - for (String research : secretChildren.keySet()) { - String[] oldPrereqs = ResearchCategories.researchCategories.get(secretChildren.get(research)).research.get(research).parentsHidden; - String[] newReqs = new String[oldPrereqs.length + 1]; - for (int x = 0; x < oldPrereqs.length; x++) { - newReqs[x] = oldPrereqs[x]; - } - newReqs[oldPrereqs.length] = key; - ResearchCategories.researchCategories.get(secretChildren.get(research)).research.get(research).setParentsHidden(newReqs); - } - } - if (siblings.size() > 0) { - for (String research : siblings.keySet()) { - String[] oldPrereqs = ResearchCategories.researchCategories.get(siblings.get(research)).research.get(research).siblings; - String[] newReqs = new String[oldPrereqs.length + 1]; - for (int x = 0; x < oldPrereqs.length; x++) { - newReqs[x] = oldPrereqs[x]; - } - newReqs[oldPrereqs.length] = key; - ResearchCategories.researchCategories.get(siblings.get(research)).research.get(research).setSiblings(newReqs); - } - } - } - - @Override - public String describeUndo() { - return "Reattaching Research: " + key; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/RefreshResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/RefreshResearch.java deleted file mode 100644 index 251cad5..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/RefreshResearch.java +++ /dev/null @@ -1,110 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import static modtweaker2.helpers.StackHelper.areEqual; -import minetweaker.IUndoableAction; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; -import thaumcraft.api.ThaumcraftApi; -import thaumcraft.api.crafting.CrucibleRecipe; -import thaumcraft.api.crafting.IArcaneRecipe; -import thaumcraft.api.crafting.InfusionRecipe; -import thaumcraft.api.research.ResearchCategories; -import thaumcraft.api.research.ResearchItem; -import thaumcraft.api.research.ResearchPage; - -public class RefreshResearch implements IUndoableAction { - String research; - String tab; - - public RefreshResearch(String target) { - research = target; - tab = ThaumcraftHelper.getResearchTab(research); - } - - @Override - public void apply() { - if (tab != null) { - ResearchItem target = ResearchCategories.researchCategories.get(tab).research.get(research); - ResearchPage[] pages = target.getPages(); - for (int x = 0; x < pages.length; x++) { - if (pages[x].recipe != null) { - if (pages[x].recipe instanceof IRecipe) { - IRecipe recipe = (IRecipe) pages[x].recipe; - for (Object craft : CraftingManager.getInstance().getRecipeList()) { - if (craft instanceof IRecipe) { - IRecipe theCraft = (IRecipe) craft; - if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) { - pages[x] = new ResearchPage(theCraft); - break; - } - } - } - } else if (pages[x].recipe instanceof IArcaneRecipe) { - IArcaneRecipe recipe = (IArcaneRecipe) pages[x].recipe; - for (Object craft : ThaumcraftApi.getCraftingRecipes()) { - if (craft instanceof IArcaneRecipe) { - IArcaneRecipe theCraft = (IArcaneRecipe) craft; - if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) { - pages[x] = new ResearchPage(theCraft); - break; - } - } - } - } else if (pages[x].recipe instanceof CrucibleRecipe) { - CrucibleRecipe recipe = (CrucibleRecipe) pages[x].recipe; - for (Object craft : ThaumcraftApi.getCraftingRecipes()) { - if (craft instanceof CrucibleRecipe) { - CrucibleRecipe theCraft = (CrucibleRecipe) craft; - if (theCraft.getRecipeOutput() != null && areEqual(theCraft.getRecipeOutput(), recipe.getRecipeOutput())) { - pages[x] = new ResearchPage(theCraft); - break; - } - } - } - } else if (pages[x].recipe instanceof InfusionRecipe) { - InfusionRecipe recipe = (InfusionRecipe) pages[x].recipe; - if (recipe.getRecipeOutput() instanceof ItemStack) { - for (Object craft : ThaumcraftApi.getCraftingRecipes()) { - if (craft instanceof InfusionRecipe) { - InfusionRecipe theCraft = (InfusionRecipe) craft; - if (theCraft.getRecipeOutput() != null && theCraft.getRecipeOutput() instanceof ItemStack && areEqual(((ItemStack) theCraft.getRecipeOutput()), (ItemStack) recipe.getRecipeOutput())) { - pages[x] = new ResearchPage(theCraft); - break; - } - } - } - } - } - } - } - } - } - - @Override - public String describe() { - return "Refreshing Research: " + research; - } - - @Override - public boolean canUndo() { - return tab != null; - } - - @Override - public void undo() { - apply(); - } - - @Override - public String describeUndo() { - return "Refreshing Research Again?: " + research; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveResearch.java deleted file mode 100644 index 3eb114c..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveResearch.java +++ /dev/null @@ -1,51 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import minetweaker.IUndoableAction; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import thaumcraft.api.research.ResearchCategories; -import thaumcraft.api.research.ResearchItem; - -public class RemoveResearch implements IUndoableAction { - String key; - String tab; - ResearchItem removed; - - public RemoveResearch(String victim) { - key = victim; - } - - @Override - public void apply() { - tab = ThaumcraftHelper.getResearchTab(key); - if (tab != null) { - removed = ResearchCategories.researchCategories.get(tab).research.get(key); - ResearchCategories.researchCategories.get(tab).research.remove(key); - } - } - - @Override - public String describe() { - return "Removing Research: " + key; - } - - @Override - public boolean canUndo() { - return tab != null && removed != null; - } - - @Override - public void undo() { - ResearchCategories.researchCategories.get(tab).research.put(key, removed); - } - - @Override - public String describeUndo() { - return "Restoring Research: " + key; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveTab.java b/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveTab.java deleted file mode 100644 index ded9eda..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/RemoveTab.java +++ /dev/null @@ -1,46 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import minetweaker.IUndoableAction; -import thaumcraft.api.research.ResearchCategories; -import thaumcraft.api.research.ResearchCategoryList; - -public class RemoveTab implements IUndoableAction { - String tab; - ResearchCategoryList list; - - public RemoveTab(String victim) { - tab = victim; - } - - @Override - public void apply() { - list = ResearchCategories.getResearchList(tab); - ResearchCategories.researchCategories.remove(tab); - } - - @Override - public String describe() { - return "Removing Research Tab: " + tab; - } - - @Override - public boolean canUndo() { - return list != null; - } - - @Override - public void undo() { - ResearchCategories.researchCategories.put(tab, list); - } - - @Override - public String describeUndo() { - return "Restoring Research Tab: " + tab; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/SetAspects.java b/src/main/java/modtweaker2/mods/thaumcraft/research/SetAspects.java deleted file mode 100644 index abc1ddf..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/SetAspects.java +++ /dev/null @@ -1,70 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import java.lang.reflect.Field; - -import minetweaker.IUndoableAction; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import thaumcraft.api.aspects.AspectList; -import thaumcraft.api.research.ResearchCategories; -import thaumcraft.api.research.ResearchItem; - -public class SetAspects implements IUndoableAction { - String key; - String tab; - AspectList oldList; - AspectList list; - boolean applied = false; - - public SetAspects(String res, AspectList asp) { - key = res; - tab = ThaumcraftHelper.getResearchTab(key); - list = asp; - } - - @Override - public void apply() { - ResearchItem research = ResearchCategories.researchCategories.get(tab).research.get(key); - oldList = research.tags; - try { - Field tags = Class.forName("thaumcraft.api.research.ResearchItem").getField("tags"); - tags.setAccessible(true); - tags.set(research, list); - applied = true; - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public String describe() { - return "Changing Aspects for " + key; - } - - @Override - public boolean canUndo() { - return applied; - } - - @Override - public void undo() { - try { - ResearchItem research = ResearchCategories.researchCategories.get(tab).research.get(key); - Field tags = Class.forName("thaumcraft.api.research.ResearchItem").getField("tags"); - tags.setAccessible(true); - tags.set(research, oldList); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public String describeUndo() { - return "Restoring Aspects for " + key; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/SetResearch.java b/src/main/java/modtweaker2/mods/thaumcraft/research/SetResearch.java deleted file mode 100644 index 82e4179..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/SetResearch.java +++ /dev/null @@ -1,111 +0,0 @@ -package modtweaker2.mods.thaumcraft.research; - -import java.lang.reflect.Field; - -import minetweaker.IUndoableAction; -import modtweaker2.mods.thaumcraft.ThaumcraftHelper; -import modtweaker2.mods.thaumcraft.handlers.Research.SetType; -import thaumcraft.api.research.ResearchCategories; -import thaumcraft.api.research.ResearchItem; - -public class SetResearch implements IUndoableAction { - String key; - String tab; - SetType type; - boolean flag; - boolean applied = false; - - public SetResearch(String res, boolean f, SetType typ) { - key = res; - tab = ThaumcraftHelper.getResearchTab(key); - type = typ; - flag = f; - } - - @Override - public void apply() { - ResearchItem research = ResearchCategories.researchCategories.get(tab).research.get(key); - if (flag) { - if (type == SetType.AUTO) research.setAutoUnlock(); - else if (type == SetType.ROUND) research.setRound(); - else if (type == SetType.SPIKE) research.setSpecial(); - else if (type == SetType.SECONDARY) research.setSecondary(); - else if (type == SetType.STUB) research.setStub(); -// else if (type == SetType.VIRTUAL) research.setsetVirtual(); -// else if (type == SetType.CONCEAL) research.setConcealed(); - applied = true; - } else { - try { - Field target = null; - if (type == SetType.AUTO) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isAutoUnlock"); - else if (type == SetType.ROUND) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isRound"); - else if (type == SetType.SPIKE) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSpecial"); - else if (type == SetType.SECONDARY) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSecondary"); - else if (type == SetType.STUB) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isStub"); - else if (type == SetType.VIRTUAL) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isVirtual"); - else if (type == SetType.CONCEAL) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isConcealed"); - - if (target != null) { - target.setAccessible(true); - target.setBoolean(research, false); - applied = true; - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - @Override - public String describe() { - return "Setting tag for " + key; - } - - @Override - public boolean canUndo() { - return applied; - } - - @Override - public void undo() { - ResearchItem research = ResearchCategories.researchCategories.get(tab).research.get(key); - if (!flag) { - if (type == SetType.AUTO) research.setAutoUnlock(); - else if (type == SetType.ROUND) research.setRound(); - else if (type == SetType.SPIKE) research.setSpecial(); - else if (type == SetType.SECONDARY) research.setSecondary(); - else if (type == SetType.STUB) research.setStub(); -// else if (type == SetType.VIRTUAL) research.setVirtual(); -// else if (type == SetType.CONCEAL) research.setConcealed(); - } else { - try { - Field target = null; - if (type == SetType.AUTO) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isAutoUnlock"); - else if (type == SetType.ROUND) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isRound"); - else if (type == SetType.SPIKE) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSpecial"); - else if (type == SetType.SECONDARY) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isSecondary"); - else if (type == SetType.STUB) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isStub"); - else if (type == SetType.VIRTUAL) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isVirtual"); - else if (type == SetType.CONCEAL) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isConcealed"); - - if (target != null) { - target.setAccessible(true); - target.setBoolean(research, false); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - @Override - public String describeUndo() { - return "Reversing tag for " + key; - } - - @Override - public String getOverrideKey() { - return null; - } - -} \ No newline at end of file diff --git a/src/main/java/modtweaker2/mods/thaumcraft/research/commands/ResearchLogger.java b/src/main/java/modtweaker2/mods/thaumcraft/research/commands/ResearchLogger.java deleted file mode 100644 index d19b52c..0000000 --- a/src/main/java/modtweaker2/mods/thaumcraft/research/commands/ResearchLogger.java +++ /dev/null @@ -1,35 +0,0 @@ -package modtweaker2.mods.thaumcraft.research.commands; - -import static modtweaker2.helpers.LogHelper.log; -import static modtweaker2.helpers.LogHelper.logPrinted; -import minetweaker.MineTweakerAPI; -import minetweaker.api.player.IPlayer; -import minetweaker.api.server.ICommandFunction; -import thaumcraft.api.research.ResearchCategories; - -public class ResearchLogger implements ICommandFunction { - @Override - public void execute(String[] arguments, IPlayer player) { - if (arguments == null || arguments.length <= 0 || arguments[0] == null) { - System.out.println("Research Categories:"); - MineTweakerAPI.logCommand("Research Categories:"); - for (String tab : ResearchCategories.researchCategories.keySet()) { - System.out.println(tab); - MineTweakerAPI.logCommand(tab); - } - - logPrinted(player); - } else if (arguments[0] != null && ResearchCategories.researchCategories.containsKey(arguments[0])) { - System.out.println("Research Keys for " + arguments[0] + ":"); - MineTweakerAPI.logCommand("Research Keys for " + arguments[0] + ":"); - for (String key : ResearchCategories.researchCategories.get(arguments[0]).research.keySet()) { - System.out.println(key); - MineTweakerAPI.logCommand(key); - } - - logPrinted(player); - } else if (arguments[0] != null && player != null) { - log(player, "Cannot find research category " + arguments[0]); - } - } -}