mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-27 15:43:06 +00:00
Also changes like all packages inb4 "jared changes a package name in ModTweaker2 breaking compatability with everything" drama tweet.
This commit is contained in:
1 parent
4fd2551072
commit
ec562b62ea
187 files changed
+977
-991
No files matched your search
@@ -0,0 +1,21 @@
|
||||
package modtweaker2.mods.thaumcraft;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
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.Research;
|
||||
import modtweaker2.mods.thaumcraft.handlers.Warp;
|
||||
|
||||
public class Thaumcraft {
|
||||
public Thaumcraft() {
|
||||
MineTweakerAPI.registerClass(Arcane.class);
|
||||
MineTweakerAPI.registerClass(Aspects.class);
|
||||
MineTweakerAPI.registerClass(Crucible.class);
|
||||
MineTweakerAPI.registerClass(Infusion.class);
|
||||
MineTweakerAPI.registerClass(Research.class);
|
||||
MineTweakerAPI.registerClass(Warp.class);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package modtweaker2.mods.thaumcraft;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import modtweaker2.helpers.ReflectionHelper;
|
||||
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 ArrayList recipes = null;
|
||||
public static HashMap<Object, Integer> warpList;
|
||||
|
||||
static {
|
||||
try {
|
||||
recipes = ReflectionHelper.getStaticObject(ThaumcraftApi.class, "recipes");
|
||||
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.getAspectsSortedAmount())
|
||||
{
|
||||
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.getAspectsSortedAmount())
|
||||
{
|
||||
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<EntityTags> 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.getAspectsSortedAmount())
|
||||
{
|
||||
if(aspect!=null)
|
||||
output+=aspect.getName()+" "+aspects.getAmount(aspect)+",";
|
||||
}
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package modtweaker2.mods.thaumcraft.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.MineTweakerImplementationAPI;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.api.server.ICommandFunction;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import thaumcraft.api.ThaumcraftApi;
|
||||
import thaumcraft.api.ThaumcraftApi.EntityTags;
|
||||
import thaumcraft.api.ThaumcraftApi.EntityTagsNBT;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
|
||||
public class AspectLogger implements ICommandFunction{
|
||||
|
||||
@Override
|
||||
public void execute(String[] arguments, IPlayer player) {
|
||||
List<String> lines=new ArrayList();
|
||||
for(Entry<List, AspectList> entry : ThaumcraftApi.objectTags.entrySet())
|
||||
{
|
||||
List<String> itemList=new ArrayList<String>();
|
||||
for(int i=0;i<entry.getKey().size();i+=2)
|
||||
{
|
||||
Item item=(Item)entry.getKey().get(i);
|
||||
|
||||
itemList.add("<"+Item.itemRegistry.getNameForObject(item)+":"+entry.getKey().get(i+1)+">");
|
||||
}
|
||||
lines.add(itemList.toString()+": "+ThaumcraftHelper.aspectsToString(entry.getValue()));
|
||||
}
|
||||
for (EntityTags tags : ThaumcraftApi.scanEntities)
|
||||
{
|
||||
List<String> tagsList=new ArrayList<String>();
|
||||
for(EntityTagsNBT tag : tags.nbts)
|
||||
{
|
||||
tagsList.add(tag.name+":"+tag.value);
|
||||
}
|
||||
String stringTags="";
|
||||
if(tags.nbts.length!=0)
|
||||
stringTags=":"+tagsList.toString();
|
||||
lines.add("<"+tags.entityName+stringTags+">"+": "+ThaumcraftHelper.aspectsToString(tags.aspects));
|
||||
}
|
||||
System.out.println("Aspects: " + lines.size());
|
||||
for (String line : lines) {
|
||||
System.out.println("Aspect " + line);
|
||||
MineTweakerAPI.logCommand(line);
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
player.sendChat(MineTweakerImplementationAPI.platform.getMessage("List generated; see minetweaker.log in your minecraft dir"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package modtweaker2.mods.thaumcraft.handlers;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import modtweaker2.util.BaseListAddition;
|
||||
import modtweaker2.util.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;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.StackHelper.*;
|
||||
|
||||
@ZenClass("mods.thaumcraft.Arcane")
|
||||
public class Arcane {
|
||||
@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("Thaumcraft Arcane Worktable", ThaumcraftApi.getCraftingRecipes(), recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
Object out = ((IArcaneRecipe) recipe).getRecipeOutput();
|
||||
if (out instanceof ItemStack) {
|
||||
return ((ItemStack) out).getDisplayName();
|
||||
} else
|
||||
return super.getRecipeInfo();
|
||||
}
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(output)));
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval {
|
||||
public Remove(ItemStack stack) {
|
||||
super("Thaumcraft Arcane Worktable", ThaumcraftApi.getCraftingRecipes(), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
|
||||
if (o instanceof IArcaneRecipe) {
|
||||
IArcaneRecipe r = (IArcaneRecipe) o;
|
||||
if (r.getRecipeOutput() != null && r.getRecipeOutput().isItemEqual(stack)) {
|
||||
ThaumcraftApi.getCraftingRecipes().remove(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
package modtweaker2.mods.thaumcraft.handlers;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import modtweaker2.util.BaseDescriptionAddition;
|
||||
import modtweaker2.util.BaseDescriptionRemoval;
|
||||
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;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.StackHelper.*;
|
||||
|
||||
@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 BaseDescriptionAddition {
|
||||
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 = ThaumcraftApiHelper.getObjectAspects(stack);
|
||||
if (!replace) newList = ThaumcraftHelper.parseAspects(oldList, aspects);
|
||||
else newList = ThaumcraftHelper.parseAspects(aspects);
|
||||
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList);
|
||||
}
|
||||
|
||||
@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 BaseDescriptionRemoval {
|
||||
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 = ThaumcraftApiHelper.getObjectAspects(stack);
|
||||
if (oldList != null) {
|
||||
newList = ThaumcraftHelper.removeAspects(oldList, aspects);
|
||||
ThaumcraftApi.objectTags.put(Arrays.asList(stack.getItem(), stack.getItemDamage()), newList);
|
||||
}
|
||||
}
|
||||
|
||||
@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 BaseDescriptionAddition {
|
||||
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);
|
||||
}
|
||||
|
||||
@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 BaseDescriptionRemoval {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return oldList != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
ThaumcraftHelper.removeEntityAspects(entityName);
|
||||
ThaumcraftApi.registerEntityTag(entityName, oldList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return entityName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package modtweaker2.mods.thaumcraft.handlers;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import modtweaker2.util.BaseListAddition;
|
||||
import modtweaker2.util.BaseListRemoval;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import thaumcraft.api.ThaumcraftApi;
|
||||
import thaumcraft.api.crafting.CrucibleRecipe;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.StackHelper.*;
|
||||
|
||||
@ZenClass("mods.thaumcraft.Crucible")
|
||||
public class 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("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return ((CrucibleRecipe) recipe).getRecipeOutput().getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(output)));
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval {
|
||||
public Remove(ItemStack stack) {
|
||||
super("Thaumcraft Crucible", ThaumcraftApi.getCraftingRecipes(), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
|
||||
if (o instanceof CrucibleRecipe) {
|
||||
CrucibleRecipe r = (CrucibleRecipe) o;
|
||||
if (r.getRecipeOutput() != null && areEqual(r.getRecipeOutput(), stack)) {
|
||||
recipe = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ThaumcraftApi.getCraftingRecipes().remove(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package modtweaker2.mods.thaumcraft.handlers;
|
||||
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import modtweaker2.mods.thaumcraft.ThaumcraftHelper;
|
||||
import modtweaker2.mods.thaumcraft.recipe.MTInfusionRecipe;
|
||||
import modtweaker2.util.BaseListAddition;
|
||||
import modtweaker2.util.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;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.StackHelper.*;
|
||||
|
||||
@ZenClass("mods.thaumcraft.Infusion")
|
||||
public class Infusion {
|
||||
@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.enchantmentsList[enchantID], instability, ThaumcraftHelper.parseAspects(aspects), toStacks(recipe))));
|
||||
}
|
||||
|
||||
private static class Add extends BaseListAddition {
|
||||
public Add(InfusionRecipe recipe) {
|
||||
super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
Object out = ((InfusionRecipe) recipe).getRecipeOutput();
|
||||
if (out instanceof ItemStack) {
|
||||
return ((ItemStack) out).getDisplayName();
|
||||
} else return super.getRecipeInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private static class AddEnchant implements IUndoableAction {
|
||||
InfusionEnchantmentRecipe recipe;
|
||||
|
||||
public AddEnchant(InfusionEnchantmentRecipe inp) {
|
||||
recipe = inp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
ThaumcraftApi.getCraftingRecipes().add(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Infusion Enchantment Recipe: " + recipe.enchantment.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return recipe != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
ThaumcraftApi.getCraftingRecipes().remove(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing Infusion Enchantment Recipe: " + recipe.enchantment.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output) {
|
||||
MineTweakerAPI.apply(new Remove(toStack(output)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeEnchant(int id) {
|
||||
MineTweakerAPI.apply(new RemoveEnchant(Enchantment.enchantmentsList[id]));
|
||||
}
|
||||
|
||||
private static class Remove extends BaseListRemoval {
|
||||
public Remove(ItemStack stack) {
|
||||
super("Thaumcraft Infusion", ThaumcraftApi.getCraftingRecipes(), stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Object o : ThaumcraftApi.getCraftingRecipes()) {
|
||||
if (o instanceof InfusionRecipe) {
|
||||
InfusionRecipe r = (InfusionRecipe) o;
|
||||
if (r.getRecipeOutput() != null && r.getRecipeOutput() instanceof ItemStack && areEqual((ItemStack) r.getRecipeOutput(), stack)) {
|
||||
recipe = r;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ThaumcraftApi.getCraftingRecipes().remove(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeInfo() {
|
||||
return stack.getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveEnchant implements IUndoableAction {
|
||||
Enchantment enchant;
|
||||
InfusionEnchantmentRecipe removed;
|
||||
|
||||
public RemoveEnchant(Enchantment ench) {
|
||||
enchant = ench;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
for (Object recipe : ThaumcraftApi.getCraftingRecipes()) {
|
||||
if (recipe instanceof InfusionEnchantmentRecipe) {
|
||||
InfusionEnchantmentRecipe enchRecipe = (InfusionEnchantmentRecipe) recipe;
|
||||
if (enchRecipe.getEnchantment() == enchant) {
|
||||
removed = enchRecipe;
|
||||
ThaumcraftApi.getCraftingRecipes().remove(enchRecipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing Infusion Enchantment Recipe: " + enchant.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return removed != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
ThaumcraftApi.getCraftingRecipes().add(removed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Restoring Infusion Enchantment Recipe: " + enchant.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package modtweaker2.mods.thaumcraft.handlers;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
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.ResearchItem;
|
||||
import thaumcraft.api.research.ResearchPage.PageType;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.StackHelper.*;
|
||||
|
||||
@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 iconDomain, String iconPath) {
|
||||
addTab(key, iconDomain, iconPath, null, null);
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void addTab(String key, 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, icon, background);
|
||||
}
|
||||
|
||||
private static void addTab(String key, ResourceLocation icon, ResourceLocation background) {
|
||||
MineTweakerAPI.apply(new AddTab(key, 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))));
|
||||
}
|
||||
|
||||
@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))));
|
||||
}
|
||||
|
||||
@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.enchantmentsList[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 ThaumcraftApiHelper.isResearchComplete(player.getName(), key);
|
||||
}
|
||||
|
||||
public static enum SetType {
|
||||
AUTO, ROUND, SPIKE, SECONDARY, STUB, VIRTUAL, CONCEAL
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package modtweaker2.mods.thaumcraft.handlers;
|
||||
|
||||
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;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.StackHelper.*;
|
||||
|
||||
@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<Object, Integer> oldMap = new HashMap<Object, Integer>();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
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;
|
||||
|
||||
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<ItemStack> input, ItemStack central, World world, EntityPlayer player) {
|
||||
if (getRecipeInput() == null) return false;
|
||||
|
||||
if (research.length() > 0 && !ThaumcraftApiHelper.isResearchComplete(player.getCommandSenderName(), research)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack i2 = central.copy();
|
||||
if (getRecipeInput().getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
||||
i2.setItemDamage(OreDictionary.WILDCARD_VALUE);
|
||||
}
|
||||
|
||||
if (!areItemStacksEqual(i2, getRecipeInput(), fuzzyCentre)) return false;
|
||||
|
||||
ArrayList<ItemStack> ii = new ArrayList<ItemStack>();
|
||||
for (ItemStack is : input) {
|
||||
ii.add(is.copy());
|
||||
}
|
||||
|
||||
for (int j = 0; j < getComponents().length; j++) {
|
||||
ItemStack comp = 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package modtweaker2.mods.thaumcraft.research;
|
||||
|
||||
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;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.StackHelper.*;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package modtweaker2.mods.thaumcraft.research;
|
||||
|
||||
import minetweaker.IUndoableAction;
|
||||
import thaumcraft.api.research.ResearchCategories;
|
||||
import thaumcraft.api.research.ResearchItem;
|
||||
|
||||
public class AddResearch implements IUndoableAction {
|
||||
String key;
|
||||
String tab;
|
||||
ResearchItem research;
|
||||
|
||||
public AddResearch(ResearchItem res) {
|
||||
research = res;
|
||||
tab = research.category;
|
||||
key = research.key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package modtweaker2.mods.thaumcraft.research;
|
||||
|
||||
import minetweaker.IUndoableAction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import thaumcraft.api.research.ResearchCategories;
|
||||
|
||||
public class AddTab implements IUndoableAction {
|
||||
String tab;
|
||||
ResourceLocation icon;
|
||||
ResourceLocation background;
|
||||
|
||||
public AddTab(String research, ResourceLocation pic, ResourceLocation back) {
|
||||
icon = pic;
|
||||
background = back;
|
||||
tab = research;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
ResearchCategories.registerCategory(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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
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<String, String> children = new HashMap();
|
||||
HashMap<String, String> secretChildren = new HashMap();
|
||||
HashMap<String, String> 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<String> 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<String> 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<String> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package modtweaker2.mods.thaumcraft.research;
|
||||
|
||||
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;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.StackHelper.*;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
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.setVirtual();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package modtweaker2.mods.thaumcraft.research.commands;
|
||||
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.player.IPlayer;
|
||||
import minetweaker.api.server.ICommandFunction;
|
||||
import thaumcraft.api.research.ResearchCategories;
|
||||
import static modtweaker2.helpers.InputHelper.*;
|
||||
import static modtweaker2.helpers.LogHelper.*;
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user