diff options
Diffstat (limited to 'src/main/java/gregtech/api')
27 files changed, 231 insertions, 250 deletions
diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index 7e87ef432c..eec20576af 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -192,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 */ @@ -217,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"); } /** @@ -304,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/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 f3d4fb1f8e..df4813d1f3 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -1408,7 +1408,7 @@ public enum Materials implements IColorModulationContainer, ISubTagContainer { */ public static void init(GT_Config aConfiguration) { for (Materials tMaterial : VALUES) { - String tString = tMaterial.toString().toLowerCase(); + String tString = tMaterial.toString().toLowerCase(Locale.ENGLISH); tMaterial.mHeatDamage = (float) aConfiguration.get(ConfigCategories.Materials.heatdamage, tString, tMaterial.mHeatDamage); if (tMaterial.mBlastFurnaceRequired) tMaterial.mBlastFurnaceRequired = aConfiguration.get(ConfigCategories.Materials.blastfurnacerequirements, tString, true); 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/items/GT_EnergyArmor_Item.java b/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java index 9ad6deb636..78814803e4 100644 --- a/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java +++ b/src/main/java/gregtech/api/items/GT_EnergyArmor_Item.java @@ -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 1e0e59a080..7796691540 100644 --- a/src/main/java/gregtech/api/items/GT_MetaBase_Item.java +++ b/src/main/java/gregtech/api/items/GT_MetaBase_Item.java @@ -39,7 +39,6 @@ public abstract class GT_MetaBase_Item extends GT_Generic_Item implements ISpeci * 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); @@ -290,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_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index 112cc510f3..2d26eb0478 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -599,7 +599,7 @@ 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; 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/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 99bcc0bf03..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,8 +178,9 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } long tTime = System.currentTimeMillis(); + int tCode = 0; - try { for (int tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { + try { for (tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { switch (tCode) { case 0: tCode++; @@ -285,7 +285,8 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE tCode = -1; break; } - }} catch (Throwable e) { + } + } 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); } @@ -295,7 +296,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE 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; @@ -309,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); } @@ -356,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) @@ -704,7 +705,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } @Override - public ITexture[] getTexture(Block block, byte aSide) { + public ITexture[] getTexture(Block aBlock, byte aSide) { ITexture rIcon = getCoverTexture(aSide); if (rIcon != null) return new ITexture[]{rIcon}; return getTextureUncovered(aSide); @@ -729,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 08240d1d1c..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,8 +248,11 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE mRunningThroughTick = true; long tTime = System.currentTimeMillis(); + int tCode = 0; + boolean aSideServer = isServerSide(); + boolean aSideClient = isClientSide(); - try { for (int tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { + try { for (tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { switch (tCode) { case 0: tCode++; @@ -259,13 +260,11 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE oX = xCoord; oY = yCoord; oZ = zCoord; - if (isServerSide()) for (byte i = 0; i < 6; i++) + 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; @@ -274,7 +273,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } case 1: tCode++; - if (isClientSide()) { + if (aSideClient) { if (mColor != oColor) { mMetaTileEntity.onColorChangeClient(oColor = mColor); issueTextureUpdate(); @@ -305,7 +304,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE case 5: case 6: case 7: - if (isServerSide() && mTickTimer > 10) { + if (aSideServer && mTickTimer > 10) { for (byte i = (byte) (tCode - 2); i < 6; i++) if (getCoverIDAtSide(i) != 0) { tCode++; @@ -323,7 +322,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } case 8: tCode = 9; - if (isServerSide()) { + if (aSideServer) { if (++mAverageEUInputIndex >= mAverageEUInput.length) mAverageEUInputIndex = 0; if (++mAverageEUOutputIndex >= mAverageEUOutput.length) mAverageEUOutputIndex = 0; @@ -339,7 +338,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } case 10: tCode++; - if (isServerSide()) { + if (aSideServer) { if (mRedstone != oRedstone || mTickTimer == 10) { for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); @@ -412,10 +411,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE || (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) { - } + GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); doEnergyExplosion(); } else setOnFire(); } @@ -424,10 +420,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE 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) { - } + GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); doEnergyExplosion(); } } @@ -442,7 +435,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } case 11: tCode++; - if (isServerSide()) { + 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()) { @@ -456,7 +449,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } case 12: tCode++; - if (isServerSide()) { + 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) { @@ -484,7 +477,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } case 15: tCode++; - if (isServerSide()) { + 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); @@ -521,14 +514,14 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } default: tCode = -1; - break; - }} + } + } } 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; @@ -587,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); @@ -597,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) @@ -1075,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/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_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 ab24de0ba7..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]); 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_FluidStack.java b/src/main/java/gregtech/api/objects/GT_FluidStack.java index 6ff1627ab7..f4aad8ed5e 100644 --- a/src/main/java/gregtech/api/objects/GT_FluidStack.java +++ b/src/main/java/gregtech/api/objects/GT_FluidStack.java @@ -45,6 +45,7 @@ public class GT_FluidStack extends FluidStack { } } + @Deprecated public final void fixFluidIDForFucksSake() { if (ForgeVersion.getBuildVersion() < 1355 && ForgeVersion.getRevisionVersion() < 4) { int fluidID; 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 e4a39fd532..4609e8e613 100644 --- a/src/main/java/gregtech/api/objects/ItemData.java +++ b/src/main/java/gregtech/api/objects/ItemData.java @@ -119,6 +119,6 @@ public class ItemData { @Override public String toString() { if (mPrefix == null || mMaterial == null || mMaterial.mMaterial == null) return ""; - return mPrefix.name() + mMaterial.mMaterial.name(); + return String.valueOf(new StringBuilder().append(mPrefix.name()).append(mMaterial.mMaterial.name())); } }
\ 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/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 05205cfb97..37b8c1e0da 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -39,7 +39,6 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; import java.util.Map.Entry; @@ -559,7 +558,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); + 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)) { @@ -593,31 +592,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; + 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; } /** @@ -1186,7 +1185,7 @@ public class GT_ModHandler { 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; } @@ -1321,21 +1320,21 @@ public class GT_ModHandler { ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); int tList_sS=tList.size(); try { - for (int i = 0; i < tList_sS; i++) { - temp = false; - temp = tList.get(i).matches(aCrafting, DW); - 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); + for (int i = 0; i < tList_sS; i++) { + temp = false; + temp = tList.get(i).matches(aCrafting, DW); + 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);} + }} catch (Throwable e) {e.printStackTrace(GT_Log.err);} return null; } @@ -1345,17 +1344,15 @@ public class GT_ModHandler { * This also removes old Recipes from the List. */ public static ArrayList<ItemStack> getVanillyToolRecipeOutputs(ItemStack... aRecipe) { - 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()*/) { + if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) + sSingleNonBlockDamagableRecipeList.clear(); + if (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 ShapedOreRecipe) { boolean temp = true; - for (Object tObject : ((ShapedOreRecipe) tRecipe).getInput()) { + 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; @@ -1366,8 +1363,7 @@ public class GT_ModHandler { break; } } - } - if (temp) {sSingleNonBlockDamagableRecipeList.add(tRecipe);} + if (temp) sSingleNonBlockDamagableRecipeList.add(tRecipe); } else if (tRecipe instanceof ShapedRecipes) { boolean temp = true; for (ItemStack tObject : ((ShapedRecipes) tRecipe).recipeItems) { @@ -1376,36 +1372,17 @@ public class GT_ModHandler { break; } } - if (temp) {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> */ - 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();} + ArrayList<ItemStack> rList = getRecipeOutputs(sSingleNonBlockDamagableRecipeList, true, aRecipe); + if (!GregTech_API.sPostloadStarted || GregTech_API.sPostloadFinished) + sSingleNonBlockDamagableRecipeList.clear(); return rList; } @@ -1463,11 +1440,11 @@ public class GT_ModHandler { } else { rList.add(GT_Utility.copy(tOutput)); if (aDeleteFromList) {tempaList_list.add(i);} - } } } - //boolean tempaList_list_b = tempaList_list.size() != 0 ? true : false; - if (aDeleteFromList && tempaList_list.size() != 0) { + } + //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; @@ -1525,7 +1502,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 dddf2ec576..c8d95140a2 100644 --- a/src/main/java/gregtech/api/util/GT_OreDictUnificator.java +++ b/src/main/java/gregtech/api/util/GT_OreDictUnificator.java @@ -260,12 +260,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_RecipeRegistrator.java b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java index 0c05e5738a..df26dce0d4 100644 --- a/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java +++ b/src/main/java/gregtech/api/util/GT_RecipeRegistrator.java @@ -178,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) { @@ -240,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) { diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 309dc47889..34ef3d0963 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -920,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) { @@ -1094,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) { @@ -1102,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; @@ -1409,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>(); @@ -1721,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()); } |