mirror of
https://github.com/GTNewHorizons/ModTweaker.git
synced 2026-11-12 00:07:57 +00:00
Add a "hidden" option to thaumcraft research (#4)
* Add a "hidden" option to thaumcraft research * Add aspect triggers for "hidden" option * Reformat
This commit is contained in:
1 parent
fb757729e8
commit
ceabe58b03
3 files changed
+25
-9
No files matched your search
@@ -78,19 +78,19 @@ public class 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));
|
||||
MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, new ResourceLocation(domain, path)), null, 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));
|
||||
MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, toStack(item)),null, 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) {
|
||||
public static void addResearch(String key, String tab, @Optional String aspects, int x, int y, int difficulty, IItemStack item, IItemStack[] triggers, String[] entTriggers, String aspectsTrigger) {
|
||||
|
||||
MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, toStack(item)), InputHelper.toStacks(triggers), entTriggers));
|
||||
MineTweakerAPI.apply(new AddResearch(new ResearchItem(key, tab, ThaumcraftHelper.parseAspects(aspects), x, y, difficulty, toStack(item)), InputHelper.toStacks(triggers), entTriggers, ThaumcraftHelper.parseAspects(aspectsTrigger)));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
@@ -201,6 +201,11 @@ public class Research {
|
||||
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.CONCEAL));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void setHidden(String key, boolean flag) {
|
||||
MineTweakerAPI.apply(new SetResearch(key, flag, SetType.HIDDEN));
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void setAspects(String key, String aspects) {
|
||||
|
||||
@@ -231,7 +236,7 @@ public class Research {
|
||||
return ThaumcraftApiHelper.isResearchComplete(player.getName(), key);
|
||||
}
|
||||
|
||||
public static enum SetType {
|
||||
AUTO, ROUND, SPIKE, SECONDARY, STUB, VIRTUAL, CONCEAL
|
||||
public enum SetType {
|
||||
AUTO, ROUND, SPIKE, SECONDARY, STUB, VIRTUAL, CONCEAL, HIDDEN
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package modtweaker2.mods.thaumcraft.research;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import minetweaker.IUndoableAction;
|
||||
import thaumcraft.api.aspects.Aspect;
|
||||
import thaumcraft.api.aspects.AspectList;
|
||||
import thaumcraft.api.research.ResearchCategories;
|
||||
import thaumcraft.api.research.ResearchItem;
|
||||
|
||||
@@ -12,13 +14,15 @@ public class AddResearch implements IUndoableAction {
|
||||
ResearchItem oldResearch;
|
||||
ItemStack[] itemTriggers;
|
||||
String[] entityTriggers;
|
||||
AspectList aspectTriggers;
|
||||
|
||||
public AddResearch(ResearchItem res, ItemStack[] triggers, String[] entTriggers) {
|
||||
public AddResearch(ResearchItem res, ItemStack[] itemTriggers, String[] entityTriggers, AspectList aspectTriggers) {
|
||||
research = res;
|
||||
tab = research.category;
|
||||
key = research.key;
|
||||
itemTriggers = triggers;
|
||||
entityTriggers = entTriggers;
|
||||
this.itemTriggers = itemTriggers;
|
||||
this.entityTriggers = entityTriggers;
|
||||
this.aspectTriggers = aspectTriggers;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,6 +34,9 @@ public class AddResearch implements IUndoableAction {
|
||||
if (entityTriggers != null) {
|
||||
research = research.setEntityTriggers(entityTriggers);
|
||||
}
|
||||
if (aspectTriggers != null) {
|
||||
research = research.setAspectTriggers(aspectTriggers.getAspects());
|
||||
}
|
||||
research.registerResearchItem();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ public class SetResearch implements IUndoableAction {
|
||||
else if (type == SetType.STUB) research.setStub();
|
||||
else if (type == SetType.VIRTUAL) research.setVirtual();
|
||||
else if (type == SetType.CONCEAL) research.setConcealed();
|
||||
else if (type == SetType.HIDDEN) research.setHidden();
|
||||
applied = true;
|
||||
} else {
|
||||
try {
|
||||
@@ -46,6 +47,7 @@ public class SetResearch implements IUndoableAction {
|
||||
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");
|
||||
else if (type == SetType.HIDDEN) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isHidden");
|
||||
|
||||
if (target != null) {
|
||||
target.setAccessible(true);
|
||||
@@ -83,6 +85,7 @@ public class SetResearch implements IUndoableAction {
|
||||
else if (type == SetType.STUB) research.setStub();
|
||||
else if (type == SetType.VIRTUAL) research.setVirtual();
|
||||
else if (type == SetType.CONCEAL) research.setConcealed();
|
||||
else if (type == SetType.HIDDEN) research.setHidden();
|
||||
} else {
|
||||
try {
|
||||
Field target = null;
|
||||
@@ -93,6 +96,7 @@ public class SetResearch implements IUndoableAction {
|
||||
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");
|
||||
else if (type == SetType.HIDDEN) target = Class.forName("thaumcraft.api.research.ResearchItem").getDeclaredField("isHidden");
|
||||
|
||||
if (target != null) {
|
||||
target.setAccessible(true);
|
||||
|
||||
Reference in new issue
Block a user