From 82604eadb847335e4b4ddf2e90a28b325786837b Mon Sep 17 00:00:00 2001 From: Alexdoru <57050655+Alexdoru@users.noreply.github.com> Date: Sat, 7 Sep 2024 05:40:03 +0200 Subject: Remove a bunch more reflection (#3074) Co-authored-by: boubou19 --- .../java/gtPlusPlus/api/objects/data/AutoMap.java | 30 +- .../gtPlusPlus/core/block/base/BlockBaseOre.java | 27 +- .../gtPlusPlus/core/gui/widget/GuiValueField.java | 8 +- .../gtPlusPlus/core/handler/PacketHandler.java | 17 +- .../core/item/chemistry/AgriculturalChem.java | 45 +-- .../core/item/chemistry/MilledOreProcessing.java | 11 +- .../core/item/tool/misc/ItemGregtechPump.java | 2 +- src/main/java/gtPlusPlus/core/lib/GTPPCore.java | 34 +- .../gtPlusPlus/core/material/MaterialStack.java | 7 +- .../machines/TileEntityPestKiller.java | 9 +- .../gtPlusPlus/core/util/minecraft/ItemUtils.java | 7 +- .../core/util/minecraft/MiningUtils.java | 76 ++--- .../core/util/reflect/ReflectionUtils.java | 22 +- .../agrichem/item/algae/ItemAgrichemBase.java | 22 -- .../plugin/fixes/vanilla/VanillaBedHeightFix.java | 1 + .../gtPlusPlus/xmod/bop/BiomesOPlentyHandler.java | 169 +--------- .../forestry/bees/registry/GTPP_BeeDefinition.java | 59 ++-- .../xmod/forestry/bees/registry/GTPP_Bees.java | 17 +- .../implementations/MTEHatchNaquadah.java | 40 ++- .../implementations/base/GTPPMultiBlockBase.java | 43 +-- .../gregtech/loaders/RecipeGenFluidCanning.java | 9 +- .../xmod/gregtech/loaders/RecipeGenRecycling.java | 13 +- .../gtPlusPlus/xmod/tinkers/HandlerTinkers.java | 5 +- .../xmod/tinkers/material/BaseTinkersMaterial.java | 19 +- .../xmod/tinkers/util/TinkersDryingRecipe.java | 91 ++---- .../gtPlusPlus/xmod/tinkers/util/TinkersUtils.java | 356 +++------------------ 26 files changed, 222 insertions(+), 917 deletions(-) (limited to 'src/main/java/gtPlusPlus') diff --git a/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java b/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java index a3551326c2..4de2e9ab78 100644 --- a/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java +++ b/src/main/java/gtPlusPlus/api/objects/data/AutoMap.java @@ -41,13 +41,13 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect /** * Generates an AutoMap from the List. - * + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(List aList) { mInternalMap = new LinkedHashMap<>(); mInternalNameMap = new LinkedHashMap<>(); - if (aList != null && aList.size() > 0) { + if (aList != null && !aList.isEmpty()) { for (V obj : aList) { add(obj); } @@ -56,13 +56,13 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect /** * Generates an AutoMap from a Set. - * + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(Set aList) { mInternalMap = new LinkedHashMap<>(); mInternalNameMap = new LinkedHashMap<>(); - if (aList != null && aList.size() > 0) { + if (aList != null && !aList.isEmpty()) { for (V obj : aList) { add(obj); } @@ -71,13 +71,13 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect /** * Generates an AutoMap from a Collection. - * + * * @param aList - Data to be inserted into the AutoMap. */ public AutoMap(Collection aList) { mInternalMap = new LinkedHashMap<>(); mInternalNameMap = new LinkedHashMap<>(); - if (aList != null && aList.size() > 0) { + if (aList != null && !aList.isEmpty()) { for (V obj : aList) { add(obj); } @@ -86,13 +86,13 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect /** * Generates an AutoMap from a Array. - * + * * @param aArray - Data to be inserted into the AutoMap. */ public AutoMap(V[] aArray) { mInternalMap = new LinkedHashMap<>(); mInternalNameMap = new LinkedHashMap<>(); - if (aArray != null && aArray.length > 0) { + if (aArray != null) { for (V obj : aArray) { add(obj); } @@ -107,12 +107,8 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect public synchronized boolean setValue(V object) { int mOriginalID = this.mInternalID; put(object); - if (this.mInternalMap.get(mOriginalID) - .equals(object) || mOriginalID > this.mInternalID) { - return true; - } else { - return false; - } + return this.mInternalMap.get(mOriginalID) + .equals(object) || mOriginalID > this.mInternalID; } public synchronized V put(V object) { @@ -168,7 +164,6 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect this.mInternalID = 0; this.mInternalMap.clear(); this.mInternalNameMap.clear(); - return; } @Override @@ -322,7 +317,6 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect for (V of : mInternalMap.values()) { if (of != o) { aCount++; - continue; } else { return aCount; } @@ -353,9 +347,7 @@ public class AutoMap implements Iterable, Cloneable, Serializable, Collect AutoMap aNewSubList = new AutoMap<>(); for (int slot = fromIndex; slot <= toIndex; slot++) { V obj = mInternalMap.get(slot); - if (obj == null) { - continue; - } else { + if (obj != null) { aNewSubList.put(obj); } } diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java index b0ee1c0c77..7ba3e7e474 100644 --- a/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/main/java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -1,6 +1,5 @@ package gtPlusPlus.core.block.base; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Random; @@ -21,7 +20,6 @@ import cpw.mods.fml.common.registry.GameRegistry; import gregtech.GTMod; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.util.GTOreDictUnificator; import gtPlusPlus.api.interfaces.ITexturedBlock; @@ -30,7 +28,6 @@ import gtPlusPlus.core.item.base.itemblock.ItemBlockOre; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.objects.GTPPCopiedBlockTexture; import gtPlusPlus.xmod.gregtech.api.objects.GTPPRenderedTexture; @@ -100,13 +97,6 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { return Blocks.stone.getIcon(0, 0); } - /** - * GT Texture Handler - */ - - // .08 compat - public static IIconContainer[] hiddenTextureArray; - @Override public ITexture[] getTexture(ForgeDirection side) { return getTexture(null, side); @@ -120,21 +110,8 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { this.blockMaterial.getRGBA()); return new ITexture[] { new GTPPCopiedBlockTexture(Blocks.stone, 0, 0), aIconSet }; } - - if (hiddenTextureArray == null) { - try { - Field o = ReflectionUtils.getField(Textures.BlockIcons.class, "STONES"); - if (o != null) { - hiddenTextureArray = (IIconContainer[]) o.get(Textures.BlockIcons.class); - } - if (hiddenTextureArray == null) { - hiddenTextureArray = new IIconContainer[6]; - } - } catch (IllegalArgumentException | IllegalAccessException e) { - hiddenTextureArray = new IIconContainer[6]; - } - } - return new ITexture[] { new GTPPRenderedTexture(hiddenTextureArray[0], new short[] { 240, 240, 240, 0 }) }; + return new ITexture[] { + new GTPPRenderedTexture(Textures.BlockIcons.STONES[0], new short[] { 240, 240, 240, 0 }) }; } @Override diff --git a/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java b/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java index 26e7d907d3..8f549364c1 100644 --- a/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java +++ b/src/main/java/gtPlusPlus/core/gui/widget/GuiValueField.java @@ -31,13 +31,7 @@ public class GuiValueField extends GuiTextField { } public boolean isBackgroundDrawingEnabled() { - Field enableBackgroundDrawing = ReflectionUtils.getField( - GuiTextField.class, - !PreloaderCore.DEV_ENVIRONMENT ? "field_146215_m" : "enableBackgroundDrawing"); - if (enableBackgroundDrawing != null) { - return ReflectionUtils.getFieldValue(enableBackgroundDrawing, this); - } - return true; + return this.getEnableBackgroundDrawing(); } public int getLineScrollOffset() { diff --git a/src/main/java/gtPlusPlus/core/handler/PacketHandler.java b/src/main/java/gtPlusPlus/core/handler/PacketHandler.java index 735d381706..9c5d6b25d2 100644 --- a/src/main/java/gtPlusPlus/core/handler/PacketHandler.java +++ b/src/main/java/gtPlusPlus/core/handler/PacketHandler.java @@ -22,7 +22,7 @@ public class PacketHandler { private static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(GTPlusPlus.ID); - public static final void init() { + public static void init() { registerMessage(PacketVolumetricFlaskGui.class, PacketVolumetricFlaskGui.class); registerMessage(PacketVolumetricFlaskGui2.class, PacketVolumetricFlaskGui2.class); } @@ -50,30 +50,29 @@ public class PacketHandler { /** * Send this message to the specified player. See {@link SimpleNetworkWrapper#sendTo(IMessage, EntityPlayerMP)} */ - public static final void sendTo(IMessage message, EntityPlayerMP player) { + public static void sendTo(IMessage message, EntityPlayerMP player) { INSTANCE.sendTo(message, player); } /** * Send this message to everyone within a certain range of a point. See - * {@link SimpleNetworkWrapper#sendToDimension(IMessage, NetworkRegistry.TargetPoint)} + * {@link SimpleNetworkWrapper#sendToAllAround(IMessage, NetworkRegistry.TargetPoint)} */ - public static final void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { + public static void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { INSTANCE.sendToAllAround(message, point); } /** * Sends a message to everyone within a certain range of the coordinates in the same dimension. */ - public static final void sendToAllAround(IMessage message, int dimension, double x, double y, double z, - double range) { + public static void sendToAllAround(IMessage message, int dimension, double x, double y, double z, double range) { sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range)); } /** * Sends a message to everyone within a certain range of the player provided. */ - public static final void sendToAllAround(IMessage message, EntityPlayer player, double range) { + public static void sendToAllAround(IMessage message, EntityPlayer player, double range) { sendToAllAround(message, player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, range); } @@ -81,14 +80,14 @@ public class PacketHandler { * Send this message to everyone within the supplied dimension. See * {@link SimpleNetworkWrapper#sendToDimension(IMessage, int)} */ - public static final void sendToDimension(IMessage message, int dimensionId) { + public static void sendToDimension(IMessage message, int dimensionId) { INSTANCE.sendToDimension(message, dimensionId); } /** * Send this message to the server. See {@link SimpleNetworkWrapper#sendToServer(IMessage)} */ - public static final void sendToServer(IMessage message) { + public static void sendToServer(IMessage message) { INSTANCE.sendToServer(message); } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java b/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java index 4bbf29c88f..4c7dc05804 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/AgriculturalChem.java @@ -1,7 +1,6 @@ package gtPlusPlus.core.item.chemistry; import static gregtech.api.enums.Mods.BiomesOPlenty; -import static gregtech.api.enums.Mods.Forestry; import static gregtech.api.enums.Mods.TinkerConstruct; import static gregtech.api.recipe.RecipeMaps.centrifugeRecipes; import static gregtech.api.recipe.RecipeMaps.compressorRecipes; @@ -12,7 +11,6 @@ import static gregtech.api.util.GTRecipeConstants.UniversalChemical; import static gtPlusPlus.api.recipe.GTPPRecipeMaps.chemicalDehydratorRecipes; import static gtPlusPlus.api.recipe.GTPPRecipeMaps.semiFluidFuels; -import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; @@ -23,8 +21,12 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import forestry.core.items.ItemForestryBonemeal; +import forestry.core.items.ItemRegistryCore; +import forestry.plugins.PluginCore; import gregtech.api.enums.GTValues; import gregtech.api.enums.Materials; +import gregtech.api.enums.Mods; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TierEU; import gregtech.api.util.GTOreDictUnificator; @@ -37,7 +39,6 @@ import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.plugin.agrichem.BioRecipes; import gtPlusPlus.plugin.agrichem.item.algae.ItemAgrichemBase; import gtPlusPlus.plugin.agrichem.item.algae.ItemAlgaeBase; @@ -543,33 +544,19 @@ public class AgriculturalChem extends ItemPackage { ItemStack aManureByprod = ItemUtils.getSimpleStack(dustManureByproducts, 1); // Dehydrate Organise Fert to Normal Fert. + if (Mods.Forestry.isModLoaded()) { + ItemRegistryCore aItemRegInstance = PluginCore.items; + if (aItemRegInstance != null) { + ItemForestryBonemeal fertilizerCompound = aItemRegInstance.fertilizerCompound; + aFertForestry = ItemUtils.getSimpleStack(fertilizerCompound); - /* - * Forestry Support - */ - if (Forestry.isModLoaded()) { - Field aItemField = ReflectionUtils - .getField(ReflectionUtils.getClass("forestry.plugins.PluginCore"), "items"); - try { - Object aItemRegInstance = aItemField != null ? aItemField.get(aItemField) : null; - if (aItemRegInstance != null) { - Field aFertField = ReflectionUtils.getField(aItemRegInstance.getClass(), "fertilizerCompound"); - Object aItemInstance = aFertField.get(aItemRegInstance); - if (aItemInstance instanceof Item aForestryFert) { - aFertForestry = ItemUtils.getSimpleStack((Item) aItemInstance); - - GTValues.RA.stdBuilder() - .itemInputs( - GTUtility.getIntegratedCircuit(11), - ItemUtils.getSimpleStack(aDustOrganicFert, 4)) - .itemOutputs(ItemUtils.getSimpleStack(aForestryFert, 3), aManureByprod, aManureByprod) - .outputChances(100_00, 20_00, 20_00) - .eut(240) - .duration(20 * SECONDS) - .addTo(chemicalDehydratorRecipes); - } - } - } catch (IllegalArgumentException | IllegalAccessException e) { + GTValues.RA.stdBuilder() + .itemInputs(GTUtility.getIntegratedCircuit(11), ItemUtils.getSimpleStack(aDustOrganicFert, 4)) + .itemOutputs(ItemUtils.getSimpleStack(fertilizerCompound, 3), aManureByprod, aManureByprod) + .outputChances(100_00, 20_00, 20_00) + .eut(240) + .duration(20 * SECONDS) + .addTo(chemicalDehydratorRecipes); } } diff --git a/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java b/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java index 078dcdee88..4909d269cc 100644 --- a/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java +++ b/src/main/java/gtPlusPlus/core/item/chemistry/MilledOreProcessing.java @@ -14,6 +14,8 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; +import biomesoplenty.api.content.BOPCBlocks; +import biomesoplenty.api.content.BOPCItems; import gregtech.api.enums.GTValues; import gregtech.api.enums.Materials; import gregtech.api.enums.TierEU; @@ -33,7 +35,6 @@ import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; -import gtPlusPlus.xmod.bop.BiomesOPlentyHandler; import gtPlusPlus.xmod.bop.blocks.BOPBlockRegistrator; import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler; @@ -654,10 +655,10 @@ public class MilledOreProcessing extends ItemPackage { aPinecones.add(ItemUtils.getSimpleStack(AgriculturalChem.mPinecone, 1)); if (BiomesOPlenty.isModLoaded()) { - aLogs.add(BiomesOPlentyHandler.getStack(BiomesOPlentyHandler.logs4, 0, 1)); - aLeaves.add(BiomesOPlentyHandler.getStack(BiomesOPlentyHandler.colorizedLeaves2, 1, 1)); - aSaplings.add(BiomesOPlentyHandler.getStack(BiomesOPlentyHandler.colorizedSaplings, 5, 1)); - aPinecones.add(ItemUtils.simpleMetaStack(BiomesOPlentyHandler.mPineCone, 13, 1)); + aLogs.add(ItemUtils.simpleMetaStack(BOPCBlocks.logs4, 0, 1)); + aLeaves.add(ItemUtils.simpleMetaStack(BOPCBlocks.colorizedLeaves2, 1, 1)); + aSaplings.add(ItemUtils.simpleMetaStack(BOPCBlocks.colorizedSaplings, 5, 1)); + aPinecones.add(ItemUtils.simpleMetaStack(BOPCItems.misc, 13, 1)); } if (Forestry.isModLoaded()) { ItemStack aForestryLog = ItemUtils.getItemStackFromFQRN("Forestry:logs", 1); diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/ItemGregtechPump.java b/src/main/java/gtPlusPlus/core/item/tool/misc/ItemGregtechPump.java index 082f74ad2b..1c896e8497 100644 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/ItemGregtechPump.java +++ b/src/main/java/gtPlusPlus/core/item/tool/misc/ItemGregtechPump.java @@ -1238,7 +1238,7 @@ public class ItemGregtechPump extends Item implements ISpecialElectricItem, IEle if (aTileEntity == null) { return null; } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();; + final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null || aMetaTileEntity instanceof MTEHatchMultiInput) { // blacklist multiinput hatch as it's too complex return null; diff --git a/src/main/java/gtPlusPlus/core/lib/GTPPCore.java b/src/main/java/gtPlusPlus/core/lib/GTPPCore.java index c78d734cb6..af6bedfa61 100644 --- a/src/main/java/gtPlusPlus/core/lib/GTPPCore.java +++ b/src/main/java/gtPlusPlus/core/lib/GTPPCore.java @@ -6,23 +6,17 @@ import java.util.List; import java.util.Map; import java.util.Random; import java.util.UUID; -import java.util.WeakHashMap; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Supplier; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -import com.mojang.authlib.GameProfile; import cpw.mods.fml.common.FMLCommonHandler; import gregtech.GT_Version; import gregtech.api.objects.XSTR; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.preloader.PreloaderCore; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.common.tileentities.automation.MTETesseractGenerator; @@ -30,8 +24,6 @@ import gtPlusPlus.xmod.gregtech.common.tileentities.automation.MTETesseractTermi public class GTPPCore { - public static Map PlayerCache; - // Math Related public static final float PI = (float) Math.PI; public static volatile Random RANDOM = new XSTR(); @@ -48,11 +40,6 @@ public class GTPPCore { public static int turbineCutoffBase = 75000; - // GT++ Fake Player Profile - public static final GameProfile gameProfile = new GameProfile( - UUID.nameUUIDFromBytes("gtplusplus.core".getBytes()), - "[GT++]"); - public static final WeakHashMap fakePlayerCache = new WeakHashMap<>(); // Tooltips; public static final Supplier GT_Tooltip = () -> StatCollector.translateToLocal("GTPP.core.GT_Tooltip"); public static final Supplier GT_Tooltip_Builder = () -> StatCollector @@ -202,34 +189,19 @@ public class GTPPCore { public static final String VERSION = GT_Version.VERSION; } - public static final void crash() { + public static void crash() { crash("Generic Crash"); } - public static final void crash(String aReason) { + public static void crash(String aReason) { try { Logger.INFO("=========================================================="); Logger.INFO("[GT++ CRASH]"); Logger.INFO("=========================================================="); Logger.INFO("Oooops..."); - Logger.INFO("This should only happy in a development environment or when something really bad happens."); + Logger.INFO("This should only happen in a development environment or when something really bad happens."); Logger.INFO("Reason: " + aReason); Logger.INFO("=========================================================="); - Logger.INFO("Called from: " + ReflectionUtils.getMethodName(1)); - Logger.INFO(ReflectionUtils.getMethodName(2)); - Logger.INFO(ReflectionUtils.getMethodName(3)); - Logger.INFO(ReflectionUtils.getMethodName(4)); - Logger.INFO(ReflectionUtils.getMethodName(5)); - Logger.INFO(ReflectionUtils.getMethodName(6)); - Logger.INFO(ReflectionUtils.getMethodName(7)); - Logger.INFO(ReflectionUtils.getMethodName(8)); - Logger.INFO(ReflectionUtils.getMethodName(9)); - Logger.INFO(ReflectionUtils.getMethodName(10)); - Logger.INFO(ReflectionUtils.getMethodName(11)); - Logger.INFO(ReflectionUtils.getMethodName(12)); - Logger.INFO(ReflectionUtils.getMethodName(13)); - Logger.INFO(ReflectionUtils.getMethodName(14)); - Logger.INFO(ReflectionUtils.getMethodName(15)); } catch (Throwable t) { t.printStackTrace(); } diff --git a/src/main/java/gtPlusPlus/core/material/MaterialStack.java b/src/main/java/gtPlusPlus/core/material/MaterialStack.java index d4d11781c5..aeb23a9455 100644 --- a/src/main/java/gtPlusPlus/core/material/MaterialStack.java +++ b/src/main/java/gtPlusPlus/core/material/MaterialStack.java @@ -8,7 +8,6 @@ import net.minecraft.item.ItemStack; import gregtech.api.enums.OrePrefixes; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.bartworks.BWUtils; public class MaterialStack { @@ -69,11 +68,7 @@ public class MaterialStack { public Material getStackMaterial() { if (this.stackMaterial == null) { - Logger.MATERIALS("Tried getStackMaterial, got an invalid material."); - Logger.MATERIALS(ReflectionUtils.getMethodName(0)); - Logger.MATERIALS(ReflectionUtils.getMethodName(1)); - Logger.MATERIALS(ReflectionUtils.getMethodName(2)); - Logger.MATERIALS(ReflectionUtils.getMethodName(3)); + Logger.modLogger.error("Tried getStackMaterial, got an invalid material.", new Exception()); return null; } return this.stackMaterial; diff --git a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java index 66378f0f7a..c91476f556 100644 --- a/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java +++ b/src/main/java/gtPlusPlus/core/tileentities/machines/TileEntityPestKiller.java @@ -1,7 +1,5 @@ package gtPlusPlus.core.tileentities.machines; -import static gregtech.api.enums.Mods.Forestry; - import java.util.ArrayList; import java.util.List; @@ -27,6 +25,8 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.oredict.OreDictionary; +import forestry.lepidopterology.entities.EntityButterfly; +import gregtech.api.enums.Mods; import gregtech.api.util.GTUtility; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; @@ -36,7 +36,6 @@ import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.EntityUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; public class TileEntityPestKiller extends TileEntity implements ISidedInventory, IFluidHandler { @@ -56,8 +55,8 @@ public class TileEntityPestKiller extends TileEntity implements ISidedInventory, static { mEntityMap.put(EntityBat.class); - if (Forestry.isModLoaded()) { - mEntityMap.put(ReflectionUtils.getClass("forestry.lepidopterology.entities.EntityButterfly")); + if (Mods.Forestry.isModLoaded()) { + mEntityMap.put(EntityButterfly.class); } } diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java index 1e211290cd..26d7783b78 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/ItemUtils.java @@ -46,7 +46,6 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.preloader.PreloaderCore; import gtPlusPlus.xmod.gregtech.api.items.GTMetaTool; import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; @@ -309,11 +308,7 @@ public class ItemUtils { public static ItemStack getItemStackOfAmountFromOreDictNoBroken(String oredictName, final int amount) { if (PreloaderCore.DEBUG_MODE) { - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(1)); - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(2)); - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(3)); - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(4)); - Logger.WARNING("Looking up: " + oredictName + " - from method: " + ReflectionUtils.getMethodName(5)); + Logger.modLogger.warn("Looking up: " + oredictName + " - from : ", new Exception()); } try { diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java index 16e5652e82..8845409da9 100644 --- a/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java +++ b/src/main/java/gtPlusPlus/core/util/minecraft/MiningUtils.java @@ -2,10 +2,14 @@ package gtPlusPlus.core.util.minecraft; import java.util.HashMap; +import gregtech.api.enums.Mods; import gregtech.common.WorldgenGTOreLayer; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.util.reflect.ReflectionUtils; +import micdoodle8.mods.galacticraft.core.util.ConfigManagerCore; +import micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids; +import micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars; public class MiningUtils { @@ -48,42 +52,17 @@ public class MiningUtils { public static boolean findAndMapOreTypesFromGT() { // Gets Moon ID - boolean aEndAsteroids; - try { - if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore") != null - && mMoonID == -99) { - mMoonID = ReflectionUtils - .getField( - ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.util.ConfigManagerCore"), - "idDimensionMoon") - .getInt(null); + if (Mods.GalacticraftCore.isModLoaded()) { + if (mMoonID == -99) { + mMoonID = ConfigManagerCore.idDimensionMoon; } - } catch (IllegalArgumentException | IllegalAccessException ignored) {} - - // Gets Mars ID - try { - if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars") != null - && mMarsID == -99) { - mMarsID = ReflectionUtils - .getField( - ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.mars.ConfigManagerMars"), - "dimensionIDMars") - .getInt(null); + if (mMarsID == -99) { + mMarsID = ConfigManagerMars.dimensionIDMars; } - } catch (IllegalArgumentException | IllegalAccessException ignored) {} - - // Get Comets ID - try { - if (ReflectionUtils.getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids") - != null && mCometsID == -99) { - mCometsID = ReflectionUtils - .getField( - ReflectionUtils - .getClass("micdoodle8.mods.galacticraft.planets.asteroids.ConfigManagerAsteroids"), - "dimensionIDAsteroids") - .getInt(null); + if (mCometsID == -99) { + mCometsID = ConfigManagerAsteroids.dimensionIDAsteroids; } - } catch (IllegalArgumentException | IllegalAccessException ignored) {} + } // Clear Cache Ores_Overworld.clear(); @@ -91,32 +70,23 @@ public class MiningUtils { Ores_End.clear(); Ores_Misc.clear(); - for (WorldgenGTOreLayer x : WorldgenGTOreLayer.sList) { - if (x.mEnabled) { - - try { - aEndAsteroids = ReflectionUtils.getField(WorldgenGTOreLayer.class, "mEndAsteroid") - .getBoolean(x); - } catch (IllegalArgumentException | IllegalAccessException e) { - aEndAsteroids = false; + for (WorldgenGTOreLayer gtOreLayer : WorldgenGTOreLayer.sList) { + if (gtOreLayer.mEnabled) { + if (gtOreLayer.mOverworld) { + Ores_Overworld.put(gtOreLayer); } - - if (x.mOverworld) { - Ores_Overworld.put(x); - } - if (x.mNether) { - Ores_Nether.put(x); + if (gtOreLayer.mNether) { + Ores_Nether.put(gtOreLayer); } - if (x.mEnd || aEndAsteroids) { - Ores_End.put(x); + if (gtOreLayer.mEnd || gtOreLayer.mEndAsteroid) { + Ores_End.put(gtOreLayer); } - if (x.mOverworld || x.mNether || (x.mEnd || aEndAsteroids)) { + if (gtOreLayer.mOverworld || gtOreLayer.mNether || (gtOreLayer.mEnd || gtOreLayer.mEndAsteroid)) { continue; } - - Ores_Misc.put(x); + Ores_Misc.put(gtOreLayer); } else { - Ores_Comets.put(x); + Ores_Comets.put(gtOreLayer); } } diff --git a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java index 078cef6ea8..576c236de6 100644 --- a/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java +++ b/src/main/java/gtPlusPlus/core/util/reflect/ReflectionUtils.java @@ -126,7 +126,7 @@ public class ReflectionUtils { /** * Returns a cached {@link Constructor} object. - * + * * @param aClass - Class containing the Constructor. * @param aTypes - Varags Class Types for objects constructor. * @return - Valid, non-final, {@link Method} object, or {@link null}. @@ -155,7 +155,7 @@ public class ReflectionUtils { /** * Returns a cached {@link Class} object. - * + * * @param aClassCanonicalName - The canonical name of the underlying class. * @return - Valid, {@link Class} object, or {@link null}. */ @@ -176,7 +176,7 @@ public class ReflectionUtils { /** * Returns a cached {@link Method} object. Wraps {@link #getMethod(Class, String, Class...)}. - * + * * @param aObject - Object containing the Method. * @param aMethodName - Method's name in {@link String} form. * @param aTypes - Class Array of Types for {@link Method}'s constructor. @@ -188,7 +188,7 @@ public class ReflectionUtils { /** * Returns a cached {@link Method} object. - * + * * @param aClass - Class containing the Method. * @param aMethodName - Method's name in {@link String} form. * @param aTypes - Varags Class Types for {@link Method}'s constructor. @@ -217,7 +217,7 @@ public class ReflectionUtils { /** * Returns a cached {@link Field} object. - * + * * @param aClass - Class containing the Method. * @param aFieldName - Field name in {@link String} form. * @return - Valid, non-final, {@link Field} object, or {@link null}. @@ -246,7 +246,7 @@ public class ReflectionUtils { /** * Returns a cached {@link Field} object. - * + * * @param aInstance - {@link Object} to get the field instance from. * @param aFieldName - Field name in {@link String} form. * @return - Valid, non-final, {@link Field} object, or {@link null}. @@ -286,7 +286,7 @@ public class ReflectionUtils { /** * Get the method name for a depth in call stack.
* Utility function - * + * * @param depth depth in the call stack (0 means current method, 1 means call method, ...) * @return Method name */ @@ -323,14 +323,6 @@ public class ReflectionUtils { return loaded > 0; } - public static void loadClass(String aClassName) { - try { - Class.forName(aClassName, true, ReflectionUtils.class.getClassLoader()); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - public static boolean setField(final Object object, final String fieldName, final Object fieldValue) { Class clazz; if (object instanceof Class) { diff --git a/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java b/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java index 8a6d189898..b7784580fd 100644 --- a/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java +++ b/src/main/java/gtPlusPlus/plugin/agrichem/item/algae/ItemAgrichemBase.java @@ -2,12 +2,9 @@ package gtPlusPlus.plugin.agrichem.item.algae; import static gregtech.api.enums.Mods.GTPlusPlus; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -23,7 +20,6 @@ import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.core.item.chemistry.general.ItemGenericChemBase; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.OreDictUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; public class ItemAgrichemBase extends Item { @@ -150,24 +146,6 @@ public class ItemAgrichemBase extends Item { } } - private boolean isTextureValid(String aPath) { - if (aPath == null) { - return false; - } else if (aPath.indexOf(92) == -1) { - Constructor aTextureAtlasSprite = ReflectionUtils.getConstructor(TextureAtlasSprite.class, String.class); - if (aTextureAtlasSprite != null) { - try { - TextureAtlasSprite aTestAtlas = (TextureAtlasSprite) aTextureAtlasSprite.newInstance(aPath); - if (aTestAtlas != null) { - return true; - } - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) {} - } - } - return false; - } - @Override public IIcon getIconFromDamageForRenderPass(final int damage, final int pass) { return this.base[damage]; diff --git a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java b/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java index bf69ead5e2..31c0a2e41c 100644 --- a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java +++ b/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java @@ -15,6 +15,7 @@ import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.plugin.fixes.interfaces.IBugFix; import gtPlusPlus.preloader.PreloaderCore; +// TODO move this as a mixin in hodgepodge public class VanillaBedHeightFix implements IBugFix { private final Method mSleepInBedAt; diff --git a/src/main/java/gtPlusPlus/xmod/bop/BiomesOPlentyHandler.java b/src/main/java/gtPlusPlus/xmod/bop/BiomesOPlentyHandler.java index b1e97782af..272b2dacf5 100644 --- a/src/main/java/gtPlusPlus/xmod/bop/BiomesOPlentyHandler.java +++ b/src/main/java/gtPlusPlus/xmod/bop/BiomesOPlentyHandler.java @@ -1,178 +1,27 @@ package gtPlusPlus.xmod.bop; -import static gregtech.api.enums.Mods.BiomesOPlenty; - -import java.lang.reflect.Field; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import biomesoplenty.api.content.BOPCItems; +import gregtech.api.enums.Mods; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.bop.blocks.BOPBlockRegistrator; public class BiomesOPlentyHandler { - public static Item mPineCone; - - public static Block logs1; - public static Block logs2; - public static Block logs3; - public static Block logs4; - - public static Block leaves1; - public static Block leaves2; - public static Block leaves3; - public static Block leaves4; - - public static Block colorizedLeaves1; - public static Block colorizedLeaves2; - - public static Block saplings; - public static Block colorizedSaplings; - public static void preInit() { BOPBlockRegistrator.run(); - if (BiomesOPlenty.isModLoaded()) { - setFields(); - registerPineconeToOreDict(); + if (Mods.BiomesOPlenty.isModLoaded()) { + if (BOPCItems.misc != null) { + ItemStack aPinecone = ItemUtils.simpleMetaStack(BOPCItems.misc, 13, 1); + if (aPinecone != null) { + ItemUtils.addItemToOreDictionary(aPinecone, "pinecone"); + } + } } } public static void postInit() { BOPBlockRegistrator.recipes(); } - - private static void registerPineconeToOreDict() { - if (mPineCone != null) { - ItemStack aPinecone = ItemUtils.simpleMetaStack(mPineCone, 13, 1); - if (aPinecone != null) { - ItemUtils.addItemToOreDictionary(aPinecone, "pinecone"); - } - } - } - - public static ItemStack getStack(Block aBlock, int aMeta, int aSize) { - return ItemUtils.simpleMetaStack(aBlock, aMeta, aSize); - } - - // BOPCBlocks.logs4 - 0 - // BOPCBlocks.colorizedLeaves2 - 1 - - private static void setFields() { - Field aBopMiscItem = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCItems"), "misc"); - - Field aBopBlock1 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs1"); - Field aBopBlock2 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs2"); - Field aBopBlock3 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs3"); - Field aBopBlock4 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "logs4"); - - Field aBopLeaves1 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves1"); - Field aBopLeaves2 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves2"); - Field aBopLeaves3 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves3"); - Field aBopLeaves4 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "leaves4"); - - Field aBopColouredLeaves1 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedLeaves1"); - Field aBopColouredLeaves2 = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedLeaves2"); - - Field aBopSapling = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "saplings"); - Field aBopColouredSapling = ReflectionUtils - .getField(ReflectionUtils.getClass("biomesoplenty.api.content.BOPCBlocks"), "colorizedSaplings"); - - if (aBopMiscItem != null) { - Item aMiscItem = ReflectionUtils.getFieldValue(aBopMiscItem); - if (aMiscItem != null) { - mPineCone = aMiscItem; - } - } - - if (aBopBlock1 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopBlock1); - if (aBlock != null) { - logs1 = aBlock; - } - } - if (aBopBlock2 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopBlock2); - if (aBlock != null) { - logs2 = aBlock; - } - } - if (aBopBlock3 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopBlock3); - if (aBlock != null) { - logs3 = aBlock; - } - } - if (aBopBlock4 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopBlock4); - if (aBlock != null) { - logs4 = aBlock; - } - } - - if (aBopLeaves1 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves1); - if (aBlock != null) { - leaves1 = aBlock; - } - } - if (aBopLeaves2 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves2); - if (aBlock != null) { - leaves2 = aBlock; - } - } - if (aBopLeaves3 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves3); - if (aBlock != null) { - leaves3 = aBlock; - } - } - if (aBopLeaves4 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopLeaves4); - if (aBlock != null) { - leaves4 = aBlock; - } - } - - if (aBopColouredLeaves1 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopColouredLeaves1); - if (aBlock != null) { - colorizedLeaves1 = aBlock; - } - } - if (aBopColouredLeaves2 != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopColouredLeaves2); - if (aBlock != null) { - colorizedLeaves2 = aBlock; - } - } - - if (aBopSapling != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopSapling); - if (aBlock != null) { - saplings = aBlock; - } - } - if (aBopColouredSapling != null) { - Block aBlock = ReflectionUtils.getFieldValue(aBopColouredSapling); - if (aBlock != null) { - colorizedSaplings = aBlock; - } - } - } } diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BeeDefinition.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BeeDefinition.java index 11397e3ef3..95813e45bd 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BeeDefinition.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_BeeDefinition.java @@ -8,7 +8,6 @@ import static forestry.api.apiculture.EnumBeeChromosome.TEMPERATURE_TOLERANCE; import static forestry.api.core.EnumHumidity.ARID; import static gregtech.api.enums.Mods.Forestry; -import java.lang.reflect.Field; import java.util.Arrays; import java.util.Locale; import java.util.function.Consumer; @@ -47,7 +46,6 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialsElements.STANDALONE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.MaterialUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.forestry.bees.handler.GTPPCombType; public enum GTPP_BeeDefinition implements IBeeDefinition { @@ -65,7 +63,11 @@ public enum GTPP_BeeDefinition implements IBeeDefinition { AlleleHelper.instance.set(template, TEMPERATURE_TOLERANCE, Tolerance.BOTH_3); AlleleHelper.instance.set(template, HUMIDITY_TOLERANCE, Tolerance.BOTH_3); }, dis -> { - IBeeMutationCustom tMutation = dis.registerMutation("DRAGONESSENCE", "NEUTRONIUM", 2); + IBeeMutationCustom tMutation = dis.registerMutation( + GTBeeDefinition.DRAGONESSENCE.getSpecies(), + GTBeeDefinition.NEUTRONIUM.getSpecies(), + 2, + 1f); tMutation.restrictHumidity(ARID); tMutation.requireResource(STANDALONE.DRAGON_METAL.getBlock(), 1); tMutation.addMutationCondition(new GTBees.DimensionMutationCondition(1, "End")); // End Dim @@ -84,7 +86,8 @@ public enum GTPP_BeeDefinition implements IBeeDefinition { AlleleHelper.instance.set(template, TEMPERATURE_TOLERANCE, Tolerance.BOTH_1); AlleleHelper.instance.set(template, HUMIDITY_TOLERANCE, Tolerance.BOTH_1); }, dis -> { - IBeeMutationCustom tMutation = dis.registerMutation("STEEL", "GOLD", 10); + IBeeMutationCustom tMutation = dis + .registerMutation(GTBeeDefinition.STEEL.getSpecies(), GTBeeDefinition.GOLD.getSpecies(), 10, 1f); tMutation.restrictHumidity(ARID); tMutation.restrictBiomeType(BiomeDictionary.Type.HOT); }),; @@ -185,15 +188,15 @@ public enum GTPP_BeeDefinition implements IBeeDefinition { return ret; } - private final void setSpeciesProperties(GTPPAlleleBeeSpecies species2) { + private void setSpeciesProperties(GTPPAlleleBeeSpecies species2) { this.mSpeciesProperties.accept(species2); } - private final void setAlleles(IAllele[] template) { + private void setAlleles(IAllele[] template) { this.mAlleles.accept(template); } - private final void registerMutations() { + private void registerMutations() { this.mMutations.accept(this); } @@ -209,59 +212,47 @@ public enum GTPP_BeeDefinition implements IBeeDefinition { BeeManager.beeRoot.registerTemplate(template); } - private final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, - int chance) { + private IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, int chance) { return registerMutation(parent1, parent2, chance, 1f); } - private final IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, IAlleleBeeSpecies parent2, - int chance) { + private IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, IAlleleBeeSpecies parent2, int chance) { return registerMutation(parent1, parent2, chance, 1f); } - private final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, GTPP_BeeDefinition parent2, - int chance) { + private IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, GTPP_BeeDefinition parent2, int chance) { return registerMutation(parent1, parent2, chance, 1f); } - private final IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, GTPP_BeeDefinition parent2, - int chance) { + private IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, GTPP_BeeDefinition parent2, int chance) { return registerMutation(parent1, parent2, chance, 1f); } - private final IBeeMutationCustom registerMutation(String parent1, String parent2, int chance) { - return registerMutation(getGregtechBeeType(parent1), getGregtechBeeType(parent2), chance, 1f); - } - /** * Diese neue Funtion erlaubt Mutationsraten unter 1%. Setze dazu die Mutationsrate als Bruch mit chance / * chancedivider This new function allows Mutation percentages under 1%. Set them as a fraction with chance / * chancedivider */ - private final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, int chance, + private IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, IAlleleBeeSpecies parent2, int chance, float chancedivider) { return new GTPPBeeMutation(parent1, parent2, this.getTemplate(), chance, chancedivider); } - private final IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, IAlleleBeeSpecies parent2, int chance, + private IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, IAlleleBeeSpecies parent2, int chance, float chancedivider) { return registerMutation(parent1.species, parent2, chance, chancedivider); } - private final IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, GTPP_BeeDefinition parent2, int chance, + private IBeeMutationCustom registerMutation(IAlleleBeeSpecies parent1, GTPP_BeeDefinition parent2, int chance, float chancedivider) { return registerMutation(parent1, parent2.species, chance, chancedivider); } - private final IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, GTPP_BeeDefinition parent2, - int chance, float chancedivider) { + private IBeeMutationCustom registerMutation(GTPP_BeeDefinition parent1, GTPP_BeeDefinition parent2, int chance, + float chancedivider) { return registerMutation(parent1.species, parent2, chance, chancedivider); } - private final IBeeMutationCustom registerMutation(String parent1, String parent2, int chance, float chancedivider) { - return registerMutation(getGregtechBeeType(parent1), getGregtechBeeType(parent2), chance, chancedivider); - } - @Override public final IAllele[] getTemplate() { return Arrays.copyOf(template, template.length); @@ -285,16 +276,4 @@ public enum GTPP_BeeDefinition implements IBeeDefinition { public final IBeeDefinition getRainResist() { return new BeeVariation.RainResist(this); } - - public static IAlleleBeeSpecies getGregtechBeeType(String name) { - try { - // This is still cursed, but the species field is private and I don't want to go modify that right now - GTBeeDefinition aBeeObject = GTBeeDefinition.valueOf(name); - Field gtBeesField = ReflectionUtils.getField(GTBeeDefinition.class, "species"); - return ReflectionUtils.getFieldValue(gtBeesField, aBeeObject); - } catch (Throwable t) { - t.printStackTrace(); - return null; - } - } } diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bees.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bees.java index bfdddcca8b..7ba5bc326a 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bees.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/registry/GTPP_Bees.java @@ -7,7 +7,6 @@ import java.util.HashMap; import gregtech.GTMod; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.forestry.bees.handler.GTPPCombType; import gtPlusPlus.xmod.forestry.bees.handler.GTPPDropType; import gtPlusPlus.xmod.forestry.bees.handler.GTPPPollenType; @@ -45,7 +44,12 @@ public class GTPP_Bees { combs = new GTPPComb(); Logger.BEES("Loading types."); - initTypes(); + // call values() to force initialization of enum entries + GTPP_BeeDefinition.values(); + GTPPCombType.values(); + GTPPDropType.values(); + GTPPPollenType.values(); + GTPPPropolisType.values(); Logger.BEES("Adding recipes."); GTPPDrop.initDropsRecipes(); @@ -58,13 +62,4 @@ public class GTPP_Bees { Logger.BEES("Done!"); } } - - private static void initTypes() { - // This is stupid - ReflectionUtils.loadClass(GTPP_BeeDefinition.class.getName()); - ReflectionUtils.loadClass(GTPPCombType.class.getName()); - ReflectionUtils.loadClass(GTPPDropType.class.getName()); - ReflectionUtils.loadClass(GTPPPollenType.class.getName()); - ReflectionUtils.loadClass(GTPPPropolisType.class.getName()); - } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java index 43e43a1d4e..90db739be7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchNaquadah.java @@ -120,30 +120,26 @@ public class MTEHatchNaquadah extends MTEHatchInput { private static String[] aDescCache = new String[3]; - private String formatFluidString(FluidStack f) { - FluidStack mLockedStack = f; - Integer mLockedTemp = 0;; - String mTempMod = "" + EnumChatFormatting.RESET; - mLockedTemp = mLockedStack.getFluid() + private String formatFluidString(FluidStack fluidStack) { + String mTempMod = EnumChatFormatting.RESET.toString(); + int mLockedTemp = fluidStack.getFluid() .getTemperature(); - if (mLockedTemp != null) { - if (mLockedTemp <= -3000) { - mTempMod = "" + EnumChatFormatting.DARK_PURPLE; - } else if (mLockedTemp >= -2999 && mLockedTemp <= -500) { - mTempMod = "" + EnumChatFormatting.DARK_BLUE; - } else if (mLockedTemp >= -499 && mLockedTemp <= -50) { - mTempMod = "" + EnumChatFormatting.BLUE; - } else if (mLockedTemp >= 30 && mLockedTemp <= 300) { - mTempMod = "" + EnumChatFormatting.AQUA; - } else if (mLockedTemp >= 301 && mLockedTemp <= 800) { - mTempMod = "" + EnumChatFormatting.YELLOW; - } else if (mLockedTemp >= 801 && mLockedTemp <= 1500) { - mTempMod = "" + EnumChatFormatting.GOLD; - } else if (mLockedTemp >= 1501) { - mTempMod = "" + EnumChatFormatting.RED; - } + if (mLockedTemp <= -3000) { + mTempMod = "" + EnumChatFormatting.DARK_PURPLE; + } else if (mLockedTemp <= -500) { + mTempMod = "" + EnumChatFormatting.DARK_BLUE; + } else if (mLockedTemp <= -50) { + mTempMod = "" + EnumChatFormatting.BLUE; + } else if (mLockedTemp >= 30 && mLockedTemp <= 300) { + mTempMod = "" + EnumChatFormatting.AQUA; + } else if (mLockedTemp >= 301 && mLockedTemp <= 800) { + mTempMod = "" + EnumChatFormatting.YELLOW; + } else if (mLockedTemp >= 801 && mLockedTemp <= 1500) { + mTempMod = "" + EnumChatFormatting.GOLD; + } else if (mLockedTemp >= 1501) { + mTempMod = "" + EnumChatFormatting.RED; } - return mTempMod + mLockedStack.getLocalizedName(); + return mTempMod + fluidStack.getLocalizedName(); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java index 738afb0d90..b1af2451aa 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GTPPMultiBlockBase.java @@ -2,7 +2,6 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base; import static gregtech.api.util.GTUtility.filterValidMTEs; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -208,7 +207,7 @@ public abstract class GTPPMultiBlockBase aMap) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenRecycling.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenRecycling.java index 8fe051dd71..305422ccea 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenRecycling.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGenRecycling.java @@ -28,7 +28,6 @@ import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; public class RecipeGenRecycling implements Runnable { @@ -252,11 +251,7 @@ public class RecipeGenRecycling implements Runnable { public static ItemStack get(final Object aName, final ItemStack aReplacement, final long aAmount, final boolean aMentionPossibleTypos, final boolean aNoInvalidAmounts) { if (aNoInvalidAmounts && (aAmount < 1L)) { - Logger.WARNING("Returning Null. Method: " + ReflectionUtils.getMethodName(0)); - Logger.WARNING("Called from me