diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-03-04 18:10:39 +0000 |
---|---|---|
committer | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2019-03-04 18:10:39 +0000 |
commit | 8ead0095f30769b0c12d558953323d45a2790d6e (patch) | |
tree | 36fb314ace8d36603230560c390a1049b1484099 /src/Java/gtPlusPlus/xmod/thaumcraft/aspect | |
parent | 91371c9020ec10827653414d58dc7311b73ea686 (diff) | |
download | GT5-Unofficial-8ead0095f30769b0c12d558953323d45a2790d6e.tar.gz GT5-Unofficial-8ead0095f30769b0c12d558953323d45a2790d6e.tar.bz2 GT5-Unofficial-8ead0095f30769b0c12d558953323d45a2790d6e.zip |
+ Added more Wrappers for TC.
- Removed some obsolete classes.
$ Rewrote more TC code to be reflective.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/thaumcraft/aspect')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java | 99 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java | 13 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_Aspects.java | 77 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_AspectList_Wrapper.java | 40 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java (renamed from src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java) | 91 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_PageType_Wrapper.java | 17 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategories_Wrapper.java | 89 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategoryList_Wrapper.java | 21 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchItem_Wrapper.java | 244 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java | 10 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java | 222 |
11 files changed, 747 insertions, 176 deletions
diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java index c363cba459..ea4c97fbfc 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectCompat.java @@ -1,40 +1,29 @@ package gtPlusPlus.xmod.thaumcraft.aspect; -import gregtech.common.GT_ThaumcraftCompat; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.xmod.thaumcraft.aspect.GTPP_Aspects.TC_AspectStack_Ex; -import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; - -import gregtech.api.enums.TC_Aspects; -import gregtech.api.enums.TC_Aspects.TC_AspectStack; -import gregtech.api.interfaces.internal.IThaumcraftCompat; -import gregtech.api.util.GT_LanguageManager; - import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; +import gregtech.api.enums.TC_Aspects; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.GT_ThaumcraftCompat; +import gtPlusPlus.api.objects.Logger; import net.minecraft.util.ResourceLocation; -import thaumcraft.api.aspects.Aspect; -import thaumcraft.api.aspects.AspectList; -public class GTPP_AspectCompat implements IThaumcraftCompat { +public class GTPP_AspectCompat { public static volatile Method m = null; - private static HashMap<String, TC_Aspect> mAspectCache = new LinkedHashMap<String, TC_Aspect>(); + private static HashMap<String, TC_Aspect_Wrapper> mAspectCache = new LinkedHashMap<String, TC_Aspect_Wrapper>(); - public static TC_Aspect ASPECT_BALANCE; - public static TC_Aspect ASPECT_LUST; - public static TC_Aspect ASPECT_STARBOUND; - public static TC_Aspect ASPECT_TOXIC; - public static TC_Aspect ASPECT_HEAVEN; + public static TC_Aspect_Wrapper ASPECT_BALANCE; + public static TC_Aspect_Wrapper ASPECT_LUST; + public static TC_Aspect_Wrapper ASPECT_STARBOUND; + public static TC_Aspect_Wrapper ASPECT_TOXIC; + public static TC_Aspect_Wrapper ASPECT_HEAVEN; /* TC_Aspects.AER.mAspect = Aspect.AIR; @@ -92,11 +81,11 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { // Generate all existing Aspects as TC_Aspects - LinkedHashMap<String, Object> h = TC_Aspect.getVanillaAspectList(); + LinkedHashMap<String, Object> h = TC_Aspect_Wrapper.getVanillaAspectList(); for (String g : h.keySet()) { Object aBaseAspect = h.get(g); - if (aBaseAspect != null && TC_Aspect.isObjectAnAspect(aBaseAspect)) { - TC_Aspect aS = TC_Aspect.getAspect(g); + if (aBaseAspect != null && TC_Aspect_Wrapper.isObjectAnAspect(aBaseAspect)) { + TC_Aspect_Wrapper aS = TC_Aspect_Wrapper.getAspect(g); if (aS != null) { mAspectCache.put(g, aS); continue; @@ -109,10 +98,10 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { // Custom Aspects ASPECT_BALANCE = - new TC_Aspect( + new TC_Aspect_Wrapper( "Purity", 15647411, - new TC_Aspect[]{ + new TC_Aspect_Wrapper[]{ get(TC_Aspects.GELUM), get(TC_Aspects.IGNIS) }, @@ -120,10 +109,10 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { false, 1); ASPECT_LUST = - new TC_Aspect( + new TC_Aspect_Wrapper( "Vengeance", 15647411, - new TC_Aspect[]{ + new TC_Aspect_Wrapper[]{ get(TC_Aspects.CORPUS), get(TC_Aspects.ORDO) }, @@ -149,24 +138,24 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { GT_LanguageManager.addStringLocalization("tc.aspect.custom5", "Heaven"); } - private TC_Aspect get(TC_Aspects aGtObjects) { + private TC_Aspect_Wrapper get(TC_Aspects aGtObjects) { try { - return TC_Aspect.generate(aGtObjects.mAspect); - } catch (IllegalArgumentException | IllegalAccessException e) { + return TC_Aspect_Wrapper.generate(aGtObjects.mAspect); + } catch (IllegalArgumentException e) { e.printStackTrace(); return null; } } - public static synchronized final AspectList getAspectList(final List<TC_AspectStack_Ex> aAspects) { - AspectList o = null; + public static synchronized final TC_AspectList_Wrapper getTC_AspectList_Wrapper(final List<GTPP_AspectStack> aAspects) { + TC_AspectList_Wrapper o = null; try { if (m == null || (m != null && !m.isAccessible())) { - m = GT_ThaumcraftCompat.class.getDeclaredMethod("getAspectList", List.class); + m = GT_ThaumcraftCompat.class.getDeclaredMethod("getTC_AspectList_Wrapper", List.class); m.setAccessible(true); } if (m != null) { - o = (AspectList) m.invoke(null, aAspects); + o = (TC_AspectList_Wrapper) m.invoke(null, aAspects); } } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { @@ -177,44 +166,6 @@ public class GTPP_AspectCompat implements IThaumcraftCompat { } return o; } - - public static synchronized final AspectList getAspectList_Ex(final List<TC_AspectStack_Ex> aAspects) { - final AspectList rAspects = new AspectList(); - for (final TC_AspectStack_Ex tAspect : aAspects) { - rAspects.add((Aspect) tAspect.mAspect.mAspect, (int) tAspect.mAmount); - } - return rAspects; - } - - @Override - public boolean registerPortholeBlacklistedBlock(Block p0) { - return ThaumcraftUtils.registerPortholeBlacklistedBlock(p0); - } - - @Override - public boolean registerThaumcraftAspectsToItem(ItemStack p0, List<TC_AspectStack> p1, boolean p2) { - return ThaumcraftUtils.registerThaumcraftAspectsToItem(p0, ThaumcraftUtils.convertAspectStack(p1), p2); - } - - @Override - public boolean registerThaumcraftAspectsToItem(ItemStack p0, List<TC_AspectStack> p1, String p2) { - return ThaumcraftUtils.registerThaumcraftAspectsToItem(p0, ThaumcraftUtils.convertAspectStack(p1), p2); - } - - @Override - public Object addCrucibleRecipe(String p0, Object p1, ItemStack p2, List<TC_AspectStack> p3) { - return ThaumcraftUtils.addCrucibleRecipe(p0, p1, p2, ThaumcraftUtils.convertAspectStack(p3)); - } - @Override - public Object addInfusionRecipe(String p0, ItemStack p1, ItemStack[] p2, ItemStack p3, int p4, List<TC_AspectStack> p5) { - return ThaumcraftUtils.addInfusionRecipe(p0, p1, p2, p3, p4, ThaumcraftUtils.convertAspectStack(p5)); - } - - @Override - public Object addResearch(String p0, String p1, String p2, String[] p3, String p4, ItemStack p5, int p6, int p7, - int p8, int p9, List<TC_AspectStack> p10, ItemStack[] p11, Object[] p12) { - return ThaumcraftUtils.addResearch(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, ThaumcraftUtils.convertAspectStack(p10), p11, p12); - } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java new file mode 100644 index 0000000000..d7cfa7d326 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_AspectStack.java @@ -0,0 +1,13 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +public class GTPP_AspectStack { + + public final TC_Aspect_Wrapper mAspect; + public final int mAmount; + + public GTPP_AspectStack(TC_Aspect_Wrapper aAspect, int aAmount) { + mAspect = aAspect; + mAmount= aAmount; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_Aspects.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_Aspects.java deleted file mode 100644 index e1df0dabf5..0000000000 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/GTPP_Aspects.java +++ /dev/null @@ -1,77 +0,0 @@ -package gtPlusPlus.xmod.thaumcraft.aspect; - -import java.util.List; - -import thaumcraft.api.aspects.Aspect; - -public enum GTPP_Aspects { - - //Standard TC and GT Aspects - AER(1), ALIENIS(20), AQUA(3), ARBOR(1), AURAM(16), BESTIA(6), - COGNITIO(2), CORPUS(2), ELECTRUM(24), EXANIMIS(32), FABRICO(2), - FAMES(2), GELUM(1), GRANUM(4), HERBA(2), HUMANUS(8), IGNIS(4), - INSTRUMENTUM(4), ITER(6), LIMUS(3), LUCRUM(32), LUX(4), MACHINA(16), - MAGNETO(24), MESSIS(3), METALLUM(8), METO(2), MORTUUS(16), MOTUS(4), - NEBRISUM(48), ORDO(8), PANNUS(6), PERDITIO(2), PERFODIO(4), - PERMUTATIO(12), POTENTIA(16), PRAECANTATIO(16), RADIO(48), - SANO(24), SENSUS(4), SPIRITUS(24), STRONTIO(64), TELUM(6), - TERRA(1), TEMPESTAS(64), TENEBRAE(24), TUTAMEN(12), VACUOS(6), - VENENUM(16), VICTUS(4), VINCULUM(16), VITIUM(48), VITREUS(3), VOLATUS(12), - - //Custom Aspects - CUSTOM_3(24), CUSTOM_4(24), CUSTOM_2(48), CUSTOM_5(48), CUSTOM_1(64); - - public Aspect mAspect; - public int mValue; - - private GTPP_Aspects(final int aValue) { - this.mValue = aValue; - } - - public static class TC_AspectStack_Ex { - public GTPP_Aspects mAspect; - public long mAmount; - - public TC_AspectStack_Ex(final GTPP_Aspects aAspect, final long aAmount) { - this.mAspect = aAspect; - this.mAmount = aAmount; - } - - public TC_AspectStack_Ex copy() { - return new TC_AspectStack_Ex(this.mAspect, this.mAmount); - } - - public TC_AspectStack_Ex copy(final long aAmount) { - return new TC_AspectStack_Ex(this.mAspect, aAmount); - } - - public List<TC_AspectStack_Ex> addToAspectList(final List<TC_AspectStack_Ex> aList) { - if (this.mAmount == 0L) { - return aList; - } - for (final TC_AspectStack_Ex tAspect : aList) { - if (tAspect.mAspect == this.mAspect) { - final TC_AspectStack_Ex tc_AspectStack = tAspect; - tc_AspectStack.mAmount += this.mAmount; - return aList; - } - } - aList.add(this.copy()); - return aList; - } - - public boolean removeFromAspectList(final List<TC_AspectStack_Ex> aList) { - for (final TC_AspectStack_Ex tAspect : aList) { - if (tAspect.mAspect == this.mAspect && tAspect.mAmount >= this.mAmount) { - final TC_AspectStack_Ex tc_AspectStack = tAspect; - tc_AspectStack.mAmount -= this.mAmount; - if (tAspect.mAmount == 0L) { - aList.remove(tAspect); - } - return true; - } - } - return false; - } - } -}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_AspectList_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_AspectList_Wrapper.java new file mode 100644 index 0000000000..0a7f2d6a3c --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_AspectList_Wrapper.java @@ -0,0 +1,40 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import net.minecraft.item.ItemStack; + +public class TC_AspectList_Wrapper { + + + //thaumcraft.api.aspects.Aspect; + //thaumcraft.api.aspects.AspectList; + + public TC_AspectList_Wrapper() { + + } + + public TC_AspectList_Wrapper(ItemStack stack) { + + } + + public TC_AspectList_Wrapper(Object invoke) { + // TODO Auto-generated constructor stub + } + + public int size() { + // TODO Auto-generated method stub + return 0; + } + + public Object getVanillaAspectList() { + // TODO Auto-generated method stub + return null; + } + + public void add(TC_Aspect_Wrapper mAspect, int mAmount) { + // TODO Auto-generated method stub + + } + + + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java index 5b84733dd1..78c2a670bb 100644 --- a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect.java +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_Aspect_Wrapper.java @@ -7,6 +7,7 @@ import java.lang.reflect.Method; import java.util.LinkedHashMap; import java.util.Map; +import gregtech.api.enums.TC_Aspects; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ReflectionUtils; @@ -18,19 +19,24 @@ import net.minecraft.util.ResourceLocation; * @author Alkalus * */ -public class TC_Aspect { +public class TC_Aspect_Wrapper { private static Class mClass_Aspect; private static Field mField_Aspects; private final String tag; - private final TC_Aspect[] components; + private final TC_Aspect_Wrapper[] components; private final int color; private String chatcolor; private final ResourceLocation image; private final int blend; - private final Object mAspect; + public final Object mAspect; + + /** + * May be null, but links back to the TC_Aspects class from GT for convinience. + */ + public final TC_Aspects mGtEnumField; @@ -82,8 +88,8 @@ public class TC_Aspect { * @param chatcolor * @param blend */ - public TC_Aspect(String tag, int color, String chatcolor, int blend) { - this(tag, color, (TC_Aspect[]) null, blend); + public TC_Aspect_Wrapper(String tag, int color, String chatcolor, int blend) { + this(tag, color, (TC_Aspect_Wrapper[]) null, blend); this.chatcolor = chatcolor; } @@ -94,7 +100,7 @@ public class TC_Aspect { * @param color * @param components */ - public TC_Aspect(String tag, int color, TC_Aspect[] components) { + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components) { this(tag, color, components, false, 1); } @@ -106,7 +112,7 @@ public class TC_Aspect { * @param components * @param blend */ - public TC_Aspect(String tag, int color, TC_Aspect[] components, int blend) { + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, int blend) { this(tag, color, components, false, blend); } @@ -120,12 +126,12 @@ public class TC_Aspect { * @param image * @param blend */ - public TC_Aspect(String tag, int color, TC_Aspect[] components, boolean vanilla, int blend) { + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, boolean vanilla, int blend) { this(tag, color, components, vanilla ? new ResourceLocation("thaumcraft", "textures/aspects/" + tag.toLowerCase() + ".png") : new ResourceLocation(CORE.MODID, "textures/aspects/" + tag.toLowerCase() + ".png"), vanilla, blend); } - public TC_Aspect(String tag, int color, TC_Aspect[] components, ResourceLocation image, boolean vanilla, int blend) { + public TC_Aspect_Wrapper(String tag, int color, TC_Aspect_Wrapper[] components, ResourceLocation image, boolean vanilla, int blend) { if (getAspectList().containsKey(tag.toLowerCase())) { throw new IllegalArgumentException(tag + " already registered!"); } else { @@ -134,7 +140,28 @@ public class TC_Aspect { this.color = color; this.image = image; this.blend = blend; - this.mAspect = vanilla ? getVanillaAspectObject(this.tag) : this.generateTcAspect(); + this.mAspect = vanilla ? getVanillaAspectObject(this.tag) : this.generateTcAspect(); + + //Set GT Type if exists + TC_Aspects y = null; + for (TC_Aspects e : TC_Aspects.values()) { + TC_Aspect_Wrapper g; + try { + g = generate(e.mAspect); + if (g != null) { + if (g.tag.equals(this.tag)) { + y = e; + break; + } + } + } catch (IllegalArgumentException e1) { + e1.printStackTrace(); + } + } + mGtEnumField = y; + + + Logger.INFO("[Thaumcraft++] Adding support for Aspect: "+tag); } } @@ -148,12 +175,21 @@ public class TC_Aspect { * @throws IllegalAccessException */ @SuppressWarnings("unused") - public static TC_Aspect generate(Object aBaseAspect) throws IllegalArgumentException, IllegalAccessException { - String aTag = ((String) ReflectionUtils.getField(mClass_Aspect, "tag").get(aBaseAspect)).toLowerCase(); + public static TC_Aspect_Wrapper generate(Object aBaseAspect) { + try { + Field aTagF = ReflectionUtils.getField(mClass_Aspect, "tag"); + if (aTagF == null) { + return null; + } + String aTafB = (String) aTagF.get(aBaseAspect); + if (aTafB == null) { + return null; + } + String aTag = aTafB.toLowerCase(); if (aTag != null && getAspectList().containsKey(aTag.toLowerCase())) { return getAspect(aTag); } else { - TC_Aspect aTemp = new TC_Aspect( + TC_Aspect_Wrapper aTemp = new TC_Aspect_Wrapper( aTag, (int) ReflectionUtils.getField(mClass_Aspect, "color").get(aBaseAspect), generateAspectArrayInternal(ReflectionUtils.getField(mClass_Aspect, "components"), (aBaseAspect)), @@ -168,52 +204,57 @@ public class TC_Aspect { else { return null; } - } + } + } + catch (Throwable t) { + t.printStackTrace(); + return null; + } } /** * Internal Map containing all the TC_Aspects. */ - private static Map<String, TC_Aspect> mInternalAspectCache = new LinkedHashMap<String, TC_Aspect>(); + private static Map<String, TC_Aspect_Wrapper> mInternalAspectCache = new LinkedHashMap<String, TC_Aspect_Wrapper>(); /** * Public getter for all TC_Aspects * @param aAspectName - Aspect Name * @return - A GT++ Aspect wrapper or null. (TC_Aspect) */ - public static TC_Aspect getAspect(String aAspectName) { + public static TC_Aspect_Wrapper getAspect(String aAspectName) { String aName = aAspectName.toLowerCase(); - TC_Aspect g = mInternalAspectCache.get(aName); + TC_Aspect_Wrapper g = mInternalAspectCache.get(aName); if (g != null) { return g; } else { try { - TC_Aspect aTemp = generate(getVanillaAspectList().get(aName)); + TC_Aspect_Wrapper aTemp = generate(getVanillaAspectList().get(aName)); if (aTemp != null) { mInternalAspectCache.put(aName, aTemp); return aTemp; } - } catch (IllegalArgumentException | IllegalAccessException e) { + } catch (IllegalArgumentException e) { e.printStackTrace(); } } return null; } - public static Map<String, TC_Aspect> getAspectList(){ + public static Map<String, TC_Aspect_Wrapper> getAspectList(){ return mInternalAspectCache; } - private static TC_Aspect[] generateAspectArrayInternal(Field aField, Object aInstance) { + private static TC_Aspect_Wrapper[] generateAspectArrayInternal(Field aField, Object aInstance) { //thaumcraft.api.aspects.Aspect.Aspect() Object[] components; - TC_Aspect[] aAspectArray; + TC_Aspect_Wrapper[] aAspectArray; try { components = (Object[]) aField.get(aInstance); - aAspectArray = new TC_Aspect[components.length]; + aAspectArray = new TC_Aspect_Wrapper[components.length]; if (components.length > 0) { int i = 0; for (Object g : components) { @@ -223,7 +264,7 @@ public class TC_Aspect { } } catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); - aAspectArray = new TC_Aspect[0]; + aAspectArray = new TC_Aspect_Wrapper[0]; } return aAspectArray; } @@ -239,7 +280,7 @@ public class TC_Aspect { if (components.length > 0) { aAspectArray = (Object[]) Array.newInstance(mClass_Aspect, components.length); int i = 0; - for (TC_Aspect g : components) { + for (TC_Aspect_Wrapper g : components) { ((Object[]) aAspectArray)[i++] = g.mAspect; } } diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_PageType_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_PageType_Wrapper.java new file mode 100644 index 0000000000..5a608e290f --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_PageType_Wrapper.java @@ -0,0 +1,17 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +public class TC_PageType_Wrapper { + + public static final TC_PageType_Wrapper TEXT = null; + public static final TC_PageType_Wrapper TEXT_CONCEALED = null; + public static final TC_PageType_Wrapper NORMAL_CRAFTING = null; + public static final TC_PageType_Wrapper ARCANE_CRAFTING = null; + public static final TC_PageType_Wrapper CRUCIBLE_CRAFTING = null; + public static final TC_PageType_Wrapper INFUSION_CRAFTING = null; + public static final TC_PageType_Wrapper COMPOUND_CRAFTING = null; + public static final TC_PageType_Wrapper SMELTING = null; + public static final TC_PageType_Wrapper INFUSION_ENCHANTMENT = null; + public static final TC_PageType_Wrapper IMAGE = null; + public static final TC_PageType_Wrapper ASPECTS = null; + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategories_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategories_Wrapper.java new file mode 100644 index 0000000000..3392dbcff9 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategories_Wrapper.java @@ -0,0 +1,89 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import cpw.mods.fml.common.FMLLog; +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedHashMap; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import org.apache.logging.log4j.Level; + +public class TC_ResearchCategories_Wrapper { + + public static LinkedHashMap<String, TC_ResearchCategoryList_Wrapper> researchCategories = new LinkedHashMap<String, TC_ResearchCategoryList_Wrapper>(); + + public static TC_ResearchCategoryList_Wrapper getResearchList(String key) { + return (TC_ResearchCategoryList_Wrapper) researchCategories.get(key); + } + + public static String getCategoryName(String key) { + return StatCollector.translateToLocal("tc.research_category." + key); + } + + public static TC_ResearchItem_Wrapper getResearch(String key) { + Collection rc = researchCategories.values(); + Iterator i$ = rc.iterator(); + + while (i$.hasNext()) { + Object cat = i$.next(); + Collection rl = ((TC_ResearchCategoryList_Wrapper) cat).research.values(); + Iterator i$1 = rl.iterator(); + + while (i$1.hasNext()) { + Object ri = i$1.next(); + if (((TC_ResearchItem_Wrapper) ri).key.equals(key)) { + return (TC_ResearchItem_Wrapper) ri; + } + } + } + + return null; + } + + public static void registerCategory(String key, ResourceLocation icon, ResourceLocation background) { + if (getResearchList(key) == null) { + TC_ResearchCategoryList_Wrapper rl = new TC_ResearchCategoryList_Wrapper(icon, background); + researchCategories.put(key, rl); + } + + } + + public static void addResearch(TC_ResearchItem_Wrapper ri) { + TC_ResearchCategoryList_Wrapper rl = getResearchList(ri.category); + if (rl != null && !rl.research.containsKey(ri.key)) { + if (!ri.isVirtual()) { + Iterator i$ = rl.research.values().iterator(); + + while (i$.hasNext()) { + TC_ResearchItem_Wrapper rr = (TC_ResearchItem_Wrapper) i$.next(); + if (rr.displayColumn == ri.displayColumn && rr.displayRow == ri.displayRow) { + FMLLog.log(Level.FATAL, + "[Thaumcraft] Research [" + ri.getName() + + "] not added as it overlaps with existing research [" + rr.getName() + "]", + new Object[0]); + return; + } + } + } + + rl.research.put(ri.key, ri); + if (ri.displayColumn < rl.minDisplayColumn) { + rl.minDisplayColumn = ri.displayColumn; + } + + if (ri.displayRow < rl.minDisplayRow) { + rl.minDisplayRow = ri.displayRow; + } + + if (ri.displayColumn > rl.maxDisplayColumn) { + rl.maxDisplayColumn = ri.displayColumn; + } + + if (ri.displayRow > rl.maxDisplayRow) { + rl.maxDisplayRow = ri.displayRow; + } + } + + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategoryList_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategoryList_Wrapper.java new file mode 100644 index 0000000000..4c9102648a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchCategoryList_Wrapper.java @@ -0,0 +1,21 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.util.ResourceLocation; + +public class TC_ResearchCategoryList_Wrapper { + public int minDisplayColumn; + public int minDisplayRow; + public int maxDisplayColumn; + public int maxDisplayRow; + public ResourceLocation icon; + public ResourceLocation background; + public Map<String, TC_ResearchItem_Wrapper> research = new HashMap<String, TC_ResearchItem_Wrapper>(); + + public TC_ResearchCategoryList_Wrapper(ResourceLocation icon, ResourceLocation background) { + this.icon = icon; + this.background = background; + } +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchItem_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchItem_Wrapper.java new file mode 100644 index 0000000000..399ec5ad09 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchItem_Wrapper.java @@ -0,0 +1,244 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import gtPlusPlus.xmod.thaumcraft.util.ThaumcraftUtils; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class TC_ResearchItem_Wrapper { + + public final String key; + public final String category; + public final TC_AspectList_Wrapper tags; + public String[] parents = null; + public String[] parentsHidden = null; + public String[] siblings = null; + public final int displayColumn; + public final int displayRow; + public final ItemStack icon_item; + public final ResourceLocation icon_resource; + private int complexity; + private boolean isSpecial; + private boolean isSecondary; + private boolean isRound; + private boolean isStub; + private boolean isVirtual; + private boolean isConcealed; + private boolean isHidden; + private boolean isLost; + private boolean isAutoUnlock; + private ItemStack[] itemTriggers; + private String[] entityTriggers; + private TC_Aspect_Wrapper[] aspectTriggers; + private Object[] pages = null; + + public TC_ResearchItem_Wrapper(String key, String category) { + this.key = key; + this.category = category; + this.tags = new TC_AspectList_Wrapper(); + this.icon_resource = null; + this.icon_item = null; + this.displayColumn = 0; + this.displayRow = 0; + this.setVirtual(); + } + + public TC_ResearchItem_Wrapper(String key, String category, TC_AspectList_Wrapper tags, int col, int row, int complex, + ResourceLocation icon) { + this.key = key; + this.category = category; + this.tags = tags; + this.icon_resource = icon; + this.icon_item = null; + this.displayColumn = col; + this.displayRow = row; + this.complexity = complex; + if (this.complexity < 1) { + this.complexity = 1; + } + + if (this.complexity > 3) { + this.complexity = 3; + } + + } + + public TC_ResearchItem_Wrapper(String key, String category, TC_AspectList_Wrapper tags, int col, int row, int complex, ItemStack icon) { + this.key = key; + this.category = category; + this.tags = tags; + this.icon_item = icon; + this.icon_resource = null; + this.displayColumn = col; + this.displayRow = row; + this.complexity = complex; + if (this.complexity < 1) { + this.complexity = 1; + } + + if (this.complexity > 3) { + this.complexity = 3; + } + + } + + public TC_ResearchItem_Wrapper setSpecial() { + this.isSpecial = true; + return this; + } + + public TC_ResearchItem_Wrapper setStub() { + this.isStub = true; + return this; + } + + public TC_ResearchItem_Wrapper setLost() { + this.isLost = true; + return this; + } + + public TC_ResearchItem_Wrapper setConcealed() { + this.isConcealed = true; + return this; + } + + public TC_ResearchItem_Wrapper setHidden() { + this.isHidden = true; + return this; + } + + public TC_ResearchItem_Wrapper setVirtual() { + this.isVirtual = true; + return this; + } + + public TC_ResearchItem_Wrapper setParents(String... par) { + this.parents = par; + return this; + } + + public TC_ResearchItem_Wrapper setParentsHidden(String... par) { + this.parentsHidden = par; + return this; + } + + public TC_ResearchItem_Wrapper setSiblings(String... sib) { + this.siblings = sib; + return this; + } + + public TC_ResearchItem_Wrapper setPages(Object... par) { + this.pages = par; + return this; + } + + public Object[] getPages() { + return this.pages; + } + + public TC_ResearchItem_Wrapper setItemTriggers(ItemStack... par) { + this.itemTriggers = par; + return this; + } + + public TC_ResearchItem_Wrapper setEntityTriggers(String... par) { + this.entityTriggers = par; + return this; + } + + public TC_ResearchItem_Wrapper setAspectTriggers(TC_Aspect_Wrapper... par) { + this.aspectTriggers = par; + return this; + } + + public ItemStack[] getItemTriggers() { + return this.itemTriggers; + } + + public String[] getEntityTriggers() { + return this.entityTriggers; + } + + public TC_Aspect_Wrapper[] getAspectTriggers() { + return this.aspectTriggers; + } + + public TC_ResearchItem_Wrapper registerResearchItem() { + ThaumcraftUtils.addResearch(this); + return this; + } + + public String getName() { + return StatCollector.translateToLocal("tc.research_name." + this.key); + } + + public String getText() { + return StatCollector.translateToLocal("tc.research_text." + this.key); + } + + public boolean isSpecial() { + return this.isSpecial; + } + + public boolean isStub() { + return this.isStub; + } + + public boolean isLost() { + return this.isLost; + } + + public boolean isConcealed() { + return this.isConcealed; + } + + public boolean isHidden() { + return this.isHidden; + } + + public boolean isVirtual() { + return this.isVirtual; + } + + public boolean isAutoUnlock() { + return this.isAutoUnlock; + } + + public TC_ResearchItem_Wrapper setAutoUnlock() { + this.isAutoUnlock = true; + return this; + } + + public boolean isRound() { + return this.isRound; + } + + public TC_ResearchItem_Wrapper setRound() { + this.isRound = true; + return this; + } + + public boolean isSecondary() { + return this.isSecondary; + } + + public TC_ResearchItem_Wrapper setSecondary() { + this.isSecondary = true; + return this; + } + + public int getComplexity() { + return this.complexity; + } + + public TC_ResearchItem_Wrapper setComplexity(int complexity) { + this.complexity = complexity; + return this; + } + + public TC_Aspect_Wrapper getResearchPrimaryTag() { + //TODO + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java new file mode 100644 index 0000000000..64f1ce088a --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchNoteData_Wrapper.java @@ -0,0 +1,10 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +public class TC_ResearchNoteData_Wrapper { + + public Object getResearchNoteData() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java new file mode 100644 index 0000000000..256e9c19ed --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/thaumcraft/aspect/TC_ResearchPage_Wrapper.java @@ -0,0 +1,222 @@ +package gtPlusPlus.xmod.thaumcraft.aspect; + +import java.util.List; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class TC_ResearchPage_Wrapper { + public TC_PageType_Wrapper type; + public String text; + public String research; + public ResourceLocation image; + public TC_AspectList_Wrapper aspects; + public Object recipe; + public ItemStack recipeOutput; + + public TC_ResearchPage_Wrapper(String text) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.TEXT; + this.text = text; + } + + public TC_ResearchPage_Wrapper(String research, String text) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.TEXT_CONCEALED; + this.research = research; + this.text = text; + } + + public TC_ResearchPage_Wrapper(IRecipe recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.NORMAL_CRAFTING; + this.recipe = recipe; + this.recipeOutput = recipe.getRecipeOutput(); + } + + public TC_ResearchPage_Wrapper(IRecipe[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.NORMAL_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(IArcaneRecipe[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.ARCANE_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(CrucibleRecipe[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.CRUCIBLE_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(InfusionRecipe[] recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.INFUSION_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(List recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.COMPOUND_CRAFTING; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(IArcaneRecipe recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.ARCANE_CRAFTING; + this.recipe = recipe; + this.recipeOutput = recipe.getRecipeOutput(); + } + + public TC_ResearchPage_Wrapper(CrucibleRecipe recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.CRUCIBLE_CRAFTING; + this.recipe = recipe; + this.recipeOutput = recipe.getRecipeOutput(); + } + + public TC_ResearchPage_Wrapper(ItemStack input) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.SMELTING; + this.recipe = input; + this.recipeOutput = FurnaceRecipes.smelting().getSmeltingResult(input); + } + + public TC_ResearchPage_Wrapper(InfusionRecipe recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.INFUSION_CRAFTING; + this.recipe = recipe; + if (recipe.getRecipeOutput() instanceof ItemStack) { + this.recipeOutput = (ItemStack) recipe.getRecipeOutput(); + } else { + this.recipeOutput = recipe.getRecipeInput(); + } + + } + + public TC_ResearchPage_Wrapper(InfusionEnchantmentRecipe recipe) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.INFUSION_ENCHANTMENT; + this.recipe = recipe; + } + + public TC_ResearchPage_Wrapper(ResourceLocation image, String caption) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.IMAGE; + this.image = image; + this.text = caption; + } + + public TC_ResearchPage_Wrapper(TC_AspectList_Wrapper as) { + this.type = TC_PageType_Wrapper.TEXT; + this.text = null; + this.research = null; + this.image = null; + this.aspects = null; + this.recipe = null; + this.recipeOutput = null; + this.type = TC_PageType_Wrapper.ASPECTS; + this.aspects = as; + } + + public String getTranslatedText() { + String ret = ""; + if (this.text != null) { + ret = StatCollector.translateToLocal(this.text); + if (ret.isEmpty()) { + ret = this.text; + } + } + + return ret; + } +}
\ No newline at end of file |