diff options
author | miozune <miozune@gmail.com> | 2023-02-08 17:40:18 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-08 09:40:18 +0100 |
commit | 8fd4fef38b18244b2e728dce895728b043c70ce7 (patch) | |
tree | dded1f4879b79a8e54b2e7f876083251d319222a /src/main/java/gtPlusPlus/xmod | |
parent | ef697bc6094a6a3ab43657ab02c4dec8751da831 (diff) | |
download | GT5-Unofficial-8fd4fef38b18244b2e728dce895728b043c70ce7.tar.gz GT5-Unofficial-8fd4fef38b18244b2e728dce895728b043c70ce7.tar.bz2 GT5-Unofficial-8fd4fef38b18244b2e728dce895728b043c70ce7.zip |
Remove a bunch of reflections against GT (#531)
* Remove a bunch of reflections against GT
* missed this one
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod')
33 files changed, 184 insertions, 1732 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java index 624d8161d6..00799a1030 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bee_Definition.java @@ -17,6 +17,7 @@ import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; import forestry.apiculture.genetics.*; import forestry.core.genetics.alleles.AlleleHelper; +import gregtech.loaders.misc.GT_BeeDefinition; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; @@ -575,16 +576,14 @@ public enum GTPP_Bee_Definition implements IBeeDefinition { } public static IAlleleBeeSpecies getGregtechBeeType(String name) { - Class<?> gtBees; try { - Class gtBeeTypes = Class.forName("gregtech.loaders.misc.GT_BeeDefinition"); - Enum gtBeeEnumObject = Enum.valueOf(gtBeeTypes, name); - Field gtBeesField = FieldUtils.getDeclaredField(gtBeeTypes, "species", true); + Enum<GT_BeeDefinition> gtBeeEnumObject = Enum.valueOf(GT_BeeDefinition.class, name); + Field gtBeesField = FieldUtils.getDeclaredField(GT_BeeDefinition.class, "species", true); gtBeesField.setAccessible(true); ReflectionUtils.makeFieldAccessible(gtBeesField); Object beeType = gtBeesField.get(gtBeeEnumObject); return (IAlleleBeeSpecies) beeType; - } catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException e) { + } catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); } return null; diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java index 9d49df7487..f5d37817ff 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/GTPP_Bees.java @@ -75,7 +75,6 @@ public class GTPP_Bees { private void setCustomItems() { dropForceGem = new BaseItemMisc("Force", new short[] { 250, 250, 20 }, 64, MiscTypes.GEM, null); - // mGregMatLoader.enableMaterial(Materials.Force); // MaterialUtils.tryEnableMaterial(Materials.Force); // MaterialUtils.tryEnableMaterialPart(OrePrefixes.dust, Materials.Force); // MaterialUtils.tryEnableMaterialPart(OrePrefixes.ingot, Materials.Force); @@ -85,8 +84,6 @@ public class GTPP_Bees { // Nikolite may not exist, so lets make it. dropNikoliteDust = ItemUtils .generateSpecialUseDusts("Nikolite", "Nikolite", Utils.rgbtoHexValue(60, 180, 200))[2]; - // mGregMatLoader.enableMaterial(Materials.BlueAlloy); - // mGregMatLoader.enableMaterial(Materials.Nikolite); // MaterialUtils.tryEnableMaterial(Materials.Nikolite); // MaterialUtils.tryEnableMaterialPart(OrePrefixes.dust, Materials.Nikolite); // MaterialUtils.tryEnableMaterialPart(OrePrefixes.ingot, Materials.Nikolite); diff --git a/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/ItemCustomComb.java b/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/ItemCustomComb.java index 60ffb8a051..43ab2fb191 100644 --- a/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/ItemCustomComb.java +++ b/src/main/java/gtPlusPlus/xmod/forestry/bees/custom/ItemCustomComb.java @@ -1,6 +1,5 @@ package gtPlusPlus.xmod.forestry.bees.custom; -import java.lang.reflect.Field; import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; @@ -9,8 +8,6 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import org.apache.commons.lang3.reflect.FieldUtils; - import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -187,7 +184,7 @@ public class ItemCustomComb extends Item { } public void addProcess(ItemStack tComb, Materials aMaterial, int chance) { - if (tryGetNerfBoolean()) { + if (GT_Mod.gregtechproxy.mNerfedCombs) { GT_Values.RA.addChemicalRecipe( GT_Utility.copyAmount(9, tComb), GT_OreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1), @@ -224,7 +221,7 @@ public class ItemCustomComb extends Item { } public void addProcess(ItemStack tComb, Materials aInMaterial, Materials aOutMaterial, int chance) { - if (tryGetNerfBoolean()) { + if (GT_Mod.gregtechproxy.mNerfedCombs) { GT_Values.RA.addChemicalRecipe( GT_Utility.copyAmount(9, tComb), GT_OreDictUnificator.get(OrePrefixes.crushed, aInMaterial, 1), @@ -259,15 +256,4 @@ public class ItemCustomComb extends Item { // ItemList.FR_Wax.get(1, new Object[0]), 0.3f)); } } - - private static boolean tryGetNerfBoolean() { - try { - Class mProxy = Class.forName("gregtech.GT_Mod.gregtechproxy"); - Field mNerf = FieldUtils.getDeclaredField(mProxy, "mNerfedCombs", true); - boolean returnValue = (boolean) mNerf.get(GT_Mod.gregtechproxy); - return returnValue; - } catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException e) { - return false; - } - } } 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 10d9929bc8..56383192c0 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 cpw.mods.fml.common.Loader; import gregtech.GT_Mod; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.forestry.bees.handler.*; @@ -34,13 +33,6 @@ public class GTPP_Bees { public GTPP_Bees() { if (Loader.isModLoaded(MOD_ID_FR) && GT_Mod.gregtechproxy.mGTBees) { - - if (!ReflectionUtils.doesClassExist("gregtech.loaders.misc.GT_BeeDefinition")) { - CORE.crash("Missing gregtech.loaders.misc.GT_BeeDefinition."); - } else { - Logger.BEES("Loading GT++ Bees!"); - } - Logger.BEES("Creating required items."); propolis = new GTPP_Propolis(); pollen = new GTPP_Pollen(); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java index 51f5697cc4..5eb536fa85 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/HANDLER_GT.java @@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import cpw.mods.fml.common.event.FMLLoadCompleteEvent; +import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Element; import gregtech.api.enums.ItemList; @@ -46,7 +47,6 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.minecraft.RecipeUtils; import gtPlusPlus.core.util.reflect.AddGregtechRecipe; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.everglades.gen.gt.WorldGen_GT; import gtPlusPlus.xmod.gregtech.api.enums.CustomOrePrefix; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; @@ -54,7 +54,6 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.util.GTPP_Config; import gtPlusPlus.xmod.gregtech.api.world.GTPP_Worldgen; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.fluid.GregtechFluidHandler; import gtPlusPlus.xmod.gregtech.common.computer.GT_ComputerCube_Setup; import gtPlusPlus.xmod.gregtech.common.computer.GT_Computercube_Description; @@ -71,7 +70,6 @@ import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_AlgaeFarm; import gtPlusPlus.xmod.gregtech.loaders.recipe.RecipeLoader_MolecularTransformer; import gtPlusPlus.xmod.gregtech.recipes.RecipesToRemove; import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechConduits; -import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechNitroDieselFix; public class HANDLER_GT { @@ -123,10 +121,6 @@ public class HANDLER_GT { new ProcessingElectricButcherKnife().run(); new ProcessingElectricLighter().run(); - if (CORE.ConfigSwitches.enableNitroFix) { - GregtechNitroDieselFix.run(); - } - // Register custom singles to the PA AddCustomMachineToPA.register(); @@ -233,18 +227,13 @@ public class HANDLER_GT { } private static void convertPyroToCokeOven() { - if (ReflectionUtils.doesFieldExist(GT_Recipe.GT_Recipe_Map.class, "sPyrolyseRecipes")) { - int aCount = 0; - GT_Recipe_Map aMap = StaticFields59.getPyrolyseRecipeMap(); - if (aMap != null) { - for (GT_Recipe g : aMap.mRecipeList) { - if (AddGregtechRecipe.importPyroRecipe(g)) { - aCount++; - } - } - Logger.INFO("Converted " + aCount + " Pyrolyse recipes into Industrial Coke Oven recipes."); + int aCount = 0; + for (GT_Recipe g : GT_Recipe_Map.sPyrolyseRecipes.mRecipeList) { + if (AddGregtechRecipe.importPyroRecipe(g)) { + aCount++; } } + Logger.INFO("Converted " + aCount + " Pyrolyse recipes into Industrial Coke Oven recipes."); } private static GT_Recipe replaceItemInRecipeWithAnother(GT_Recipe aRecipe, ItemStack aExisting, @@ -281,16 +270,6 @@ public class HANDLER_GT { } private static void removeOldHighTierCasingRecipes() { - - Logger.INFO("Trying to appropriately retier GT Machine Hulls/Casings from LuV+"); - final Object aHardCasingsTest = StaticFields59.getFieldFromGregtechProxy("mHardMachineCasings"); - - boolean aHardCasings = aHardCasingsTest != null ? (boolean) aHardCasingsTest : false; - - Logger.INFO( - "Are Hard casings/hulls enabled within GT? " - + (aHardCasingsTest == null ? "Version does not support config option" : aHardCasings)); - // Static objects to save memory ItemStack aCasing_LUV = CI.machineCasing_LuV; ItemStack aCasing_ZPM = CI.machineCasing_ZPM; @@ -445,7 +424,7 @@ public class HANDLER_GT { bits, new Object[] { "PPP", "PwP", "PPP", 'P', CI.getPlate(aTier_UV, 1) }); - if (!aHardCasings) { + if (!GT_Mod.gregtechproxy.mHardMachineCasings) { Logger.INFO("Adding new easy Shaped recipes for Hulls."); GT_ModHandler.addCraftingRecipe( ItemList.Hull_LuV.get(1), diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java index aae4494f88..60ccb1ae37 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java @@ -18,7 +18,6 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.api.interfaces.IBaseCustomMetaTileEntity; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; import ic2.api.Direction; public class BaseCustomTileEntity extends BaseMetaTileEntity implements IBaseCustomMetaTileEntity { @@ -109,13 +108,7 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity implements IBaseCus this.mMetaTileEntity.onExplosion(); int i; - boolean aExplosionDropItem = false; - Object aProxyField = StaticFields59.getFieldFromGregtechProxy(false, "mExplosionItemDrop"); - if (boolean.class.isInstance(aProxyField) || Boolean.class.isInstance(aProxyField)) { - aExplosionDropItem = (boolean) aProxyField; - } - - if (aExplosionDropItem) { + if (GT_Mod.gregtechproxy.mExplosionItemDrop) { for (i = 0; i < this.getSizeInventory(); ++i) { ItemStack tItem = this.getStackInSlot(i); if (tItem != null && tItem.stackSize > 0 && this.isValidSlot(i)) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java index 5e1f0ab055..b1d0731521 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_ControlCore.java @@ -19,7 +19,6 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.item.general.ItemControlCore; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch { @@ -84,11 +83,7 @@ public class GT_MetaTileEntity_Hatch_ControlCore extends GT_MetaTileEntity_Hatch @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_ControlCore( - mName, - mTier, - StaticFields59.getDescriptionArray(this), - mTextures); + return new GT_MetaTileEntity_Hatch_ControlCore(mName, mTier, mDescriptionArray, mTextures); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java index ef5711769d..d5f10a01fa 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy_RTG.java @@ -17,6 +17,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.InventoryUtils; @@ -235,7 +236,7 @@ public class GT_MetaTileEntity_Hatch_Energy_RTG extends GT_MetaTileEntity_Hatch_ for (ItemStack o : aTile.mInventory) { if (o != null) { for (ItemStack i : mFuelInstanceMap.values()) { - if (ItemUtils.areItemsEqual(o, i)) { + if (GT_Utility.areStacksEqual(o, i)) { return true; } } @@ -264,7 +265,7 @@ public class GT_MetaTileEntity_Hatch_Energy_RTG extends GT_MetaTileEntity_Hatch_ for (ItemStack o : aTile.mInventory) { if (o != null) { for (ItemStack i : mFuelInstanceMap.values()) { - if (ItemUtils.areItemsEqual(o, i)) { + if (GT_Utility.areStacksEqual(o, i)) { return o; } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java index 7897dda8bc..a78892a692 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler_Adv.java @@ -9,6 +9,7 @@ import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import gregtech.GT_Mod; import gregtech.api.enums.GT_Values; import gregtech.api.gui.modularui.GT_UIInfos; import gregtech.api.gui.modularui.GUITextureSet; @@ -24,7 +25,6 @@ import gtPlusPlus.core.item.general.ItemAirFilter; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.minecraft.gregtech.PollutionUtils; import gtPlusPlus.xmod.gregtech.api.gui.GTPP_UITextures; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch_Muffler implements IAddGregtechLogo { @@ -35,8 +35,8 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch public void onConfigLoad(GT_Config aConfig) { super.onConfigLoad(aConfig); try { - Integer a1 = (int) StaticFields59.getFieldFromGregtechProxy("mPollutionSmogLimit"); - if (a1 != null && a1 > 0) { + int a1 = GT_Mod.gregtechproxy.mPollutionSmogLimit; + if (a1 > 0) { mPollutionSmogLimit = a1; } } catch (Throwable t) { @@ -56,17 +56,17 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } public String[] getDescription() { - String[] mDescArray = StaticFields59.getDescriptionArray(this); - String[] desc = new String[mDescArray.length + 7]; - System.arraycopy(mDescArray, 0, desc, 0, mDescArray.length); - desc[mDescArray.length] = "DO NOT OBSTRUCT THE OUTPUT!"; - desc[mDescArray.length + 1] = "Requires 3 Air on the exhaust face"; - desc[mDescArray.length + 2] = "Requires Air Filters"; - desc[mDescArray.length + 3] = "Mufflers require T2 Filters from IV-" + GT_Values.VN[9]; - desc[mDescArray.length + 4] = "Reduces Pollution to " + this.calculatePollutionReductionForTooltip(100) + "%"; - desc[mDescArray.length + 5] = "Recovers " + (105 - this.calculatePollutionReductionForTooltip(100)) + String[] desc = new String[mDescriptionArray.length + 7]; + System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); + desc[mDescriptionArray.length] = "DO NOT OBSTRUCT THE OUTPUT!"; + desc[mDescriptionArray.length + 1] = "Requires 3 Air on the exhaust face"; + desc[mDescriptionArray.length + 2] = "Requires Air Filters"; + desc[mDescriptionArray.length + 3] = "Mufflers require T2 Filters from IV-" + GT_Values.VN[9]; + desc[mDescriptionArray.length + 4] = "Reduces Pollution to " + this.calculatePollutionReductionForTooltip(100) + + "%"; + desc[mDescriptionArray.length + 5] = "Recovers " + (105 - this.calculatePollutionReductionForTooltip(100)) + "% of CO2/CO/SO2"; - desc[mDescArray.length + 6] = CORE.GT_Tooltip.get(); + desc[mDescriptionArray.length + 6] = CORE.GT_Tooltip.get(); return desc; } @@ -83,11 +83,7 @@ public class GT_MetaTileEntity_Hatch_Muffler_Adv extends GT_MetaTileEntity_Hatch } public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Muffler_Adv( - this.mName, - this.mTier, - StaticFields59.getDescriptionArray(this), - this.mTextures); + return new GT_MetaTileEntity_Hatch_Muffler_Adv(this.mName, this.mTier, mDescriptionArray, this.mTextures); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java index 041c5635c5..0317518c5d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Naquadah.java @@ -18,7 +18,6 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; public class GT_MetaTileEntity_Hatch_Naquadah extends GT_MetaTileEntity_Hatch_Input { @@ -184,7 +183,7 @@ public class GT_MetaTileEntity_Hatch_Naquadah extends GT_MetaTileEntity_Hatch_In byte texturePointer = (byte) (a1 & 127); if (aSide == 1 || aSide == 0) { - ITexture g = textureIndex > 0 ? StaticFields59.getCasingTexturePages(a2, texturePointer) + ITexture g = textureIndex > 0 ? BlockIcons.casingTexturePages[a2][texturePointer] : BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]; return new ITexture[] { g, @@ -192,11 +191,11 @@ public class GT_MetaTileEntity_Hatch_Naquadah extends GT_MetaTileEntity_Hatch_In } return aSide != aFacing - ? (textureIndex > 0 ? new ITexture[] { StaticFields59.getCasingTexturePages(a2, texturePointer) } + ? (textureIndex > 0 ? new ITexture[] { BlockIcons.casingTexturePages[a2][texturePointer] } : new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1] }) : (textureIndex > 0 - ? (aActive ? this.getTexturesActive(StaticFields59.getCasingTexturePages(a2, texturePointer)) - : this.getTexturesInactive(StaticFields59.getCasingTexturePages(a2, texturePointer))) + ? (aActive ? this.getTexturesActive(BlockIcons.casingTexturePages[a2][texturePointer]) + : this.getTexturesInactive(BlockIcons.casingTexturePages[a2][texturePointer])) : (aActive ? this.getTexturesActive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]) : this.getTexturesInactive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]))); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java index 969694aad9..1c9f092fc8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java @@ -19,7 +19,6 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Output { @@ -197,18 +196,18 @@ public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Outp byte texturePointer = (byte) (a1 & 127); if (aSide == 1 || aSide == 0) { - ITexture g = textureIndex > 0 ? StaticFields59.getCasingTexturePages(a2, texturePointer) + ITexture g = textureIndex > 0 ? BlockIcons.casingTexturePages[a2][texturePointer] : BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]; return new ITexture[] { g }; } return aSide != aFacing - ? (textureIndex > 0 ? new ITexture[] { StaticFields59.getCasingTexturePages(a2, texturePointer) } + ? (textureIndex > 0 ? new ITexture[] { BlockIcons.casingTexturePages[a2][texturePointer] } : new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1] }) : (textureIndex > 0 - ? (aActive ? this.getTexturesActive(StaticFields59.getCasingTexturePages(a2, texturePointer)) - : this.getTexturesInactive(StaticFields59.getCasingTexturePages(a2, texturePointer))) + ? (aActive ? this.getTexturesActive(BlockIcons.casingTexturePages[a2][texturePointer]) + : this.getTexturesInactive(BlockIcons.casingTexturePages[a2][texturePointer])) : (aActive ? this.getTexturesActive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]) : this.getTexturesInactive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]))); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java index ae8dc12077..4323cfb5e2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Turbine.java @@ -29,7 +29,6 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.turbines.GregtechMetaTileEntity_LargerTurbineBase; @SuppressWarnings("deprecation") @@ -126,7 +125,7 @@ public class GT_MetaTileEntity_Hatch_Turbine extends GT_MetaTileEntity_Hatch { @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Turbine(mName, mTier, StaticFields59.getDescriptionArray(this), mTextures); + return new GT_MetaTileEntity_Hatch_Turbine(mName, mTier, mDescriptionArray, mTextures); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java index 26ed6b2bcd..d49d06c1e6 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GregtechMetaPipeEntityFluid.java @@ -11,18 +11,10 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid; import gregtech.api.render.TextureFactory; import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; public class GregtechMetaPipeEntityFluid extends GT_MetaPipeEntity_Fluid { - public static final boolean mGt6Pipe; - - static { - mGt6Pipe = StaticFields59.mGT6StylePipes; - } - public final GT_Materials mMaterial; - private boolean mCheckConnections; public GregtechMetaPipeEntityFluid(int aID, String aName, String aNameRegional, float aThickNess, GT_Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof) { @@ -39,7 +31,6 @@ public class GregtechMetaPipeEntityFluid extends GT_MetaPipeEntity_Fluid { super(aID, aName, aNameRegional, aThickNess, null, aCapacity, aHeatResistance, aGasProof); this.mLastReceivedFrom = 0; this.oLastReceivedFrom = 0; - this.mCheckConnections = !mGt6Pipe; this.mMaterial = aMaterial; } @@ -48,7 +39,6 @@ public class GregtechMetaPipeEntityFluid extends GT_MetaPipeEntity_Fluid { super(aName, aThickNess, null, aCapacity, aHeatResistance, aGasProof); this.mLastReceivedFrom = 0; this.oLastReceivedFrom = 0; - this.mCheckConnections = !mGt6Pipe; this.mMaterial = aMaterial; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 88215b7f44..775a2a50a7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -89,41 +89,6 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex public static final boolean DEBUG_DISABLE_CORES_TEMPORARILY = true; - static { - Method a08 = findRecipe08 = ReflectionUtils.getMethod( - GT_Recipe_Map.class, - "findRecipe", - IHasWorldObjectAndCoords.class, - GT_Recipe.class, - boolean.class, - long.class, - FluidStack[].class, - ItemStack.class, - ItemStack[].class); - Method a09 = findRecipe09 = ReflectionUtils.getMethod( - GT_Recipe_Map.class, - "findRecipe", - IHasWorldObjectAndCoords.class, - GT_Recipe.class, - boolean.class, - boolean.class, - long.class, - FluidStack[].class, - ItemStack.class, - ItemStack[].class); - Logger.MACHINE_INFO("Found .08 findRecipe method? " + (a08 != null)); - Logger.MACHINE_INFO("Found .09 findRecipe method? " + (a09 != null)); - - try { - calculatePollutionReduction = GT_MetaTileEntity_Hatch_Muffler.class - .getDeclaredMethod("calculatePollutionReduction", int.class); - } catch (NoSuchMethodException | SecurityException e) {} - } - - // Find Recipe Methods - private static final Method findRecipe08; - private static final Method findRecipe09; - public GT_Recipe mLastRecipe; private boolean mInternalCircuit = false; protected long mTotalRunTime = 0; @@ -1885,21 +1850,15 @@ public abstract class GregtechMeta_MultiBlockBase<T extends GT_MetaTileEntity_Ex "Invalid recipe, Fallback lookup. " + this.getRecipeMap().mRecipeList.size() + " | " + this.getRecipeMap().mNEIName); - try { - return (GT_Recipe) findRecipe09.invoke( - getRecipeMap(), - aTileEntity, - aRecipe, - aNotUnificated, - aDontCheckStackSizes, - aVoltage, - aFluids, - aSpecialSlot, - aInputs); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); - return null; - } + return getRecipeMap().findRecipe( + aTileEntity, + aRecipe, + aNotUnificated, + aDontCheckStackSizes, + aVoltage, + aFluids, + aSpecialSlot, + aInputs); } else { return mRecipeResult; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java index 16d65ca889..a2cfdd4e86 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_Catalysts.java @@ -3,6 +3,8 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; import net.minecraft.item.ItemStack; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; @@ -44,8 +46,8 @@ public class GT_MetaTileEntity_Hatch_Catalysts extends GT_MetaTileEntity_Hatch_N } @Override - public Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass() { - return GT_MetaTileEntity_Hatch_Catalysts.class; + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_Catalysts(mName, mDescriptionArray, mTextures); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java index 300e631cd0..c4550f3f42 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_MillingBalls.java @@ -3,6 +3,8 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; import net.minecraft.item.ItemStack; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; @@ -44,8 +46,8 @@ public class GT_MetaTileEntity_Hatch_MillingBalls extends GT_MetaTileEntity_Hatc } @Override - public Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass() { - return GT_MetaTileEntity_Hatch_MillingBalls.class; + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Hatch_MillingBalls(mName, mDescriptionArray, mTextures); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java index 5bfe3f21f6..a39d3ede8a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/nbthandlers/GT_MetaTileEntity_Hatch_NbtConsumable.java @@ -1,7 +1,5 @@ package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.nbthandlers; -import java.lang.reflect.Constructor; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -22,8 +20,6 @@ import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; public abstract class GT_MetaTileEntity_Hatch_NbtConsumable extends GT_MetaTileEntity_Hatch implements IAddGregtechLogo { @@ -86,21 +82,7 @@ public abstract class GT_MetaTileEntity_Hatch_NbtConsumable extends GT_MetaTileE } @Override - public final MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - Constructor<?> aConstructor = ReflectionUtils.getConstructor( - getHatchEntityClass(), - new Class[] { String.class, String[].class, ITexture[][][].class }); - GT_MetaTileEntity_Hatch_NbtConsumable aInstance = ReflectionUtils.createNewInstanceFromConstructor( - aConstructor, - new Object[] { mName, StaticFields59.getDescriptionArray(this), mTextures }); - if (aInstance instanceof GT_MetaTileEntity_Hatch_NbtConsumable) { - GT_MetaTileEntity_Hatch_NbtConsumable aMetaTile = (GT_MetaTileEntity_Hatch_NbtConsumable) aInstance; - return aMetaTile; - } - return null; - } - - public abstract Class<? extends GT_MetaTileEntity_Hatch_NbtConsumable> getHatchEntityClass(); + public abstract MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity); @Override public final boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java deleted file mode 100644 index 52950e1ae0..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/util/GregtechOreDictUnificator.java +++ /dev/null @@ -1,414 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.util; - -import static gregtech.api.enums.GT_Values.*; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.SubTag; -import gregtech.api.objects.GT_HashSet; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.ItemData; -import gregtech.api.objects.MaterialStack; -import gregtech.api.util.*; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; - -public class GregtechOreDictUnificator { - - private static final Map<String, ItemStack> sName2StackMap = new HashMap<String, ItemStack>(); - private static final Map<GT_ItemStack, ItemData> sItemStack2DataMap = new HashMap<GT_ItemStack, ItemData>(); - private static final Map<GT_ItemStack, List<ItemStack>> sUnificationTable = new HashMap<GT_ItemStack, List<ItemStack>>(); - private static final GT_HashSet<GT_ItemStack> sNoUnificationList = new GT_HashSet<GT_ItemStack>(); - - private static int isRegisteringOre = 0, isAddingOre = 0; - private static boolean mRunThroughTheList = true; - - static { - if (ReflectionUtils.getField(GT_OreDictUnificator.class, "sUnificationTable") == null) { - GregTech_API.sItemStackMappings.add(sUnificationTable); - } - } - - /** - * The Blacklist just prevents the Item from being unificated into something else. Useful if you have things like - * the Industrial Diamond, which is better than regular Diamond, but also usable in absolutely all Diamond Recipes. - */ - public static void addToBlacklist(ItemStack aStack) { - if (GT_Utility.isStackValid(aStack) && !GT_Utility.isStackInList(aStack, sNoUnificationList)) - sNoUnificationList.add(aStack); - } - - public static boolean isBlacklisted(ItemStack aStack) { - return GT_Utility.isStackInList(aStack, sNoUnificationList); - } - - public static void add(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack) { - set(aPrefix, aMaterial, aStack, false, false); - } - - public static void set(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack) { - set(aPrefix, aMaterial, aStack, true, false); - } - - public static void set(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, boolean aOverwrite, - boolean aAlreadyRegistered) { - if (aMaterial == null || aPrefix == null - || GT_Utility.isStackInvalid(aStack) - || Items.feather.getDamage(aStack) == W) - return; - isAddingOre++; - aStack = GT_Utility.copyAmount(1, aStack); - if (!aAlreadyRegistered) registerOre(aPrefix.get(aMaterial), aStack); - addAssociation(aPrefix, aMaterial, aStack, isBlacklisted(aStack)); - if (aOverwrite || GT_Utility.isStackInvalid(sName2StackMap.get(aPrefix.get(aMaterial).toString()))) - sName2StackMap.put(aPrefix.get(aMaterial).toString(), aStack); - isAddingOre--; - } - - public static ItemStack getFirstOre(Object aName, long aAmount) { - if (GT_Utility.isStringInvalid(aName)) return null; - ItemStack tStack = sName2StackMap.get(aName.toString()); - if (GT_Utility.isStackValid(tStack)) return GT_Utility.copyAmount(aAmount, tStack); - return GT_Utility.copyAmount(aAmount, getOres(aName).toArray()); - } - - public static ItemStack get(Object aName, long aAmount) { - return get(aName, null, aAmount, true, true); - } - - public static ItemStack get(Object aName, ItemStack aReplacement, long aAmount) { - return get(aName, aReplacement, aAmount, true, true); - } - - public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, long aAmount) { - return get(aPrefix, aMaterial, null, aAmount); - } - - public static ItemStack get(OrePrefixes aPrefix, Object aMaterial, ItemStack aReplacement, long aAmount) { - // if (Materials.mDefaultComponents.contains(aPrefix) && !aPrefix.mDynamicItems.contains((Materials)aMaterial)) - // aPrefix.mDynamicItems.add((Materials) aMaterial); - if (StaticFields59.geOrePrefixesBooleanPreventableComponents().contains(aPrefix) - && StaticFields59.getOrePrefixesBooleanDisabledItems().contains(aMaterial)) - return aReplacement; - return get(aPrefix.get(aMaterial), aReplacement, aAmount, false, true); - } - - public static ItemStack get(Object aName, ItemStack aReplacement, long aAmount, boolean aMentionPossibleTypos, - boolean aNoInvalidAmounts) { - if (aNoInvalidAmounts && aAmount < 1) return null; - if (!sName2StackMap.containsKey(aName.toString()) && aMentionPossibleTypos) - GT_Log.err.println("Unknown Key for Unification, Typo? " + aName); - return GT_Utility - .copyAmount(aAmount, sName2StackMap.get(aName.toString()), getFirstOre(aName, aAmount), aReplacement); - } - - public static ItemStack[] setStackArray(boolean aUseBlackList, ItemStack... aStacks) { - for (int i = 0; i < aStacks.length; i++) aStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i])); - return aStacks; - } - - public static ItemStack[] getStackArray(boolean aUseBlackList, Object... aStacks) { - ItemStack[] rStacks = new ItemStack[aStacks.length]; - for (int i = 0; i < aStacks.length; i++) rStacks[i] = get(aUseBlackList, GT_Utility.copy(aStacks[i])); - return rStacks; - } - - public static ItemStack setStack(ItemStack aStack) { - return setStack(true, aStack); - } - - public static ItemStack setStack(boolean aUseBlackList, ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) return aStack; - ItemStack tStack = get(aUseBlackList, aStack); - if (GT_Utility.areStacksEqual(aStack, tStack)) return aStack; - aStack.func_150996_a(tStack.getItem()); - Items.feather.setDamage(aStack, Items.feather.getDamage(tStack)); - return aStack; - } - - public static ItemStack get(ItemStack aStack) { - return get(true, aStack); - } - - public static ItemStack get(boolean aUseBlackList, ItemStack aStack) { - return get(aUseBlackList, aStack, false); - } - - public static ItemStack get(boolean aUseBlackList, ItemStack aStack, boolean aOnUnificationTableCreation) { - if (GT_Utility.isStackInvalid(aStack)) return null; - ItemData tPrefixMaterial = getAssociation(aStack); - ItemStack rStack = null; - if (tPrefixMaterial == null || !tPrefixMaterial.hasValidPrefixMaterialData() - || (aUseBlackList && tPrefixMaterial.mBlackListed)) - return GT_Utility.copy(aStack); - if (aUseBlackList && !GregTech_API.sUnificationEntriesRegistered && isBlacklisted(aStack)) { - tPrefixMaterial.mBlackListed = true; - return GT_Utility.copy(aStack); - } - if (tPrefixMaterial.mUnificationTarget == null) { - tPrefixMaterial.mUnificationTarget = sName2StackMap.get(tPrefixMaterial.toString()); - if (!aOnUnificationTableCreation) sUnificationTable.clear(); - } - rStack = tPrefixMaterial.mUnificationTarget; - if (GT_Utility.isStackInvalid(rStack)) return GT_Utility.copy(aStack); - assert rStack != null; - rStack.setTagCompound(aStack.getTagCompound()); - return GT_Utility.copyAmount(aStack.stackSize, rStack); - } - - public static List<ItemStack> getNonUnifiedStacks(Object obj) { - synchronized (sUnificationTable) { - if (sUnificationTable.isEmpty() && !sItemStack2DataMap.isEmpty()) { - for (GT_ItemStack tGTStack0 : sItemStack2DataMap.keySet()) { - ItemStack tStack0 = tGTStack0.toStack(); - ItemStack tStack1 = get(false, tStack0, true); - if (tStack0 != null && tStack1 != null && !GT_Utility.areStacksEqual(tStack0, tStack1)) { - GT_ItemStack tGTStack1 = new GT_ItemStack(tStack1); - List<ItemStack> list = sUnificationTable.get(tGTStack1); - if (list == null) sUnificationTable.put(tGTStack1, list = new ArrayList<ItemStack>()); - if (!list.contains(tStack0)) list.add(tStack0); - } - } - } - } - ItemStack[] aStacks = {}; - if (obj instanceof ItemStack) aStacks = new ItemStack[] { (ItemStack) obj }; - else if (obj instanceof ItemStack[]) aStacks = (ItemStack[]) obj; - else if (obj instanceof List) aStacks = (ItemStack[]) ((List) obj).toArray(new ItemStack[0]); - List<ItemStack> rList = new ArrayList<ItemStack>(); - for (ItemStack aStack : aStacks) { - rList.add(aStack); - List<ItemStack> tList = sUnificationTable.get(new GT_ItemStack(aStack)); - if (tList != null) { - for (ItemStack tStack : tList) { - ItemStack tStack1 = GT_Utility.copyAmount(aStack.stackSize, tStack); - tStack1.setTagCompound(aStack.getTagCompound()); - rList.add(tStack1); - } - } - } - return rList; - } - - public static void addItemData(ItemStack aStack, ItemData aData) { - if (GT_Utility.isStackValid(aStack) && getItemData(aStack) == null && aData != null) setItemData(aStack, aData); - } - - public static void setItemData(ItemStack aStack, ItemData aData) { - if (GT_Utility.isStackInvalid(aStack) || aData == null) return; - ItemData tData = getItemData(aStack); - if (tData == null || !tData.hasValidPrefixMaterialData()) { - if (tData != null) for (Object tObject : tData.mExtraData) - if (!aData.mExtraData.contains(tObject)) aData.mExtraData.add(tObject); - if (aStack.stackSize > 1) { - if (aData.mMaterial != null) aData.mMaterial.mAmount /= aStack.stackSize; - for (MaterialStack tMaterial : aData.mByProducts) tMaterial.mAmount /= aStack.stackSize; - aStack = GT_Utility.copyAmount(1, aStack); - } - sItemStack2DataMap.put(new GT_ItemStack(aStack), aData); - if (aData.hasValidMaterialData()) { - long tValidMaterialAmount = aData.mMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 - : aData.mMaterial.mAmount >= 0 ? aData.mMaterial.mAmount : M; - for (MaterialStack tMaterial : aData.mByProducts) - tValidMaterialAmount += tMaterial.mMaterial.contains(SubTag.NO_RECYCLING) ? 0 - : tMaterial.mAmount >= 0 ? tMaterial.mAmount : M; - if (tValidMaterialAmount < M) GT_ModHandler.addToRecyclerBlackList(aStack); - } - if (mRunThroughTheList) { - if (GregTech_API.sLoadStarted) { - mRunThroughTheList = false; - for (Entry<GT_ItemStack, ItemData> tEntry : sItemStack2DataMap.entrySet()) - if (!tEntry.getValue().hasValidPrefixData() || tEntry.getValue().mPrefix.mAllowNormalRecycling) - GT_RecipeRegistrator - .registerMaterialRecycling(tEntry.getKey().toStack(), tEntry.getValue()); - } - } else { - if (!aData.hasValidPrefixData() || aData.mPrefix.mAllowNormalRecycling) - GT_RecipeRegistrator.registerMaterialRecycling(aStack, aData); - } - } else { - for (Object tObject : aData.mExtraData) - if (!tData.mExtraData.contains(tObject)) tData.mExtraData.add(tObject); - } - } - - public static void addAssociation(OrePrefixes aPrefix, Materials aMaterial, ItemStack aStack, - boolean aBlackListed) { - if (aPrefix == null || aMaterial == null || GT_Utility.isStackInvalid(aStack)) return; - if (Items.feather.getDamage(aStack) == W) for (byte i = 0; i < 16; i++) - setItemData(GT_Utility.copyAmountAndMetaData(1, i, aStack), new ItemData(aPrefix, aMaterial, aBlackListed)); - setItemData(aStack, new ItemData(aPrefix, aMaterial, aBlackListed)); - } - - public static ItemData getItemData(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) return null; - ItemData rData = sItemStack2DataMap.get(new GT_ItemStack(aStack)); - if (rData == null) rData = sItemStack2DataMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, aStack))); - return rData; - } - - public static ItemData getAssociation(ItemStack aStack) { - ItemData rData = getItemData(aStack); - return rData != null && rData.hasValidPrefixMaterialData() ? rData : null; - } - - public static boolean isItemStackInstanceOf(ItemStack aStack, Object aName) { - if (GT_Utility.isStringInvalid(aName) || GT_Utility.isStackInvalid(aStack)) return false; - for (ItemStack tOreStack : getOres(aName.toString())) - if (GT_Utility.areStacksEqual(tOreStack, aStack, true)) return true; - return false; - } - - public static boolean isItemStackDye(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) return false; - for (Dyes tDye : Dyes.VALUES) if (isItemStackInstanceOf(aStack, tDye.toString())) return true; - return false; - } - - public static boolean registerOre(OrePrefixes aPrefix, Object aMaterial, ItemStack aStack) { - return registerOre(aPrefix.get(aMaterial), aStack); - } - - public static boolean registerOre(Object aName, ItemStack aStack) { - if (aName == null || GT_Utility.isStackInvalid(aStack)) return false; - String tName = aName.toString(); - if (GT_Utility.isStringInvalid(tName)) return false; - ArrayList<ItemStack> tList = getOres(tName); - for (int i = 0; i < tList.size(); i++) if (GT_Utility.areStacksEqual(tList.get(i), aStack, true)) return false; - isRegisteringOre++; - OreDictionary.registerOre(tName, GT_Utility.copyAmount(1, aStack)); - isRegisteringOre--; - return true; - } - - public static boolean isRegisteringOres() { - return isRegisteringOre > 0; - } - - public static boolean isAddingOres() { - return isAddingOre > 0; - } - - public static void resetUnificationEntries() { - for (ItemData tPrefixMaterial : sItemStack2DataMap.values()) tPrefixMaterial.mUnificationTarget = null; - sUnificationTable.clear(); - } - - public static ItemStack getGem(MaterialStack aMaterial) { - return aMaterial == null ? null : getGem(aMaterial.mMaterial, aMaterial.mAmount); - } - - public static ItemStack getGem(Materials aMaterial, OrePrefixes aPrefix) { - return aMaterial == null ? null : getGem(aMaterial, aPrefix.mMaterialAmount); - } - - public static ItemStack getGem(Materials aMaterial, long aMaterialAmount) { - ItemStack rStack = null; - if (((aMaterialAmount >= M))) rStack = get(OrePrefixes.gem, aMaterial, aMaterialAmount / M); - if (rStack == null) { - if ((((aMaterialAmount * 2) % M == 0) || aMaterialAmount >= M * 16)) - rStack = get(OrePrefixes.gemFlawed, aMaterial, (aMaterialAmount * 2) / M); - if ((((aMaterialAmount * 4) >= M))) - rStack = get(OrePrefixes.gemChipped, aMaterial, (aMaterialAmount * 4) / M); - } - return rStack; - } - - public static ItemStack getDust(MaterialStack aMaterial) { - return aMaterial == null ? null : getDust(aMaterial.mMaterial, aMaterial.mAmount); - } - - public static ItemStack getDust(Materials aMaterial, OrePrefixes aPrefix) { - return aMaterial == null ? null : getDust(aMaterial, aPrefix.mMaterialAmount); - } - - public static ItemStack getDust(Materials aMaterial, long aMaterialAmount) { - if (aMaterialAmount <= 0) return null; - ItemStack rStack = null; - if (((aMaterialAmount % M == 0) || aMaterialAmount >= M * 16)) - rStack = get(OrePrefixes.dust, aMaterial, aMaterialAmount / M); - if (rStack == null && (((aMaterialAmount * 4) % M == 0) || aMaterialAmount >= M * 8)) - rStack = get(OrePrefixes.dustSmall, aMaterial, (aMaterialAmount * 4) / M); - if (rStack == null && (((aMaterialAmount * 9) >= M))) - rStack = get(OrePrefixes.dustTiny, aMaterial, (aMaterialAmount * 9) / M); - return rStack; - } - - public static ItemStack getIngot(MaterialStack aMaterial) { - return aMaterial == null ? null : getIngot(aMaterial.mMaterial, aMaterial.mAmount); - } - - public static ItemStack getIngot(Materials aMaterial, OrePrefixes aPrefix) { - return aMaterial == null ? null : getIngot(aMaterial, aPrefix.mMaterialAmount); - } - - public static ItemStack getIngot(Materials aMaterial, long aMaterialAmount) { - if (aMaterialAmount <= 0) return null; - ItemStack rStack = null; - if (((aMaterialAmount % (M * 9) == 0 && aMaterialAmount / (M * 9) > 1) || aMaterialAmount >= M * 72)) - rStack = get(OrePrefixes.block, aMaterial, aMaterialAmount / (M * 9)); - if (rStack == null && ((aMaterialAmount % M == 0) || aMaterialAmount >= M * 8)) - rStack = get(OrePrefixes.ingot, aMaterial, aMaterialAmount / M); - if (rStack == null && (((aMaterialAmount * 9) >= M))) - rStack = get(OrePrefixes.nugget, aMaterial, (aMaterialAmount * 9) / M); - return rStack; - } - - public static ItemStack getIngotOrDust(Materials aMaterial, long aMaterialAmount) { - if (aMaterialAmount <= 0) return null; - ItemStack rStack = getIngot(aMaterial, aMaterialAmount); - if (rStack == null) rStack = getDust(aMaterial, aMaterialAmount); - return rStack; - } - - public static ItemStack getIngotOrDust(MaterialStack aMaterial) { - ItemStack rStack = getIngot(aMaterial); - if (aMaterial != null && aMaterial.mMaterial != null - && (aMaterial.mMaterial == Materials.Naquadah || aMaterial.mMaterial == Materials.NaquadahEnriched)) - rStack = getDust(aMaterial); - if (rStack == null) rStack = getDust(aMaterial); - return rStack; - } - - public static ItemStack getDustOrIngot(Materials aMaterial, long aMaterialAmount) { - if (aMaterialAmount <= 0) return null; - ItemStack rStack = getDust(aMaterial, aMaterialAmount); - if (rStack == null) rStack = getIngot(aMaterial, aMaterialAmount); - return rStack; - } - - public static ItemStack getDustOrIngot(MaterialStack aMaterial) { - ItemStack rStack = getDust(aMaterial); - if (rStack == null) rStack = getIngot(aMaterial); - return rStack; - } - - /** - * @return a Copy of the OreDictionary.getOres() List - */ - public static ArrayList<ItemStack> getOres(OrePrefixes aPrefix, Object aMaterial) { - return getOres(aPrefix.get(aMaterial)); - } - - /** - * @return a Copy of the OreDictionary.getOres() List - */ - public static ArrayList<ItemStack> getOres(Object aOreName) { - String aName = aOreName == null ? E : aOreName.toString(); - ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); - if (GT_Utility.isStringValid(aName)) rList.addAll(OreDictionary.getOres(aName)); - return rList; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index a33a74c151..3f91aa7f55 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -47,11 +47,6 @@ import ic2.core.init.InternalName; public class Meta_GT_Proxy { - static { - Logger.INFO("GT_PROXY - initialized."); - sDoesVolumetricFlaskExist = ReflectionUtils.doesClassExist("gregtech.common.items.GT_VolumetricFlask"); - } - public static List<Runnable> GT_BlockIconload = new ArrayList<>(); public static List<Runnable> GT_ItemIconload = new ArrayList<>(); @@ -64,11 +59,6 @@ public class Meta_GT_Proxy { public static final Map<String, FormattedTooltipString> mCustomGregtechMetaTooltips = new LinkedHashMap<String, FormattedTooltipString>(); - /** - * Does this feature exist within GT? Saves loading useless content if not. - */ - public static final boolean sDoesVolumetricFlaskExist; - @SideOnly(Side.CLIENT) public static IIconRegister sBlockIcons, sItemIcons; @@ -94,15 +84,6 @@ public class Meta_GT_Proxy { "GT++ Mod: Fatal Error ocurred while initializing custom BaseMetaTileEntities, crashing Minecraft."); } - // Gotta set it here so that we don't try call gregtech too early. - // Must set on the correct side - - if (ReflectionUtils.doesFieldExist(GT_Proxy.class, "gt6Pipe")) { - StaticFields59.mGT6StylePipes = (boolean) StaticFields59.getFieldFromGregtechProxy("gt6Pipe"); - } else { - StaticFields59.mGT6StylePipes = false; - } - GT_Log.out.println("GT++ Mod: Registering custom BaseMetaTileEntities."); GameRegistry.registerTileEntity(tBaseMetaTileEntity.getClass(), "BaseMetaTileEntity_GTPP"); GameRegistry.registerTileEntity(tBaseMetaTileEntity2.getClass(), "BaseMetaTileEntity_GTPP2"); @@ -394,13 +375,6 @@ public class Meta_GT_Proxy { static GT_Proxy[] mProxies = new GT_Proxy[2]; - /** - * @deprecated Use {@link StaticFields59#getFieldFromGregtechProxy(boolean,String)} instead - */ - public static Object getFieldFromGregtechProxy(boolean client, String fieldName) { - return StaticFields59.getFieldFromGregtechProxy(client, fieldName); - } - public static void setCustomGregtechTooltip(String aNbtTagName, FormattedTooltipString aData) { mCustomGregtechMetaTooltips.put(aNbtTagName, aData); } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java deleted file mode 100644 index 02148c3ef9..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/StaticFields59.java +++ /dev/null @@ -1,291 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.interfaces.ITexture; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.common.GT_Proxy; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.reflect.ProxyFinder; -import gtPlusPlus.core.util.reflect.ReflectionUtils; - -public class StaticFields59 { - - public static boolean mGT6StylePipes; - - public static final Field mGtBlockCasings5; - public static final Field mPreventableComponents; - public static final Field mDisabledItems; - public static final Field mMultiblockChemicalRecipes; - public static final Field mPyrolyseRecipes; - public static final Field mDescriptionArray; - public static final Field mCasingTexturePages; - public static final Field mAssLineVisualMapNEI; - public static final GT_Recipe_Map sAssemblylineVisualRecipes; - - public static final Method mCalculatePollutionReduction; - public static final Method mAddFurnaceRecipe; - - private static final Map<String, Materials> mMaterialCache = new LinkedHashMap<String, Materials>(); - - // OrePrefixes - - static { - Logger.INFO("[SH] Creating Static Helper for various fields which require reflective access."); - - mGtBlockCasings5 = getField(GregTech_API.class, "sBlockCasings5"); - Logger.INFO("[SH] Got Field: sBlockCasings5"); - mPreventableComponents = getField(OrePrefixes.class, "mPreventableComponents"); - Logger.INFO("[SH] Got Field: mPreventableComponents"); - mDisabledItems = getField(OrePrefixes.class, "mDisabledItems"); - Logger.INFO("[SH] Got Field: mDisabledItems"); - mDescriptionArray = getField(GT_MetaTileEntity_TieredMachineBlock.class, "mDescriptionArray"); - Logger.INFO("[SH] Got Field: mDescriptionArray"); - mCasingTexturePages = getField(BlockIcons.class, "casingTexturePages"); - Logger.INFO("[SH] Got Field: casingTexturePages"); - - mAssLineVisualMapNEI = getField(GT_Recipe_Map.class, "sAssemblylineVisualRecipes"); - Logger.INFO("[SH] Got Field: mAssLineVisualMapNEI"); - GT_Recipe_Map aTemp; - if (mAssLineVisualMapNEI != null) { - try { - aTemp = (GT_Recipe_Map) mAssLineVisualMapNEI.get(null); - Logger.INFO("[SH] Got Field: sAssemblylineVisualRecipes"); - } catch (IllegalArgumentException | IllegalAccessException e) { - aTemp = null; - } - } else { - aTemp = null; - } - - sAssemblylineVisualRecipes = aTemp; - - mMultiblockChemicalRecipes = getField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes"); - Logger.INFO("[SH] Got Field: sMultiblockChemicalRecipes"); - if (ReflectionUtils.doesFieldExist(GT_Recipe.GT_Recipe_Map.class, "sPyrolyseRecipes")) { - mPyrolyseRecipes = getField(GT_Recipe_Map.class, "sPyrolyseRecipes"); - Logger.INFO("[SH] Got Field: sPyrolyseRecipes"); - } else { - mPyrolyseRecipes = null; - } - - mCalculatePollutionReduction = getMethod( - GT_MetaTileEntity_Hatch_Muffler.class, - "calculatePollutionReduction", - int.class); - Logger.INFO("[SH] Got Method: calculatePollutionReduction"); - - // Yep... - mAddFurnaceRecipe = getMethod( - GT_ModHandler.class, - "addSmeltingAndAlloySmeltingRecipe", - ItemStack.class, - ItemStack.class, - boolean.class); - Logger.INFO("[SH] Got Method: addSmeltingAndAlloySmeltingRecipe"); - } - - public static final synchronized Block getBlockCasings5() { - try { - return (Block) mGtBlockCasings5.get(GregTech_API.class); - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } - - public static int calculatePollutionReducation(GT_MetaTileEntity_Hatch_Muffler h, int i) { - try { - return (int) mCalculatePollutionReduction.invoke(h, i); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return 0; - } - } - - public static Field getField(Class a, String b) { - return ReflectionUtils.getField(a, b); - } - - public static Method getMethod(Class a, String b, Class... params) { - return ReflectionUtils.getMethod(a, b, params); - } - - public static final synchronized Collection<Materials> getOrePrefixesBooleanDisabledItems() { - try { - return (Collection<Materials>) mDisabledItems.get(OrePrefixes.class); - } catch (IllegalArgumentException | IllegalAccessException e) { - return new ArrayList<Materials>(); - } - } - - public static final synchronized List<OrePrefixes> geOrePrefixesBooleanPreventableComponents() { - try { - return (List<OrePrefixes>) mPreventableComponents.get(OrePrefixes.class); - } catch (IllegalArgumentException | IllegalAccessException e) { - return new ArrayList<OrePrefixes>(); - } - } - - public static final synchronized GT_Recipe_Map getLargeChemicalReactorRecipeMap() { - try { - return (GT_Recipe_Map) mMultiblockChemicalRecipes.get(null); - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } - - public static final synchronized GT_Recipe_Map getPyrolyseRecipeMap() { - try { - return mPyrolyseRecipes != null ? (GT_Recipe_Map) mPyrolyseRecipes.get(null) : null; - } catch (IllegalArgumentException | IllegalAccessException e) { - return null; - } - } - - public static Materials getMaterial(String aMaterialName) { - Materials m = mMaterialCache.get(aMaterialName); - if (m != null) { - return m; - } else { - m = Materials.get(aMaterialName); - if (m != null) { - mMaterialCache.put(aMaterialName, m); - return m; - } - return null; - } - } - - public static String[] getDescriptionArray(GT_MetaTileEntity_TieredMachineBlock aTile) { - try { - return (String[]) mDescriptionArray.get(aTile); - } catch (IllegalArgumentException | IllegalAccessException e) { - return new String[] { aTile.mDescription }; - } - } - - public static ITexture getCasingTexturePages(int a, int b) { - try { - ITexture[][] g = (ITexture[][]) mCasingTexturePages.get(null); - if (g != null) { - return g[a][b]; - } - } catch (Throwable t) { - - } - return null; - } - - public static Object getFieldFromGregtechProxy(String fieldName) { - return getFieldFromGregtechProxy(Utils.isServer() ? false : true, fieldName); - } - - public static Object getFieldFromGregtechProxy(boolean client, String fieldName) { - Object proxyGT; - - if (Meta_GT_Proxy.mProxies[0] != null && client) { - proxyGT = Meta_GT_Proxy.mProxies[0]; - } else if (Meta_GT_Proxy.mProxies[1] != null && !client) { - proxyGT = Meta_GT_Proxy.mProxies[1]; - } else { - try { - proxyGT = (client ? ProxyFinder.getClientProxy(GT_Mod.instance) - : ProxyFinder.getServerProxy(GT_Mod.instance)); - } catch (final ReflectiveOperationException e1) { - proxyGT = null; - Logger.INFO("Failed to obtain instance of GT " + (client ? "Client" : "Server") + " proxy."); - } - if (Meta_GT_Proxy.mProxies[0] == null && client) { - Meta_GT_Proxy.mProxies[0] = (GT_Proxy) proxyGT; - } else if (Meta_GT_Proxy.mProxies[1] == null && !client) { - Meta_GT_Proxy.mProxies[1] = (GT_Proxy) proxyGT; - } - } - - if (proxyGT != null && proxyGT instanceof GT_Proxy) { - try { - return ReflectionUtils.getField(proxyGT.getClass(), fieldName).get(proxyGT); - } catch (IllegalArgumentException | IllegalAccessException e) {} - } - return null; - } - - public static int getTierForCoil(Block aBlock, int aMeta) { - if (aBlock == GregTech_API.sBlockCasings1 && (aMeta >= 12 && aMeta <= 14)) { - return aMeta == 12 ? 1 : aMeta == 13 ? 2 : 3; - } else if (aBlock == getBlockCasings5() && (aMeta >= 0 && aMeta <= 10)) { - return aMeta; - } - return 0; - } - - public static int getHeatingCapacityForCoil(Block aBlock, int aMeta) { - int aTier = getTierForCoil(aBlock, aMeta); - return aTier > 0 ? getHeatingCapacityForCoilTier(aTier) : 0; - } - - public static int getHeatingCapacityForCoilTier(int aCoilTier) { - int mHeatingCapacity = 0; - switch (aCoilTier) { - case 0: - mHeatingCapacity = 1800; - break; - case 1: - mHeatingCapacity = 2700; - break; - case 2: - mHeatingCapacity = 3600; - break; - case 3: - mHeatingCapacity = 4500; - break; - case 4: - mHeatingCapacity = 5400; - break; - case 5: - mHeatingCapacity = 7200; - break; - case 6: - mHeatingCapacity = 9000; - break; - case 7: - mHeatingCapacity = 9900; - break; - case 8: - mHeatingCapacity = 10800; - break; - case 9: - mHeatingCapacity = 6300; - break; - case 10: - mHeatingCapacity = 9000; - break; - default: - Logger.INFO("Heating Coils are bad."); - mHeatingCapacity = 0; - } - if (aCoilTier <= 10) { - mHeatingCapacity += 1; - } - return mHeatingCapacity; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index ac30942a5f..fff2e68200 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -18,6 +18,7 @@ import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_ModHandler; import gregtech.common.items.GT_MetaGenerated_Item_01; import gregtech.common.items.GT_MetaGenerated_Item_02; +import gregtech.common.items.GT_MetaGenerated_Item_03; import gregtech.common.items.GT_MetaGenerated_Tool_01; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.Pair; @@ -26,7 +27,6 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.NBTUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; @@ -322,10 +322,9 @@ public class ChargingHelper { if (mTemp.getItem() instanceof GT_MetaGenerated_Tool_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_01 || mTemp.getItem() instanceof GT_MetaGenerated_Item_02 - || ReflectionUtils.getClass("gregtech.common.items.GT_MetaGenerated_Item_03") - .isInstance(mTemp.getItem()) - || mTemp.getItem().getClass().getName().toLowerCase() - .equals(("gregtech.common.items.GT_MetaGenerated_Tool_01").toLowerCase())) { + || mTemp.getItem() instanceof GT_MetaGenerated_Item_03 + || mTemp.getItem().getClass().getName() + .equalsIgnoreCase(GT_MetaGenerated_Tool_01.class.getName())) { if (!NBTUtils.hasKey(mTemp, "GT.ItemCharge")) { if (!mTemp.getDisplayName().toLowerCase().contains("battery")) { if (!GT_ModHandler.isElectricItem(mTemp)) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java index 0c0baf4723..a9dc1d1323 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/GT_MethodHelper.java @@ -1,78 +1,17 @@ package gtPlusPlus.xmod.gregtech.common.helpers; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; -import gregtech.api.metatileentity.BaseMetaTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gregtech.api.interfaces.tileentity.ITexturedTileEntity; public class GT_MethodHelper { - private static final Method mGetTexture; - private static final Class mITexturedTileEntity; - - static { - Class clazz = null; - Method aMeth = null; - if (ReflectionUtils.doesClassExist("gregtech.api.interfaces.tileentity.ITexturedTileEntity")) { - clazz = ReflectionUtils.getClass("gregtech.api.interfaces.tileentity.ITexturedTileEntity"); - aMeth = ReflectionUtils.getMethod(clazz, "getTexture", Block.class, byte.class); - } - mITexturedTileEntity = clazz; - mGetTexture = aMeth; - } - public static ITexture[] getTexture(TileEntity tTileEntity, Block aBlock, byte aSide) { - - if (mITexturedTileEntity.isInstance(tTileEntity)) { - - if (mGetTexture != null) { - try { - mGetTexture.invoke(tTileEntity, aBlock, aSide); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - e.printStackTrace(); - } - } else { - if (tTileEntity instanceof BaseMetaTileEntity) { - try { - BaseMetaTileEntity aTile = (BaseMetaTileEntity) tTileEntity; - ITexture rIcon = aTile.getCoverTexture(aSide); - Field aFacing = ReflectionUtils.getField(BaseMetaTileEntity.class, "mFacing"); - Field aColor = ReflectionUtils.getField(BaseMetaTileEntity.class, "mColor"); - Field aActive = ReflectionUtils.getField(BaseMetaTileEntity.class, "mActive"); - Field aMetaTile = ReflectionUtils.getField(BaseMetaTileEntity.class, "mMetaTileEntity"); - Method aHasValidTile = ReflectionUtils - .getMethod(BaseMetaTileEntity.class, "hasValidMetaTileEntity", new Class[] {}); - - boolean hasValidTileObj = (boolean) aHasValidTile.invoke(aTile, new Object[] {}); - boolean aActiveObj = aActive.getBoolean(aTile); - byte aFacingObj = aFacing.getByte(aTile); - byte aColorObj = aColor.getByte(aTile);; - MetaTileEntity aMetaTileObj = (MetaTileEntity) aMetaTile.get(aTile); - - if (rIcon != null) { - return new ITexture[] { rIcon }; - } else { - return hasValidTileObj ? aMetaTileObj.getTexture( - aTile, - aSide, - aFacingObj, - (byte) (aColorObj - 1), - aActiveObj, - aTile.getOutputRedstoneSignal(aSide) > 0) : BlockIcons.ERROR_RENDERING; - } - } catch (Throwable t) { - t.printStackTrace(); - } - } - } + if (tTileEntity instanceof ITexturedTileEntity) { + return ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, aSide); } return BlockIcons.ERROR_RENDERING; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java index 52aeb864dd..2b0e2a7a4d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/VolumetricFlaskHelper.java @@ -1,99 +1,49 @@ package gtPlusPlus.xmod.gregtech.common.helpers; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gregtech.api.enums.ItemList; +import gregtech.common.items.GT_VolumetricFlask; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; public class VolumetricFlaskHelper { - private static final Class sClassVolumetricFlask; - private static final Method sMethodGetFlaskMaxCapacity; - private static Item mFlask; - - static { - if (Meta_GT_Proxy.sDoesVolumetricFlaskExist) { - sClassVolumetricFlask = ReflectionUtils.getClass("gregtech.common.items.GT_VolumetricFlask"); - Method aMaxCapacity = null; - try { - aMaxCapacity = sClassVolumetricFlask.getDeclaredMethod("getMaxCapacity", new Class[] {}); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - CORE.crash( - "Secondary Error Obtaining instance of 'getMaxCapacity' from 'GT_VolumetricFlask'. Crashing."); - } - sMethodGetFlaskMaxCapacity = aMaxCapacity; - } else { - sClassVolumetricFlask = null; - sMethodGetFlaskMaxCapacity = null; - } - } - public static ItemStack getVolumetricFlask(int aAmount) { - ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", aAmount, (ItemStack) null); - return aFlask; + return ItemList.VOLUMETRIC_FLASK.get(aAmount); } public static ItemStack getLargeVolumetricFlask(int aAmount) { - ItemStack aFlask = GregtechItemList.VOLUMETRIC_FLASK_8k.get(aAmount); - return aFlask; + return GregtechItemList.VOLUMETRIC_FLASK_8k.get(aAmount); } public static ItemStack getGiganticVolumetricFlask(int aAmount) { - ItemStack aFlask = GregtechItemList.VOLUMETRIC_FLASK_32k.get(aAmount); - return aFlask; + return GregtechItemList.VOLUMETRIC_FLASK_32k.get(aAmount); } public static boolean isVolumetricFlask(ItemStack aStack) { - if (isNormalVolumetricFlask(aStack) || isLargeVolumetricFlask(aStack) || isGiganticVolumetricFlask(aStack)) { - return true; - } - return false; + return isNormalVolumetricFlask(aStack) || isLargeVolumetricFlask(aStack) || isGiganticVolumetricFlask(aStack); } public static boolean isNormalVolumetricFlask(ItemStack aStack) { - if (mFlask == null) { - ItemStack aFlask = ItemUtils.getValueOfItemList("VOLUMETRIC_FLASK", 1, (ItemStack) null); - if (aFlask != null) { - mFlask = aFlask.getItem(); - } - } - if (aStack.getItem() == mFlask) { - return true; - } - return false; + return aStack.getItem() == ItemList.VOLUMETRIC_FLASK.getItem(); } public static boolean isLargeVolumetricFlask(ItemStack aStack) { - if (GregtechItemList.VOLUMETRIC_FLASK_8k.getItem() == aStack.getItem()) { - return true; - } - return false; + return GregtechItemList.VOLUMETRIC_FLASK_8k.getItem() == aStack.getItem(); } public static boolean isGiganticVolumetricFlask(ItemStack aStack) { - if (GregtechItemList.VOLUMETRIC_FLASK_32k.getItem() == aStack.getItem()) { - return true; - } - return false; + return GregtechItemList.VOLUMETRIC_FLASK_32k.getItem() == aStack.getItem(); } public static int getMaxFlaskCapacity(ItemStack aStack) { - if (aStack != null && sMethodGetFlaskMaxCapacity != null) { + if (aStack != null) { Item aItem = aStack.getItem(); - if (sClassVolumetricFlask.isInstance(aItem)) { - int aMaxCapacity = (int) ReflectionUtils - .invokeNonBool(aItem, sMethodGetFlaskMaxCapacity, new Object[] {}); - return aMaxCapacity; + if (aItem instanceof GT_VolumetricFlask) { + return ((GT_VolumetricFlask) aItem).getMaxCapacity(); } } return 0; @@ -170,16 +120,6 @@ public class VolumetricFlaskHelper { } public static Item generateNewFlask(String unlocalized, String english, int maxCapacity) { - Constructor aFlask = ReflectionUtils - .getConstructor(sClassVolumetricFlask, new Class[] { String.class, String.class, int.class }); - if (aFlask != null) { - Object aInstance = ReflectionUtils - .createNewInstanceFromConstructor(aFlask, new Object[] { unlocalized, english, maxCapacity }); - if (aInstance != null && aInstance instanceof Item) { - Item aNewFlaskItem = (Item) aInstance; - return aNewFlaskItem; - } - } - return null; + return new GT_VolumetricFlask(unlocalized, english, maxCapacity); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java index e59c71c5bd..cd81bfce76 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechTools.java @@ -1,14 +1,9 @@ package gtPlusPlus.xmod.gregtech.common.items; -import java.lang.reflect.Field; - import gregtech.api.GregTech_API; import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.ToolDictNames; import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.objects.GT_HashSet; -import gregtech.api.objects.GT_ItemStack; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechToolDictNames; import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_AngleGrinder; import gtPlusPlus.xmod.gregtech.common.tools.TOOL_Gregtech_Choocher; @@ -60,25 +55,8 @@ public class MetaGeneratedGregtechTools extends GT_MetaGenerated_Tool { new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 2L), new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 2L) }); - GT_HashSet<GT_ItemStack> aWireCutterList = new GT_HashSet<GT_ItemStack>(); - // Does not exist prior to 5.09.32, use an empty field if we can't find the existing one. - if (ReflectionUtils.doesFieldExist(GregTech_API.class, "sWireCutterList")) { - Field sWireCutterList = ReflectionUtils.getField(GregTech_API.class, "sWireCutterList"); - try { - if (sWireCutterList != null) { - Object val = sWireCutterList.get(null); - if (val != null && val instanceof GT_HashSet) { - aWireCutterList = (GT_HashSet<GT_ItemStack>) val; - } - } - - } catch (IllegalArgumentException | IllegalAccessException e) { - // Not found, so it's GT 5.09.31 or earlier. - } - } - // Electric Wire Cutter - GregTech_API.registerTool( + GregTech_API.registerWireCutter( this.addTool( ELECTRIC_SNIPS, "Automatic Snips", @@ -88,8 +66,7 @@ public class MetaGeneratedGregtechTools extends GT_MetaGenerated_Tool { ToolDictNames.craftingToolWireCutter, new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 4L), new TC_Aspects.TC_AspectStack(TC_Aspects.FABRICO, 4L), - new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 4L) }), - aWireCutterList); + new TC_Aspects.TC_AspectStack(TC_Aspects.ORDO, 4L) })); // Electric Lighter this.addTool( diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java deleted file mode 100644 index 3d66558c4f..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java +++ /dev/null @@ -1,229 +0,0 @@ -package gtPlusPlus.xmod.gregtech.loaders; - -import java.lang.reflect.*; -import java.util.HashMap; -import java.util.Map; - -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.MaterialUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; - -public class GT_Material_Loader { - - private static volatile GT_Material_Loader instance = new GT_Material_Loader(); - private volatile Object mProxyObject; - private static AutoMap<Materials> mMaterials = new AutoMap<Materials>(); - private static volatile boolean mHasRun = false; - - public synchronized GT_Material_Loader getInstance() { - return GT_Material_Loader.instance; - } - - public synchronized boolean getRunAbility() { - return (mHasRun ? false : true); - } - - public synchronized void setRunAbility(boolean b) { - mHasRun = Utils.invertBoolean(b); - } - - public GT_Material_Loader() { - if (getRunAbility()) { - // Set Singleton Instance - instance = this; - - // Try Reflectively add ourselves to the GT loader. - Class mInterface = ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); - if (mInterface != null) { - - // Make this class Dynamically implement IMaterialHandler - if (mProxyObject == null) { - mProxyObject = Proxy.newProxyInstance( - mInterface.getClassLoader(), - new Class[] { mInterface }, - new MaterialHandler(getInstance())); - } - - if (ReflectionUtils.invoke( - Materials.class, - "add", - new Class[] { ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler") }, - new Object[] { mProxyObject })) { - Logger.REFLECTION("Successfully invoked add, on the proxied object implementing IMaterialHandler."); - - Logger.REFLECTION("Examining Proxy to ensure it implements the correct Interface."); - Class[] i = mProxyObject.getClass().getInterfaces(); - for (int r = 0; r < i.length; r++) { - Logger.REFLECTION("Contains " + i[r].getCanonicalName() + "."); - if (i[r] == mInterface) { - Logger.REFLECTION("Found gregtech.api.interfaces.IMaterialHandler. This Proxy is valid."); - } - } - } else { - Logger.REFLECTION("Failed to invoke add, on the proxied object implementing IMaterialHandler."); - } - } - // Materials.add(this); - - // Stupid shit running twice, I don't think so. - setRunAbility(false); - } - } - - public void onMaterialsInit() { - Logger.DEBUG_MATERIALS("onMaterialsInit()"); - } - - public void onComponentInit() { - Logger.DEBUG_MATERIALS("onComponentInit()"); - if (!mMaterials.isEmpty()) { - Logger.DEBUG_MATERIALS("Found " + mMaterials.size() + " materials to re-enable."); - for (Materials M : mMaterials.values()) { - String name = MaterialUtils.getMaterialName(M); - Logger.DEBUG_MATERIALS("Trying to enable " + name + "."); - boolean success = tryEnableAllComponentsForMaterial(M); - if (success) { - Logger.DEBUG_MATERIALS("Success! Enabled " + name + "."); - } else { - Logger.DEBUG_MATERIALS("Failure... Did not enable " + name + "."); - } - } - } - } - - public void onComponentIteration(Materials aMaterial) { - Logger.DEBUG_MATERIALS("onComponentIteration()"); - } - - public synchronized boolean enableMaterial(Materials m) { - if (mMaterials.setValue(m)) { - Logger.DEBUG_MATERIALS("Added " + MaterialUtils.getMaterialName(m) + " to internal Map."); - return true; - } - Logger.DEBUG_MATERIALS("Failed to add " + MaterialUtils.getMaterialName(m) + " to internal Map."); - return false; - } - - /* - * Static internal handler methods - */ - - private static synchronized boolean tryEnableMaterial(Materials mMaterial) { - boolean value = ReflectionUtils.setField(mMaterial, "mHasParentMod", true); - if (value) { - Logger.DEBUG_MATERIALS("Set mHasParentMod true for " + mMaterial.mDefaultLocalName); - } else { - Logger.DEBUG_MATERIALS("Failed to set mHasParentMod true for " + mMaterial.mDefaultLocalName); - } - return value; - } - - private static synchronized boolean tryEnableMaterialPart(OrePrefixes prefix, Materials mMaterial) { - try { - Method enableComponent = ReflectionUtils.getClass("gregtech.api.enums.OrePrefixes") - .getDeclaredMethod("enableComponent", Materials.class); - enableComponent.invoke(prefix, mMaterial); - Logger.DEBUG_MATERIALS("Enabled " + prefix.name() + " for " + mMaterial.mDefaultLocalName + "."); - return true; - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException - | SecurityException error) { - Logger.DEBUG_MATERIALS( - "Failed to enabled " + prefix.name() - + " for " - + mMaterial.mDefaultLocalName - + ". Caught " - + error.getCause().toString() - + "."); - error.printStackTrace(); - } - Logger.DEBUG_MATERIALS( - "Did not enable " + prefix.name() - + " for " - + mMaterial.mDefaultLocalName - + ". Report this error to Alkalus on Github."); - return false; - } - - private static synchronized boolean tryEnableAllComponentsForMaterial(Materials material) { - try { - tryEnableMaterial(material); - int mValid = 0; - for (OrePrefixes ore : OrePrefixes.values()) { - if (tryEnableMaterialPart(ore, material)) { - mValid++; - } - } - if (mValid > 0) { - Logger.DEBUG_MATERIALS( - "Success - Re-enabled all components for " + MaterialUtils.getMaterialName(material)); - } else { - Logger.DEBUG_MATERIALS( - "Failure - Did not enable any components for " + MaterialUtils.getMaterialName(material)); - } - return mValid > 0; - } catch (SecurityException | IllegalArgumentException e) { - Logger.DEBUG_MATERIALS( - "Total Failure - Unable to re-enable " + MaterialUtils.getMaterialName(material) - + ". Most likely an IllegalArgumentException, but small chance it's a SecurityException."); - return false; - } - } - - /** - * Special Dynamic Interface Class - */ - public class MaterialHandler implements InvocationHandler { - - private final Map<String, Method> methods = new HashMap<String, Method>(); - private Object target; - - public MaterialHandler(Object target) { - Logger.REFLECTION("Created a Proxy Interface which implements IMaterialHandler."); - this.target = target; - for (Method method : target.getClass().getDeclaredMethods()) { - Logger.REFLECTION("Adding " + method.getName() + " to internal method map."); - this.methods.put(method.getName(), method); - } - } - - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - long start = System.nanoTime(); - Object result = methods.get(method.getName()).invoke(target, args); - long elapsed = System.nanoTime() - start; - Logger.INFO("[Debug] Executed " + method.getName() + " in " + elapsed + " ns"); - return result; - } - } - - /* - * public static class ProxyListener implements java.lang.reflect.InvocationHandler { public static Object - * IMaterialHandlerProxy; ProxyListener(){ Logger.REFLECTION("Failed setting IMaterialHandler Proxy instance."); } - * //Loading the class at runtime public static void main(String[] args) throws IllegalAccessException, - * IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException, - * ClassNotFoundException { Class<?> someInterface = - * ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); Object instance = - * Proxy.newProxyInstance(someInterface.getClassLoader(), new Class<?>[]{someInterface}, new InvocationHandler() { - * @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { //Handle the - * invocations if(method.getName().equals("onMaterialsInit")){ - * Logger.REFLECTION("Invoked onMaterialsInit() via IMaterialHandler proxy"); return 1; } else - * if(method.getName().equals("onComponentInit")){ - * Logger.REFLECTION("Invoked onComponentInit() via IMaterialHandler proxy"); return 2; } else - * if(method.getName().equals("onComponentIteration")){ - * Logger.REFLECTION("Invoked onComponentIteration() via IMaterialHandler proxy"); return 3; } else { return -1; } } - * }); System.out.println(instance.getClass().getDeclaredMethod("someMethod", (Class<?>[])null).invoke(instance, new - * Object[]{})); } private static class MaterialHandler implements InvocationHandler { private final Object - * original; public MaterialHandler(Object original) { this.original = original; } - * @Override public Object invoke(Object proxy, Method method, Object[] args) throws IllegalAccessException, - * IllegalArgumentException, InvocationTargetException { System.out.println("BEFORE"); method.invoke(original, - * args); System.out.println("AFTER"); return null; } } public static void init(){ Class<?> someInterface = - * ReflectionUtils.getClass("gregtech.api.interfaces.IMaterialHandler"); GT_Material_Loader original = - * GT_Material_Loader.instance; MaterialHandler handler = new MaterialHandler(original); Object f = - * Proxy.newProxyInstance(someInterface.getClassLoader(), new Class[] { someInterface }, handler); - * f.originalMethod("Hallo"); } } - */ -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Extruder.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Extruder.java index 3d2ed68a3f..5c294ae403 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Extruder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Extruder.java @@ -16,11 +16,9 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; public class RecipeGen_Extruder extends RecipeGen_Base { public static final Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); - private static boolean mRotorShapeEnabled = false; static { MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); - mRotorShapeEnabled = ItemUtils.doesItemListEntryExist("Shape_Extruder_Rotor"); } public RecipeGen_Extruder(final Material M) { @@ -145,11 +143,11 @@ public class RecipeGen_Extruder extends RecipeGen_Base { // Rotor Recipe // Shape_Extruder_Rotor - if (mRotorShapeEnabled && ItemUtils.checkForInvalidItems(material.getIngot(1)) + if (ItemUtils.checkForInvalidItems(material.getIngot(1)) && ItemUtils.checkForInvalidItems(material.getRotor(1))) if (GT_Values.RA.addExtruderRecipe( material.getIngot(5), - ItemUtils.getValueOfItemList("Shape_Extruder_Rotor", 0, ItemUtils.getErrorStack(1)), + ItemList.Shape_Extruder_Rotor.get(0), material.getRotor(1), 200, 60)) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java index 35d1a987e2..fa08380596 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java @@ -14,11 +14,9 @@ import gtPlusPlus.core.util.minecraft.ItemUtils; public class RecipeGen_Fluids extends RecipeGen_Base { public static final Set<RunnableWithInfo<Material>> mRecipeGenMap = new HashSet<RunnableWithInfo<Material>>(); - private static boolean mRotorShapeEnabled = false; static { MaterialGenerator.mRecipeMapsToGenerate.put(mRecipeGenMap); - mRotorShapeEnabled = ItemUtils.doesItemListEntryExist("Shape_Extruder_Rotor"); } public RecipeGen_Fluids(final Material M) { @@ -119,139 +117,104 @@ public class RecipeGen_Fluids extends RecipeGen_Base { // GTNH - // Shape_Mold_Rod - // Shape_Mold_Rod_Long - // Shape_Mold_Bolt, - // Shape_Mold_Screw, - // Shape_Mold_Ring, - - ItemList mold_Rod = ItemUtils.getValueOfItemList("Shape_Mold_Rod", null); - ItemList mold_Rod_Long = ItemUtils.getValueOfItemList("Shape_Mold_Rod_Long", null); - ItemList mold_Bolt = ItemUtils.getValueOfItemList("Shape_Mold_Bolt", null); - ItemList mold_Screw = ItemUtils.getValueOfItemList("Shape_Mold_Screw", null); - ItemList mold_Ring = ItemUtils.getValueOfItemList("Shape_Mold_Ring", null); - ItemList mold_Rotor = ItemUtils.getValueOfItemList("Shape_Mold_Rotor", null); - // Rod - if (ItemUtils.checkForInvalidItems(material.getRod(1))) - if (mold_Rod != null && GT_Values.RA.addFluidSolidifierRecipe( - mold_Rod.get(0), // Item Shape - material.getFluidStack(72), // Fluid Input - material.getRod(1), // output - 150, // Duration - material.vVoltageMultiplier // Eu Tick - )) { - Logger.WARNING( - (144 * 9) + "l fluid molder from 1 rod Recipe: " - + material.getLocalizedName() - + " - Success"); - } else { - Logger.WARNING( - (144 * 9) + "l fluid molder from 1 rod Recipe: " - + material.getLocalizedName() - + " - Failed"); - } + if (ItemUtils.checkForInvalidItems(material.getRod(1))) if (GT_Values.RA.addFluidSolidifierRecipe( + ItemList.Shape_Mold_Rod.get(0), // Item Shape + material.getFluidStack(72), // Fluid Input + material.getRod(1), // output + 150, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING( + (144 * 9) + "l fluid molder from 1 rod Recipe: " + material.getLocalizedName() + " - Success"); + } else { + Logger.WARNING( + (144 * 9) + "l fluid molder from 1 rod Recipe: " + material.getLocalizedName() + " - Failed"); + } // Rod Long - if (ItemUtils.checkForInvalidItems(material.getLongRod(1))) - if (mold_Rod_Long != null && GT_Values.RA.addFluidSolidifierRecipe( - mold_Rod_Long.get(0), // Item - // Shape - material.getFluidStack(144), // Fluid Input - material.getLongRod(1), // output - 300, // Duration - material.vVoltageMultiplier // Eu Tick - )) { - Logger.WARNING( - (144 * 9) + "l fluid molder from 1 rod long Recipe: " - + material.getLocalizedName() - + " - Success"); - } else { - Logger.WARNING( - (144 * 9) + "l fluid molder from 1 rod long Recipe: " - + material.getLocalizedName() - + " - Failed"); - } + if (ItemUtils.checkForInvalidItems(material.getLongRod(1))) if (GT_Values.RA.addFluidSolidifierRecipe( + ItemList.Shape_Mold_Rod_Long.get(0), // Item + // Shape + material.getFluidStack(144), // Fluid Input + material.getLongRod(1), // output + 300, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING( + (144 * 9) + "l fluid molder from 1 rod long Recipe: " + + material.getLocalizedName() + + " - Success"); + } else { + Logger.WARNING( + (144 * 9) + "l fluid molder from 1 rod long Recipe: " + + material.getLocalizedName() + + " - Failed"); + } // Bolt - if (ItemUtils.checkForInvalidItems(material.getBolt(1))) - if (mold_Bolt != null && GT_Values.RA.addFluidSolidifierRecipe( - mold_Bolt.get(0), // Item Shape - material.getFluidStack(18), // Fluid Input - material.getBolt(1), // output - 50, // Duration - material.vVoltageMultiplier // Eu Tick - )) { - Logger.WARNING( - (144 * 9) + "l fluid molder from 1 bolt Recipe: " - + material.getLocalizedName() - + " - Success"); - } else { - Logger.WARNING( - (144 * 9) + "l fluid molder from 1 bolt Recipe: " - + material.getLocalizedName() - + " - Failed"); - } + if (ItemUtils.checkForInvalidItems(material.getBolt(1))) if (GT_Values.RA.addFluidSolidifierRecipe( + ItemList.Shape_Mold_Bolt.get(0), // Item Shape + material.getFluidStack(18), // Fluid Input + material.getBolt(1), // output + 50, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING( + (144 * 9) + "l fluid molder from 1 bolt Recipe: " + material.getLocalizedName() + " - Success"); + } else { + Logger.WARNING( + (144 * 9) + "l fluid molder from 1 bolt Recipe: " + material.getLocalizedName() + " - Failed"); + } // Screw - if (ItemUtils.checkForInvalidItems(material.getScrew(1))) - if (mold_Screw != null && GT_Values.RA.addFluidSolidifierRecipe( - mold_Screw.get(0), // Item Shape - material.getFluidStack(18), // Fluid Input - material.getScrew(1), // output - 50, // Duration - material.vVoltageMultiplier // Eu Tick - )) { - Logger.WARNING( - (144 * 9) + "l fluid molder from 1 screw Recipe: " - + material.getLocalizedName() - + " - Success"); - } else { - Logger.WARNING( - (144 * 9) + "l fluid molder from 1 screw Recipe: " - + material.getLocalizedName() - + " - Failed"); - } + if (ItemUtils.checkForInvalidItems(material.getScrew(1))) if (GT_Values.RA.addFluidSolidifierRecipe( + ItemList.Shape_Mold_Screw.get(0), // Item Shape + material.getFluidStack(18), // Fluid Input + material.getScrew(1), // output + 50, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING( + (144 * 9) + "l fluid molder from 1 screw Recipe: " + + material.getLocalizedName() + + " - Success"); + } else { + Logger.WARNING( + (144 * 9) + "l fluid molder from 1 screw Recipe: " + material.getLocalizedName() + " - Failed"); + } // Ring - if (ItemUtils.checkForInvalidItems(material.getRing(1))) - if (mold_Ring != null && GT_Values.RA.addFluidSolidifierRecipe( - mold_Ring.get(0), // Item Shape - material.getFluidStack(36), // Fluid Input - material.getRing(1), // output - 100, // Duration - material.vVoltageMultiplier // Eu Tick - )) { - Logger.WARNING( - (144 * 9) + "l fluid molder from 1 ring Recipe: " - + material.getLocalizedName() - + " - Success"); - } else { - Logger.WARNING( - (144 * 9) + "l fluid molder from 1 ring Recipe: " - + material.getLocalizedName() - + " - Failed"); - } + if (ItemUtils.checkForInvalidItems(material.getRing(1))) if (GT_Values.RA.addFluidSolidifierRecipe( + ItemList.Shape_Mold_Ring.get(0), // Item Shape + material.getFluidStack(36), // Fluid Input + material.getRing(1), // output + 100, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING( + (144 * 9) + "l fluid molder from 1 ring Recipe: " + material.getLocalizedName() + " - Success"); + } else { + Logger.WARNING( + (144 * 9) + "l fluid molder from 1 ring Recipe: " + material.getLocalizedName() + " - Failed"); + } // Rotor - if (ItemUtils.checkForInvalidItems(material.getRotor(1))) - if (mold_Rotor != null && GT_Values.RA.addFluidSolidifierRecipe( - mold_Rotor.get(0), // Item Shape - material.getFluidStack(612), // Fluid Input - material.getRotor(1), // output - 100, // Duration - material.vVoltageMultiplier // Eu Tick - )) { - Logger.WARNING( - (144 * 9) + "l fluid molder from 1 rotor Recipe: " - + material.getLocalizedName() - + " - Success"); - } else { - Logger.WARNING( - (144 * 9) + "l fluid molder from 1 rotor Recipe: " - + material.getLocalizedName() - + " - Failed"); - } + if (ItemUtils.checkForInvalidItems(material.getRotor(1))) if (GT_Values.RA.addFluidSolidifierRecipe( + ItemList.Shape_Mold_Rotor.get(0), // Item Shape + material.getFluidStack(612), // Fluid Input + material.getRotor(1), // output + 100, // Duration + material.vVoltageMultiplier // Eu Tick + )) { + Logger.WARNING( + (144 * 9) + "l fluid molder from 1 rotor Recipe: " + + material.getLocalizedName() + + " - Success"); + } else { + Logger.WARNING( + (144 * 9) + "l fluid molder from 1 rotor Recipe: " + material.getLocalizedName() + " - Failed"); + } } } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java index be7023433e..e05e32331d 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/loaders/misc/AssLineAchievements.java @@ -18,7 +18,6 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; public class AssLineAchievements { @@ -42,12 +41,7 @@ public class AssLineAchievements { private static void init() { if (!ready) { active = GT_Mod.gregtechproxy.mAchievements; - try { - recipeTotal = ((GT_Recipe.GT_Recipe_Map) StaticFields59.mAssLineVisualMapNEI.get(null)).mRecipeList - .size(); - } catch (IllegalArgumentException | IllegalAccessException e) { - recipeTotal = 0; - } + recipeTotal = GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList.size(); mAchievementMap = new ConcurrentHashMap<String, Achievement>(); mIssuedAchievementMap = new ConcurrentHashMap<String, Boolean>(); ready = true; @@ -151,19 +145,15 @@ public class AssLineAchievements { return; } - if (StaticFields59.sAssemblylineVisualRecipes == null) { - return; - } - Logger.INFO("Trying to check for achievements"); // Debug scanner unlocks all AL recipes in creative if (player.capabilities.isCreativeMode && aPickupUnlocalSafe.equals("gt.metaitem.01.32761")) { - for (GT_Recipe recipe : StaticFields59.sAssemblylineVisualRecipes.mRecipeList) { + for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { issueAchievement(player, recipe.getOutput(0).getUnlocalizedName()); recipe.mHidden = false; } } - for (GT_Recipe recipe : StaticFields59.sAssemblylineVisualRecipes.mRecipeList) { + for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { String aSafeUnlocalName; if (recipe.getOutput(0) == null) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index 45a0c27bc9..923a593019 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -2,9 +2,6 @@ package gtPlusPlus.xmod.gregtech.recipes; import static gregtech.api.enums.GT_Values.RA; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -27,7 +24,6 @@ import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.IGregtech_RecipeAdder; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy_RTG; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; import gtPlusPlus.xmod.gregtech.common.helpers.FlotationRecipeHandler; import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GregtechMetaTileEntity_RTG; import gtPlusPlus.xmod.gregtech.recipes.machines.RECIPEHANDLER_MatterFabricator; @@ -748,12 +744,7 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { */ @Override public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aDust, ItemStack aOutput) { - Method m = StaticFields59.mAddFurnaceRecipe; - try { - return (boolean) m.invoke(null, aDust, aOutput, true); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - return false; - } + return GT_ModHandler.addSmeltingAndAlloySmeltingRecipe(aDust, aOutput, true); } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechComponentAssembler.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechComponentAssembler.java index dcd11a4dba..1a4771394b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechComponentAssembler.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechComponentAssembler.java @@ -507,10 +507,8 @@ public class GregtechComponentAssembler { else if (tier == 5) mWT = "16"; else mWT = "01"; - ItemStack eyeQuantum = ItemUtils - .getValueOfItemList("QuantumEye", 1, ItemUtils.getSimpleStack(Items.ender_eye, 4)); - ItemStack starQuantum = ItemUtils - .getValueOfItemList("QuantumStar", 1, ItemUtils.getSimpleStack(Items.nether_star, 4)); + ItemStack eyeQuantum = ItemList.QuantumEye.get(1); + ItemStack starQuantum = ItemList.QuantumStar.get(1); if (tier == 1) gem = ItemUtils.getSimpleStack(Items.ender_pearl); else if (tier == 2) gem = ItemUtils.getSimpleStack(Items.ender_eye); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechHiAmpTransformer.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechHiAmpTransformer.java index 410732ffbb..57cc981923 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechHiAmpTransformer.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechHiAmpTransformer.java @@ -2,6 +2,7 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; import net.minecraft.item.ItemStack; +import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -9,7 +10,6 @@ import gregtech.api.util.GT_ModHandler; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTransformerHiAmp; -import gtPlusPlus.xmod.gregtech.common.StaticFields59; public class GregtechHiAmpTransformer { @@ -89,12 +89,9 @@ public class GregtechHiAmpTransformer { ItemStack mItem_2; ItemStack mItem_3; - mItem_1 = ItemUtils - .simpleMetaStack(ItemUtils.getSimpleStack(StaticFields59.getBlockCasings5()).getItem(), 3, 1); - mItem_2 = ItemUtils - .simpleMetaStack(ItemUtils.getSimpleStack(StaticFields59.getBlockCasings5()).getItem(), 4, 1); - mItem_3 = ItemUtils - .simpleMetaStack(ItemUtils.getSimpleStack(StaticFields59.getBlockCasings5()).getItem(), 9, 1); + mItem_1 = ItemUtils.simpleMetaStack(ItemUtils.getSimpleStack(GregTech_API.sBlockCasings5).getItem(), 3, 1); + mItem_2 = ItemUtils.simpleMetaStack(ItemUtils.getSimpleStack(GregTech_API.sBlockCasings5).getItem(), 4, 1); + mItem_3 = ItemUtils.simpleMetaStack(ItemUtils.getSimpleStack(GregTech_API.sBlockCasings5).getItem(), 9, 1); GT_ModHandler.addCraftingRecipe( GregtechItemList.Transformer_HA_LV_ULV.get(1L, new Object[0]), diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java deleted file mode 100644 index e545ea19f0..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechNitroDieselFix.java +++ /dev/null @@ -1,247 +0,0 @@ -package gtPlusPlus.xmod.gregtech.registration.gregtech; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -import org.apache.commons.lang3.reflect.FieldUtils; - -import gregtech.GT_Mod; -import gregtech.api.enums.*; -import gregtech.api.objects.MaterialStack; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.MaterialUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; - -public class GregtechNitroDieselFix { - - @SuppressWarnings("unchecked") - public static void run() { - if (CORE.ConfigSwitches.enableNitroFix) { - Logger.INFO("Gregtech5u Content | Attempting to Fix Nitro-Diesel production."); - try { - Class mb = ReflectionUtils.getClass("gregtech.api.enums.MaterialBuilder"); - Object df = mb.getConstructor(int.class, TextureSet.class, String.class) - .newInstance(975, TextureSet.SET_FLUID, "Nitro-Diesel [Old]"); - if (mb.isInstance(df)) { - - Logger.INFO("[Nitro] Created new instance of Material builder, for Nitro fix."); - - // Get Methods - Method addFluid = mb.getDeclaredMethod("addFluid"); - Method addCell = mb.getDeclaredMethod("addCell"); - Method setColour = mb.getDeclaredMethod("setColor", Dyes.class); - Method setFuelPower = mb.getDeclaredMethod("setFuelPower", int.class); - Method setMaterials = mb.getDeclaredMethod("setMaterialList", List.class); - Method setTemp = mb.getDeclaredMethod("setLiquidTemperature", int.class); - Method setRGB = mb.getDeclaredMethod("setRGB", int.class, int.class, int.class); - Method construct = mb.getDeclaredMethod("constructMaterial"); - Logger.INFO("[Nitro] Got internal methods for setting fields."); - - // Invoke the methods - addFluid.invoke(df); - addCell.invoke(df); - setColour.invoke(df, Dyes.dyeLime); - setFuelPower.invoke(df, 512000); - setMaterials.invoke( - df, - Arrays.asList( - new MaterialStack(Materials.Glyceryl, 1), - new MaterialStack(Materials.Fuel, 4))); - setTemp.invoke(df, 295); - setRGB.invoke(df, 200, 255, 0); - Materials mNitroFix = (Materials) construct.invoke(df); - Logger.INFO("[Nitro] Invoked 8 method calls successfully."); - - GT_Mod.gregtechproxy.addFluid( - "NitroFuel_Old", - "Nitro Diesel [Old]", - mNitroFix, - 1, - 295, - GT_OreDictUnificator.get(OrePrefixes.cell, mNitroFix, 1L), - ItemUtils.getEmptyCell(), - 1000); - Logger.INFO("[Nitro] Added a fluid."); - - /** - * Reflectively get all the values to maintain 5.08.xx compat - */ - GT_Recipe_Map recipeMapMultiblockChemReactor; - recipeMapMultiblockChemReactor = (GT_Recipe_Map) FieldUtils - .getDeclaredField(GT_Recipe_Map.class, "sMultiblockChemicalRecipes", true).get(null); - - /** - * Do Recipe Stuff - */ - - // Set up some Variables - final Collection<GT_Recipe> xSingle = GT_Recipe_Map.sChemicalRecipes.mRecipeList; - final Collection<GT_Recipe> xMulti = recipeMapMultiblockChemReactor.mRecipeList; - final FluidStack mNitroStack = Materials.NitroFuel.getFluid(1000); - GT_Recipe toRemoveSingle[] = new GT_Recipe[99]; - GT_Recipe toRemoveMulti[] = new GT_Recipe[99]; - int mIndexSingle = 0; - int mIndexMulti = 0; - - // Iterate Single Block recipes for Nitro production. - for (GT_Recipe rnd : xSingle) { - for (FluidStack mOutputFluid : rnd.mFluidOutputs) { - if (mOutputFluid.isFluidEqual(mNitroStack)) { - toRemoveSingle[mIndexSingle++] = rnd; - } - } - } - Logger.INFO("[Nitro] Found " + mIndexSingle + " single block Chemical Reactor recipes to remove."); - - // Iterate Multi Block recipes for Nitro production. - for (GT_Recipe rnd : xMulti) { - for (FluidStack mOutputFluid : rnd.mFluidOutputs) { - if (mOutputFluid.isFluidEqual(mNitroStack)) { - toRemoveMulti[mIndexMulti++] = rnd; - } - } - } - Logger.INFO("[Nitro] Found " + mIndexMulti + " multi block Chemical Reactor recipes to remove."); - - // Remove Single Block recipes found. - int mRemovedSingle = 0; - int mRemovedMulti = 0; - for (GT_Recipe single : toRemoveSingle) { - if (GT_Recipe_Map.sChemicalRecipes.mRecipeList.remove(single)) { - mRemovedSingle++; - } - } - Logger.INFO("[Nitro] Removed " + mRemovedSingle + " single block Chemical Reactor recipes."); - - // Remove Multi Block recipes found. - for (GT_Recipe multi : toRemoveMulti) { - if (recipeMapMultiblockChemReactor.mRecipeList.remove(multi)) { - mRemovedMulti++; - } - } - Logger.INFO("[Nitro] Removed " + mRemovedMulti + " multi block Chemical Reactor recipes."); - - Materials mGlycerol = Materials.valueOf("Glycerol"); - Materials mLightFuel = Materials.valueOf("LightFuel"); - - // Build a New Recipe set - Materials mFuels[] = { mLightFuel, Materials.Fuel }; - for (Materials fuel : mFuels) { - boolean didAdd[] = new boolean[3]; - Logger.INFO( - "[Nitro] Getting ready to add back in the old nitro-diesel recipe to the mixer, using " - + fuel.mDefaultLocalName - + " as the fuel input."); - didAdd[0] = GT_Values.RA.addMixerRecipe( - getCells(fuel, 4), - getCells(mGlycerol, 1), - GT_Values.NI, - GT_Values.NI, - GT_Values.NF, - GT_Values.NF, - getCells(mNitroFix, 5), - 20, - 30); - didAdd[1] = GT_Values.RA.addMixerRecipe( - getCells(fuel, 4), - GT_Values.NI, - GT_Values.NI, - GT_Values.NI, - mGlycerol.getFluid(1000L), - mNitroFix.getFluid(5000L), - ItemList.Cell_Empty.get(4L), - 20, - 30); - didAdd[2] = GT_Values.RA.addMixerRecipe( - getCells(mGlycerol, 1), - GT_Values.NI, - GT_Values.NI, - GT_Values.NI, - fuel.getFluid(4000L), - mNitroFix.getFluid(5000L), - ItemList.Cell_Empty.get(1L), - 20, - 30); - Logger.INFO( - "[Nitro] Did the recipes add? 1: " + didAdd[0] - + " | 2: " - + didAdd[1] - + " | 3: " - + didAdd[2]); - } - - for (Materials fuel : mFuels) { - boolean didAdd[] = new boolean[3]; - Logger.INFO( - "[Nitro] Getting ready to add back in the old nitro-diesel recipe to the chemical reactors, using " - + fuel.mDefaultLocalName - + " as the fuel input."); - didAdd[0] = GT_Values.RA.addChemicalRecipe( - getCells(fuel, 4), - getCells(mGlycerol, 1), - GT_Values.NF, - GT_Values.NF, - getCells(mNitroFix, 5), - 20); - didAdd[1] = GT_Values.RA.addChemicalRecipe( - getCells(fuel, 4), - GT_Values.NI, - mGlycerol.getFluid(1000L), - mNitroFix.getFluid(5000L), - ItemList.Cell_Empty.get(4L), - 20); - didAdd[2] = GT_Values.RA.addChemicalRecipe( - getCells(mGlycerol, 1), - GT_Values.NI, - fuel.getFluid(4000L), - mNitroFix.getFluid(5000L), - ItemList.Cell_Empty.get(1L), - 20); - Logger.INFO( - "[Nitro] Did the recipes add? 1: " + didAdd[0] - + " | 2: " - + didAdd[1] - + " | 3: " - + didAdd[2]); - } - - Logger.INFO("[Nitro] Getting ready to add back in the old glycerol recipe!"); - GT_Values.RA.addChemicalRecipe( - getCells(Materials.Nitrogen, 1), - getDust(Materials.Carbon, 1), - Materials.Water.getFluid(2000L), - mGlycerol.getFluid(3000L), - ItemList.Cell_Empty.get(1), - 3000); - Logger.INFO("[Nitro] Added recipes."); - } - } catch (IllegalArgumentException | IllegalAccessException | InstantiationException - | InvocationTargetException | NoSuchMethodException | SecurityException e) { - Logger.INFO("[Nitro] ================ Error ================"); - e.printStackTrace(); - Logger.INFO("[Nitro] ================ Error ================"); - } - } - } - - public static ItemStack getCells(Materials mat, int amount) { - String mName = MaterialUtils.getMaterialName(mat); - return ItemUtils.getItemStackOfAmountFromOreDict("cell" + mName, amount); - } - - public static ItemStack getDust(Materials mat, int amount) { - String mName = MaterialUtils.getMaterialName(mat); - return ItemUtils.getItemStackOfAmountFromOreDict("dust" + mName, amount); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRocketFuelGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRocketFuelGenerator.java index fd2382bd75..4187759a88 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRocketFuelGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechRocketFuelGenerator.java @@ -10,7 +10,6 @@ import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.tileentities.generators.GregtechMetaTileEntityRocketFuelGenerator; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMetaTileEntity_LargeRocketEngine; @@ -31,15 +30,13 @@ public class GregtechRocketFuelGenerator { "gtpp.multimachine.rocketengine", "Rocketdyne F-1A Engine").getStackForm(1L)); - ItemList aDieselEngine = ItemUtils - .getValueOfItemList("Machine_Multi_DieselEngine", ItemList.Machine_Multi_LargeBoiler_TungstenSteel); - GT_ModHandler.addCraftingRecipe( GregtechItemList.Controller_RocketEngine.get(1L), CI.bitsd, - new Object[] { "PCP", "EME", "GWG", 'M', aDieselEngine, 'P', ItemList.Electric_Piston_IV, 'E', - ItemList.Field_Generator_EV, 'C', OrePrefixes.circuit.get(Materials.Master), 'W', - OrePrefixes.cableGt08.get(Materials.Platinum), 'G', ALLOY.MARAGING350.getGear(1) }); + new Object[] { "PCP", "EME", "GWG", 'M', ItemList.Machine_Multi_DieselEngine.get(1), 'P', + ItemList.Electric_Piston_IV, 'E', ItemList.Field_Generator_EV, 'C', + OrePrefixes.circuit.get(Materials.Master), 'W', OrePrefixes.cableGt08.get(Materials.Platinum), + 'G', ALLOY.MARAGING350.getGear(1) }); GT_ModHandler.addCraftingRecipe( GregtechItemList.Casing_RocketEngine.get(1L), |