diff options
Diffstat (limited to 'src/main/java/gregtech/api')
49 files changed, 1339 insertions, 929 deletions
diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index beae1ea08f..f3bb7f6764 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -29,6 +29,7 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import static gregtech.api.enums.GT_Values.*; @@ -82,8 +83,9 @@ public class GregTech_API { * 9728 - 10239 are reserved for 28Smiles. * 10240 - 10751 are reserved for VirMan. * 10752 - 11263 are reserved for Briareos81. - * 11264 - 12000 are reserved for the next one who asks me. - * 9728 - 32766 are currently free. + * 11264 - 12000 are reserved for Quantum64. + * 12001 - 12200 are reserved for the next one who asks me. + * 12001 - 32766 are currently free. * <p/> * Contact me if you need a free ID-Range, which doesn't conflict with other Addons. * You could make an ID-Config, but we all know, what "stupid" customers think about conflicting ID's @@ -92,35 +94,35 @@ public class GregTech_API { /** * The Icon List for Covers */ - public static final Map<GT_ItemStack, ITexture> sCovers = new HashMap<GT_ItemStack, ITexture>(); + public static final Map<GT_ItemStack, ITexture> sCovers = new ConcurrentHashMap<GT_ItemStack, ITexture>(); /** * The List of Cover Behaviors for the Covers */ - public static final Map<GT_ItemStack, GT_CoverBehavior> sCoverBehaviors = new HashMap<GT_ItemStack, GT_CoverBehavior>(); + public static final Map<GT_ItemStack, GT_CoverBehavior> sCoverBehaviors = new ConcurrentHashMap<GT_ItemStack, GT_CoverBehavior>(); /** * The List of Circuit Behaviors for the Redstone Circuit Block */ - public static final Map<Integer, GT_CircuitryBehavior> sCircuitryBehaviors = new HashMap<Integer, GT_CircuitryBehavior>(); + public static final Map<Integer, GT_CircuitryBehavior> sCircuitryBehaviors = new ConcurrentHashMap<Integer, GT_CircuitryBehavior>(); /** * The List of Blocks, which can conduct Machine Block Updates */ - public static final Map<Block, Integer> sMachineIDs = new HashMap<Block, Integer>(); + public static final Map<Block, Integer> sMachineIDs = new ConcurrentHashMap<Block, Integer>(); /** * The Redstone Frequencies */ - public static final Map<Integer, Byte> sWirelessRedstone = new HashMap<Integer, Byte>(); + public static final Map<Integer, Byte> sWirelessRedstone = new ConcurrentHashMap<Integer, Byte>(); /** * The IDSU Frequencies */ - public static final Map<Integer, Integer> sIDSUList = new HashMap<Integer, Integer>(); + public static final Map<Integer, Integer> sIDSUList = new ConcurrentHashMap<Integer, Integer>(); /** * A List of all Books, which were created using @GT_Utility.getWrittenBook the original Title is the Key Value */ - public static final Map<String, ItemStack> sBookList = new HashMap<String, ItemStack>(); + public static final Map<String, ItemStack> sBookList = new ConcurrentHashMap<String, ItemStack>(); /** * The List of all Sounds used in GT, indices are in the static Block at the bottom */ - public static final Map<Integer, String> sSoundList = new HashMap<Integer, String>(); + public static final Map<Integer, String> sSoundList = new ConcurrentHashMap<Integer, String>(); /** * The List of Tools, which can be used. Accepts regular damageable Items and Electric Items */ @@ -190,6 +192,7 @@ public class GregTech_API { public static int mRFtoEU = 20; public static boolean mRFExplosions = true; public static boolean mServerStarted = false; + private static final String aTextIC2Lower = MOD_ID_IC2.toLowerCase(Locale.ENGLISH); /** * Getting assigned by the Mod loading */ @@ -215,29 +218,29 @@ public class GregTech_API { sSoundList.put(5, "random.explode"); sSoundList.put(6, "fire.ignite"); - sSoundList.put(100, MOD_ID_IC2.toLowerCase() + ":" + "tools.Wrench"); - sSoundList.put(101, MOD_ID_IC2.toLowerCase() + ":" + "tools.RubberTrampoline"); - sSoundList.put(102, MOD_ID_IC2.toLowerCase() + ":" + "tools.Painter"); - sSoundList.put(103, MOD_ID_IC2.toLowerCase() + ":" + "tools.BatteryUse"); - sSoundList.put(104, MOD_ID_IC2.toLowerCase() + ":" + "tools.chainsaw.ChainsawUseOne"); - sSoundList.put(105, MOD_ID_IC2.toLowerCase() + ":" + "tools.chainsaw.ChainsawUseTwo"); - sSoundList.put(106, MOD_ID_IC2.toLowerCase() + ":" + "tools.drill.DrillSoft"); - sSoundList.put(107, MOD_ID_IC2.toLowerCase() + ":" + "tools.drill.DrillHard"); - sSoundList.put(108, MOD_ID_IC2.toLowerCase() + ":" + "tools.ODScanner"); - - sSoundList.put(200, MOD_ID_IC2.toLowerCase() + ":" + "machines.ExtractorOp"); - sSoundList.put(201, MOD_ID_IC2.toLowerCase() + ":" + "machines.MaceratorOp"); - sSoundList.put(202, MOD_ID_IC2.toLowerCase() + ":" + "machines.InductionLoop"); - sSoundList.put(203, MOD_ID_IC2.toLowerCase() + ":" + "machines.CompressorOp"); - sSoundList.put(204, MOD_ID_IC2.toLowerCase() + ":" + "machines.RecyclerOp"); - sSoundList.put(205, MOD_ID_IC2.toLowerCase() + ":" + "machines.MinerOp"); - sSoundList.put(206, MOD_ID_IC2.toLowerCase() + ":" + "machines.PumpOp"); - sSoundList.put(207, MOD_ID_IC2.toLowerCase() + ":" + "machines.ElectroFurnaceLoop"); - sSoundList.put(208, MOD_ID_IC2.toLowerCase() + ":" + "machines.InductionLoop"); - sSoundList.put(209, MOD_ID_IC2.toLowerCase() + ":" + "machines.MachineOverload"); - sSoundList.put(210, MOD_ID_IC2.toLowerCase() + ":" + "machines.InterruptOne"); - sSoundList.put(211, MOD_ID_IC2.toLowerCase() + ":" + "machines.KaChing"); - sSoundList.put(212, MOD_ID_IC2.toLowerCase() + ":" + "machines.MagnetizerLoop"); + sSoundList.put(100, aTextIC2Lower + ":" + "tools.Wrench"); + sSoundList.put(101, aTextIC2Lower + ":" + "tools.RubberTrampoline"); + sSoundList.put(102, aTextIC2Lower + ":" + "tools.Painter"); + sSoundList.put(103, aTextIC2Lower + ":" + "tools.BatteryUse"); + sSoundList.put(104, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseOne"); + sSoundList.put(105, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseTwo"); + sSoundList.put(106, aTextIC2Lower + ":" + "tools.drill.DrillSoft"); + sSoundList.put(107, aTextIC2Lower + ":" + "tools.drill.DrillHard"); + sSoundList.put(108, aTextIC2Lower + ":" + "tools.ODScanner"); + + sSoundList.put(200, aTextIC2Lower + ":" + "machines.ExtractorOp"); + sSoundList.put(201, aTextIC2Lower + ":" + "machines.MaceratorOp"); + sSoundList.put(202, aTextIC2Lower + ":" + "machines.InductionLoop"); + sSoundList.put(203, aTextIC2Lower + ":" + "machines.CompressorOp"); + sSoundList.put(204, aTextIC2Lower + ":" + "machines.RecyclerOp"); + sSoundList.put(205, aTextIC2Lower + ":" + "machines.MinerOp"); + sSoundList.put(206, aTextIC2Lower + ":" + "machines.PumpOp"); + sSoundList.put(207, aTextIC2Lower + ":" + "machines.ElectroFurnaceLoop"); + sSoundList.put(208, aTextIC2Lower + ":" + "machines.InductionLoop"); + sSoundList.put(209, aTextIC2Lower + ":" + "machines.MachineOverload"); + sSoundList.put(210, aTextIC2Lower + ":" + "machines.InterruptOne"); + sSoundList.put(211, aTextIC2Lower + ":" + "machines.KaChing"); + sSoundList.put(212, aTextIC2Lower + ":" + "machines.MagnetizerLoop"); } /** @@ -302,7 +305,7 @@ public class GregTech_API { if (GregTech_API.sThaumcraftCompat != null) GregTech_API.sThaumcraftCompat.registerPortholeBlacklistedBlock(aBlock); int rMeta = 0; - for (byte i = 0; i < aMeta.length && i < 16; i++) if (aMeta[i]) rMeta |= B[i]; + for (byte i = 0; i < 16 && i < aMeta.length; i++) if (aMeta[i]) rMeta |= B[i]; sMachineIDs.put(aBlock, rMeta); return true; } diff --git a/src/main/java/gregtech/api/enums/Dyes.java b/src/main/java/gregtech/api/enums/Dyes.java index 66c3927783..c59b310d55 100644 --- a/src/main/java/gregtech/api/enums/Dyes.java +++ b/src/main/java/gregtech/api/enums/Dyes.java @@ -64,7 +64,7 @@ public enum Dyes implements IColorModulationContainer { public static Dyes get(String aColor) { Object tObject = GT_Utility.getFieldContent(Dyes.class, aColor, false, false); - if (tObject != null && tObject instanceof Dyes) return (Dyes) tObject; + if (tObject instanceof Dyes) return (Dyes) tObject; return _NULL; } diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index 93c7ef73e6..af2ec92195 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -8,6 +8,8 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import java.util.Locale; + /** * Made for static imports, this Class is just a Helper. * <p/> @@ -89,7 +91,7 @@ public class GT_Values { * File Paths and Resource Paths */ public static final String - TEX_DIR = "textures/", TEX_DIR_GUI = TEX_DIR + "gui/", TEX_DIR_ITEM = TEX_DIR + "items/", TEX_DIR_BLOCK = TEX_DIR + "blocks/", TEX_DIR_ENTITY = TEX_DIR + "entity/", TEX_DIR_ASPECTS = TEX_DIR + "aspects/", RES_PATH = MOD_ID + ":" + TEX_DIR, RES_PATH_GUI = MOD_ID + ":" + TEX_DIR_GUI, RES_PATH_ITEM = MOD_ID + ":", RES_PATH_BLOCK = MOD_ID + ":", RES_PATH_ENTITY = MOD_ID + ":" + TEX_DIR_ENTITY, RES_PATH_ASPECTS = MOD_ID + ":" + TEX_DIR_ASPECTS, RES_PATH_IC2 = MOD_ID_IC2.toLowerCase() + ":", RES_PATH_MODEL = MOD_ID + ":" + TEX_DIR + "models/"; + TEX_DIR = "textures/", TEX_DIR_GUI = TEX_DIR + "gui/", TEX_DIR_ITEM = TEX_DIR + "items/", TEX_DIR_BLOCK = TEX_DIR + "blocks/", TEX_DIR_ENTITY = TEX_DIR + "entity/", TEX_DIR_ASPECTS = TEX_DIR + "aspects/", RES_PATH = MOD_ID + ":" + TEX_DIR, RES_PATH_GUI = MOD_ID + ":" + TEX_DIR_GUI, RES_PATH_ITEM = MOD_ID + ":", RES_PATH_BLOCK = MOD_ID + ":", RES_PATH_ENTITY = MOD_ID + ":" + TEX_DIR_ENTITY, RES_PATH_ASPECTS = MOD_ID + ":" + TEX_DIR_ASPECTS, RES_PATH_IC2 = MOD_ID_IC2.toLowerCase(Locale.ENGLISH) + ":", RES_PATH_MODEL = MOD_ID + ":" + TEX_DIR + "models/"; /** * The Mod Object itself. That is the GT_Mod-Object. It's needed to open GUI's and similar. */ diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index 8ddfafce4d..f6d6d9a27e 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -9,6 +9,7 @@ import gregtech.api.interfaces.IMaterialHandler; import gregtech.api.interfaces.ISubTagContainer; import gregtech.api.objects.GT_FluidStack; import gregtech.api.objects.MaterialStack; +import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.ItemStack; @@ -1169,7 +1170,8 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { Tartarite, Thyrium, Tritanium, Vulcanite, Vyroxeres, Yellorium, Zectium, AluminiumBrass, Osmiridium, Sunnarium, AnnealedCopper, BatteryAlloy, Brass, Bronze, ChromiumDioxide, Cupronickel, DeepIron, Electrum, Invar, IronCompressed, Kanthal, Magnalium, Nichrome, NiobiumNitride, NiobiumTitanium, PigIron, SolderingAlloy, StainlessSteel, Steel, Ultimet, VanadiumGallium, WroughtIron, YttriumBariumCuprate, IronWood, Alumite, Manyullyn, ShadowIron, ShadowSteel, Steeleaf, SterlingSilver, RoseGold, BlackBronze, BismuthBronze, BlackSteel, RedSteel, BlueSteel, DamascusSteel, - TungstenSteel, AstralSilver, Midasium, Mithril, BlueAlloy, RedAlloy, CobaltBrass, Thaumium, IronMagnetic, SteelMagnetic, NeodymiumMagnetic, Knightmetal, HSSG, HSSE, HSSS); + TungstenSteel, AstralSilver, Midasium, Mithril, BlueAlloy, RedAlloy, CobaltBrass, Thaumium, IronMagnetic, SteelMagnetic, NeodymiumMagnetic, Knightmetal, HSSG, HSSE, HSSS, TungstenCarbide, Endium, + VanadiumSteel, Kalendrite, Ignatius); SubTag.FOOD.addTo(MeatRaw, MeatCooked, Ice, Water, Salt, Chili, Cocoa, Cheese, Coffee, Chocolate, Milk, Honey, FryingOilHot, FishOil, SeedOil, SeedOilLin, SeedOilHemp, Wheat, Sugar, FreshWater); @@ -1368,6 +1370,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { aMaterial.mMeltingPoint = (short) GregTech_API.sMaterialProperties.get(aConfigPath, "MeltingPoint", aMaterial.mMeltingPoint); aMaterial.mBlastFurnaceRequired = GregTech_API.sMaterialProperties.get(aConfigPath, "BlastFurnaceRequired", aMaterial.mBlastFurnaceRequired); aMaterial.mBlastFurnaceTemp = (short) GregTech_API.sMaterialProperties.get(aConfigPath, "BlastFurnaceTemp", aMaterial.mBlastFurnaceTemp); + if (GT_Mod.gregtechproxy.mTEMachineRecipes && aMaterial.mBlastFurnaceRequired && aMaterial.mBlastFurnaceTemp < 1500) GT_ModHandler.ThermalExpansion.addSmelterBlastOre(aMaterial); aMaterial.mFuelPower = GregTech_API.sMaterialProperties.get(aConfigPath, "FuelPower", aMaterial.mFuelPower); aMaterial.mFuelType = GregTech_API.sMaterialProperties.get(aConfigPath, "FuelType", aMaterial.mFuelType); aMaterial.mOreValue = GregTech_API.sMaterialProperties.get(aConfigPath, "OreValue", aMaterial.mOreValue); @@ -1483,6 +1486,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { if (GT_Mod.gregtechproxy.mChangeHarvestLevels && aMaterial.mToolQuality > 0 && aMaterial.mMetaItemSubID < GT_Mod.gregtechproxy.mHarvestLevel.length && aMaterial.mMetaItemSubID >= 0) { GT_Mod.gregtechproxy.mHarvestLevel[aMaterial.mMetaItemSubID] = GregTech_API.sMaterialProperties.get(aConfigPath, "HarvestLevel", aMaterial.mToolQuality); } + aMaterial.mHandleMaterial = (aMaterial == Desh ? aMaterial.mHandleMaterial : aMaterial == Diamond || aMaterial == Thaumium ? Wood : aMaterial.contains(SubTag.BURNING) ? Blaze : aMaterial.contains(SubTag.MAGICAL) && aMaterial.contains(SubTag.CRYSTAL) && Loader.isModLoaded(GT_Values.MOD_ID_TC) ? Thaumium : aMaterial.getMass() > Element.Tc.getMass() * 2 ? TungstenSteel : aMaterial.getMass() > Element.Tc.getMass() ? Steel : Wood); } aConfigPathSB.setLength(0); } @@ -1622,6 +1626,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { /** * This is for keeping compatibility with addons mods (Such as TinkersGregworks etc) that looped over the old materials enum */ + @Deprecated public String name() { return mName; } @@ -1629,6 +1634,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { /** * This is for keeping compatibility with addons mods (Such as TinkersGregworks etc) that looped over the old materials enum */ + @Deprecated public static Materials valueOf(String aMaterialName) { return getMaterialsMap().get(aMaterialName); } @@ -1753,7 +1759,8 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public boolean remove(ItemStack aStack) { if (aStack == null) return false; boolean temp = false; - for (int i = 0; i < mMaterialItems.size(); i++) + int mMaterialItems_sS=mMaterialItems.size(); + for (int i = 0; i < mMaterialItems_sS; i++) if (GT_Utility.areStacksEqual(aStack, mMaterialItems.get(i))) { mMaterialItems.remove(i--); temp = true; diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index 812a82b768..001b373412 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -800,7 +800,7 @@ public enum OrePrefixes { public static OrePrefixes getPrefix(String aPrefixName, OrePrefixes aReplacement) { Object tObject = GT_Utility.getFieldContent(OrePrefixes.class, aPrefixName, false, false); - if (tObject != null && tObject instanceof OrePrefixes) return (OrePrefixes) tObject; + if (tObject instanceof OrePrefixes) return (OrePrefixes) tObject; return aReplacement; } diff --git a/src/main/java/gregtech/api/enums/TextureSet.java b/src/main/java/gregtech/api/enums/TextureSet.java index 4cedf08ec0..891a808553 100644 --- a/src/main/java/gregtech/api/enums/TextureSet.java +++ b/src/main/java/gregtech/api/enums/TextureSet.java @@ -14,136 +14,138 @@ public class TextureSet { public final IIconContainer[] mTextures = new IIconContainer[128]; public final String mSetName; + private final static String aTextMatIconDir = "materialicons/"; + private final static String aTextVoidDir = "/void"; public TextureSet(String aSetName) { mSetName = aSetName; - mTextures[0] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/dustTiny"); - mTextures[1] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/dustSmall"); - mTextures[2] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/dust"); - mTextures[3] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/dustImpure"); - mTextures[4] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/dustPure"); - mTextures[5] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/crushed"); - mTextures[6] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/crushedPurified"); - mTextures[7] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/crushedCentrifuged"); - mTextures[8] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/gem"); - mTextures[9] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/nugget"); - mTextures[10] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[11] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/ingot"); - mTextures[12] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/ingotHot"); - mTextures[13] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/ingotDouble"); - mTextures[14] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/ingotTriple"); - mTextures[15] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/ingotQuadruple"); - mTextures[16] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/ingotQuintuple"); - mTextures[17] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/plate"); - mTextures[18] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/plateDouble"); - mTextures[19] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/plateTriple"); - mTextures[20] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/plateQuadruple"); - mTextures[21] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/plateQuintuple"); - mTextures[22] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/plateDense"); - mTextures[23] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/stick"); - mTextures[24] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/lens"); - mTextures[25] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/round"); - mTextures[26] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/bolt"); - mTextures[27] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/screw"); - mTextures[28] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/ring"); - mTextures[29] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/foil"); - mTextures[30] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/cell"); - mTextures[31] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/cellPlasma"); - mTextures[32] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadSword"); - mTextures[33] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadPickaxe"); - mTextures[34] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadShovel"); - mTextures[35] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadAxe"); - mTextures[36] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadHoe"); - mTextures[37] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadHammer"); - mTextures[38] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadFile"); - mTextures[39] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadSaw"); - mTextures[40] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadDrill"); - mTextures[41] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadChainsaw"); - mTextures[42] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadWrench"); - mTextures[43] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadUniversalSpade"); - mTextures[44] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadSense"); - mTextures[45] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadPlow"); - mTextures[46] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadArrow"); - mTextures[47] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadScrewdriver"); - mTextures[48] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadBuzzSaw"); - mTextures[49] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadSoldering"); - mTextures[50] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[51] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/wireFine"); - mTextures[52] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/gearGtSmall"); - mTextures[53] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/rotor"); - mTextures[54] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/stickLong"); - mTextures[55] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/springSmall"); - mTextures[56] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/spring"); - mTextures[57] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/arrowGtWood"); - mTextures[58] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/arrowGtPlastic"); - mTextures[59] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/gemChipped"); - mTextures[60] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/gemFlawed"); - mTextures[61] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/gemFlawless"); - mTextures[62] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/gemExquisite"); - mTextures[63] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/gearGt"); - mTextures[64] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[65] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[66] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[67] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/oreSmall"); - mTextures[68] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/ore"); - mTextures[69] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/wire"); - mTextures[70] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/foil"); - mTextures[71] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/block1"); - mTextures[72] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/block2"); - mTextures[73] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/block3"); - mTextures[74] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/block4"); - mTextures[75] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/block5"); - mTextures[76] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/block6"); - mTextures[77] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/pipeSide"); - mTextures[78] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/pipeTiny"); - mTextures[79] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/pipeSmall"); - mTextures[80] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/pipeMedium"); - mTextures[81] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/pipeLarge"); - mTextures[82] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/pipeHuge"); - mTextures[83] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/frameGt"); - mTextures[84] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[85] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[86] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[87] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[88] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[89] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[90] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[91] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[92] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[93] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[94] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[95] = new Textures.BlockIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[96] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/crateGtDust"); - mTextures[97] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/crateGtIngot"); - mTextures[98] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/crateGtGem"); - mTextures[99] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/crateGtPlate"); - mTextures[100] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/turbineBlade"); - mTextures[101] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[102] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[103] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[104] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[105] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[106] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[107] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[108] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[109] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[110] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[111] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[112] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[113] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[114] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[115] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[116] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[117] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[118] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[119] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[120] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[121] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[122] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[123] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[124] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[125] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/void"); - mTextures[126] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/handleMallet"); - mTextures[127] = new Textures.ItemIcons.CustomIcon("materialicons/" + mSetName + "/toolHeadMallet"); + mTextures[0] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/dustTiny"); + mTextures[1] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/dustSmall"); + mTextures[2] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/dust"); + mTextures[3] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/dustImpure"); + mTextures[4] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/dustPure"); + mTextures[5] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/crushed"); + mTextures[6] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/crushedPurified"); + mTextures[7] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/crushedCentrifuged"); + mTextures[8] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/gem"); + mTextures[9] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/nugget"); + mTextures[10] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[11] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/ingot"); + mTextures[12] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/ingotHot"); + mTextures[13] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/ingotDouble"); + mTextures[14] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/ingotTriple"); + mTextures[15] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/ingotQuadruple"); + mTextures[16] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/ingotQuintuple"); + mTextures[17] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/plate"); + mTextures[18] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/plateDouble"); + mTextures[19] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/plateTriple"); + mTextures[20] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/plateQuadruple"); + mTextures[21] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/plateQuintuple"); + mTextures[22] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/plateDense"); + mTextures[23] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/stick"); + mTextures[24] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/lens"); + mTextures[25] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/round"); + mTextures[26] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/bolt"); + mTextures[27] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/screw"); + mTextures[28] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/ring"); + mTextures[29] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/foil"); + mTextures[30] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/cell"); + mTextures[31] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/cellPlasma"); + mTextures[32] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadSword"); + mTextures[33] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadPickaxe"); + mTextures[34] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadShovel"); + mTextures[35] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadAxe"); + mTextures[36] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadHoe"); + mTextures[37] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadHammer"); + mTextures[38] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadFile"); + mTextures[39] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadSaw"); + mTextures[40] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadDrill"); + mTextures[41] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadChainsaw"); + mTextures[42] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadWrench"); + mTextures[43] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadUniversalSpade"); + mTextures[44] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadSense"); + mTextures[45] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadPlow"); + mTextures[46] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadArrow"); + mTextures[47] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadScrewdriver"); + mTextures[48] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadBuzzSaw"); + mTextures[49] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadSoldering"); + mTextures[50] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[51] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/wireFine"); + mTextures[52] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/gearGtSmall"); + mTextures[53] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/rotor"); + mTextures[54] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/stickLong"); + mTextures[55] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/springSmall"); + mTextures[56] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/spring"); + mTextures[57] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/arrowGtWood"); + mTextures[58] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/arrowGtPlastic"); + mTextures[59] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/gemChipped"); + mTextures[60] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/gemFlawed"); + mTextures[61] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/gemFlawless"); + mTextures[62] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/gemExquisite"); + mTextures[63] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/gearGt"); + mTextures[64] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[65] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[66] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[67] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/oreSmall"); + mTextures[68] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/ore"); + mTextures[69] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/wire"); + mTextures[70] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/foil"); + mTextures[71] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/block1"); + mTextures[72] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/block2"); + mTextures[73] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/block3"); + mTextures[74] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/block4"); + mTextures[75] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/block5"); + mTextures[76] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/block6"); + mTextures[77] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/pipeSide"); + mTextures[78] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/pipeTiny"); + mTextures[79] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/pipeSmall"); + mTextures[80] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/pipeMedium"); + mTextures[81] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/pipeLarge"); + mTextures[82] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/pipeHuge"); + mTextures[83] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + "/frameGt"); + mTextures[84] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[85] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[86] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[87] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[88] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[89] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[90] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[91] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[92] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[93] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[94] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[95] = new Textures.BlockIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[96] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/crateGtDust"); + mTextures[97] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/crateGtIngot"); + mTextures[98] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/crateGtGem"); + mTextures[99] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/crateGtPlate"); + mTextures[100] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/turbineBlade"); + mTextures[101] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[102] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[103] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[104] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[105] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[106] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[107] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[108] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[109] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[110] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[111] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[112] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[113] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[114] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[115] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[116] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[117] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[118] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[119] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[120] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[121] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[122] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[123] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[124] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[125] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + aTextVoidDir); + mTextures[126] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/handleMallet"); + mTextures[127] = new Textures.ItemIcons.CustomIcon(aTextMatIconDir + mSetName + "/toolHeadMallet"); } }
\ No newline at end of file diff --git a/src/main/java/gregtech/api/gui/GT_Container.java b/src/main/java/gregtech/api/gui/GT_Container.java index 614d459cb9..8eb908ecae 100644 --- a/src/main/java/gregtech/api/gui/GT_Container.java +++ b/src/main/java/gregtech/api/gui/GT_Container.java @@ -124,7 +124,7 @@ public class GT_Container extends Container { if ((aShifthold == 0 || aShifthold == 1) && (aMouseclick == 0 || aMouseclick == 1)) { if (aSlotIndex == -999) { - if (aPlayerInventory.getItemStack() != null && aSlotIndex == -999) { + if (aPlayerInventory.getItemStack() != null) { if (aMouseclick == 0) { aPlayer.dropPlayerItemWithRandomChoice(aPlayerInventory.getItemStack(), true); aPlayerInventory.setItemStack(null); @@ -228,11 +228,11 @@ public class GT_Container extends Container { var9 |= tTempStackSize > -1; } - if (aSlot.getHasStack() && var9) { + if (var9 && aSlot.getHasStack()) { aHoldStack = aSlot.getStack(); aPlayerInventory.setInventorySlotContents(aMouseclick, aHoldStack); - if ((aSlot.inventory != aPlayerInventory || !aSlot.isItemValid(tTempStack)) && tTempStack != null) { + if (tTempStack != null && (aSlot.inventory != aPlayerInventory || !aSlot.isItemValid(tTempStack))) { if (tTempStackSize > -1) { aPlayerInventory.addItemStackToInventory(tTempStack); aSlot.decrStackSize(aHoldStack.stackSize); @@ -244,7 +244,7 @@ public class GT_Container extends Container { aSlot.putStack(tTempStack); aSlot.onPickupFromSlot(aPlayer, aHoldStack); } - } else if (!aSlot.getHasStack() && tTempStack != null && aSlot.isItemValid(tTempStack)) { + } else if (tTempStack != null && !aSlot.getHasStack() && aSlot.isItemValid(tTempStack)) { aPlayerInventory.setInventorySlotContents(aMouseclick, (ItemStack) null); aSlot.putStack(tTempStack); } @@ -267,8 +267,7 @@ public class GT_Container extends Container { mTileEntity.markDirty(); - //null checks and checks if the item can be stacked (maxStackSize > 1) - if (getSlotCount() > 0 && slotObject != null && slotObject.getHasStack() && !(slotObject instanceof GT_Slot_Holo)) { + if (getSlotCount() > 0 && !(slotObject instanceof GT_Slot_Holo) && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = GT_Utility.copy(stackInSlot); diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java index 4c20715e68..b9cae3e0b3 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java @@ -29,7 +29,7 @@ public class GT_GUIContainerMetaTile_Machine extends GT_GUIContainer { super.drawGuiContainerBackgroundLayer(par1, par2, par3); if (GregTech_API.sColoredGUI && mContainer != null && mContainer.mTileEntity != null) { int tColor = mContainer.mTileEntity.getColorization() & 15; - if (tColor >= 0 && tColor < ItemDye.field_150922_c.length) { + if (tColor < ItemDye.field_150922_c.length) { tColor = ItemDye.field_150922_c[tColor]; GL11.glColor4f(((tColor >> 16) & 255) / 255.0F, ((tColor >> 8) & 255) / 255.0F, (tColor & 255) / 255.0F, 1.0F); } else GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java index 510f314d8c..54f1f484b7 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntityItemPipe.java @@ -65,9 +65,9 @@ public interface IMetaTileEntityItemPipe extends IMetaTileEntity { continue; } } - if (tItemPipe != null && tItemPipe instanceof BaseMetaPipeEntity) { + if (tItemPipe instanceof BaseMetaPipeEntity) { IMetaTileEntity tMetaTileEntity = tItemPipe.getMetaTileEntity(); - if (tMetaTileEntity != null && tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsOut(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) { + if (tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsOut(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) { scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, aMap, aStep, aSuckItems, aIgnoreCapacity); } } @@ -84,7 +84,7 @@ public interface IMetaTileEntityItemPipe extends IMetaTileEntity { } if (tItemPipe instanceof BaseMetaPipeEntity) { IMetaTileEntity tMetaTileEntity = tItemPipe.getMetaTileEntity(); - if (tMetaTileEntity != null && tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsIn(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) { + if (tMetaTileEntity instanceof IMetaTileEntityItemPipe && tItemPipe.getCoverBehaviorAtSide(j).letsItemsIn(j, tItemPipe.getCoverIDAtSide(j), tItemPipe.getCoverDataAtSide(j), -2, tItemPipe)) { scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, aMap, aStep, aSuckItems, aIgnoreCapacity); } } diff --git a/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java b/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java index 6e3c6df6e1..78814803e4 100644 --- a/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java +++ b/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java @@ -23,14 +23,14 @@ import net.minecraftforge.common.ISpecialArmor; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingFallEvent; -import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import static gregtech.api.enums.GT_Values.RES_PATH_ITEM; public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor { - public static Map jumpChargeMap = new HashMap(); + public static Map jumpChargeMap = new ConcurrentHashMap(); public int mCharge, mTransfer, mTier, mDamageEnergyCost, mSpecials; public boolean mChargeProvider; public double mArmorAbsorbtionPercentage; @@ -200,9 +200,6 @@ public class GT_EnergyArmor_Item extends ItemArmor implements ISpecialArmor { if (tTargetChargeItem == null || !GT_ModHandler.isElectricItem(tTargetChargeItem)) { tTargetChargeItem = null; } - if (tTargetDechargeItem == null || !GT_ModHandler.isElectricItem(tTargetChargeItem) || !(aStack == tTargetDechargeItem || GT_ModHandler.isChargerItem(tTargetDechargeItem))) { - tTargetDechargeItem = null; - } if (aPlayer.worldObj.isDaytime() && aPlayer.worldObj.canBlockSeeTheSky(MathHelper.floor_double(aPlayer.posX), MathHelper.floor_double(aPlayer.posY + 1), MathHelper.floor_double(aPlayer.posZ))) { if ((mSpecials & 32) != 0 && tTargetChargeItem != null) { diff --git a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java index a921377a2e..7796691540 100644 --- a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java @@ -25,21 +25,20 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; +import java.util.concurrent.ConcurrentHashMap; import static gregtech.api.enums.GT_Values.D1; import static gregtech.api.enums.GT_Values.V; public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpecialElectricItem, IElectricItemManager, IFluidContainerItem { /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ - private final HashMap<Short, ArrayList<IItemBehaviour<GT_MetaBase_Item>>> mItemBehaviors = new HashMap<Short, ArrayList<IItemBehaviour<GT_MetaBase_Item>>>(); + private final ConcurrentHashMap<Short, ArrayList<IItemBehaviour<GT_MetaBase_Item>>> mItemBehaviors = new ConcurrentHashMap<Short, ArrayList<IItemBehaviour<GT_MetaBase_Item>>>(); /** * Creates the Item using these Parameters. * * @param aUnlocalized The Unlocalized Name of this Item. - * @param aGeneratedPrefixList The OreDict Prefixes you want to have generated. */ public GT_MetaBase_Item(String aUnlocalized) { super(aUnlocalized, "Generated Item", null, false); @@ -120,19 +119,18 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci use(aStack, 0, aPlayer); isItemStackUsable(aStack); ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack)); - if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList) - try { - if (tBehavior.onLeftClickEntity(this, aStack, aPlayer, aEntity)) { - if (aStack.stackSize <= 0) aPlayer.destroyCurrentEquippedItem(); - return true; - } - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - return false; - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); + try { if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList) + if (tBehavior.onLeftClickEntity(this, aStack, aPlayer, aEntity)) { + if (aStack.stackSize <= 0) aPlayer.destroyCurrentEquippedItem(); + return true; } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + return false; + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } return false; } @@ -141,19 +139,18 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci use(aStack, 0, aPlayer); isItemStackUsable(aStack); ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack)); - if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList) - try { - if (tBehavior.onItemUse(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) { - if (aStack.stackSize <= 0) aPlayer.destroyCurrentEquippedItem(); - return true; - } - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - return false; - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); + try { if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList) + if (tBehavior.onItemUse(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) { + if (aStack.stackSize <= 0) aPlayer.destroyCurrentEquippedItem(); + return true; } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + return false; + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } return false; } @@ -162,19 +159,18 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci use(aStack, 0, aPlayer); isItemStackUsable(aStack); ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack)); - if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList) - try { - if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) { - if (aStack.stackSize <= 0) aPlayer.destroyCurrentEquippedItem(); - return true; - } - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - return false; - } - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); + try { if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList) + if (tBehavior.onItemUseFirst(this, aStack, aPlayer, aWorld, aX, aY, aZ, aSide, hitX, hitY, hitZ)) { + if (aStack.stackSize <= 0) aPlayer.destroyCurrentEquippedItem(); + return true; } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + return false; + } + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } return false; } @@ -183,12 +179,11 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci use(aStack, 0, aPlayer); isItemStackUsable(aStack); ArrayList<IItemBehaviour<GT_MetaBase_Item>> tList = mItemBehaviors.get((short) getDamage(aStack)); - if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList) - try { - aStack = tBehavior.onItemRightClick(this, aStack, aWorld, aPlayer); - } catch (Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } + try { if (tList != null) for (IItemBehaviour<GT_MetaBase_Item> tBehavior : tList) + aStack = tBehavior.onItemRightClick(this, aStack, aWorld, aPlayer); + } catch (Throwable e) { + if (D1) e.printStackTrace(GT_Log.err); + } return aStack; } @@ -207,7 +202,7 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci if (tStats[3] == -2 && tCharge <= 0) { aList.add(EnumChatFormatting.AQUA + "Empty. You should recycle it properly." + EnumChatFormatting.GRAY); } else { - aList.add(EnumChatFormatting.AQUA + "" + GT_Utility.formatNumbers(tCharge) + " / " + GT_Utility.formatNumbers(Math.abs(tStats[0])) + " EU - Voltage: " + V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)] + EnumChatFormatting.GRAY); + aList.add(String.valueOf(EnumChatFormatting.AQUA) + GT_Utility.formatNumbers(tCharge) + " / " + GT_Utility.formatNumbers(Math.abs(tStats[0])) + " EU - Voltage: " + V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)] + EnumChatFormatting.GRAY); } } } @@ -294,7 +289,7 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci chargeFromArmor(aStack, aPlayer); if (aPlayer instanceof EntityPlayer && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) return true; double tTransfer = discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, true); - if (tTransfer == aAmount) { + if (Math.abs(tTransfer - aAmount) < .0000001) { discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); chargeFromArmor(aStack, aPlayer); return true; diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java index a246e83d7a..9020eb09e8 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Item.java @@ -31,6 +31,7 @@ import squeek.applecore.api.food.FoodValues; import squeek.applecore.api.food.IEdible; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import static gregtech.api.enums.GT_Values.*; @@ -54,7 +55,7 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements * <p/> * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. */ - public static final HashMap<String, GT_MetaGenerated_Item> sInstances = new HashMap<String, GT_MetaGenerated_Item>(); + public static final ConcurrentHashMap<String, GT_MetaGenerated_Item> sInstances = new ConcurrentHashMap<String, GT_MetaGenerated_Item>(); /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ @@ -63,10 +64,10 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements public final BitSet mVisibleItems; public final IIcon[][] mIconList; - public final HashMap<Short, IFoodStat> mFoodStats = new HashMap<Short, IFoodStat>(); - public final HashMap<Short, Long[]> mElectricStats = new HashMap<Short, Long[]>(); - public final HashMap<Short, Long[]> mFluidContainerStats = new HashMap<Short, Long[]>(); - public final HashMap<Short, Short> mBurnValues = new HashMap<Short, Short>(); + public final ConcurrentHashMap<Short, IFoodStat> mFoodStats = new ConcurrentHashMap<Short, IFoodStat>(); + public final ConcurrentHashMap<Short, Long[]> mElectricStats = new ConcurrentHashMap<Short, Long[]>(); + public final ConcurrentHashMap<Short, Long[]> mFluidContainerStats = new ConcurrentHashMap<Short, Long[]>(); + public final ConcurrentHashMap<Short, Short> mBurnValues = new ConcurrentHashMap<Short, Short>(); /** * Creates the Item using these Parameters. @@ -299,7 +300,8 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements @Override @SideOnly(Side.CLIENT) public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { - for (int i = 0, j = mEnabledItems.length(); i < j; i++) + int j = mEnabledItems.length(); + for (int i = 0; i < j; i++) if (mVisibleItems.get(i) || (D1 && mEnabledItems.get(i))) { Long[] tStats = mElectricStats.get((short) (mOffset + i)); if (tStats != null && tStats[3] < 0) { @@ -319,7 +321,8 @@ public abstract class GT_MetaGenerated_Item extends GT_MetaBase_Item implements @Override @SideOnly(Side.CLIENT) public final void registerIcons(IIconRegister aIconRegister) { - for (short i = 0, j = (short) mEnabledItems.length(); i < j; i++) + short j = (short) mEnabledItems.length(); + for (short i = 0; i < j; i++) if (mEnabledItems.get(i)) { for (byte k = 1; k < mIconList[i].length; k++) { mIconList[i][k] = aIconRegister.registerIcon(RES_PATH_ITEM + (GT_Config.troll ? "troll" : getUnlocalizedName() + "/" + i + "/" + k)); diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index 29306be0c7..0fae6d119b 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -43,10 +43,9 @@ import net.minecraftforge.common.IShearable; import net.minecraftforge.event.world.BlockEvent; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map.Entry; -import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; import static gregtech.api.enums.GT_Values.MOD_ID_FR; import static gregtech.api.enums.GT_Values.MOD_ID_RC; @@ -63,11 +62,11 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements * <p/> * You can also use the unlocalized Name gotten from getUnlocalizedName() as Key if you want to get a specific Item. */ - public static final HashMap<String, GT_MetaGenerated_Tool> sInstances = new HashMap<String, GT_MetaGenerated_Tool>(); + public static final ConcurrentHashMap<String, GT_MetaGenerated_Tool> sInstances = new ConcurrentHashMap<String, GT_MetaGenerated_Tool>(); /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ - public final HashMap<Short, IToolStats> mToolStats = new HashMap<Short, IToolStats>(); + public final ConcurrentHashMap<Short, IToolStats> mToolStats = new ConcurrentHashMap<Short, IToolStats>(); /** * Creates the Item using these Parameters. @@ -415,7 +414,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements return true; } if (use(aStack, (int) aAmount, null)) { - if (new Random().nextInt(25) == 0) { + if (java.util.concurrent.ThreadLocalRandom.current().nextInt(0, 25) == 0) { long tNewDamage = getToolDamage(aStack) + aAmount; setToolDamage(aStack, tNewDamage); if (tNewDamage >= getToolMaxDamage(aStack)) { @@ -600,13 +599,13 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements @Override public boolean isItemStackUsable(ItemStack aStack) { IToolStats tStats = getToolStatsInternal(aStack); - if (aStack.getItemDamage() % 2 == 1 || tStats == null) { + if (aStack.getItemDamage() % 2 != 0 || tStats == null) { NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) aNBT.removeTag("ench"); return false; } Materials aMaterial = getPrimaryMaterial(aStack); - HashMap<Integer, Integer> tMap = new HashMap<Integer, Integer>(), tResult = new HashMap<Integer, Integer>(); + ConcurrentHashMap<Integer, Integer> tMap = new ConcurrentHashMap<Integer, Integer>(), tResult = new ConcurrentHashMap<Integer, Integer>(); if (aMaterial.mEnchantmentTools != null) { tMap.put(aMaterial.mEnchantmentTools.effectId, (int) aMaterial.mEnchantmentToolsLevel); if (aMaterial.mEnchantmentTools == Enchantment.fortune) diff --git a/src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java b/src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java index 455cfb14a5..9304068159 100644 --- a/src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java +++ b/src/main/java/gregtech/api/items/GT_RadioactiveCellIC_Item.java @@ -1,7 +1,6 @@ package gregtech.api.items; -import gregtech.api.enums.ItemList; import ic2.api.reactor.IReactor; import ic2.api.reactor.IReactorComponent; import ic2.core.IC2Potion; @@ -54,7 +53,7 @@ public class GT_RadioactiveCellIC_Item extends GT_RadioactiveCell_Item implement for (int i = 0; i < pulses; i++) { acceptUraniumPulse(reactor, yourStack, yourStack, x, y, x, y, heatrun); } - pulses += checkPulseable(reactor, x - 1, y, yourStack, x, y, heatrun) + checkPulseable(reactor, x + 1, y, yourStack, x, y, heatrun) + checkPulseable(reactor, x, y - 1, yourStack, x, y, heatrun) + checkPulseable(reactor, x, y + 1, yourStack, x, y, heatrun); + checkPulseable(reactor, x - 1, y, yourStack, x, y, heatrun);checkPulseable(reactor, x + 1, y, yourStack, x, y, heatrun);checkPulseable(reactor, x, y - 1, yourStack, x, y, heatrun);checkPulseable(reactor, x, y + 1, yourStack, x, y, heatrun); } else { pulses += checkPulseable(reactor, x - 1, y, yourStack, x, y, heatrun) + checkPulseable(reactor, x + 1, y, yourStack, x, y, heatrun) + checkPulseable(reactor, x, y - 1, yourStack, x, y, heatrun) + checkPulseable(reactor, x, y + 1, yourStack, x, y, heatrun); diff --git a/src/main/java/gregtech/api/items/GT_Spray_Hardener_Item.java b/src/main/java/gregtech/api/items/GT_Spray_Hardener_Item.java index b9b0b7462b..926bcc60dc 100644 --- a/src/main/java/gregtech/api/items/GT_Spray_Hardener_Item.java +++ b/src/main/java/gregtech/api/items/GT_Spray_Hardener_Item.java @@ -50,7 +50,7 @@ public class GT_Spray_Hardener_Item extends GT_Tool_Item { } ItemStack tStack1 = GT_ModHandler.getIC2Item("constructionFoam", 1), tStack2 = GT_ModHandler.getIC2Item("constructionFoamWall", 1); - if (tStack1 != null && tStack1.isItemEqual(new ItemStack(aBlock)) && tStack2 != null && tStack2.getItem() != null && tStack2.getItem() instanceof ItemBlock) { + if (tStack1 != null && tStack1.isItemEqual(new ItemStack(aBlock)) && tStack2 != null && tStack2.getItem() instanceof ItemBlock) { if (GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) { GT_Utility.sendSoundToPlayers(aWorld, GregTech_API.sSoundList.get(102), 1.0F, -1, aX, aY, aZ); aWorld.setBlock(aX, aY, aZ, GT_Utility.getBlockFromStack(tStack2), 7, 3); diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 91201a2a8d..01ca8c0f7b 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -1,5 +1,6 @@ package gregtech.api.metatileentity; +import cpw.mods.fml.common.FMLLog; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -158,13 +159,11 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE if (aID <= 0 || aID >= GregTech_API.METATILEENTITIES.length || GregTech_API.METATILEENTITIES[aID] == null) { GT_Log.err.println("MetaID " + aID + " not loadable => locking TileEntity!"); } else { - if (aID != 0) { - if (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null); - GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); - mTickTimer = 0; - mID = aID; - return true; - } + if (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null); + GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); + mTickTimer = 0; + mID = aID; + return true; } return false; } @@ -179,125 +178,125 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } long tTime = System.currentTimeMillis(); + int tCode = 0; - for (int tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { - try { - switch (tCode) { - case 0: - tCode++; - if (mTickTimer++ == 0) { - oX = xCoord; - oY = yCoord; - oZ = zCoord; - if (isServerSide()) for (byte i = 0; i < 6; i++) - if (getCoverIDAtSide(i) != 0) - if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) - dropCover(i, i, true); - worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this); - mMetaTileEntity.onFirstTick(this); - if (!hasValidMetaTileEntity()) return; + try { for (tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { + switch (tCode) { + case 0: + tCode++; + if (mTickTimer++ == 0) { + oX = xCoord; + oY = yCoord; + oZ = zCoord; + if (isServerSide()) for (byte i = 0; i < 6; i++) + if (getCoverIDAtSide(i) != 0) + if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) + dropCover(i, i, true); + worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this); + mMetaTileEntity.onFirstTick(this); + if (!hasValidMetaTileEntity()) return; + } + case 1: + tCode++; + if (isClientSide()) { + if (mColor != oColor) { + mMetaTileEntity.onColorChangeClient(oColor = mColor); + issueTextureUpdate(); } - case 1: - tCode++; - if (isClientSide()) { - if (mColor != oColor) { - mMetaTileEntity.onColorChangeClient(oColor = mColor); - issueTextureUpdate(); - } - if (mNeedsUpdate) { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - //worldObj.func_147479_m(xCoord, yCoord, zCoord); - mNeedsUpdate = false; - } + if (mNeedsUpdate) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + //worldObj.func_147479_m(xCoord, yCoord, zCoord); + mNeedsUpdate = false; } - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - if (isServerSide() && mTickTimer > 10) { - for (byte i = (byte) (tCode - 2); i < 6; i++) - if (getCoverIDAtSide(i) != 0) { - tCode++; - GT_CoverBehavior tCover = getCoverBehaviorAtSide(i); - int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this); - if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) { - mCoverData[i] = tCover.doCoverThings(i, getInputRedstoneSignal(i), getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); - if (!hasValidMetaTileEntity()) return; - } + } + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + if (isServerSide() && mTickTimer > 10) { + for (byte i = (byte) (tCode - 2); i < 6; i++) + if (getCoverIDAtSide(i) != 0) { + tCode++; + GT_CoverBehavior tCover = getCoverBehaviorAtSide(i); + int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this); + if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) { + mCoverData[i] = tCover.doCoverThings(i, getInputRedstoneSignal(i), getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); + if (!hasValidMetaTileEntity()) return; } - mConnections = (byte) (mMetaTileEntity.mConnections | (mConnections & ~63)); - if ((mConnections & -64) == 64 && getRandomNumber(1000) == 0) { - mConnections = (byte) ((mConnections & ~64) | -128); } + mConnections = (byte) (mMetaTileEntity.mConnections | (mConnections & ~63)); + if ((mConnections & -64) == 64 && getRandomNumber(1000) == 0) { + mConnections = (byte) ((mConnections & ~64) | -128); + } + } + case 8: + tCode = 9; + mMetaTileEntity.onPreTick(this, mTickTimer); + if (!hasValidMetaTileEntity()) return; + case 9: + tCode++; + if (isServerSide()) { + if (mTickTimer == 10) { + for (byte i = 0; i < 6; i++) + mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); + issueBlockUpdate(); } - case 8: - tCode = 9; - mMetaTileEntity.onPreTick(this, mTickTimer); - if (!hasValidMetaTileEntity()) return; - case 9: - tCode++; - if (isServerSide()) { - if (mTickTimer == 10) { - for (byte i = 0; i < 6; i++) - mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - issueBlockUpdate(); - } - if (xCoord != oX || yCoord != oY || zCoord != oZ) { - oX = xCoord; - oY = yCoord; - oZ = zCoord; - issueClientUpdate(); - clearTileEntityBuffer(); - } + if (xCoord != oX || yCoord != oY || zCoord != oZ) { + oX = xCoord; + oY = yCoord; + oZ = zCoord; + issueClientUpdate(); + clearTileEntityBuffer(); } - case 10: - tCode++; - mMetaTileEntity.onPostTick(this, mTickTimer); - if (!hasValidMetaTileEntity()) return; - case 11: - tCode++; - if (isServerSide()) { - if (mTickTimer % 10 == 0) { - if (mSendClientData) { - NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], oTextureData = mConnections, oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), oColor = mColor), xCoord, zCoord); - mSendClientData = false; - } + } + case 10: + tCode++; + mMetaTileEntity.onPostTick(this, mTickTimer); + if (!hasValidMetaTileEntity()) return; + case 11: + tCode++; + if (isServerSide()) { + if (mTickTimer % 10 == 0) { + if (mSendClientData) { + NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], oTextureData = mConnections, oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), oColor = mColor), xCoord, zCoord); + mSendClientData = false; } + } - if (mTickTimer > 10) { - if (mConnections != oTextureData) sendBlockEvent((byte) 0, oTextureData = mConnections); - byte tData = mMetaTileEntity.getUpdateData(); - if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData); - if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor); - tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)); - if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData); - } + if (mTickTimer > 10) { + if (mConnections != oTextureData) sendBlockEvent((byte) 0, oTextureData = mConnections); + byte tData = mMetaTileEntity.getUpdateData(); + if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData); + if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor); + tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)); + if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData); + } - if (mNeedsBlockUpdate) { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0)); - mNeedsBlockUpdate = false; - } + if (mNeedsBlockUpdate) { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0)); + mNeedsBlockUpdate = false; } - default: - tCode = -1; - break; - } - } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); + } + default: + tCode = -1; + break; } } + } catch (Throwable e) { + //GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + e.printStackTrace(GT_Log.err); + } if (isServerSide() && hasValidMetaTileEntity()) { tTime = System.currentTimeMillis() - tTime; if (mTimeStatistics.length > 0) mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = (int) tTime; if (tTime > 0 && tTime > GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING && mTickTimer > 1000 && getMetaTileEntity().doTickProfilingMessageDuringThisTick() && mLagWarningCount++ < 10) - System.out.println("WARNING: Possible Lag Source at [" + xCoord + ", " + yCoord + ", " + zCoord + "] in Dimension " + worldObj.provider.dimensionId + " with " + tTime + "ms caused by an instance of " + getMetaTileEntity().getClass()); + FMLLog.warning("WARNING: Possible Lag Source at [%s,%s,%s] in Dimension %s with %s ms caused by an instance of %s", xCoord, yCoord, zCoord, worldObj.provider.dimensionId, tTime, getMetaTileEntity().getClass()); } mWorkUpdate = mInventoryChanged = false; @@ -311,7 +310,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE public final void receiveMetaTileEntityData(short aID, int aCover0, int aCover1, int aCover2, int aCover3, int aCover4, int aCover5, byte aTextureData, byte aUpdateData, byte aRedstoneData, byte aColorData) { issueTextureUpdate(); - if (mID != aID && aID > 0) { + if (aID > 0 && mID != aID) { mID = aID; createNewMetatileEntity(mID); } @@ -358,12 +357,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE mColor = (byte) aValue; break; case 3: - mSidedRedstone[0] = (byte) ((aValue & 1) > 0 ? 15 : 0); - mSidedRedstone[1] = (byte) ((aValue & 2) > 0 ? 15 : 0); - mSidedRedstone[2] = (byte) ((aValue & 4) > 0 ? 15 : 0); - mSidedRedstone[3] = (byte) ((aValue & 8) > 0 ? 15 : 0); - mSidedRedstone[4] = (byte) ((aValue & 16) > 0 ? 15 : 0); - mSidedRedstone[5] = (byte) ((aValue & 32) > 0 ? 15 : 0); + mSidedRedstone[0] = (byte) ((aValue & 1) == 1 ? 15 : 0); + mSidedRedstone[1] = (byte) ((aValue & 2) == 2 ? 15 : 0); + mSidedRedstone[2] = (byte) ((aValue & 4) == 4 ? 15 : 0); + mSidedRedstone[3] = (byte) ((aValue & 8) == 8 ? 15 : 0); + mSidedRedstone[4] = (byte) ((aValue & 16) == 16 ? 15 : 0); + mSidedRedstone[5] = (byte) ((aValue & 32) == 32 ? 15 : 0); break; case 4: if (hasValidMetaTileEntity() && mTickTimer > 20) @@ -731,7 +730,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } protected boolean canAccessData() { - return !isDead && hasValidMetaTileEntity(); + return hasValidMetaTileEntity() && !isDead; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 9917ca62d7..e2a23e4b41 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -206,13 +206,11 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if (aID <= 0 || aID >= GregTech_API.METATILEENTITIES.length || GregTech_API.METATILEENTITIES[aID] == null) { GT_Log.err.println("MetaID " + aID + " not loadable => locking TileEntity!"); } else { - if (aID != 0) { - if (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null); - GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); - mTickTimer = 0; - mID = aID; - return true; - } + if (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null); + GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); + mTickTimer = 0; + mID = aID; + return true; } return false; } @@ -250,293 +248,280 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mRunningThroughTick = true; long tTime = System.currentTimeMillis(); + int tCode = 0; + boolean aSideServer = isServerSide(); + boolean aSideClient = isClientSide(); - for (int tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { - try { - switch (tCode) { - case 0: - tCode++; - if (mTickTimer++ == 0) { - oX = xCoord; - oY = yCoord; - oZ = zCoord; - if (isServerSide()) for (byte i = 0; i < 6; i++) - if (getCoverIDAtSide(i) != 0) - if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) - dropCover(i, i, true); - - worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this); - - mMetaTileEntity.onFirstTick(this); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } + try { for (tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { + switch (tCode) { + case 0: + tCode++; + if (mTickTimer++ == 0) { + oX = xCoord; + oY = yCoord; + oZ = zCoord; + if (aSideServer) for (byte i = 0; i < 6; i++) + if (getCoverIDAtSide(i) != 0) + if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) + dropCover(i, i, true); + worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this); + mMetaTileEntity.onFirstTick(this); + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + } + case 1: + tCode++; + if (aSideClient) { + if (mColor != oColor) { + mMetaTileEntity.onColorChangeClient(oColor = mColor); + issueTextureUpdate(); } - case 1: - tCode++; - if (isClientSide()) { - if (mColor != oColor) { - mMetaTileEntity.onColorChangeClient(oColor = mColor); - issueTextureUpdate(); - } - if (mLightValue != oLightValueClient) { - worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord + 1, yCoord, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord - 1, yCoord, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord + 1, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord - 1, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1); - oLightValueClient = mLightValue; - issueTextureUpdate(); - } + if (mLightValue != oLightValueClient) { + worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord + 1, yCoord, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord - 1, yCoord, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord + 1, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord - 1, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1); + oLightValueClient = mLightValue; + issueTextureUpdate(); + } - if (mNeedsUpdate) { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - //worldObj.func_147479_m(xCoord, yCoord, zCoord); - mNeedsUpdate = false; - } + if (mNeedsUpdate) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + //worldObj.func_147479_m(xCoord, yCoord, zCoord); + mNeedsUpdate = false; } - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - if (isServerSide() && mTickTimer > 10) { - for (byte i = (byte) (tCode - 2); i < 6; i++) - if (getCoverIDAtSide(i) != 0) { - tCode++; - GT_CoverBehavior tCover = getCoverBehaviorAtSide(i); - int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this); - if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) { - mCoverData[i] = tCover.doCoverThings(i, getInputRedstoneSignal(i), getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } + } + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + if (aSideServer && mTickTimer > 10) { + for (byte i = (byte) (tCode - 2); i < 6; i++) + if (getCoverIDAtSide(i) != 0) { + tCode++; + GT_CoverBehavior tCover = getCoverBehaviorAtSide(i); + int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this); + if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) { + mCoverData[i] = tCover.doCoverThings(i, getInputRedstoneSignal(i), getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; } } + } + } + case 8: + tCode = 9; + if (aSideServer) { + if (++mAverageEUInputIndex >= mAverageEUInput.length) mAverageEUInputIndex = 0; + if (++mAverageEUOutputIndex >= mAverageEUOutput.length) mAverageEUOutputIndex = 0; + + mAverageEUInput[mAverageEUInputIndex] = 0; + mAverageEUOutput[mAverageEUOutputIndex] = 0; + } + case 9: + tCode++; + mMetaTileEntity.onPreTick(this, mTickTimer); + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + case 10: + tCode++; + if (aSideServer) { + if (mRedstone != oRedstone || mTickTimer == 10) { + for (byte i = 0; i < 6; i++) + mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); + oRedstone = mRedstone; + issueBlockUpdate(); } - case 8: - tCode = 9; - if (isServerSide()) { - if (++mAverageEUInputIndex >= mAverageEUInput.length) mAverageEUInputIndex = 0; - if (++mAverageEUOutputIndex >= mAverageEUOutput.length) mAverageEUOutputIndex = 0; - - mAverageEUInput[mAverageEUInputIndex] = 0; - mAverageEUOutput[mAverageEUOutputIndex] = 0; + + if (xCoord != oX || yCoord != oY || zCoord != oZ) { + oX = xCoord; + oY = yCoord; + oZ = zCoord; + issueClientUpdate(); + clearTileEntityBuffer(); } - case 9: - tCode++; - mMetaTileEntity.onPreTick(this, mTickTimer); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; + + if (mFacing != oFacing) { + oFacing = mFacing; + for (byte i = 0; i < 6; i++) + if (getCoverIDAtSide(i) != 0) + if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) + dropCover(i, i, true); + issueBlockUpdate(); } - case 10: - tCode++; - if (isServerSide()) { - if (mRedstone != oRedstone || mTickTimer == 10) { - for (byte i = 0; i < 6; i++) - mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - oRedstone = mRedstone; - issueBlockUpdate(); - } - if (xCoord != oX || yCoord != oY || zCoord != oZ) { - oX = xCoord; - oY = yCoord; - oZ = zCoord; - issueClientUpdate(); - clearTileEntityBuffer(); - } + if (mTickTimer > 20 && mMetaTileEntity.isElectric()) { + mAcceptedAmperes = 0; - if (mFacing != oFacing) { - oFacing = mFacing; - for (byte i = 0; i < 6; i++) - if (getCoverIDAtSide(i) != 0) - if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) - dropCover(i, i, true); - issueBlockUpdate(); + if (getOutputVoltage() != oOutput) { + oOutput = getOutputVoltage(); } - if (mTickTimer > 20 && mMetaTileEntity.isElectric()) { - mAcceptedAmperes = 0; - - if (getOutputVoltage() != oOutput) { - oOutput = getOutputVoltage(); - } - - if (mMetaTileEntity.isEnetOutput() || mMetaTileEntity.isEnetInput()) { - for (byte i = 0; i < 6; i++) { - boolean - temp = isEnergyInputSide(i); - if (temp != mActiveEUInputs[i]) { - mActiveEUInputs[i] = temp; - } - temp = isEnergyOutputSide(i); - if (temp != mActiveEUOutputs[i]) { - mActiveEUOutputs[i] = temp; - } + if (mMetaTileEntity.isEnetOutput() || mMetaTileEntity.isEnetInput()) { + for (byte i = 0; i < 6; i++) { + boolean + temp = isEnergyInputSide(i); + if (temp != mActiveEUInputs[i]) { + mActiveEUInputs[i] = temp; + } + temp = isEnergyOutputSide(i); + if (temp != mActiveEUOutputs[i]) { + mActiveEUOutputs[i] = temp; } } + } - if (mMetaTileEntity.isEnetOutput() && oOutput > 0) { - long tOutputVoltage = Math.max(oOutput, oOutput + (1 << GT_Utility.getTier(oOutput))), tUsableAmperage = Math.min(getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); - if (tUsableAmperage > 0) { - long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork(oOutput, tUsableAmperage, this); - mAverageEUOutput[mAverageEUOutputIndex] += tEU; - decreaseStoredEU(tEU, true); - } + if (mMetaTileEntity.isEnetOutput() && oOutput > 0) { + long tOutputVoltage = Math.max(oOutput, oOutput + (1 << GT_Utility.getTier(oOutput))), tUsableAmperage = Math.min(getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); + if (tUsableAmperage > 0) { + long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork(oOutput, tUsableAmperage, this); + mAverageEUOutput[mAverageEUOutputIndex] += tEU; + decreaseStoredEU(tEU, true); + } + } + if (getEUCapacity() > 0) { + if (GregTech_API.sMachineFireExplosions && getRandomNumber(1000) == 0) { + Block tBlock = getBlockAtSide((byte) getRandomNumber(6)); + if (tBlock instanceof BlockFire) doEnergyExplosion(); } - if (getEUCapacity() > 0) { - if (GregTech_API.sMachineFireExplosions && getRandomNumber(1000) == 0) { - Block tBlock = getBlockAtSide((byte) getRandomNumber(6)); - if (tBlock != null && tBlock instanceof BlockFire) doEnergyExplosion(); - } - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } - if (getRandomNumber(1000) == 0) { - if ((getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord) - || (getCoverIDAtSide((byte) 2) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord - 1) - 1 < yCoord) - || (getCoverIDAtSide((byte) 3) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord + 1) - 1 < yCoord) - || (getCoverIDAtSide((byte) 4) == 0 && worldObj.getPrecipitationHeight(xCoord - 1, zCoord) - 1 < yCoord) - || (getCoverIDAtSide((byte) 5) == 0 && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) - 1 < yCoord)) { - if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) { - if (getRandomNumber(10) == 0) { - try { - GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); - } catch (Exception e) { - } - doEnergyExplosion(); - } else setOnFire(); - } - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getBiome().rainfall > 0 && getRandomNumber(3) == 0) { - try { - GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); - } catch (Exception e) { - } + if (getRandomNumber(1000) == 0) { + if ((getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord) + || (getCoverIDAtSide((byte) 2) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord - 1) - 1 < yCoord) + || (getCoverIDAtSide((byte) 3) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord + 1) - 1 < yCoord) + || (getCoverIDAtSide((byte) 4) == 0 && worldObj.getPrecipitationHeight(xCoord - 1, zCoord) - 1 < yCoord) + || (getCoverIDAtSide((byte) 5) == 0 && worldObj.getPrecipitationHeight(xCoord + 1, zCoord) - 1 < yCoord)) { + if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) { + if (getRandomNumber(10) == 0) { + GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); doEnergyExplosion(); - } + } else setOnFire(); } - } - } - } - - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - } - case 11: - tCode++; - if (isServerSide()) { - if (mMetaTileEntity.dechargerSlotCount() > 0 && getStoredEU() < getEUCapacity()) { - for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { - if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) { - dischargeItem(mMetaTileEntity.mInventory[i]); - if(ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i])>0){ - if((getStoredEU() + ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i]))<getEUCapacity()){ - increaseStoredEnergyUnits((long)ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i]),false); - mMetaTileEntity.mInventory[i].stackSize--; - } + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getBiome().rainfall > 0 && getRandomNumber(3) == 0) { + GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); + doEnergyExplosion(); } - if (mMetaTileEntity.mInventory[i].stackSize <= 0) - mMetaTileEntity.mInventory[i] = null; - mInventoryChanged = true; - } - } - } - } - case 12: - tCode++; - if (isServerSide()) { - if (mMetaTileEntity.rechargerSlotCount() > 0 && getStoredEU() > 0) { - for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { - if (getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) { - chargeItem(mMetaTileEntity.mInventory[i]); - if (mMetaTileEntity.mInventory[i].stackSize <= 0) - mMetaTileEntity.mInventory[i] = null; - mInventoryChanged = true; } } } } - case 13: - tCode++; - updateStatus(); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - case 14: - tCode++; - mMetaTileEntity.onPostTick(this, mTickTimer); + if (!hasValidMetaTileEntity()) { mRunningThroughTick = false; return; } - case 15: - tCode++; - if (isServerSide()) { - if (mTickTimer % 10 == 0) { - if (mSendClientData) { - NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)), oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), oColor = mColor), xCoord, zCoord); - mSendClientData = false; + } + case 11: + tCode++; + if (aSideServer) { + if (mMetaTileEntity.dechargerSlotCount() > 0 && getStoredEU() < getEUCapacity()) { + for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { + if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) { + dischargeItem(mMetaTileEntity.mInventory[i]); + if (mMetaTileEntity.mInventory[i].stackSize <= 0) + mMetaTileEntity.mInventory[i] = null; + mInventoryChanged = true; } } - - if (mTickTimer > 10) { - byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)); - if (tData != oTextureData) sendBlockEvent((byte) 0, oTextureData = tData); - tData = mMetaTileEntity.getUpdateData(); - if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData); - if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor); - tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)); - if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData); - if (mLightValue != oLightValue) { - worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord + 1, yCoord, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord - 1, yCoord, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord + 1, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord - 1, zCoord); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1); - worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1); - issueTextureUpdate(); - sendBlockEvent((byte) 7, oLightValue = mLightValue); + } + } + case 12: + tCode++; + if (aSideServer) { + if (mMetaTileEntity.rechargerSlotCount() > 0 && getStoredEU() > 0) { + for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { + if (getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) { + chargeItem(mMetaTileEntity.mInventory[i]); + if (mMetaTileEntity.mInventory[i].stackSize <= 0) + mMetaTileEntity.mInventory[i] = null; + mInventoryChanged = true; } } + } + } + case 13: + tCode++; + updateStatus(); + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + case 14: + tCode++; + mMetaTileEntity.onPostTick(this, mTickTimer); + if (!hasValidMetaTileEntity()) { + mRunningThroughTick = false; + return; + } + case 15: + tCode++; + if (aSideServer) { + if (mTickTimer % 10 == 0) { + if (mSendClientData) { + NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_TileEntity(xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)), oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), oColor = mColor), xCoord, zCoord); + mSendClientData = false; + } + } - if (mNeedsBlockUpdate) { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0)); - mNeedsBlockUpdate = false; + if (mTickTimer > 10) { + byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)); + if (tData != oTextureData) sendBlockEvent((byte) 0, oTextureData = tData); + tData = mMetaTileEntity.getUpdateData(); + if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData); + if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor); + tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)); + if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData); + if (mLightValue != oLightValue) { + worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord + 1, yCoord, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord - 1, yCoord, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord + 1, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord - 1, zCoord); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1); + worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1); + issueTextureUpdate(); + sendBlockEvent((byte) 7, oLightValue = mLightValue); } } - default: - tCode = -1; - break; - } - } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); + + if (mNeedsBlockUpdate) { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0)); + mNeedsBlockUpdate = false; + } + } + default: + tCode = -1; } } + } catch (Throwable e) { + //gregtech.api.util.GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + e.printStackTrace(GT_Log.err); + } - if (isServerSide() && hasValidMetaTileEntity()) { + if (aSideServer && hasValidMetaTileEntity()) { tTime = System.currentTimeMillis() - tTime; if (mTimeStatistics.length > 0) mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = (int) tTime; @@ -595,7 +580,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mFacing = (byte) (aValue & 7); mActive = ((aValue & 8) != 0); mRedstone = ((aValue & 16) != 0); -// mLockUpgrade = ((aValue&32) != 0); + //mLockUpgrade = ((aValue&32) != 0); break; case 1: if (hasValidMetaTileEntity()) mMetaTileEntity.onValueUpdate((byte) aValue); @@ -605,12 +590,12 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mColor = (byte) aValue; break; case 3: - mSidedRedstone[0] = (byte) ((aValue & 1) > 0 ? 15 : 0); - mSidedRedstone[1] = (byte) ((aValue & 2) > 0 ? 15 : 0); - mSidedRedstone[2] = (byte) ((aValue & 4) > 0 ? 15 : 0); - mSidedRedstone[3] = (byte) ((aValue & 8) > 0 ? 15 : 0); - mSidedRedstone[4] = (byte) ((aValue & 16) > 0 ? 15 : 0); - mSidedRedstone[5] = (byte) ((aValue & 32) > 0 ? 15 : 0); + mSidedRedstone[0] = (byte) ((aValue & 1) == 1 ? 15 : 0); + mSidedRedstone[1] = (byte) ((aValue & 2) == 2 ? 15 : 0); + mSidedRedstone[2] = (byte) ((aValue & 4) == 4 ? 15 : 0); + mSidedRedstone[3] = (byte) ((aValue & 8) == 8 ? 15 : 0); + mSidedRedstone[4] = (byte) ((aValue & 16) == 16 ? 15 : 0); + mSidedRedstone[5] = (byte) ((aValue & 32) == 32 ? 15 : 0); break; case 4: if (hasValidMetaTileEntity() && mTickTimer > 20) @@ -1083,8 +1068,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE public boolean playerOwnsThis(EntityPlayer aPlayer, boolean aCheckPrecicely) { if (!canAccessData()) return false; - if (aCheckPrecicely || privateAccess() || mOwnerName.equals("")) - if (mOwnerName.equals("") && isServerSide()) setOwnerName(aPlayer.getDisplayName()); + if (aCheckPrecicely || privateAccess() || (mOwnerName.length() == 0)) + if ((mOwnerName.length() == 0) && isServerSide()) setOwnerName(aPlayer.getDisplayName()); else if (privateAccess() && !aPlayer.getDisplayName().equals("Player") && !mOwnerName.equals("Player") && !mOwnerName.equals(aPlayer.getDisplayName())) return false; return true; diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntityUE.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntityUE.java index 26388bd187..fda019f486 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntityUE.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntityUE.java @@ -75,7 +75,7 @@ public class BaseMetaTileEntityUE extends BaseMetaTileEntity /*implements IUETil for (byte i = 0; i < 6; i++) { if (inputEnergyFrom(i)) { Object tTileEntity = getTileEntityAtSide(i); - if (tTileEntity != null && tTileEntity instanceof IConductor) { + if (tTileEntity instanceof IConductor) { rSides.add(ForgeDirection.getOrientation(i)); } } @@ -88,7 +88,7 @@ public class BaseMetaTileEntityUE extends BaseMetaTileEntity /*implements IUETil for (byte i = 0; i < 6; i++) { if (outputsEnergyTo(i)) { Object tTileEntity = getTileEntityAtSide(i); - if (tTileEntity != null && tTileEntity instanceof IConductor) { + if (tTileEntity instanceof IConductor) { rSides.add(ForgeDirection.getOrientation(i)); } } diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index ac3da1a60a..b34483c31b 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -30,6 +30,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import static gregtech.api.enums.GT_Values.GT; import static gregtech.api.enums.GT_Values.V; @@ -83,7 +84,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity { } else { throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!"); } - mName = aBasicName.replaceAll(" ", "_").toLowerCase(); + mName = aBasicName.replaceAll(" ", "_").toLowerCase(Locale.ENGLISH); setBaseMetaTileEntity(new BaseMetaPipeEntity()); getBaseMetaTileEntity().setMetaTileID((short) aID); GT_LanguageManager.addStringLocalization("gt.blockmachines." + mName + ".name", aRegionalName); diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index e410c3cf12..662dc59d80 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -30,6 +30,7 @@ import net.minecraftforge.fluids.FluidTankInfo; import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import static gregtech.api.enums.GT_Values.GT; import static gregtech.api.enums.GT_Values.V; @@ -79,7 +80,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity { } else { throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!"); } - mName = aBasicName.replaceAll(" ", "_").toLowerCase(); + mName = aBasicName.replaceAll(" ", "_").toLowerCase(Locale.ENGLISH); setBaseMetaTileEntity(GregTech_API.constructBaseMetaTileEntity()); getBaseMetaTileEntity().setMetaTileID((short) aID); GT_LanguageManager.addStringLocalization("gt.blockmachines." + mName + ".name", aRegionalName); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java index 59e38ac5d9..560ddb0947 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java @@ -12,6 +12,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.objects.XSTR; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import net.minecraft.entity.Entity; @@ -27,8 +28,8 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import java.util.ArrayList; -import java.util.HashMap; import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; import static gregtech.api.enums.GT_Values.D1; @@ -186,7 +187,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { } if (mLastReceivedFrom == oLastReceivedFrom) { - HashMap<IFluidHandler, ForgeDirection> tTanks = new HashMap<IFluidHandler, ForgeDirection>(); + ConcurrentHashMap<IFluidHandler, ForgeDirection> tTanks = new ConcurrentHashMap<IFluidHandler, ForgeDirection>(); mConnections = 0; @@ -264,7 +265,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 5, 1.0F, aX, aY, aZ); for (byte i = 0; i < 6; i++) for (int l = 0; l < 2; ++l) - getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5 + Math.random(), aY - 0.5 + Math.random(), aZ - 0.5 + Math.random(), ForgeDirection.getOrientation(i).offsetX / 5.0, ForgeDirection.getOrientation(i).offsetY / 5.0, ForgeDirection.getOrientation(i).offsetZ / 5.0); + getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5 + (new XSTR()).nextFloat(), aY - 0.5 + (new XSTR()).nextFloat(), aZ - 0.5 + (new XSTR()).nextFloat(), ForgeDirection.getOrientation(i).offsetX / 5.0, ForgeDirection.getOrientation(i).offsetY / 5.0, ForgeDirection.getOrientation(i).offsetZ / 5.0); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java index 7cb88cb0cd..0a3ee8d5ce 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java @@ -19,7 +19,7 @@ import net.minecraft.tileentity.TileEntityDispenser; import net.minecraft.tileentity.TileEntityHopper; import java.util.ArrayList; -import java.util.HashMap; +import java.util.concurrent.ConcurrentHashMap; public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileEntityItemPipe { public final float mThickNess; @@ -205,7 +205,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE for (boolean temp = true; temp && !isInventoryEmpty() && pipeCapacityCheck(); ) { temp = false; tPipeList.clear(); - for (IMetaTileEntityItemPipe tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes(this, new HashMap<IMetaTileEntityItemPipe, Long>(), 0, false, false)).keySet()) { + for (IMetaTileEntityItemPipe tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes(this, new ConcurrentHashMap<IMetaTileEntityItemPipe, Long>(), 0, false, false)).keySet()) { if (temp) break; tPipeList.add(tTileEntity); while (!temp && !isInventoryEmpty() && tTileEntity.sendItemStack(aBaseMetaTileEntity)) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java index 026ecc27a5..131f52f351 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java @@ -6,6 +6,7 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.objects.XSTR; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import net.minecraft.entity.EntityLivingBase; @@ -149,7 +150,7 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE if (aIndex == 9) { GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 5, 1.0F, aX, aY, aZ); for (int l = 0; l < 8; ++l) - getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5 + Math.random(), aY - 0.5 + Math.random(), aZ - 0.5 + Math.random(), ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX / 5.0, ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetY / 5.0, ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ / 5.0); + getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5 + (new XSTR()).nextFloat(), aY - 0.5 + (new XSTR()).nextFloat(), aZ - 0.5 + (new XSTR()).nextFloat(), ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX / 5.0, ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetY / 5.0, ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ / 5.0); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java index fb863ef37a..9b0e386df4 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java @@ -1,7 +1,5 @@ package gregtech.api.metatileentity.implementations; -import java.util.Random; - import gregtech.api.enums.*; import gregtech.api.gui.GT_Container_BasicMachine; import gregtech.api.gui.GT_GUIContainer_BasicMachine; @@ -19,6 +17,9 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import java.util.Locale; +import java.util.Random; + import static gregtech.api.enums.GT_Values.V; import static gregtech.api.enums.GT_Values.W; @@ -35,7 +36,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ private final boolean mSharedTank, mRequiresFluidForFiltering; private final byte mGUIParameterA, mGUIParameterB; public GT_MetaTileEntity_BasicMachine_GT_Recipe(int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe) { - super(aID, aName, aNameRegional, aTier, aRecipes.mAmperage, aDescription, aInputSlots, aOutputSlots, aGUIName, aRecipes.mNEIName, new ITexture[]{new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_BOTTOM"))}); + super(aID, aName, aNameRegional, aTier, aRecipes.mAmperage, aDescription, aInputSlots, aOutputSlots, aGUIName, aRecipes.mNEIName, new ITexture[]{new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM"))}); mSharedTank = aSharedTank; mTankCapacity = aTankCapacity; mSpecialEffect = aSpecialEffect; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java index ee45c536b5..552d98f50b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java @@ -112,10 +112,7 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch } if (mSolderingTool && aPlayer instanceof EntityPlayerMP) { EntityPlayerMP tPlayer = (EntityPlayerMP) aPlayer; - try { - GT_Mod.instance.achievements.issueAchievement(tPlayer, "maintainance"); - } catch (Exception e) { - } + GT_Mod.instance.achievements.issueAchievement(tPlayer, "maintainance"); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 08bac989e3..7e45afdd2d 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -25,8 +25,6 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import org.apache.commons.lang3.ArrayUtils; - import static gregtech.api.enums.GT_Values.V; public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { @@ -240,10 +238,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { if (mOutputItems != null) for (ItemStack tStack : mOutputItems) if (tStack != null) { - try { - GT_Mod.instance.achievements.issueAchivementHatch(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack); - } catch (Exception e) { - } + GT_Mod.instance.achievements.issueAchivementHatch(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack); addOutput(tStack); } if (mOutputFluids != null && mOutputFluids.length == 1) { @@ -416,7 +411,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { NBTTagCompound tNBT = mInventory[1].getTagCompound(); if (tNBT != null) { - NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents"); + NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents");//tNBT2 dont use out if if (!tNBT.getBoolean("mDis")) { tNBT2 = new NBTTagCompound(); Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]); @@ -793,7 +788,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { @Override public String[] getInfoData() { - return new String[]{"Progress:", (mProgresstime / 20) + "secs", (mMaxProgresstime / 20) + "secs", "Efficiency:", (mEfficiency / 100.0F) + "%", "Problems:", "" + (getIdealStatus() - getRepairStatus())}; + return new String[]{"Progress:", (mProgresstime / 20) + "secs", (mMaxProgresstime / 20) + "secs", "Efficiency:", (mEfficiency / 100.0F) + "%", "Problems:", String.valueOf((getIdealStatus() - getRepairStatus()))}; } @Override diff --git a/src/main/java/gregtech/api/objects/ElementStack.java b/src/main/java/gregtech/api/objects/ElementStack.java index f3e1543614..773700f057 100644 --- a/src/main/java/gregtech/api/objects/ElementStack.java +++ b/src/main/java/gregtech/api/objects/ElementStack.java @@ -17,14 +17,14 @@ public class ElementStack implements Cloneable { @Override public ElementStack clone() { - return new ElementStack(mElement, mAmount); + try { return (ElementStack) super.clone(); } catch (Exception e) { return new ElementStack(mElement, mAmount); } } @Override public boolean equals(Object aObject) { if (aObject == this) return true; if (aObject == null) return false; - if (aObject instanceof Element) return aObject == mElement; + if (aObject instanceof Element) {return aObject == mElement;} if (aObject instanceof ElementStack) return ((ElementStack) aObject).mElement == mElement && (mAmount < 0 || ((ElementStack) aObject).mAmount < 0 || ((ElementStack) aObject).mAmount == mAmount); return false; diff --git a/src/main/java/gregtech/api/objects/GT_ArrayList.java b/src/main/java/gregtech/api/objects/GT_ArrayList.java index 5bc781e281..d16974bc78 100644 --- a/src/main/java/gregtech/api/objects/GT_ArrayList.java +++ b/src/main/java/gregtech/api/objects/GT_ArrayList.java @@ -6,6 +6,7 @@ import java.util.Collection; public class GT_ArrayList<E> extends ArrayList<E> { private static final long serialVersionUID = 1L; + private int size_sS; private final boolean mAllowNulls; @@ -17,13 +18,13 @@ public class GT_ArrayList<E> extends ArrayList<E> { public GT_ArrayList(boolean aAllowNulls, E... aArray) { super(Arrays.asList(aArray)); mAllowNulls = aAllowNulls; - if (!mAllowNulls) for (int i = 0; i < size(); i++) if (get(i) == null) remove(i--); + if (!mAllowNulls) {size_sS=size(); for (int i = 0; i < size_sS; i++) if (get(i) == null) {remove(i--);size_sS=size();}} } public GT_ArrayList(boolean aAllowNulls, Collection<? extends E> aList) { super(aList); mAllowNulls = aAllowNulls; - if (!mAllowNulls) for (int i = 0; i < size(); i++) if (get(i) == null) remove(i--); + if (!mAllowNulls) {size_sS=size(); for (int i = 0; i < size_sS; i++) if (get(i) == null) {remove(i--);size_sS=size();}} } @Override @@ -46,14 +47,14 @@ public class GT_ArrayList<E> extends ArrayList<E> { @Override public boolean addAll(Collection<? extends E> aList) { boolean rReturn = super.addAll(aList); - if (!mAllowNulls) for (int i = 0; i < size(); i++) if (get(i) == null) remove(i--); + if (!mAllowNulls) {size_sS=size(); for (int i = 0; i < size_sS; i++) if (get(i) == null) {remove(i--);size_sS=size();}} return rReturn; } @Override public boolean addAll(int aIndex, Collection<? extends E> aList) { boolean rReturn = super.addAll(aIndex, aList); - if (!mAllowNulls) for (int i = 0; i < size(); i++) if (get(i) == null) remove(i--); + if (!mAllowNulls) {size_sS=size(); for (int i = 0; i < size_sS; i++) if (get(i) == null) {remove(i--);size_sS=size();}} return rReturn; } }
\ No newline at end of file diff --git a/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java b/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java index caf46b3980..12c2e28a37 100644 --- a/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java +++ b/src/main/java/gregtech/api/objects/GT_CopiedBlockTexture.java @@ -36,7 +36,7 @@ public class GT_CopiedBlockTexture implements ITexture { this(aBlock, aSide, aMeta, Dyes._NULL.mRGBa); } - private IIcon getIcon(int aSide) { + private final IIcon getIcon(int aSide) { if (mSide == 6) return mBlock.getIcon(aSide, mMeta); return mBlock.getIcon(mSide, mMeta); } diff --git a/src/main/java/gregtech/api/objects/GT_FluidStack.java b/src/main/java/gregtech/api/objects/GT_FluidStack.java index 3f9e52818c..f4aad8ed5e 100644 --- a/src/main/java/gregtech/api/objects/GT_FluidStack.java +++ b/src/main/java/gregtech/api/objects/GT_FluidStack.java @@ -29,28 +29,25 @@ public class GT_FluidStack extends FluidStack { this(aFluid.getFluid(), aFluid.amount); } - public static synchronized void fixAllThoseFuckingFluidIDs() { - if (ForgeVersion.getBuildVersion() < 1355) { - while (lock) { - try { + public static final synchronized void fixAllThoseFuckingFluidIDs() { + if (ForgeVersion.getBuildVersion() < 1355 && ForgeVersion.getRevisionVersion() < 4) { + try { + while (lock) { Thread.sleep(1); - } catch (InterruptedException e) { - } - } + }} catch (InterruptedException e) {} lock = true; for (GT_FluidStack tFluid : sAllFluidStacks) tFluid.fixFluidIDForFucksSake(); - for (Map<Fluid, ?> tMap : GregTech_API.sFluidMappings) - try { + try { + for (Map<Fluid, ?> tMap : GregTech_API.sFluidMappings) GT_Utility.reMap(tMap); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } + } catch (Throwable e) {e.printStackTrace(GT_Log.err);} lock = false; } } - public void fixFluidIDForFucksSake() { - if (ForgeVersion.getBuildVersion() < 1355) { + @Deprecated + public final void fixFluidIDForFucksSake() { + if (ForgeVersion.getBuildVersion() < 1355 && ForgeVersion.getRevisionVersion() < 4) { int fluidID; try { fluidID = this.getFluid().getID(); @@ -67,7 +64,7 @@ public class GT_FluidStack extends FluidStack { @Override public FluidStack copy() { - if (ForgeVersion.getBuildVersion() < 1355) { + if (ForgeVersion.getBuildVersion() < 1355 && ForgeVersion.getRevisionVersion() < 4) { fixFluidIDForFucksSake(); } return new GT_FluidStack(this); diff --git a/src/main/java/gregtech/api/objects/GT_ItemStack.java b/src/main/java/gregtech/api/objects/GT_ItemStack.java index f865b348a0..9791cadeeb 100644 --- a/src/main/java/gregtech/api/objects/GT_ItemStack.java +++ b/src/main/java/gregtech/api/objects/GT_ItemStack.java @@ -24,16 +24,16 @@ public class GT_ItemStack { this(GT_Utility.intToStack(aHashCode)); } - public ItemStack toStack() { + public final ItemStack toStack() { if (mItem == null) return null; return new ItemStack(mItem, 1, mMetaData); } - public boolean isStackEqual(ItemStack aStack) { + public final boolean isStackEqual(ItemStack aStack) { return GT_Utility.areStacksEqual(toStack(), aStack); } - public boolean isStackEqual(GT_ItemStack aStack) { + public final boolean isStackEqual(GT_ItemStack aStack) { return GT_Utility.areStacksEqual(toStack(), aStack.toStack()); } diff --git a/src/main/java/gregtech/api/objects/GT_RenderedTexture.java b/src/main/java/gregtech/api/objects/GT_RenderedTexture.java index e1627da287..70b71cf125 100644 --- a/src/main/java/gregtech/api/objects/GT_RenderedTexture.java +++ b/src/main/java/gregtech/api/objects/GT_RenderedTexture.java @@ -70,10 +70,11 @@ public class GT_RenderedTexture implements ITexture, IColorModulationContainer { Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255); IIcon aIcon = mIconContainer.getIcon(); - double d3 = aIcon.getInterpolatedU(aRenderer.renderMaxX * 16.0D); - double d4 = aIcon.getInterpolatedU(aRenderer.renderMinX * 16.0D); - double d5 = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); - double d6 = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); + float d_16 = 16.0F; + float d3 = (float)aIcon.getInterpolatedU(aRenderer.renderMaxX * d_16); + float d4 = (float)aIcon.getInterpolatedU(aRenderer.renderMinX * d_16); + float d5 = (float)aIcon.getInterpolatedV(aRenderer.renderMinZ * d_16); + float d6 = (float)aIcon.getInterpolatedV(aRenderer.renderMaxZ * d_16); if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { d3 = aIcon.getMaxU(); @@ -85,24 +86,24 @@ public class GT_RenderedTexture implements ITexture, IColorModulationContainer { d6 = aIcon.getMaxV(); } - double d11 = aX + aRenderer.renderMinX; - double d12 = aX + aRenderer.renderMaxX; - double d13 = aY + aRenderer.renderMinY; - double d14 = aZ + aRenderer.renderMinZ; - double d15 = aZ + aRenderer.renderMaxZ; + float d11 = aX + (float)aRenderer.renderMinX; + float d12 = aX + (float)aRenderer.renderMaxX; + float d13 = aY + (float)aRenderer.renderMinY; + float d14 = aZ + (float)aRenderer.renderMinZ; + float d15 = aZ + (float)aRenderer.renderMaxZ; - Tessellator.instance.addVertexWithUV(d11, d13, d15, d3, d6); - Tessellator.instance.addVertexWithUV(d11, d13, d14, d3, d5); - Tessellator.instance.addVertexWithUV(d12, d13, d14, d4, d5); - Tessellator.instance.addVertexWithUV(d12, d13, d15, d4, d6); + Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d15, (double)d3, (double)d6); + Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d14, (double)d3, (double)d5); + Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d14, (double)d4, (double)d5); + Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d15, (double)d4, (double)d6); if ((aIcon = mIconContainer.getOverlayIcon()) != null) { Tessellator.instance.setColorRGBA(128, 128, 128, 255); - Tessellator.instance.addVertexWithUV(d11, d13, d15, d3, d6); - Tessellator.instance.addVertexWithUV(d11, d13, d14, d3, d5); - Tessellator.instance.addVertexWithUV(d12, d13, d14, d4, d5); - Tessellator.instance.addVertexWithUV(d12, d13, d15, d4, d6); + Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d15, (double)d3, (double)d6); + Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d14, (double)d3, (double)d5); + Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d14, (double)d4, (double)d5); + Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d15, (double)d4, (double)d6); } } diff --git a/src/main/java/gregtech/api/objects/GT_SidedTexture.java b/src/main/java/gregtech/api/objects/GT_SidedTexture.java index 2d27ecbc25..2b4f144393 100644 --- a/src/main/java/gregtech/api/objects/GT_SidedTexture.java +++ b/src/main/java/gregtech/api/objects/GT_SidedTexture.java @@ -78,10 +78,11 @@ public class GT_SidedTexture implements ITexture, IColorModulationContainer { Tessellator.instance.setColorRGBA((int) (mRGBa[0] * 0.5F), (int) (mRGBa[1] * 0.5F), (int) (mRGBa[2] * 0.5F), mAllowAlpha ? 255 - mRGBa[3] : 255); IIcon aIcon = mIconContainer[0].getIcon(); - double d3 = aIcon.getInterpolatedU(aRenderer.renderMaxX * 16.0D); - double d4 = aIcon.getInterpolatedU(aRenderer.renderMinX * 16.0D); - double d5 = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); - double d6 = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); + float d_16 = 16.0F; + float d3 = (float)aIcon.getInterpolatedU(aRenderer.renderMaxX * d_16); + float d4 = (float)aIcon.getInterpolatedU(aRenderer.renderMinX * d_16); + float d5 = (float)aIcon.getInterpolatedV(aRenderer.renderMinZ * d_16); + float d6 = (float)aIcon.getInterpolatedV(aRenderer.renderMaxZ * d_16); if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { d3 = aIcon.getMaxU(); @@ -93,24 +94,24 @@ public class GT_SidedTexture implements ITexture, IColorModulationContainer { d6 = aIcon.getMaxV(); } - double d11 = aX + aRenderer.renderMinX; - double d12 = aX + aRenderer.renderMaxX; - double d13 = aY + aRenderer.renderMinY; - double d14 = aZ + aRenderer.renderMinZ; - double d15 = aZ + aRenderer.renderMaxZ; + float d11 = aX + (float)aRenderer.renderMinX; + float d12 = aX + (float)aRenderer.renderMaxX; + float d13 = aY + (float)aRenderer.renderMinY; + float d14 = aZ + (float)aRenderer.renderMinZ; + float d15 = aZ + (float)aRenderer.renderMaxZ; - Tessellator.instance.addVertexWithUV(d11, d13, d15, d3, d6); - Tessellator.instance.addVertexWithUV(d11, d13, d14, d3, d5); - Tessellator.instance.addVertexWithUV(d12, d13, d14, d4, d5); - Tessellator.instance.addVertexWithUV(d12, d13, d15, d4, d6); + Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d15, (double)d3, (double)d6); + Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d14, (double)d3, (double)d5); + Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d14, (double)d4, (double)d5); + Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d15, (double)d4, (double)d6); if ((aIcon = mIconContainer[0].getOverlayIcon()) != null) { Tessellator.instance.setColorRGBA(128, 128, 128, 255); - d3 = aIcon.getInterpolatedU(aRenderer.renderMaxX * 16.0D); - d4 = aIcon.getInterpolatedU(aRenderer.renderMinX * 16.0D); - d5 = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); - d6 = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); + d3 = (float)aIcon.getInterpolatedU(aRenderer.renderMaxX * d_16); + d4 = (float)aIcon.getInterpolatedU(aRenderer.renderMinX * d_16); + d5 = (float)aIcon.getInterpolatedV(aRenderer.renderMinZ * d_16); + d6 = (float)aIcon.getInterpolatedV(aRenderer.renderMaxZ * d_16); if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { d3 = aIcon.getMaxU(); @@ -122,16 +123,16 @@ public class GT_SidedTexture implements ITexture, IColorModulationContainer { d6 = aIcon.getMaxV(); } - d11 = aX + aRenderer.renderMinX; - d12 = aX + aRenderer.renderMaxX; - d13 = aY + aRenderer.renderMinY; - d14 = aZ + aRenderer.renderMinZ; - d15 = aZ + aRenderer.renderMaxZ; + d11 = aX + (float)aRenderer.renderMinX; + d12 = aX + (float)aRenderer.renderMaxX; + d13 = aY + (float)aRenderer.renderMinY; + d14 = aZ + (float)aRenderer.renderMinZ; + d15 = aZ + (float)aRenderer.renderMaxZ; - Tessellator.instance.addVertexWithUV(d11, d13, d15, d3, d6); - Tessellator.instance.addVertexWithUV(d11, d13, d14, d3, d5); - Tessellator.instance.addVertexWithUV(d12, d13, d14, d4, d5); - Tessellator.instance.addVertexWithUV(d12, d13, d15, d4, d6); + Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d15, (double)d3, (double)d6); + Tessellator.instance.addVertexWithUV((double)d11, (double)d13, (double)d14, (double)d3, (double)d5); + Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d14, (double)d4, (double)d5); + Tessellator.instance.addVertexWithUV((double)d12, (double)d13, (double)d15, (double)d4, (double)d6); } } diff --git a/src/main/java/gregtech/api/objects/ItemData.java b/src/main/java/gregtech/api/objects/ItemData.java index cb741344ba..8a47867afb 100644 --- a/src/main/java/gregtech/api/objects/ItemData.java +++ b/src/main/java/gregtech/api/objects/ItemData.java @@ -93,32 +93,32 @@ public class ItemData { mByProducts = rList.toArray(new MaterialStack[rList.size()]); } - public boolean hasValidPrefixMaterialData() { + public final boolean hasValidPrefixMaterialData() { return mPrefix != null && mMaterial != null && mMaterial.mMaterial != null; } - public boolean hasValidPrefixData() { + public final boolean hasValidPrefixData() { return mPrefix != null; } - public boolean hasValidMaterialData() { + public final boolean hasValidMaterialData() { return mMaterial != null && mMaterial.mMaterial != null; } - public ArrayList<MaterialStack> getAllMaterialStacks() { + public final ArrayList<MaterialStack> getAllMaterialStacks() { ArrayList<MaterialStack> rList = new ArrayList(); if (hasValidMaterialData()) rList.add(mMaterial); rList.addAll(Arrays.asList(mByProducts)); return rList; } - public MaterialStack getByProduct(int aIndex) { + public final MaterialStack getByProduct(int aIndex) { return aIndex >= 0 && aIndex < mByProducts.length ? mByProducts[aIndex] : null; } @Override public String toString() { if (mPrefix == null || mMaterial == null || mMaterial.mMaterial == null) return ""; - return mPrefix.name() + mMaterial.mMaterial.mName; + return String.valueOf(new StringBuilder().append(mPrefix.name()).append(mMaterial.mMaterial.mName())); } }
\ No newline at end of file diff --git a/src/main/java/gregtech/api/objects/MaterialStack.java b/src/main/java/gregtech/api/objects/MaterialStack.java index 5ddb88423a..6066d3cf23 100644 --- a/src/main/java/gregtech/api/objects/MaterialStack.java +++ b/src/main/java/gregtech/api/objects/MaterialStack.java @@ -17,7 +17,7 @@ public class MaterialStack implements Cloneable { @Override public MaterialStack clone() { - return new MaterialStack(mMaterial, mAmount); + try { return (MaterialStack) super.clone(); } catch (Exception e) { return new MaterialStack(mMaterial, mAmount); } } @Override @@ -32,7 +32,15 @@ public class MaterialStack implements Cloneable { @Override public String toString() { - return (mMaterial.mMaterialList.size() > 1 && mAmount > 1 ? "(" : "") + mMaterial.getToolTip(true) + (mMaterial.mMaterialList.size() > 1 && mAmount > 1 ? ")" : "") + (mAmount > 1 ? mAmount : ""); + String temp1 = "", temp2 = mMaterial.getToolTip(true), temp3 = "", temp4 = ""; + if (mAmount > 1) { + temp4 = String.valueOf(mAmount); + if (mMaterial.mMaterialList.size() > 1) { + temp1 = "("; + temp3 = ")"; + } + } + return String.valueOf(new StringBuilder().append(temp1).append(temp2).append(temp3).append(temp4)); } @Override diff --git a/src/main/java/gregtech/api/objects/XSTR.java b/src/main/java/gregtech/api/objects/XSTR.java new file mode 100644 index 0000000000..2f185ac3bb --- /dev/null +++ b/src/main/java/gregtech/api/objects/XSTR.java @@ -0,0 +1,255 @@ +package gregtech.api.objects; +/** + * A subclass of java.util.random that implements the Xorshift random number + * generator + * + * - it is 30% faster than the generator from Java's library - it produces + * random sequences of higher quality than java.util.Random - this class also + * provides a clone() function + * + * Usage: XSRandom rand = new XSRandom(); //Instantiation x = rand.nextInt(); + * //pull a random number + * + * To use the class in legacy code, you may also instantiate an XSRandom object + * and assign it to a java.util.Random object: java.util.Random rand = new + * XSRandom(); + * + * for an explanation of the algorithm, see + * http://demesos.blogspot.com/2011/09/pseudo-random-number-generators.html + * + * @author Wilfried Elmenreich University of Klagenfurt/Lakeside Labs + * http://www.elmenreich.tk + * + * This code is released under the GNU Lesser General Public License Version 3 + * http://www.gnu.org/licenses/lgpl-3.0.txt + */ + +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; + +/** + * XSTR - Xorshift ThermiteRandom + * Modified by Bogdan-G + * 03.06.2016 + * version 0.0.4 + */ +public class XSTR extends Random { + + private static final long serialVersionUID = 6208727693524452904L; + private long seed; + private long last; + private static final long GAMMA = 0x9e3779b97f4a7c15L; + private static final int PROBE_INCREMENT = 0x9e3779b9; + private static final long SEEDER_INCREMENT = 0xbb67ae8584caa73bL; + private static final double DOUBLE_UNIT = 0x1.0p-53; // 1.0 / (1L << 53) + private static final float FLOAT_UNIT = 0x1.0p-24f; // 1.0f / (1 << 24) + + /* + MODIFIED BY: Robotia + Modification: Implemented Random class seed generator + */ + /** + * Creates a new pseudo random number generator. The seed is initialized to + * the current time, as if by + * <code>setSeed(System.currentTimeMillis());</code>. + */ + public XSTR() { + this(seedUniquifier() ^ System.nanoTime()); + } + private static final AtomicLong seedUniquifier + = new AtomicLong(8682522807148012L); + + private static long seedUniquifier() { + // L'Ecuyer, "Tables of Linear Congruential Generators of + // Different Sizes and Good Lattice Structure", 1999 + for (;;) { + long current = seedUniquifier.get(); + long next = current * 181783497276652981L; + if (seedUniquifier.compareAndSet(current, next)) { + return next; + } + } + } + + /** + * Creates a new pseudo random number generator, starting with the specified + * seed, using <code>setSeed(seed);</code>. + * + * @param seed the initial seed + */ + public XSTR(long seed) { + this.seed = seed; + } + public boolean nextBoolean() { + return next(1) != 0; + } + + public double nextDouble() { + return (((long)(next(26)) << 27) + next(27)) * DOUBLE_UNIT; + } + /** + * Returns the current state of the seed, can be used to clone the object + * + * @return the current seed + */ + public synchronized long getSeed() { + return seed; + } + + /** + * Sets the seed for this pseudo random number generator. As described + * above, two instances of the same random class, starting with the same + * seed, produce the same results, if the same methods are called. + * + * @param seed the new seed + */ + public synchronized void setSeed(long seed) { + this.seed = seed; + } + + /** + * @return Returns an XSRandom object with the same state as the original + */ + @Override + public XSTR clone() { + return new XSTR(getSeed()); + } + + /** + * Implementation of George Marsaglia's elegant Xorshift random generator + * 30% faster and better quality than the built-in java.util.random see also + * see http://www.javamex.com/tutorials/random_numbers/xorshift.shtml + * + * @param nbits + * @return + */ + public int next(int nbits) { + long x = seed; + x ^= (x << 21); + x ^= (x >>> 35); + x ^= (x << 4); + seed = x; + x &= ((1L << nbits) - 1); + return (int) x; + } + boolean haveNextNextGaussian = false; + double nextNextGaussian = 0; + synchronized public double nextGaussian() { + // See Knuth, ACP, Section 3.4.1 Algorithm C. + if (haveNextNextGaussian) { + haveNextNextGaussian = false; + return nextNextGaussian; + } else { + double v1, v2, s; + do { + v1 = 2 * nextDouble() - 1; // between -1 and 1 + v2 = 2 * nextDouble() - 1; // between -1 and 1 + s = v1 * v1 + v2 * v2; + } while (s >= 1 || s == 0); + double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s)/s); + nextNextGaussian = v2 * multiplier; + haveNextNextGaussian = true; + return v1 * multiplier; + } + } + /** + * Returns a pseudorandom, uniformly distributed {@code int} value between 0 + * (inclusive) and the specified value (exclusive), drawn from this random + * number generator's sequence. The general contract of {@code nextInt} is + * that one {@code int} value in the specified range is pseudorandomly + * generated and returned. All {@code bound} possible {@code int} values are + * produced with (approximately) equal probability. The method + * {@code nextInt(int bound)} is implemented by class {@code Random} as if + * by: + * <pre> {@code + * public int nextInt(int bound) { + * if (bound <= 0) + * throw new IllegalArgumentException("bound must be positive"); + * + * if ((bound & -bound) == bound) // i.e., bound is a power of 2 + * return (int)((bound * (long)next(31)) >> 31); + * + * int bits, val; + * do { + * bits = next(31); + * val = bits % bound; + * } while (bits - val + (bound-1) < 0); + * return val; + * }}</pre> + * + * <p>The hedge "approx + * imately" is used in the foregoing description only because the next + * method is only approximately an unbiased source of independently chosen + * bits. If it were a perfect source of randomly chosen bits, then the + * algorithm shown would choose {@code int} values from the stated range + * with perfect uniformity. + * <p> + * The algorithm is slightly tricky. It rejects values that would result in + * an uneven distribution (due to the fact that 2^31 is not divisible by n). + * The probability of a value being rejected depends on n. The worst case is + * n=2^30+1, for which the probability of a reject is 1/2, and the expected + * number of iterations before the loop terminates is 2. + * <p> + * The algorithm treats the case where n is a power of two specially: it + * returns the correct number of high-order bits from the underlying + * pseudo-random number generator. In the absence of special treatment, the + * correct number of <i>low-order</i> bits would be returned. Linear + * congruential pseudo-random number generators such as the one implemented + * by this class are known to have short periods in the sequence of values + * of their low-order bits. Thus, this special case greatly increases the + * length of the sequence of values returned by successive calls to this + * method if n is a small power of two. + * + * @param bound the upper bound (exclusive). Must be positive. + * @return the next pseudorandom, uniformly distributed {@code int} value + * between zero (inclusive) and {@code bound} (exclusive) from this random + * number generator's sequence + * @throws IllegalArgumentException if bound is not positive + * @since 1.2 + */ + public int nextInt(int bound) { + //if (bound <= 0) { + //throw new RuntimeException("BadBound"); + //} + + /*int r = next(31); + int m = bound - 1; + if ((bound & m) == 0) // i.e., bound is a power of 2 + { + r = (int) ((bound * (long) r) >> 31); + } else { + for (int u = r; + u - (r = u % bound) + m < 0; + u = next(31)) + ; + } + return r;*/ + //speedup, new nextInt ~+40% + last = seed ^ (seed << 21); + last ^= (last >>> 35); + last ^= (last << 4); + seed = last; + int out = (int) last % bound; + return (out < 0) ? -out : out; + } + public int nextInt() { + return next(32); + } + + public float nextFloat() { + return next(24) * FLOAT_UNIT; + } + + public long nextLong() { + // it's okay that the bottom word remains signed. + return ((long)(next(32)) << 32) + next(32); + } + + public void nextBytes(byte[] bytes_arr) { + for (int iba = 0, lenba = bytes_arr.length; iba < lenba; ) + for (int rndba = nextInt(), + nba = Math.min(lenba - iba, Integer.SIZE/Byte.SIZE); + nba-- > 0; rndba >>= Byte.SIZE) + bytes_arr[iba++] = (byte)rndba; + } +}
\ No newline at end of file diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java index 0909229d82..92944d3e32 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java @@ -22,9 +22,9 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable { private static void stepToUpdateMachine(World aWorld, int aX, int aY, int aZ, ArrayList<ChunkPosition> aList) { aList.add(new ChunkPosition(aX, aY, aZ)); TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity != null && tTileEntity instanceof IMachineBlockUpdateable) + if (tTileEntity instanceof IMachineBlockUpdateable) ((IMachineBlockUpdateable) tTileEntity).onMachineBlockUpdate(); - if (aList.size() < 5 || (tTileEntity != null && tTileEntity instanceof IMachineBlockUpdateable) || GregTech_API.isMachineBlock(aWorld.getBlock(aX, aY, aZ), aWorld.getBlockMetadata(aX, aY, aZ))) { + if (aList.size() < 5 || (tTileEntity instanceof IMachineBlockUpdateable) || GregTech_API.isMachineBlock(aWorld.getBlock(aX, aY, aZ), aWorld.getBlockMetadata(aX, aY, aZ))) { if (!aList.contains(new ChunkPosition(aX + 1, aY, aZ))) stepToUpdateMachine(aWorld, aX + 1, aY, aZ, aList); if (!aList.contains(new ChunkPosition(aX - 1, aY, aZ))) stepToUpdateMachine(aWorld, aX - 1, aY, aZ, aList); if (!aList.contains(new ChunkPosition(aX, aY + 1, aZ))) stepToUpdateMachine(aWorld, aX, aY + 1, aZ, aList); diff --git a/src/main/java/gregtech/api/util/GT_BaseCrop.java b/src/main/java/gregtech/api/util/GT_BaseCrop.java index f01b05a60f..6cdd6ab02b 100644 --- a/src/main/java/gregtech/api/util/GT_BaseCrop.java +++ b/src/main/java/gregtech/api/util/GT_BaseCrop.java @@ -175,7 +175,7 @@ public class GT_BaseCrop extends CropCard implements ICropCardInfo { @Override public ItemStack getGain(ICropTile aCrop) { int tDrop = 0; - if (mSpecialDrops != null && (tDrop = new Random().nextInt((mSpecialDrops.length*2) + 2)) < mSpecialDrops.length && mSpecialDrops[tDrop] != null) { + if (mSpecialDrops != null && (tDrop = java.util.concurrent.ThreadLocalRandom.current().nextInt(0, (mSpecialDrops.length*2) + 2)) < mSpecialDrops.length && mSpecialDrops[tDrop] != null) { return GT_Utility.copy(mSpecialDrops[tDrop]); } return GT_Utility.copy(mDrop); diff --git a/src/main/java/gregtech/api/util/GT_LanguageManager.java b/src/main/java/gregtech/api/util/GT_LanguageManager.java index a60189ea71..9937d0c069 100644 --- a/src/main/java/gregtech/api/util/GT_LanguageManager.java +++ b/src/main/java/gregtech/api/util/GT_LanguageManager.java @@ -75,9 +75,11 @@ public class GT_LanguageManager { public static String getTranslation(String aKey, String aSeperator) { if (aKey == null) return E; String rTranslation = E; + StringBuilder rTranslationSB = new StringBuilder(rTranslation); for (String tString : aKey.split(aSeperator)) { - rTranslation += getTranslation(tString); + rTranslationSB.append(getTranslation(tString)); } + rTranslation = String.valueOf(rTranslationSB); return rTranslation; } diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index 2154f3272e..070f748b95 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -1,5 +1,6 @@ package gregtech.api.util; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.GT_Mod; @@ -38,6 +39,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; +import java.lang.reflect.Method; import java.util.*; import java.util.Map.Entry; @@ -53,18 +55,74 @@ import static gregtech.api.enums.GT_Values.*; public class GT_ModHandler { public static final List<IRecipe> sSingleNonBlockDamagableRecipeList = new ArrayList<IRecipe>(1000); private static final Map<String, ItemStack> sIC2ItemMap = new HashMap<String, ItemStack>(); - private static final List<IRecipe> sAllRecipeList = Collections.synchronizedList(new ArrayList<IRecipe>(5000)), sBufferRecipeList = new ArrayList<IRecipe>(1000); + private static final List<IRecipe> sAllRecipeList = /*Collections.synchronizedList(*/new ArrayList<IRecipe>(5000)/*)*/, sBufferRecipeList = new ArrayList<IRecipe>(1000); public static volatile int VERSION = 509; public static Collection<String> sNativeRecipeClasses = new HashSet<String>(), sSpecialRecipeClasses = new HashSet<String>(); public static GT_HashSet<GT_ItemStack> sNonReplaceableItems = new GT_HashSet<GT_ItemStack>(); public static Object sBoxableWrapper = GT_Utility.callConstructor("gregtechmod.api.util.GT_IBoxableWrapper", 0, null, false); - private static Map<IRecipeInput, RecipeOutput> sExtractorRecipes = new HashMap<IRecipeInput, RecipeOutput>(); - private static Map<IRecipeInput, RecipeOutput> sMaceratorRecipes = new HashMap<IRecipeInput, RecipeOutput>(); - private static Map<IRecipeInput, RecipeOutput> sCompressorRecipes = new HashMap<IRecipeInput, RecipeOutput>(); - private static Map<IRecipeInput, RecipeOutput> sOreWashingRecipes = new HashMap<IRecipeInput, RecipeOutput>(); - private static Map<IRecipeInput, RecipeOutput> sThermalCentrifugeRecipes = new HashMap<IRecipeInput, RecipeOutput>(); - private static Map<IRecipeInput, RecipeOutput> sMassfabRecipes = new HashMap<IRecipeInput, RecipeOutput>(); + private static Map<IRecipeInput, RecipeOutput> sExtractorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>(); + private static Map<IRecipeInput, RecipeOutput> sMaceratorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>(); + private static Map<IRecipeInput, RecipeOutput> sCompressorRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>(); + private static Map<IRecipeInput, RecipeOutput> sOreWashingRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>(); + private static Map<IRecipeInput, RecipeOutput> sThermalCentrifugeRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>(); + private static Map<IRecipeInput, RecipeOutput> sMassfabRecipes = new /*Concurrent*/HashMap<IRecipeInput, RecipeOutput>(); private static boolean sBufferCraftingRecipes = true; + public static List<Integer> sSingleNonBlockDamagableRecipeList_list = new ArrayList<Integer>(100); + private static boolean sSingleNonBlockDamagableRecipeList_create = true; + private static final ItemStack sMt1 = new ItemStack(Blocks.dirt, 1, 0), sMt2 = new ItemStack(Blocks.dirt, 1, 0); + private static final String s_H = "h", s_F = "f", s_I = "I", s_P = "P", s_R = "R"; + private static final ItemStack[][] + sShapes1 = new ItemStack[][]{ + {sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1, null}, + {sMt1, null, sMt1, sMt1, null, sMt1, sMt1, sMt1, sMt1}, + {null, sMt1, null, sMt1, sMt1, sMt1, sMt1, null, sMt1}, + {sMt1, sMt1, sMt1, sMt1, null, sMt1, null, null, null}, + {sMt1, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1}, + {sMt1, sMt1, sMt1, sMt1, null, sMt1, sMt1, null, sMt1}, + {null, null, null, sMt1, null, sMt1, sMt1, null, sMt1}, + {null, sMt1, null, null, sMt1, null, null, sMt2, null}, + {sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2, null}, + {null, sMt1, null, null, sMt2, null, null, sMt2, null}, + {sMt1, sMt1, null, sMt1, sMt2, null, null, sMt2, null}, + {null, sMt1, sMt1, null, sMt2, sMt1, null, sMt2, null}, + {sMt1, sMt1, null, null, sMt2, null, null, sMt2, null}, + {null, sMt1, sMt1, null, sMt2, null, null, sMt2, null}, + {null, sMt1, null, sMt1, null, null, null, sMt1, sMt2}, + {null, sMt1, null, null, null, sMt1, sMt2, sMt1, null}, + {null, sMt1, null, sMt1, null, sMt1, null, null, sMt2}, + {null, sMt1, null, sMt1, null, sMt1, sMt2, null, null}, + {null, sMt2, null, null, sMt1, null, null, sMt1, null}, + {null, sMt2, null, null, sMt2, null, sMt1, sMt1, sMt1}, + {null, sMt2, null, null, sMt2, null, null, sMt1, null}, + {null, sMt2, null, sMt1, sMt2, null, sMt1, sMt1, null}, + {null, sMt2, null, null, sMt2, sMt1, null, sMt1, sMt1}, + {null, sMt2, null, null, sMt2, null, sMt1, sMt1, null}, + {sMt1, null, null, null, sMt2, null, null, null, sMt2}, + {null, null, sMt1, null, sMt2, null, sMt2, null, null}, + {sMt1, null, null, null, sMt2, null, null, null, null}, + {null, null, sMt1, null, sMt2, null, null, null, null}, + {sMt1, sMt2, null, null, null, null, null, null, null}, + {sMt2, sMt1, null, null, null, null, null, null, null}, + {sMt1, null, null, sMt2, null, null, null, null, null}, + {sMt2, null, null, sMt1, null, null, null, null, null}, + {sMt1, sMt1, sMt1, sMt1, sMt1, sMt1, null, sMt2, null}, + {sMt1, sMt1, null, sMt1, sMt1, sMt2, sMt1, sMt1, null}, + {null, sMt1, sMt1, sMt2, sMt1, sMt1, null, sMt1, sMt1}, + {null, sMt2, null, sMt1, sMt1, sMt1, sMt1, sMt1, sMt1}, + {sMt1, sMt1, sMt1, sMt1, sMt2, sMt1, null, sMt2, null}, + {sMt1, sMt1, null, sMt1, sMt2, sMt2, sMt1, sMt1, null}, + {null, sMt1, sMt1, sMt2, sMt2, sMt1, null, sMt1, sMt1}, + {null, sMt2, null, sMt1, sMt2, sMt1, sMt1, sMt1, sMt1}, + {sMt1, null, null, null, sMt1, null, null, null, null}, + {null, sMt1, null, sMt1, null, null, null, null, null}, + {sMt1, sMt1, null, sMt2, null, sMt1, sMt2, null, null}, + {null, sMt1, sMt1, sMt1, null, sMt2, null, null, sMt2} + }; + public static List<Integer> sSingleNonBlockDamagableRecipeList_validsShapes1 = new ArrayList<Integer>(44); + public static boolean sSingleNonBlockDamagableRecipeList_validsShapes1_update = false; + public static List<Integer> sSingleNonBlockDamagableRecipeList_warntOutput = new ArrayList<Integer>(50); + public static List<Integer> sVanillaRecipeList_warntOutput = new ArrayList<Integer>(50); + public static final List<IRecipe> sSingleNonBlockDamagableRecipeList_verified = new ArrayList<IRecipe>(1000); static { sNativeRecipeClasses.add(ShapedRecipes.class.getName()); @@ -501,7 +559,7 @@ public class GT_ModHandler { if (GregTech_API.sRecipeFile.get(ConfigCategories.Machines.maceration, aInput, true)) { GT_Utility.addSimpleIC2MachineRecipe(aInput, getMaceratorRecipeList(), null, aOutput1); } - + addMagneticraftRecipe(aInput, aOutput1, aOutput2, aChance2, aOutput3, aChance3); RA.addPulveriserRecipe(aInput, new ItemStack[]{aOutput1, aOutput2, aOutput3}, new int[]{10000, aChance2 <= 0 ? 1000 : 100 * aChance2, aChance3 <= 0 ? 1000 : 100 * aChance3}, 400, 2); if (!OrePrefixes.log.contains(aInput)) { @@ -537,6 +595,31 @@ public class GT_ModHandler { return true; } + static Class tClass; + static Method tMethod1; + static Method tMethod2; + + public static boolean addMagneticraftRecipe(ItemStack aInput, ItemStack aOutput1, ItemStack aOutput2, int aChance2, ItemStack aOutput3, int aChance3){ + if(GT_Mod.gregtechproxy.mMagneticraftRecipes && Loader.isModLoaded("Magneticraft")){ + try { + if(tClass==null)tClass = Class.forName("com.cout970.magneticraft.api.access.MgRecipeRegister"); + if(tMethod1==null)tMethod1 = tClass.getMethod("registerCrusherRecipe", ItemStack.class, ItemStack.class,ItemStack.class, float.class, ItemStack.class, float.class); + if(tMethod2==null)tMethod2 = tClass.getMethod("registerGrinderRecipe", ItemStack.class, ItemStack.class,ItemStack.class, float.class, ItemStack.class, float.class); + + ItemData tData = GT_OreDictUnificator.getAssociation(aInput); + if(tData!=null&&tData.mPrefix!=null){ + if(tData.mPrefix==OrePrefixes.ore||tData.mPrefix==OrePrefixes.oreBlackgranite||tData.mPrefix==OrePrefixes.oreEndstone||tData.mPrefix==OrePrefixes.oreNetherrack||tData.mPrefix==OrePrefixes.oreRedgranite){ + tMethod1.invoke(null, aInput, aOutput1, aOutput2,(float)((float)aChance2/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent), aOutput3,(float)((float)aChance3/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent)); + }else if(tData.mPrefix==OrePrefixes.crushed||tData.mPrefix==OrePrefixes.crushedCentrifuged||tData.mPrefix==OrePrefixes.crushedPurified){ + tMethod2.invoke(null, aInput, aOutput1, aOutput2,(float)((float)aChance2/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent), aOutput3,(float)((float)aChance3/GT_Mod.gregtechproxy.mMagneticraftBonusOutputPercent)); + } + } + + } catch (Exception e) {e.printStackTrace();} + } + return true; + } + /** * Adds a Recipe to the Sawmills of GregTech and ThermalCraft */ @@ -699,7 +782,7 @@ public class GT_ModHandler { public static void stopBufferingCraftingRecipes() { sBufferCraftingRecipes = false; - for (IRecipe tRecipe : sBufferRecipeList) GameRegistry.addRecipe(tRecipe); + for (IRecipe tRecipe : sBufferRecipeList) {GameRegistry.addRecipe(tRecipe);} sBufferRecipeList.clear(); } @@ -868,8 +951,8 @@ public class GT_ModHandler { if (aRecipe[idx] instanceof Boolean) { idx++; } - HashMap<Character, ItemStack> tItemStackMap = new HashMap<Character, ItemStack>(); - HashMap<Character, ItemData> tItemDataMap = new HashMap<Character, ItemData>(); + /*ConcurrentHash*/Map<Character, ItemStack> tItemStackMap = new /*ConcurrentHash*/HashMap<Character, ItemStack>(); + /*ConcurrentHash*/Map<Character, ItemData> tItemDataMap = new /*ConcurrentHash*/HashMap<Character, ItemData>(); tItemStackMap.put(' ', null); boolean tRemoveRecipe = true; @@ -954,11 +1037,12 @@ public class GT_ModHandler { if (aOnlyAddIfThereIsAnyRecipeOutputtingThis && !tThereWasARecipe) { ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); - for (int i = 0; i < tList.size() && !tThereWasARecipe; i++) { + int tList_sS=tList.size(); + for (int i = 0; i < tList_sS && !tThereWasARecipe; i++) { IRecipe tRecipe = tList.get(i); if (sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) continue; if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tRecipe.getRecipeOutput()), aResult, true)) { - tList.remove(i--); + tList.remove(i--); tList_sS=tList.size(); tThereWasARecipe = true; } } @@ -1028,11 +1112,11 @@ public class GT_ModHandler { } else if (tObject instanceof String) { tRecipe[i] = GT_OreDictUnificator.getFirstOre(tObject, 1); if (tRecipe[i] == null) break; - } else if (tObject instanceof Boolean) { + }/* else if (tObject instanceof Boolean) { // } else { throw new IllegalArgumentException(); - } + }*/ i++; } removeRecipe(tRecipe); @@ -1094,18 +1178,16 @@ public class GT_ModHandler { }, 3, 3); for (int i = 0; i < aRecipe.length && i < 9; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); - for (int i = 0; i < tList.size(); i++) { - try { - for (; i < tList.size(); i++) { + int tList_sS=tList.size(); + try { + for (int i = 0; i < tList_sS; i++) { + for (; i < tList_sS; i++) { if ((!(tList.get(i) instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tList.get(i)).isRemovable()) && tList.get(i).matches(aCrafting, DW)) { rReturn = tList.get(i).getCraftingResult(aCrafting); - if (rReturn != null) tList.remove(i--); + if (rReturn != null) tList.remove(i--); tList_sS=tList.size(); } } - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } + }} catch (Throwable e) {e.printStackTrace(GT_Log.err);} return rReturn; } @@ -1124,7 +1206,8 @@ public class GT_ModHandler { boolean rReturn = false; ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); aOutput = GT_OreDictUnificator.get(aOutput); - for (int i = 0; i < tList.size(); i++) { + int tList_sS=tList.size(); + for (int i = 0; i < tList_sS; i++) { IRecipe tRecipe = tList.get(i); if (aNotRemoveShapelessRecipes && (tRecipe instanceof ShapelessRecipes || tRecipe instanceof ShapelessOreRecipe)) continue; @@ -1135,7 +1218,7 @@ public class GT_ModHandler { } ItemStack tStack = tRecipe.getRecipeOutput(); if ((!(tRecipe instanceof IGT_CraftingRecipe) || ((IGT_CraftingRecipe) tRecipe).isRemovable()) && GT_Utility.areStacksEqual(GT_OreDictUnificator.get(tStack), aOutput, aIgnoreNBT)) { - tList.remove(i--); + tList.remove(i--); tList_sS=tList.size(); rReturn = true; } } @@ -1172,11 +1255,12 @@ public class GT_ModHandler { sAllRecipeList.clear(); sAllRecipeList.addAll(tList); } - for (int i = 0, j = sAllRecipeList.size(); i < j; i++) { + int sAllRecipeList_sS=sAllRecipeList.size(); + for (int i = 0, j = sAllRecipeList_sS; i < j; i++) { IRecipe tRecipe = sAllRecipeList.get(i); if (tRecipe.matches(aCrafting, aWorld)) { if (i > 10) { - sAllRecipeList.remove(i); + sAllRecipeList.remove(i); sAllRecipeList_sS=sAllRecipeList.size(); sAllRecipeList.add(i - 10, tRecipe); } return tRecipe.getCraftingResult(aCrafting); @@ -1236,25 +1320,23 @@ public class GT_ModHandler { }, 3, 3); for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); - for (int i = 0; i < tList.size(); i++) { - temp = false; - try { + int tList_sS=tList.size(); + try { + for (int i = 0; i < tList_sS; i++) { + temp = false; temp = tList.get(i).matches(aCrafting, DW); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - if (temp) { - ItemStack tOutput = aUncopiedStack ? tList.get(i).getRecipeOutput() : tList.get(i).getCraftingResult(aCrafting); - if (tOutput == null || tOutput.stackSize <= 0) { - // Seriously, who would ever do that shit? - if (!GregTech_API.sPostloadFinished) - throw new GT_ItsNotMyFaultException("Seems another Mod added a Crafting Recipe with null Output. Tell the Developer of said Mod to fix that."); - } else { - if (aUncopiedStack) return tOutput; - return GT_Utility.copy(tOutput); + if (temp) { + ItemStack tOutput = aUncopiedStack ? tList.get(i).getRecipeOutput() : tList.get(i).getCraftingResult(aCrafting); + if (tOutput == null || tOutput.stackSize <= 0) { + // Seriously, who would ever do that shit? + if (!GregTech_API.sPostloadFinished) + throw new GT_ItsNotMyFaultException("Seems another Mod added a Crafting Recipe with null Output. Tell the Developer of said Mod to fix that."); + } else { + if (aUncopiedStack) return tOutput; + return GT_Utility.copy(tOutput); + } } - } - } + }} catch (Throwable e) {e.printStackTrace(GT_Log.err);} return null; } @@ -1264,47 +1346,69 @@ public class GT_ModHandler { * This also removes old Recipes from the List. */ public static ArrayList<ItemStack> getVanillyToolRecipeOutputs(ItemStack... aRecipe) { - if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) - sSingleNonBlockDamagableRecipeList.clear(); - if (sSingleNonBlockDamagableRecipeList.isEmpty()) { + ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); + if (aRecipe == null) {return rList;} + if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) { + sSingleNonBlockDamagableRecipeList.clear();sSingleNonBlockDamagableRecipeList_create = true;sSingleNonBlockDamagableRecipeList_validsShapes1.clear();} + if (sSingleNonBlockDamagableRecipeList_create/*sSingleNonBlockDamagableRecipeList.isEmpty()*/) { for (IRecipe tRecipe : (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList()) { ItemStack tStack = tRecipe.getRecipeOutput(); if (GT_Utility.isStackValid(tStack) && tStack.getMaxStackSize() == 1 && tStack.getMaxDamage() > 0 && !(tStack.getItem() instanceof ItemBlock) && !(tStack.getItem() instanceof IReactorComponent) && !isElectricItem(tStack) && !GT_Utility.isStackInList(tStack, sNonReplaceableItems)) { - if (!(tRecipe instanceof ShapelessRecipes || tRecipe instanceof ShapelessOreRecipe)) { - if (tRecipe instanceof ShapedOreRecipe) { - boolean temp = true; - for (Object tObject : ((ShapedOreRecipe) tRecipe).getInput()) - if (tObject != null) { - if (tObject instanceof ItemStack && (((ItemStack) tObject).getItem() == null || ((ItemStack) tObject).getMaxStackSize() < 2 || ((ItemStack) tObject).getMaxDamage() > 0 || ((ItemStack) tObject).getItem() instanceof ItemBlock)) { - temp = false; - break; - } - if (tObject instanceof List && ((List) tObject).isEmpty()) { - temp = false; - break; - } + //if (!(tRecipe instanceof ShapelessRecipes) || tRecipe instanceof ShapelessOreRecipe) { + if (tRecipe instanceof ShapedOreRecipe) { + boolean temp = true; + for (Object tObject : ((ShapedOreRecipe) tRecipe).getInput()) { + if (tObject != null) { + if (tObject instanceof ItemStack && (((ItemStack) tObject).getItem() == null || ((ItemStack) tObject).getMaxStackSize() < 2 || ((ItemStack) tObject).getMaxDamage() > 0 || ((ItemStack) tObject).getItem() instanceof ItemBlock)) { + temp = false; + break; } - if (temp) sSingleNonBlockDamagableRecipeList.add(tRecipe); - } else if (tRecipe instanceof ShapedRecipes) { - boolean temp = true; - for (ItemStack tObject : ((ShapedRecipes) tRecipe).recipeItems) { - if (tObject != null && (tObject.getItem() == null || tObject.getMaxStackSize() < 2 || tObject.getMaxDamage() > 0 || tObject.getItem() instanceof ItemBlock)) { + if (tObject instanceof List && ((List) tObject).isEmpty()) { temp = false; break; } + }} + if (temp) {sSingleNonBlockDamagableRecipeList.add(tRecipe);} + } else if (tRecipe instanceof ShapedRecipes) { + boolean temp = true; + for (ItemStack tObject : ((ShapedRecipes) tRecipe).recipeItems) { + if (tObject != null && (tObject.getItem() == null || tObject.getMaxStackSize() < 2 || tObject.getMaxDamage() > 0 || tObject.getItem() instanceof ItemBlock)) { + temp = false; + break; } - if (temp) sSingleNonBlockDamagableRecipeList.add(tRecipe); - } else { - sSingleNonBlockDamagableRecipeList.add(tRecipe); } + if (temp) {sSingleNonBlockDamagableRecipeList.add(tRecipe);} + } else { + sSingleNonBlockDamagableRecipeList.add(tRecipe); } + //} } } GT_Log.out.println("GT_Mod: Created a List of Tool Recipes containing " + sSingleNonBlockDamagableRecipeList.size() + " Recipes for recycling." + (sSingleNonBlockDamagableRecipeList.size() > 1024 ? " Scanning all these Recipes is the reason for the startup Lag you receive right now." : E)); + int aList_move = sSingleNonBlockDamagableRecipeList.size(); + sSingleNonBlockDamagableRecipeList_list.add(aList_move); + sSingleNonBlockDamagableRecipeList_create = false; + sSingleNonBlockDamagableRecipeList_validsShapes1_update = true; + InventoryCrafting aCrafting = new InventoryCrafting(new Container() { + @Override + public boolean canInteractWith(EntityPlayer var1) {return false;}}, 3, 3); + for (int i = 0; i < aList_move; i++) { + for (int j = 0; j < sShapes1.length; j++) { + ItemStack[] sRecipe = sShapes1[j]; + for (int l = 0; l < 9 && l < sRecipe.length; l++) {aCrafting.setInventorySlotContents(l, sRecipe[l]);} + IRecipe vRecipe = sSingleNonBlockDamagableRecipeList.get(i); + if (vRecipe.matches(aCrafting, DW)) { + if (!(sSingleNonBlockDamagableRecipeList_validsShapes1.contains(j))) {sSingleNonBlockDamagableRecipeList_validsShapes1.add(j);} + sSingleNonBlockDamagableRecipeList_verified.add(vRecipe); + } + } + } + } - ArrayList<ItemStack> rList = getRecipeOutputs(sSingleNonBlockDamagableRecipeList, true, aRecipe); - if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) - sSingleNonBlockDamagableRecipeList.clear(); + /*ArrayList<ItemStack> */ + if (sSingleNonBlockDamagableRecipeList_verified.size() != 0) {rList = getRecipeOutputs(sSingleNonBlockDamagableRecipeList_verified, true, aRecipe);} + if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) { + sSingleNonBlockDamagableRecipeList.clear();sSingleNonBlockDamagableRecipeList_create = true;sSingleNonBlockDamagableRecipeList_validsShapes1.clear();} return rList; } @@ -1322,7 +1426,7 @@ public class GT_ModHandler { */ public static ArrayList<ItemStack> getRecipeOutputs(List<IRecipe> aList, boolean aDeleteFromList, ItemStack... aRecipe) { ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); - if (aRecipe == null) return rList; + if (aRecipe == null || aList.size() == 0) {return rList;} boolean temp = false; for (byte i = 0; i < aRecipe.length; i++) { if (aRecipe[i] != null) { @@ -1330,33 +1434,51 @@ public class GT_ModHandler { break; } } - if (!temp) return rList; + if (!temp) {return rList;} InventoryCrafting aCrafting = new InventoryCrafting(new Container() { @Override public boolean canInteractWith(EntityPlayer var1) { return false; } }, 3, 3); - for (int i = 0; i < 9 && i < aRecipe.length; i++) aCrafting.setInventorySlotContents(i, aRecipe[i]); - for (int i = 0; i < aList.size(); i++) { - temp = false; - try { - temp = aList.get(i).matches(aCrafting, DW); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); + for (int i = 0; i < 9 && i < aRecipe.length; i++) {aCrafting.setInventorySlotContents(i, aRecipe[i]);} + int aList_sS=aList.size(); + ArrayList<Integer> tempaList_list = new ArrayList<Integer>(); + if(!aDeleteFromList) { + for (int i = 0; i < aList_sS; i++) { + IRecipe tempALg0 = aList.get(i); + if (tempALg0.matches(aCrafting, DW)) { + ItemStack tOutput = tempALg0.getCraftingResult(aCrafting); + if (tOutput == null || tOutput.stackSize <= 0) { + if (!(sVanillaRecipeList_warntOutput.contains(i))) {sVanillaRecipeList_warntOutput.add(i);} + } else { + rList.add(GT_Utility.copy(tOutput)); + if (aDeleteFromList) {tempaList_list.add(i);} + } + } } - if (temp) { - ItemStack tOutput = aList.get(i).getCraftingResult(aCrafting); + } else { + for (int i = 0; i < aList_sS; i++) { + IRecipe tempALg0 = aList.get(i); + ItemStack tOutput = tempALg0.getCraftingResult(aCrafting); if (tOutput == null || tOutput.stackSize <= 0) { - // Seriously, who would ever do that shit? - if (!GregTech_API.sPostloadFinished) - throw new GT_ItsNotMyFaultException("Seems another Mod added a Crafting Recipe with null Output. Tell the Developer of said Mod to fix that."); + if (!(sSingleNonBlockDamagableRecipeList_warntOutput.contains(i))) {sSingleNonBlockDamagableRecipeList_warntOutput.add(i);} } else { rList.add(GT_Utility.copy(tOutput)); - if (aDeleteFromList) aList.remove(i--); + if (aDeleteFromList) {tempaList_list.add(i);} } } } + //boolean tempaList_list_b = tempaList_list.size() != 0 ? true : false; + if (aDeleteFromList && tempaList_list.size() != 0) { + List<IRecipe> tempaList_2 = new ArrayList<IRecipe>(); + for (int i = 0; i < aList_sS; i++) { + int k = 0, l = 0; + if (tempaList_list.get(k) == i) {k++;continue;} + tempaList_2.add(aList.get(l));l++; + } + aList = tempaList_2; + } return rList; } @@ -1406,7 +1528,7 @@ public class GT_ModHandler { for (Entry<IRecipeInput, RecipeOutput> tEntry : aRecipeList.entrySet()) { if (tEntry.getKey().matches(aInput)) { if (tEntry.getKey().getAmount() <= aInput.stackSize) { - ItemStack[] tList = (ItemStack[]) tEntry.getValue().items.toArray(); + ItemStack[] tList = (ItemStack[]) tEntry.getValue().items.toArray(new ItemStack[tEntry.getValue().items.size()]); if (tList.length == 0) break; ItemStack[] rList = new ItemStack[aOutputSlots.length]; rRecipeMetaData.setTag("return", tEntry.getValue().metadata); diff --git a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java index 4060f5f906..456d8cee58 100644 --- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java +++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java @@ -15,6 +15,7 @@ import net.minecraftforge.oredict.OreDictionary; import java.util.ArrayList; import java.util.HashMap; +import java.util.Map; import java.util.Map.Entry; import static gregtech.api.enums.GT_Values.*; @@ -29,8 +30,8 @@ import static gregtech.api.enums.GT_Values.*; * P.S. It is intended to be named "Unificator" and not "Unifier", because that sounds more awesome. */ public class GT_OreDictUnificator { - private static final HashMap<String, ItemStack> sName2StackMap = new HashMap<String, ItemStack>(); - private static final HashMap<GT_ItemStack, ItemData> sItemStack2DataMap = new HashMap<GT_ItemStack, ItemData>(); + private static final /*ConcurrentHash*/Map<String, ItemStack> sName2StackMap = new /*ConcurrentHash*/HashMap<String, ItemStack>(); + private static final /*ConcurrentHash*/Map<GT_ItemStack, ItemData> sItemStack2DataMap = new /*ConcurrentHash*/HashMap<GT_ItemStack, ItemData>(); private static final GT_HashSet<GT_ItemStack> sNoUnificationList = new GT_HashSet<GT_ItemStack>(); public static volatile int VERSION = 509; private static int isRegisteringOre = 0, isAddingOre = 0; @@ -265,12 +266,14 @@ public class GT_OreDictUnificator { public static ItemStack getGem(Materials aMaterial, long aMaterialAmount) { ItemStack rStack = null; - if (((aMaterialAmount >= M) || aMaterialAmount >= M * 32)) + if (((aMaterialAmount >= M))) rStack = get(OrePrefixes.gem, aMaterial, aMaterialAmount / M); - if (rStack == null && (((aMaterialAmount * 2) % M == 0) || aMaterialAmount >= M * 16)) - rStack = get(OrePrefixes.gemFlawed, aMaterial, (aMaterialAmount * 2) / M); - if (rStack == null && (((aMaterialAmount * 4) >= M))) - rStack = get(OrePrefixes.gemChipped, aMaterial, (aMaterialAmount * 4) / 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; } diff --git a/src/main/java/gregtech/api/util/GT_PlayedSound.java b/src/main/java/gregtech/api/util/GT_PlayedSound.java index 858f3b826e..136171f7b7 100644 --- a/src/main/java/gregtech/api/util/GT_PlayedSound.java +++ b/src/main/java/gregtech/api/util/GT_PlayedSound.java @@ -15,7 +15,7 @@ public class GT_PlayedSound { @Override public boolean equals(Object aObject) { - if (aObject != null && aObject instanceof GT_PlayedSound) { + if (aObject instanceof GT_PlayedSound) { return ((GT_PlayedSound) aObject).mX == mX && ((GT_PlayedSound) aObject).mY == mY && ((GT_PlayedSound) aObject).mZ == mZ && ((GT_PlayedSound) aObject).mSoundName.equals(mSoundName); } return false; diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 222da31402..079fa29fdc 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -512,11 +512,11 @@ public class GT_Recipe { /** * HashMap of Recipes based on their Items */ - public final Map<GT_ItemStack, Collection<GT_Recipe>> mRecipeItemMap = new HashMap<GT_ItemStack, Collection<GT_Recipe>>(); + public final Map<GT_ItemStack, Collection<GT_Recipe>> mRecipeItemMap = new /*Concurrent*/HashMap<GT_ItemStack, Collection<GT_Recipe>>(); /** * HashMap of Recipes based on their Fluids */ - public final Map<Fluid, Collection<GT_Recipe>> mRecipeFluidMap = new HashMap<Fluid, Collection<GT_Recipe>>(); + public final Map<Fluid, Collection<GT_Recipe>> mRecipeFluidMap = new /*Concurrent*/HashMap<Fluid, Collection<GT_Recipe>>(); /** * The List of all Recipes */ diff --git a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java index 611c8d34e2..df26dce0d4 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java +++ b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java @@ -121,6 +121,8 @@ public class GT_RecipeRegistrator { {"Scythe", s_H + s_P + s_I, s_P + s_F + s_R, " " + " " + s_R} }; public static volatile int VERSION = 509; + public static int sRodMaterialList_cycles = 0; + private static int i_count = 0; public static void registerMaterialRecycling(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByproduct) { if (GT_Utility.isStackInvalid(aStack)) return; @@ -176,7 +178,7 @@ public class GT_RecipeRegistrator { } public static void registerReverseArcSmelting(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByProduct01, MaterialStack aByProduct02, MaterialStack aByProduct03) { - registerReverseArcSmelting(aStack, new ItemData(aMaterial == null ? null : new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03)); + registerReverseArcSmelting(aStack, new ItemData(new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03)); } public static void registerReverseArcSmelting(ItemStack aStack, ItemData aData) { @@ -210,7 +212,11 @@ public class GT_RecipeRegistrator { continue; } if (tMaterial.mMaterial.contains(SubTag.METAL)) { + if(GT_Mod.gregtechproxy.mArcSmeltIntoAnnealed){ tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mArcSmeltInto; + }else{ + tMaterial.mMaterial = tMaterial.mMaterial.mSmeltInto.mSmeltInto; + } continue; } tMaterial.mAmount = 0; @@ -234,7 +240,7 @@ public class GT_RecipeRegistrator { } public static void registerReverseMacerating(ItemStack aStack, Materials aMaterial, long aMaterialAmount, MaterialStack aByProduct01, MaterialStack aByProduct02, MaterialStack aByProduct03, boolean aAllowHammer) { - registerReverseMacerating(aStack, new ItemData(aMaterial == null ? null : new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03), aAllowHammer); + registerReverseMacerating(aStack, new ItemData(new MaterialStack(aMaterial, aMaterialAmount), aByProduct01, aByProduct02, aByProduct03), aAllowHammer); } public static void registerReverseMacerating(ItemStack aStack, ItemData aData, boolean aAllowHammer) { @@ -272,7 +278,7 @@ public class GT_RecipeRegistrator { * You give this Function a Material and it will scan almost everything for adding recycling Recipes * * @param aMat a Material, for example an Ingot or a Gem. - * @param aOutput the Dust you usually get from macerating aMat + * @param aPlate the Dust you usually get from macerating aMat * @param aRecipeReplacing allows to replace the Recipe with a Plate variant */ public static synchronized void registerUsagesForMaterials(ItemStack aMat, String aPlate, boolean aRecipeReplacing) { @@ -280,8 +286,11 @@ public class GT_RecipeRegistrator { aMat = GT_Utility.copy(aMat); ItemStack tStack; ItemData aItemData = GT_OreDictUnificator.getItemData(aMat); - if (aItemData == null || aItemData.mPrefix != OrePrefixes.ingot) aPlate = null; + boolean aItemData_b_0 = aItemData != null ? true : false; + if (!aItemData_b_0 || aItemData.mPrefix != OrePrefixes.ingot) {aPlate = null;} if (aPlate != null && GT_OreDictUnificator.getFirstOre(aPlate, 1) == null) aPlate = null; + boolean aItemData_b_1 = aItemData.hasValidPrefixMaterialData() ? true : false; + boolean aPlate_b_0 = aPlate != null ? true : false; sMt1.func_150996_a(aMat.getItem()); sMt1.stackSize = 1; @@ -296,12 +305,13 @@ public class GT_RecipeRegistrator { for (ItemStack tMat : tRecipe) { if (tMat == sMt1) tAmount1++; } - if (aItemData != null && aItemData.hasValidPrefixMaterialData()) + if (aItemData_b_0 && aItemData_b_1) for (ItemStack tCrafted : GT_ModHandler.getRecipeOutputs(tRecipe)) { GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1)); } } + GT_ModHandler.getVanillyToolRecipeOutputs(sShapes1[0]); for (Materials tMaterial : sRodMaterialList) { ItemStack tMt2 = GT_OreDictUnificator.get(OrePrefixes.stick, tMaterial, 1); if (tMt2 != null) { @@ -309,37 +319,48 @@ public class GT_RecipeRegistrator { sMt2.stackSize = 1; Items.feather.setDamage(sMt2, Items.feather.getDamage(tMt2)); - for (int i = 0; i < sShapes1.length; i++) { - ItemStack[] tRecipe = sShapes1[i]; + if (GT_ModHandler.sSingleNonBlockDamagableRecipeList.size() == 0 || GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.size() == 0 || GT_ModHandler.sSingleNonBlockDamagableRecipeList_verified.size() == 0) { sRodMaterialList_cycles++;continue;} + int sShapes1_len = GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.size(); + for (int i = 0; i < sShapes1_len; i++) { + int i2 = GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.get(i); + ItemStack[] tRecipe = sShapes1[i2]; + if (tRecipe == null) continue; int tAmount1 = 0, tAmount2 = 0; for (ItemStack tMat : tRecipe) { if (tMat == sMt1) tAmount1++; if (tMat == sMt2) tAmount2++; } - for (ItemStack tCrafted : GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe)) { - if (aItemData != null && aItemData.hasValidPrefixMaterialData()) - GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1, new MaterialStack(tMaterial, OrePrefixes.stick.mMaterialAmount * tAmount2))); - - if (aRecipeReplacing && aPlate != null && sShapesA[i] != null && sShapesA[i].length > 1) { - assert aItemData != null; - if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.recipereplacements, aItemData.mMaterial.mMaterial + "." + sShapesA[i][0], true)) { - if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe))) { - switch (sShapesA[i].length) { - case 2: - GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); - break; - case 3: - GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], sShapesA[i][2], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); - break; - default: - GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i][1], sShapesA[i][2], sShapesA[i][3], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); - break; + List<ItemStack> tempTest = GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe); + if (GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1_update && GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.size() != 0) {sShapes1_len = GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1.size();GT_ModHandler.sSingleNonBlockDamagableRecipeList_validsShapes1_update = false;} + int tempTest_size_sS = tempTest.size(); + if (tempTest_size_sS > 0) { + for (ItemStack tCrafted : tempTest/*GT_ModHandler.getVanillyToolRecipeOutputs(tRecipe)*/) { + if (aItemData_b_0 && aItemData_b_1) { + GT_OreDictUnificator.addItemData(tCrafted, new ItemData(aItemData.mMaterial.mMaterial, aItemData.mMaterial.mAmount * tAmount1, new MaterialStack(tMaterial, OrePrefixes.stick.mMaterialAmount * tAmount2))); + } + + if (aRecipeReplacing && aPlate_b_0 && sShapesA[i2] != null && sShapesA[i2].length > 1) { + //assert aItemData != null;//dead dev code or decomp JAD? + if (GregTech_API.sRecipeFile.get(ConfigCategories.Recipes.recipereplacements, new StringBuilder().append(aItemData.mMaterial.mMaterial).append('.').append(sShapesA[i2][0]).toString(), true)) { + if (null != (tStack = GT_ModHandler.removeRecipe(tRecipe))) { + switch (sShapesA[i].length) { + case 2: + GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i2][1], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); + break; + case 3: + GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i2][1], sShapesA[i2][2], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); + break; + default: + GT_ModHandler.addCraftingRecipe(tStack, GT_ModHandler.RecipeBits.BUFFERED, new Object[]{sShapesA[i2][1], sShapesA[i2][2], sShapesA[i2][3], s_P.charAt(0), aPlate, s_R.charAt(0), OrePrefixes.stick.get(tMaterial), s_I.charAt(0), aItemData}); + break; + } } } } } } + sRodMaterialList_cycles++; } } } diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 29c5ab2c8b..34ef3d0963 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -20,7 +20,6 @@ import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.ItemData; import gregtech.api.threads.GT_Runnable_Sound; import gregtech.common.GT_Proxy; -import ic2.api.recipe.ICannerBottleRecipeManager; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.RecipeInputOreDict; @@ -83,11 +82,11 @@ public class GT_Utility { * Forge screwed the Fluid Registry up again, so I make my own, which is also much more efficient than the stupid Stuff over there. */ private static final List<FluidContainerData> sFluidContainerList = new ArrayList<FluidContainerData>(); - private static final Map<GT_ItemStack, FluidContainerData> sFilledContainerToData = new HashMap<GT_ItemStack, FluidContainerData>(); - private static final Map<GT_ItemStack, Map<Fluid, FluidContainerData>> sEmptyContainerToFluidToData = new HashMap<GT_ItemStack, Map<Fluid, FluidContainerData>>(); + private static final Map<GT_ItemStack, FluidContainerData> sFilledContainerToData = new /*Concurrent*/HashMap<GT_ItemStack, FluidContainerData>(); + private static final Map<GT_ItemStack, Map<Fluid, FluidContainerData>> sEmptyContainerToFluidToData = new /*Concurrent*/HashMap<GT_ItemStack, Map<Fluid, FluidContainerData>>(); public static volatile int VERSION = 509; public static boolean TE_CHECK = false, BC_CHECK = false, CHECK_ALL = true, RF_CHECK = false; - public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new HashMap<GT_PlayedSound, Integer>(); + public static Map<GT_PlayedSound, Integer> sPlayedSoundMap = new /*Concurrent*/HashMap<GT_PlayedSound, Integer>(); private static int sBookCount = 0; static { @@ -320,7 +319,7 @@ public class GT_Utility { } public static void sendChatToPlayer(EntityPlayer aPlayer, String aChatMessage) { - if (aPlayer != null && aPlayer instanceof EntityPlayerMP && aChatMessage != null) { + if (aPlayer instanceof EntityPlayerMP && aChatMessage != null) { aPlayer.addChatComponentMessage(new ChatComponentText(aChatMessage)); } } @@ -501,7 +500,7 @@ public class GT_Utility { * @return the Amount of moved Items */ public static byte moveOneItemStack(Object aTileEntity1, Object aTileEntity2, byte aGrabFrom, byte aPutTo, List<ItemStack> aFilter, boolean aInvertFilter, byte aMaxTargetStackSize, byte aMinTargetStackSize, byte aMaxMoveAtOnce, byte aMinMoveAtOnce) { - if (aTileEntity1 != null && aTileEntity1 instanceof IInventory) + if (aTileEntity1 instanceof IInventory) return moveOneItemStack((IInventory) aTileEntity1, aTileEntity2, aGrabFrom, aPutTo, aFilter, aInvertFilter, aMaxTargetStackSize, aMinTargetStackSize, aMaxMoveAtOnce, aMinMoveAtOnce, true); return 0; } @@ -598,7 +597,7 @@ public class GT_Utility { for (int i = 0; i < tGrabSlots.length; i++) tGrabSlots[i] = i; } - if (aTileEntity2 != null && aTileEntity2 instanceof IInventory) { + if (aTileEntity2 instanceof IInventory) { for (int i = 0; i < tGrabSlots.length; i++) { if (listContainsItem(aFilter, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]), true, aInvertFilter)) { if (isAllowedToTakeFromSlot((IInventory) aTileEntity1, tGrabSlots[i], aGrabFrom, ((IInventory) aTileEntity1).getStackInSlot(tGrabSlots[i]))) { @@ -698,7 +697,7 @@ public class GT_Utility { sFilledContainerToData.put(new GT_ItemStack(tData.filledContainer), tData); Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(tData.emptyContainer)); if (tFluidToContainer == null) { - sEmptyContainerToFluidToData.put(new GT_ItemStack(tData.emptyContainer), tFluidToContainer = new HashMap<Fluid, FluidContainerData>()); + sEmptyContainerToFluidToData.put(new GT_ItemStack(tData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<Fluid, FluidContainerData>()); GregTech_API.sFluidMappings.add(tFluidToContainer); } tFluidToContainer.put(tData.fluid.getFluid(), tData); @@ -710,7 +709,7 @@ public class GT_Utility { sFilledContainerToData.put(new GT_ItemStack(aData.filledContainer), aData); Map<Fluid, FluidContainerData> tFluidToContainer = sEmptyContainerToFluidToData.get(new GT_ItemStack(aData.emptyContainer)); if (tFluidToContainer == null) { - sEmptyContainerToFluidToData.put(new GT_ItemStack(aData.emptyContainer), tFluidToContainer = new HashMap<Fluid, FluidContainerData>()); + sEmptyContainerToFluidToData.put(new GT_ItemStack(aData.emptyContainer), tFluidToContainer = new /*Concurrent*/HashMap<Fluid, FluidContainerData>()); GregTech_API.sFluidMappings.add(tFluidToContainer); } tFluidToContainer.put(aData.fluid.getFluid(), aData); @@ -921,7 +920,7 @@ public class GT_Utility { } public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, double aX, double aY, double aZ) { - return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, 0.9F + new Random().nextFloat() * 0.2F, aX, aY, aZ); + return doSoundAtClient(aSoundName, aTimeUntilNextSound, aSoundStrength, 1.01818028F, aX, aY, aZ); } public static boolean doSoundAtClient(String aSoundName, int aTimeUntilNextSound, float aSoundStrength, float aSoundModulation, double aX, double aY, double aZ) { @@ -1011,7 +1010,7 @@ public class GT_Utility { } public static boolean isBlockValid(Object aBlock) { - return aBlock != null && (aBlock instanceof Block); + return (aBlock instanceof Block); } public static boolean isBlockInvalid(Object aBlock) { @@ -1027,7 +1026,7 @@ public class GT_Utility { } public static boolean isStackValid(Object aStack) { - return aStack != null && (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0; + return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null && ((ItemStack) aStack).stackSize >= 0; } public static boolean isStackInvalid(Object aStack) { @@ -1095,7 +1094,6 @@ public class GT_Utility { * Converts a Number to a String */ public static String parseNumberToString(int aNumber) { - String tString = E; boolean temp = true, negative = false; if (aNumber < 0) { @@ -1103,15 +1101,18 @@ public class GT_Utility { negative = true; } + StringBuilder tStringB = new StringBuilder(); for (int i = 1000000000; i > 0; i /= 10) { int tDigit = (aNumber / i) % 10; if (temp && tDigit != 0) temp = false; if (!temp) { - tString += tDigit; - if (i != 1) for (int j = i; j > 0; j /= 1000) if (j == 1) tString += ","; + tStringB.append(tDigit); + if (i != 1) for (int j = i; j > 0; j /= 1000) if (j == 1) tStringB.append(","); } } + String tString = tStringB.toString(); + if (tString.equals(E)) tString = "0"; return negative ? "-" + tString : tString; @@ -1379,7 +1380,7 @@ public class GT_Utility { * re-maps all Keys of a Map after the Keys were weakened. */ public static <X, Y> Map<X, Y> reMap(Map<X, Y> aMap) { - Map<X, Y> tMap = new HashMap<X, Y>(); + Map<X, Y> tMap = new /*Concurrent*/HashMap<X, Y>(); tMap.putAll(aMap); aMap.clear(); aMap.putAll(tMap); @@ -1410,7 +1411,7 @@ public class GT_Utility { Collections.sort(tEntrySet, new Comparator<Map.Entry<X, Y>>() { @Override public int compare(Entry<X, Y> aValue1, Entry<X, Y> aValue2) { - return -aValue1.getValue().compareTo(aValue2.getValue()); + return aValue2.getValue().compareTo(aValue1.getValue());//FB: RV - RV_NEGATING_RESULT_OF_COMPARETO } }); LinkedHashMap<X, Y> rMap = new LinkedHashMap<X, Y>(); @@ -1559,7 +1560,7 @@ public class GT_Utility { tList.add("----- X: " + aX + " Y: " + aY + " Z: " + aZ + " -----"); try { - if (tTileEntity != null && tTileEntity instanceof IInventory) + if (tTileEntity instanceof IInventory) tList.add("Name: " + ((IInventory) tTileEntity).getInventoryName() + " MetaData: " + aWorld.getBlockMetadata(aX, aY, aZ)); else tList.add("Name: " + tBlock.getUnlocalizedName() + " MetaData: " + aWorld.getBlockMetadata(aX, aY, aZ)); @@ -1722,10 +1723,11 @@ public class GT_Utility { + " Humidity: " + ((ic2.api.crops.ICropTile) tTileEntity).getHumidity() + " Air-Quality: " + ((ic2.api.crops.ICropTile) tTileEntity).getAirQuality() ); - String tString = E; + StringBuilder tStringB = new StringBuilder(); for (String tAttribute : ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].attributes()) { - tString += ", " + tAttribute; + tStringB.append(", ").append(tAttribute); } + String tString = tStringB.toString(); tList.add("Attributes:" + tString.replaceFirst(",", E)); tList.add("Discovered by: " + ic2.api.crops.Crops.instance.getCropList()[((ic2.api.crops.ICropTile) tTileEntity).getID()].discoveredBy()); } @@ -1994,16 +1996,14 @@ public class GT_Utility { if (aStack != null) { NBTTagList nbttaglist = aStack.getEnchantmentTagList(); if (nbttaglist != null) { - for (int i = 0; i < nbttaglist.tagCount(); ++i) { - try { + try { + for (int i = 0; i < nbttaglist.tagCount(); ++i) { short short1 = nbttaglist.getCompoundTagAt(i).getShort("id"); short short2 = nbttaglist.getCompoundTagAt(i).getShort("lvl"); if (Enchantment.enchantmentsList[short1] != null) aBullshitModifier.calculateModifier(Enchantment.enchantmentsList[short1], short2); - } catch (Throwable e) { - // } - } + } catch (Throwable e) {/**/} } } } diff --git a/src/main/java/gregtech/api/world/GT_Worldgen.java b/src/main/java/gregtech/api/world/GT_Worldgen.java index e41e2abefe..e464c475f1 100644 --- a/src/main/java/gregtech/api/world/GT_Worldgen.java +++ b/src/main/java/gregtech/api/world/GT_Worldgen.java @@ -4,16 +4,16 @@ import gregtech.api.GregTech_API; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.concurrent.ConcurrentHashMap; public abstract class GT_Worldgen { public final String mWorldGenName; public final boolean mEnabled; - private final Map<String, Boolean> mDimensionMap = new HashMap<String, Boolean>(); + private final Map<String, Boolean> mDimensionMap = new ConcurrentHashMap<String, Boolean>(); public GT_Worldgen(String aName, List aList, boolean aDefault) { mWorldGenName = aName; diff --git a/src/main/java/gregtech/api/world/GT_Worldgen_Boulder.java b/src/main/java/gregtech/api/world/GT_Worldgen_Boulder.java index 0f54796d72..22bf17aa93 100644 --- a/src/main/java/gregtech/api/world/GT_Worldgen_Boulder.java +++ b/src/main/java/gregtech/api/world/GT_Worldgen_Boulder.java @@ -21,38 +21,44 @@ public class GT_Worldgen_Boulder extends GT_Worldgen_Ore { int tX = aChunkX + aRandom.nextInt(16), tY = mMinY + aRandom.nextInt(mMaxY - mMinY), tZ = aChunkZ + aRandom.nextInt(16); Block tBlock = aWorld.getBlock(tX, tY - 7, tZ); if (tBlock != null && tBlock.isOpaqueCube() && aWorld.getBlock(tX, tY - 6, tZ).isAir(aWorld, tX, tY - 6, tZ)) { - float var6 = aRandom.nextFloat() * (float) Math.PI; - double var7 = ((tX + 8) + MathHelper.sin(var6) * mSize / 8.0F); - double var9 = ((tX + 8) - MathHelper.sin(var6) * mSize / 8.0F); - double var11 = ((tZ + 8) + MathHelper.cos(var6) * mSize / 8.0F); - double var13 = ((tZ + 8) - MathHelper.cos(var6) * mSize / 8.0F); - double var15 = (tY + aRandom.nextInt(3) - 2); - double var17 = (tY + aRandom.nextInt(3) - 2); + float math_pi = 3.141593F; + float var6 = aRandom.nextFloat() * math_pi; + float var1b = mSize / 8.0F; + float var3b = MathHelper.sin(var6) * var1b; float var4b = MathHelper.cos(var6) * var1b; + float var8b = -2*var3b;float var9b = -2*var4b; + int var10b = (tX + 8);int var11b = (tZ + 8); + float var7 = (var10b + var3b); + float var11 = (var11b + var4b); + int var5b = aRandom.nextInt(3);int var6b = aRandom.nextInt(3);int var7b = var6b - var5b; + float var15 = (tY + var5b - 2); + float var12b = math_pi / mSize; for (int var19 = 0; var19 <= mSize; ++var19) { - double var20 = var7 + (var9 - var7) * var19 / mSize; - double var22 = var15 + (var17 - var15) * var19 / mSize; - double var24 = var11 + (var13 - var11) * var19 / mSize; - double var26 = aRandom.nextDouble() * mSize / 16.0D; - double var28 = (MathHelper.sin(var19 * (float) Math.PI / mSize) + 1.0F) * var26 + 1.0D; - double var30 = (MathHelper.sin(var19 * (float) Math.PI / mSize) + 1.0F) * var26 + 1.0D; - int var32 = MathHelper.floor_double(var20 - var28 / 2.0D); - int var33 = MathHelper.floor_double(var22 - var30 / 2.0D); - int var34 = MathHelper.floor_double(var24 - var28 / 2.0D); - int var35 = MathHelper.floor_double(var20 + var28 / 2.0D); - int var36 = MathHelper.floor_double(var22 + var30 / 2.0D); - int var37 = MathHelper.floor_double(var24 + var28 / 2.0D); + float var2b = var19 / mSize; + float var20 = var7 + var8b * var2b; + float var22 = var15 + var7b * var2b; + float var24 = var11 + var9b * var2b; + float var26 = aRandom.nextFloat() * mSize / 16.0F; + float var28 = ((MathHelper.sin(var19 * var12b) + 1.0F) * var26 + 1.0F) / 2.0F; + int var32 = MathHelper.floor_float(var20 - var28); + int var33 = MathHelper.floor_float(var22 - var28); + int var34 = MathHelper.floor_float(var24 - var28); + int var35 = MathHelper.floor_float(var20 + var28); + int var36 = MathHelper.floor_float(var22 + var28); + int var37 = MathHelper.floor_float(var24 + var28); for (int var38 = var32; var38 <= var35; ++var38) { - double var39 = (var38 + 0.5D - var20) / (var28 / 2.0D); - if (var39 * var39 < 1.0D) { + float var39 = (var38 + 0.5F - var20) / (var28); + float var13b = var39 * var39; + if (var13b < 1.0F) { for (int var41 = var33; var41 <= var36; ++var41) { - double var42 = (var41 + 0.5D - var22) / (var30 / 2.0D); - if (var39 * var39 + var42 * var42 < 1.0D) { + float var42 = (var41 + 0.5F - var22) / (var28); + float var14b = var13b + var42 * var42; + if (var14b < 1.0F) { for (int var44 = var34; var44 <= var37; ++var44) { - double var45 = (var44 + 0.5D - var24) / (var28 / 2.0D); + float var45 = (var44 + 0.5F - var24) / (var28); Block block = aWorld.getBlock(var38, var41, var44); - if (var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && ((mAllowToGenerateinVoid && aWorld.getBlock(var38, var41, var44).isAir(aWorld, var38, var41, var44)) || (block != null && !(block instanceof BlockContainer)))) { + if (var14b + var45 * var45 < 1.0F && ((mAllowToGenerateinVoid && aWorld.getBlock(var38, var41, var44).isAir(aWorld, var38, var41, var44)) || (block != null && !(block instanceof BlockContainer)))) { aWorld.setBlock(var38, var41, var44, mBlock, mBlockMeta, 0); } } diff --git a/src/main/java/gregtech/api/world/GT_Worldgen_Ore.java b/src/main/java/gregtech/api/world/GT_Worldgen_Ore.java index bdba08bfb2..e8d16526c1 100644 --- a/src/main/java/gregtech/api/world/GT_Worldgen_Ore.java +++ b/src/main/java/gregtech/api/world/GT_Worldgen_Ore.java @@ -11,17 +11,18 @@ public abstract class GT_Worldgen_Ore extends GT_Worldgen { public final Block mBlock; public final Collection<String> mBiomeList; public final boolean mAllowToGenerateinVoid; + private final String aTextWorldgen = "worldgen."; public GT_Worldgen_Ore(String aName, boolean aDefault, Block aBlock, int aBlockMeta, int aDimensionType, int aAmount, int aSize, int aProbability, int aMinY, int aMaxY, Collection<String> aBiomeList, boolean aAllowToGenerateinVoid) { super(aName, GregTech_API.sWorldgenList, aDefault); mDimensionType = aDimensionType; mBlock = aBlock; mBlockMeta = Math.min(Math.max(aBlockMeta, 0), 15); - mProbability = GregTech_API.sWorldgenFile.get("worldgen." + mWorldGenName, "Probability", aProbability); - mAmount = GregTech_API.sWorldgenFile.get("worldgen." + mWorldGenName, "Amount", aAmount); - mSize = GregTech_API.sWorldgenFile.get("worldgen." + mWorldGenName, "Size", aSize); - mMinY = GregTech_API.sWorldgenFile.get("worldgen." + mWorldGenName, "MinHeight", aMinY); - mMaxY = GregTech_API.sWorldgenFile.get("worldgen." + mWorldGenName, "MaxHeight", aMaxY); + mProbability = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "Probability", aProbability); + mAmount = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "Amount", aAmount); + mSize = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "Size", aSize); + mMinY = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "MinHeight", aMinY); + mMaxY = GregTech_API.sWorldgenFile.get(aTextWorldgen + mWorldGenName, "MaxHeight", aMaxY); if (aBiomeList == null) mBiomeList = new ArrayList<String>(); else mBiomeList = aBiomeList; mAllowToGenerateinVoid = aAllowToGenerateinVoid; diff --git a/src/main/java/gregtech/api/world/GT_Worldgen_Ore_Normal.java b/src/main/java/gregtech/api/world/GT_Worldgen_Ore_Normal.java index 73b2a13d62..59ff49effb 100644 --- a/src/main/java/gregtech/api/world/GT_Worldgen_Ore_Normal.java +++ b/src/main/java/gregtech/api/world/GT_Worldgen_Ore_Normal.java @@ -20,38 +20,43 @@ public class GT_Worldgen_Ore_Normal extends GT_Worldgen_Ore { for (int i = 0; i < mAmount; i++) { int tX = aChunkX + aRandom.nextInt(16), tY = mMinY + aRandom.nextInt(mMaxY - mMinY), tZ = aChunkZ + aRandom.nextInt(16); if (mAllowToGenerateinVoid || aWorld.getBlock(tX, tY, tZ).isAir(aWorld, tX, tY, tZ)) { - float var6 = aRandom.nextFloat() * (float) Math.PI; - double var7 = ((tX + 8) + MathHelper.sin(var6) * mSize / 8.0F); - double var9 = ((tX + 8) - MathHelper.sin(var6) * mSize / 8.0F); - double var11 = ((tZ + 8) + MathHelper.cos(var6) * mSize / 8.0F); - double var13 = ((tZ + 8) - MathHelper.cos(var6) * mSize / 8.0F); - double var15 = (tY + aRandom.nextInt(3) - 2); - double var17 = (tY + aRandom.nextInt(3) - 2); + float math_pi = 3.141593F;float var1b = mSize / 8.0F; + float var6 = aRandom.nextFloat() * math_pi; + float var3b = MathHelper.sin(var6) * var1b; float var4b = MathHelper.cos(var6) * var1b; + float var8b = -2*var3b;float var9b = -2*var4b; + int var10b = (tX + 8);int var11b = (tZ + 8); + float var7 = (var10b + var3b); + float var11 = (var11b + var4b); + int var5b = aRandom.nextInt(3);int var6b = aRandom.nextInt(3);int var7b = var6b - var5b; + float var15 = (tY + var5b - 2); + float var12b = math_pi / mSize; for (int var19 = 0; var19 <= mSize; ++var19) { - double var20 = var7 + (var9 - var7) * var19 / mSize; - double var22 = var15 + (var17 - var15) * var19 / mSize; - double var24 = var11 + (var13 - var11) * var19 / mSize; - double var26 = aRandom.nextDouble() * mSize / 16.0D; - double var28 = (MathHelper.sin(var19 * (float) Math.PI / mSize) + 1.0F) * var26 + 1.0D; - double var30 = (MathHelper.sin(var19 * (float) Math.PI / mSize) + 1.0F) * var26 + 1.0D; - int var32 = MathHelper.floor_double(var20 - var28 / 2.0D); - int var33 = MathHelper.floor_double(var22 - var30 / 2.0D); - int var34 = MathHelper.floor_double(var24 - var28 / 2.0D); - int var35 = MathHelper.floor_double(var20 + var28 / 2.0D); - int var36 = MathHelper.floor_double(var22 + var30 / 2.0D); - int var37 = MathHelper.floor_double(var24 + var28 / 2.0D); + float var2b = var19 / mSize; + float var20 = var7 + var8b * var2b; + float var22 = var15 + var7b * var2b; + float var24 = var11 + var9b * var2b; + float var26 = aRandom.nextFloat() * mSize / 16.0F; + float var28 = ((MathHelper.sin(var19 * var12b) + 1.0F) * var26 + 1.0F) / 2.0F; + int var32 = MathHelper.floor_float(var20 - var28); + int var33 = MathHelper.floor_float(var22 - var28); + int var34 = MathHelper.floor_float(var24 - var28); + int var35 = MathHelper.floor_float(var20 + var28); + int var36 = MathHelper.floor_float(var22 + var28); + int var37 = MathHelper.floor_float(var24 + var28); for (int var38 = var32; var38 <= var35; ++var38) { - double var39 = (var38 + 0.5D - var20) / (var28 / 2.0D); - if (var39 * var39 < 1.0D) { + float var39 = (var38 + 0.5F - var20) / (var28); + float var13b = var39 * var39; + if (var13b < 1.0F) { for (int var41 = var33; var41 <= var36; ++var41) { - double var42 = (var41 + 0.5D - var22) / (var30 / 2.0D); - if (var39 * var39 + var42 * var42 < 1.0D) { + float var42 = (var41 + 0.5F - var22) / (var28); + float var14b = var13b + var42 * var42; + if (var14b < 1.0F) { for (int var44 = var34; var44 <= var37; ++var44) { - double var45 = (var44 + 0.5D - var24) / (var28 / 2.0D); + float var45 = (var44 + 0.5F - var24) / (var28); Block block = aWorld.getBlock(var38, var41, var44); - if (var39 * var39 + var42 * var42 + var45 * var45 < 1.0D && ((mAllowToGenerateinVoid && aWorld.getBlock(var38, var41, var44).isAir(aWorld, var38, var41, var44)) || (block != null && (block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.stone) || block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.end_stone) || block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.netherrack))))) { + if (var14b + var45 * var45 < 1.0F && ((mAllowToGenerateinVoid && aWorld.getBlock(var38, var41, var44).isAir(aWorld, var38, var41, var44)) || (block != null && (block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.stone) || block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.end_stone) || block.isReplaceableOreGen(aWorld, var38, var41, var44, Blocks.netherrack))))) { aWorld.setBlock(var38, var41, var44, mBlock, mBlockMeta, 0); } } |