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,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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user