diff options
author | Jordan Byrne <draknyte1@hotmail.com> | 2017-12-13 14:33:50 +1000 |
---|---|---|
committer | Jordan Byrne <draknyte1@hotmail.com> | 2017-12-13 14:33:50 +1000 |
commit | 28e4e6dc569d0a938bfafa1180c70aa1c864b578 (patch) | |
tree | 75e12456b111ddd31b8c14c724e98ebba7cd4628 /src/Java/gtPlusPlus/xmod/forestry/bees | |
parent | d774ccf1ad2a75001a2e61cc0d6faeb9d09504f1 (diff) | |
download | GT5-Unofficial-28e4e6dc569d0a938bfafa1180c70aa1c864b578.tar.gz GT5-Unofficial-28e4e6dc569d0a938bfafa1180c70aa1c864b578.tar.bz2 GT5-Unofficial-28e4e6dc569d0a938bfafa1180c70aa1c864b578.zip |
+ More reflection work to make bees 5.08 compliant.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/forestry/bees')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java | 20 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java | 38 |
2 files changed, 49 insertions, 9 deletions
diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java index dfbe32c9a4..24327a97a9 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java @@ -10,9 +10,8 @@ import forestry.apiculture.genetics.BeeDefinition; import forestry.apiculture.genetics.BeeVariation; import forestry.apiculture.genetics.IBeeDefinition; import forestry.core.genetics.alleles.AlleleHelper; -import gregtech.common.items.CombType; -import gregtech.loaders.misc.GT_Bees; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.ItemUtils; import net.minecraft.item.ItemStack; import org.apache.commons.lang3.text.WordUtils; @@ -25,7 +24,7 @@ public enum GTPP_Bee_Definition implements IBeeDefinition { SILICON(GTPP_Branch_Definition.METAL, "Silicon", true, Utils.rgbtoHexValue(75, 75, 75), Utils.rgbtoHexValue(125, 125, 125)) { @Override protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { - beeSpecies.addProduct(GT_Bees.combs.getStackForType(CombType.SLAG), 0.10f); + beeSpecies.addProduct(getSlagComb(), 0.10f); beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.SILICON), 0.20f); beeSpecies.setHumidity(EnumHumidity.NORMAL); beeSpecies.setTemperature(EnumTemperature.NORMAL); @@ -45,7 +44,7 @@ public enum GTPP_Bee_Definition implements IBeeDefinition { RUBBER(GTPP_Branch_Definition.ORGANIC, "Rubber", true, Utils.rgbtoHexValue(55, 55, 55), Utils.rgbtoHexValue(75, 75, 75)) { @Override protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { - beeSpecies.addProduct(GT_Bees.combs.getStackForType(CombType.SLAG), 0.10f); + beeSpecies.addProduct(getSlagComb(), 0.10f); beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.RUBBER), 0.30f); beeSpecies.setHumidity(EnumHumidity.NORMAL); beeSpecies.setTemperature(EnumTemperature.NORMAL); @@ -65,7 +64,7 @@ public enum GTPP_Bee_Definition implements IBeeDefinition { PLASTIC(GTPP_Branch_Definition.ORGANIC, "Plastic", true, Utils.rgbtoHexValue(245, 245, 245), Utils.rgbtoHexValue(175, 175, 175)) { @Override protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { - beeSpecies.addProduct(GT_Bees.combs.getStackForType(CombType.STONE), 0.30f); + beeSpecies.addProduct(getStoneComb(), 0.30f); beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.PLASTIC), 0.15f); beeSpecies.setHumidity(EnumHumidity.NORMAL); beeSpecies.setTemperature(EnumTemperature.NORMAL); @@ -85,7 +84,7 @@ public enum GTPP_Bee_Definition implements IBeeDefinition { PTFE(GTPP_Branch_Definition.ORGANIC, "Ptfe", true, Utils.rgbtoHexValue(150, 150, 150), Utils.rgbtoHexValue(75, 75, 75)) { @Override protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { - beeSpecies.addProduct(GT_Bees.combs.getStackForType(CombType.STONE), 0.30f); + beeSpecies.addProduct(getStoneComb(), 0.30f); beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.PTFE), 0.10f); beeSpecies.setHumidity(EnumHumidity.NORMAL); beeSpecies.setTemperature(EnumTemperature.NORMAL); @@ -105,7 +104,7 @@ public enum GTPP_Bee_Definition implements IBeeDefinition { PBS(GTPP_Branch_Definition.ORGANIC, "Pbs", true, Utils.rgbtoHexValue(232, 105, 0), Utils.rgbtoHexValue(183, 55, 0)) { @Override protected void setSpeciesProperties(IAlleleBeeSpeciesCustom beeSpecies) { - beeSpecies.addProduct(GT_Bees.combs.getStackForType(CombType.STONE), 0.30f); + beeSpecies.addProduct(getStoneComb(), 0.30f); beeSpecies.addProduct(GTPP_Bees.combs.getStackForType(CustomCombs.PTFE), 0.10f); beeSpecies.setHumidity(EnumHumidity.NORMAL); beeSpecies.setTemperature(EnumTemperature.NORMAL); @@ -696,4 +695,11 @@ public enum GTPP_Bee_Definition implements IBeeDefinition { return new BeeVariation.RainResist(this); } + private static ItemStack getSlagComb(){ + return ItemUtils.getSimpleStack(GTPP_Bees.Comb_Slag, 1); + } + private static ItemStack getStoneComb(){ + return ItemUtils.getSimpleStack(GTPP_Bees.Comb_Stone, 1); + } + } diff --git a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java index 9fff0c03a9..eb6beac02a 100644 --- a/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java +++ b/src/Java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java @@ -1,18 +1,26 @@ package gtPlusPlus.xmod.forestry.bees.custom; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import org.apache.commons.lang3.reflect.FieldUtils; import cpw.mods.fml.common.Loader; import gregtech.GT_Mod; import gregtech.api.enums.Materials; -import gtPlusPlus.core.lib.CORE; +import net.minecraft.item.ItemStack; public class GTPP_Bees { + //Base Comb Item public static ItemCustomComb combs; + + //Combs obtained via reflection + public static ItemStack Comb_Slag; + public static ItemStack Comb_Stone; + //Materials obtained via reflection public static Materials PTFE; public static Materials PBS; @@ -30,7 +38,7 @@ public class GTPP_Bees { private static boolean tryGetBeesBoolean(){ try { - Class mProxy = Class.forName("gregtech.GT_Mod.gregtechproxy"); + Class<?> mProxy = Class.forName("gregtech.GT_Mod.gregtechproxy"); Field mNerf = FieldUtils.getDeclaredField(mProxy, "mGTBees", true); boolean returnValue = (boolean) mNerf.get(GT_Mod.gregtechproxy); return returnValue; @@ -41,6 +49,32 @@ public class GTPP_Bees { } private void setMaterials(){ + try { + + Class<?> gtBees = Class.forName("gregtech.loaders.misc.GT_Bees"); + Class<?> gtCombItemClass = Class.forName("gregtech.common.items.ItemComb"); + Class gtCombEnumClass = Class.forName("gregtech.common.items.CombType"); + Field gtCombs = FieldUtils.getDeclaredField(gtBees, "combs", true); + Enum gtCombTypeSlag = Enum.valueOf(gtCombEnumClass, "SLAG"); + Enum gtCombTypeStone = Enum.valueOf(gtCombEnumClass, "STONE"); + Object oCombObject = gtCombs.get(gtBees); + + if (gtCombItemClass.isInstance(oCombObject)){ + Method getStackForType; + getStackForType = gtCombItemClass.getDeclaredMethod("getStackForType", gtCombEnumClass); + if (Comb_Slag == null){ + Comb_Slag = (ItemStack) getStackForType.invoke(gtBees, gtCombTypeSlag); + } + if (Comb_Stone == null){ + Comb_Stone = (ItemStack) getStackForType.invoke(gtBees, gtCombTypeStone); + } + } + + } + catch (NullPointerException | ClassNotFoundException | IllegalArgumentException | IllegalAccessException | NoSuchMethodException | SecurityException | InvocationTargetException e){ + + } + PTFE = trySetValue("Polytetrafluoroethylene"); PBS = trySetValue("StyreneButadieneRubber"); } |