diff options
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity')
17 files changed, 337 insertions, 119 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 01ca8c0f7b..247530d822 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -1,6 +1,5 @@ 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; @@ -20,6 +19,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.Packet; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; @@ -57,7 +57,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE try { super.writeToNBT(aNBT); } catch (Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } try { @@ -70,7 +70,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE aNBT.setByte("mStrongRedstone", mStrongRedstone); aNBT.setBoolean("mWorks", !mWorks); } catch (Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } try { @@ -90,12 +90,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE try { mMetaTileEntity.saveNBTData(aNBT); } catch (Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } } } catch (Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } } @@ -142,7 +142,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE try { mMetaTileEntity.loadNBTData(aNBT); } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while loading MetaTileEntity, the Server should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered Exception while loading MetaTileEntity, the Server should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } } @@ -159,11 +159,13 @@ 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 (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null); - GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); - mTickTimer = 0; - mID = aID; - return true; + if (aID != 0) { + if (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null); + GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); + mTickTimer = 0; + mID = aID; + return true; + } } return false; } @@ -178,9 +180,8 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } long tTime = System.currentTimeMillis(); - int tCode = 0; - try { for (tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { + try { for (int tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { switch (tCode) { case 0: tCode++; @@ -285,9 +286,8 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE 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!!!"); + }} 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 immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } @@ -296,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) - 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()); + 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()); } mWorkUpdate = mInventoryChanged = false; @@ -310,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 (aID > 0 && mID != aID) { + if (mID != aID && aID > 0) { mID = aID; createNewMetatileEntity(mID); } @@ -338,7 +338,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE try { mMetaTileEntity.receiveClientEvent((byte) aEventID, (byte) aValue); } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } } @@ -357,12 +357,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE mColor = (byte) aValue; break; case 3: - 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); + 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); break; case 4: if (hasValidMetaTileEntity() && mTickTimer > 20) @@ -384,18 +384,18 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aLogLevel) { ArrayList<String> tList = new ArrayList<String>(); if (aLogLevel > 2) { - tList.add("Meta-ID: " + mID + (hasValidMetaTileEntity() ? " valid" : " invalid") + (mMetaTileEntity == null ? " MetaTileEntity == null!" : " ")); + tList.add("Meta-ID: " + EnumChatFormatting.BLUE+ mID +EnumChatFormatting.RESET + (canAccessData() ? EnumChatFormatting.GREEN+" valid"+EnumChatFormatting.RESET : EnumChatFormatting.RED+" invalid"+EnumChatFormatting.RESET) + (mMetaTileEntity == null ? EnumChatFormatting.RED+" MetaTileEntity == null!"+EnumChatFormatting.RESET : " ")); } if (aLogLevel > 1) { if (mTimeStatistics.length > 0) { double tAverageTime = 0; for (int tTime : mTimeStatistics) tAverageTime += tTime; - tList.add("This particular TileEntity has caused an average CPU-load of ~" + (tAverageTime / mTimeStatistics.length) + "ms over the last " + mTimeStatistics.length + " ticks."); + tList.add("Average CPU-load of ~" + (tAverageTime / mTimeStatistics.length) + "ms since " + mTimeStatistics.length + " ticks."); } if (mLagWarningCount > 0) { - tList.add("This TileEntity has also caused " + (mLagWarningCount >= 10 ? "more than 10" : mLagWarningCount) + " Lag Spike Warnings (anything taking longer than " + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server."); + tList.add("Caused " + (mLagWarningCount >= 10 ? "more than 10" : mLagWarningCount) + " Lag Spike Warnings (anything taking longer than " + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server."); } - tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : " not ") + "accessible for you"); + tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : EnumChatFormatting.RED+" not "+EnumChatFormatting.RESET) + "accessible for you"); } return mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); } @@ -705,7 +705,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } @Override - public ITexture[] getTexture(Block aBlock, byte aSide) { + public ITexture[] getTexture(Block block, byte aSide) { ITexture rIcon = getCoverTexture(aSide); if (rIcon != null) return new ITexture[]{rIcon}; return getTextureUncovered(aSide); @@ -730,7 +730,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } protected boolean canAccessData() { - return hasValidMetaTileEntity() && !isDead; + return !isDead && hasValidMetaTileEntity(); } @Override @@ -855,7 +855,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE try { if (hasValidMetaTileEntity()) return mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ); } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } @@ -867,7 +867,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE try { if (aPlayer != null && hasValidMetaTileEntity()) mMetaTileEntity.onLeftclick(this, aPlayer); } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } } @@ -1312,4 +1312,4 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 1b3bafca90..23c72a2a03 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -24,6 +24,7 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -69,7 +70,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE try { super.writeToNBT(aNBT); } catch (Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } try { @@ -96,7 +97,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE aNBT.setBoolean("mOutputDisabled", mOutputDisabled); aNBT.setTag("GT.CraftingComponents", mRecipeStuff); } catch (Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } try { @@ -116,12 +117,12 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE try { mMetaTileEntity.saveNBTData(aNBT); } catch (Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } } } catch (Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } } @@ -186,7 +187,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE try { mMetaTileEntity.loadNBTData(aNBT); } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while loading MetaTileEntity, the Server should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered Exception while loading MetaTileEntity, the Server should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } } @@ -568,7 +569,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE try { mMetaTileEntity.receiveClientEvent((byte) aEventID, (byte) aValue); } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } } @@ -620,25 +621,25 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aLogLevel) { ArrayList<String> tList = new ArrayList<String>(); if (aLogLevel > 2) { - tList.add("Meta-ID: " + mID + (canAccessData() ? " valid" : " invalid") + (mMetaTileEntity == null ? " MetaTileEntity == null!" : " ")); + tList.add("Meta-ID: " +EnumChatFormatting.BLUE+ mID +EnumChatFormatting.RESET + (canAccessData() ? EnumChatFormatting.GREEN+" valid"+EnumChatFormatting.RESET : EnumChatFormatting.RED+" invalid"+EnumChatFormatting.RESET) + (mMetaTileEntity == null ? EnumChatFormatting.RED+" MetaTileEntity == null!"+EnumChatFormatting.RESET : " ")); } if (aLogLevel > 1) { if (mTimeStatistics.length > 0) { double tAverageTime = 0; for (int tTime : mTimeStatistics) tAverageTime += tTime; - tList.add("This particular TileEntity has caused an average CPU-load of ~" + (tAverageTime / mTimeStatistics.length) + "ms over the last " + mTimeStatistics.length + " ticks."); + tList.add("Average CPU-load of ~" + (tAverageTime / mTimeStatistics.length) + "ms since " + mTimeStatistics.length + " ticks."); } if (mLagWarningCount > 0) { - tList.add("This TileEntity has also caused " + (mLagWarningCount >= 10 ? "more than 10" : mLagWarningCount) + " Lag Spike Warnings (anything taking longer than " + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server."); + tList.add("Caused " + (mLagWarningCount >= 10 ? "more than 10" : mLagWarningCount) + " Lag Spike Warnings (anything taking longer than " + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server."); } - tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : " not ") + "accessible for you"); + tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : EnumChatFormatting.RED+" not "+EnumChatFormatting.RESET) + "accessible for you"); } if (aLogLevel > 0) { if (getSteamCapacity() > 0 && hasSteamEngineUpgrade()) tList.add(getStoredSteam() + " of " + getSteamCapacity() + " Steam"); - tList.add("Machine is " + (mActive ? "active" : "inactive")); + tList.add("Machine is " + (mActive ? EnumChatFormatting.GREEN+"active"+EnumChatFormatting.RESET : EnumChatFormatting.RED+"inactive"+EnumChatFormatting.RESET)); if (!mHasEnoughEnergy) - tList.add("ATTENTION: This Device consumes Energy at a higher Rate than you input. You could insert more to speed up the process."); + tList.add(EnumChatFormatting.RED+"ATTENTION: This Device needs more power."+EnumChatFormatting.RESET); } return mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); } @@ -1251,7 +1252,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE try { if (hasValidMetaTileEntity()) return mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ); } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } @@ -1263,7 +1264,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE try { if (aPlayer != null && hasValidMetaTileEntity()) mMetaTileEntity.onLeftclick(this, aPlayer); } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); + GT_Log.err.println("Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } } @@ -1826,4 +1827,4 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index b34483c31b..8f2b81b4de 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -30,7 +30,6 @@ 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; @@ -84,7 +83,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity { } else { throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!"); } - mName = aBasicName.replaceAll(" ", "_").toLowerCase(Locale.ENGLISH); + mName = aBasicName.replaceAll(" ", "_").toLowerCase(); setBaseMetaTileEntity(new BaseMetaPipeEntity()); getBaseMetaTileEntity().setMetaTileID((short) aID); GT_LanguageManager.addStringLocalization("gt.blockmachines." + mName + ".name", aRegionalName); @@ -167,7 +166,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity { tCovered = true; } //System.out.println("Cover: "+mBaseMetaTileEntity.getCoverIDAtSide(aSide)); - //toDo: filter cover ids that actually protect against temperature (rubber/plastic maybe?) + //toDo: filter cover ids that actually protect against temperature (rubber/plastic maybe?, more like asbestos) return tCovered; } @@ -640,7 +639,26 @@ public abstract class MetaPipeEntity implements IMetaTileEntity { @Override public void doExplosion(long aExplosionPower) { - float tStrength = aExplosionPower < V[0] ? 1.0F : aExplosionPower < V[1] ? 2.0F : aExplosionPower < V[2] ? 3.0F : aExplosionPower < V[3] ? 4.0F : aExplosionPower < V[4] ? 5.0F : aExplosionPower < V[4] * 2 ? 6.0F : aExplosionPower < V[5] ? 7.0F : aExplosionPower < V[6] ? 8.0F : aExplosionPower < V[7] ? 9.0F : 10.0F; + float tStrength = + aExplosionPower < V[0] ? 1.0F : + aExplosionPower < V[1] ? 2.0F : + aExplosionPower < V[2] ? 3.0F : + aExplosionPower < V[3] ? 4.0F : + aExplosionPower < V[4] ? 5.0F : + aExplosionPower < V[4] * 2 ? 6.0F : + aExplosionPower < V[5] ? 7.0F : + aExplosionPower < V[6] ? 8.0F : + aExplosionPower < V[7] ? 9.0F : + aExplosionPower < V[8] ? 10.0F : + aExplosionPower < V[8] * 2 ? 11.0F : + aExplosionPower < V[9] ? 12.0F : + aExplosionPower < V[10] ? 13.0F : + aExplosionPower < V[11] ? 14.0F : + aExplosionPower < V[12] ? 15.0F : + aExplosionPower < V[12] * 2 ? 16.0F : + aExplosionPower < V[13] ? 17.0F : + aExplosionPower < V[14] ? 18.0F : + aExplosionPower < V[15] ? 19.0F : 20.0F; int tX = getBaseMetaTileEntity().getXCoord(), tY = getBaseMetaTileEntity().getYCoord(), tZ = getBaseMetaTileEntity().getZCoord(); World tWorld = getBaseMetaTileEntity().getWorld(); tWorld.setBlock(tX, tY, tZ, Blocks.air); diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 662dc59d80..dc56054fee 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -30,7 +30,6 @@ 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; @@ -80,7 +79,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity { } else { throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!"); } - mName = aBasicName.replaceAll(" ", "_").toLowerCase(Locale.ENGLISH); + mName = aBasicName.replaceAll(" ", "_").toLowerCase(); setBaseMetaTileEntity(GregTech_API.constructBaseMetaTileEntity()); getBaseMetaTileEntity().setMetaTileID((short) aID); GT_LanguageManager.addStringLocalization("gt.blockmachines." + mName + ".name", aRegionalName); @@ -829,7 +828,26 @@ public abstract class MetaTileEntity implements IMetaTileEntity { @Override public void doExplosion(long aExplosionPower) { - float tStrength = aExplosionPower < V[0] ? 1.0F : aExplosionPower < V[1] ? 2.0F : aExplosionPower < V[2] ? 3.0F : aExplosionPower < V[3] ? 4.0F : aExplosionPower < V[4] ? 5.0F : aExplosionPower < V[4] * 2 ? 6.0F : aExplosionPower < V[5] ? 7.0F : aExplosionPower < V[6] ? 8.0F : aExplosionPower < V[7] ? 9.0F : 10.0F; + float tStrength = + aExplosionPower < V[0] ? 1.0F : + aExplosionPower < V[1] ? 2.0F : + aExplosionPower < V[2] ? 3.0F : + aExplosionPower < V[3] ? 4.0F : + aExplosionPower < V[4] ? 5.0F : + aExplosionPower < V[4] * 2 ? 6.0F : + aExplosionPower < V[5] ? 7.0F : + aExplosionPower < V[6] ? 8.0F : + aExplosionPower < V[7] ? 9.0F : + aExplosionPower < V[8] ? 10.0F : + aExplosionPower < V[8] * 2 ? 11.0F : + aExplosionPower < V[9] ? 12.0F : + aExplosionPower < V[10] ? 13.0F : + aExplosionPower < V[11] ? 14.0F : + aExplosionPower < V[12] ? 15.0F : + aExplosionPower < V[12] * 2 ? 16.0F : + aExplosionPower < V[13] ? 17.0F : + aExplosionPower < V[14] ? 18.0F : + aExplosionPower < V[15] ? 19.0F : 20.0F; int tX = getBaseMetaTileEntity().getXCoord(), tY = getBaseMetaTileEntity().getYCoord(), tZ = getBaseMetaTileEntity().getZCoord(); World tWorld = getBaseMetaTileEntity().getWorld(); GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ); diff --git a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java index 683fe8aab6..305dfa36c0 100644 --- a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java +++ b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java @@ -31,11 +31,11 @@ public class GT_MetaTileEntity_E_Furnace extends GT_MetaTileEntity_BasicMachine @Override public int checkRecipe() { if (null != (mOutputItems[0] = GT_ModHandler.getSmeltingOutput(getInputAt(0), true, getOutputAt(0)))) { - mEUt = 4 * (1 << (mTier - 1)) * (1 << (mTier - 1)); - mMaxProgresstime = 128 / (1 << (mTier - 1)); - return 2; + calculateOverclockedNess(4,128); + if(mMaxProgresstime==Integer.MAX_VALUE-1 && mEUt==Integer.MAX_VALUE-1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; } - return 0; + return DID_NOT_FIND_RECIPE; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index c79bca8df2..f5993c9dc8 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -77,7 +77,8 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { if (!mInsulated) - return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], Dyes.getModulation(aColorIndex, mMaterial.mRGBa) )}; + return new ITexture[]{new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], Dyes.getModulation(aColorIndex, mMaterial.mRGBa) )}; + if (aConnected) { float tThickNess = getThickNess(); if (tThickNess < 0.37F) @@ -175,7 +176,8 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile } } else if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver) { ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100); + long rfOUT = aVoltage * GregTech_API.mEUtoRF / 100; + int rfOut = rfOUT>Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)rfOUT; if (((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, true) == rfOut) { ((IEnergyReceiver) tTileEntity).receiveEnergy(tDirection, rfOut, false); rUsedAmperes++; @@ -287,4 +289,4 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile public void loadNBTData(NBTTagCompound aNBT) { // } -} +}
\ No newline at end of file diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java index 7091e70ab2..5596c5f429 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java @@ -13,6 +13,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import static gregtech.api.enums.GT_Values.V; @@ -109,12 +110,12 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier @Override public long getMinimumStoredEU() { - return V[mTier] * 16 * mInventory.length; + return V[mTier] * 16L * mInventory.length; } @Override public long maxEUStore() { - return V[mTier] * 64 * mInventory.length; + return V[mTier] * 64L * mInventory.length; } @Override @@ -129,7 +130,7 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier @Override public long maxAmperesIn() { - return mChargeableCount * 2; + return mChargeableCount * 2L; } @Override @@ -304,14 +305,15 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier } return new String[]{ - getLocalName(), + EnumChatFormatting.BLUE+getLocalName()+EnumChatFormatting.RESET, "Stored Items:", - GT_Utility.formatNumbers(mStored) + " EU /", - GT_Utility.formatNumbers(mMax) + " EU"}; + EnumChatFormatting.GREEN+GT_Utility.formatNumbers(mStored) +EnumChatFormatting.RESET+ " EU / "+ + EnumChatFormatting.YELLOW+GT_Utility.formatNumbers(mMax) +EnumChatFormatting.RESET+ " EU" + }; } @Override public boolean isGivingInformation() { return true; } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index e9c695740c..e8c8ce5d98 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -133,12 +133,12 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public long maxEUOutput() { - return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0; + return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier] : 0L; } @Override public long maxEUStore() { - return Math.max(getEUVar(), V[mTier] * 40 + getMinimumStoredEU()); + return Math.max(getEUVar(), V[mTier] * 40L + getMinimumStoredEU()); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 4ab9ad5376..417b9cc81b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -18,6 +18,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; @@ -185,12 +186,12 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public long getMinimumStoredEU() { - return V[mTier] * 16; + return V[mTier] * 16L; } @Override public long maxEUStore() { - return V[mTier] * 64; + return V[mTier] * 64L; } @Override @@ -205,7 +206,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public long maxAmperesIn() { - return (mEUt * 2) / V[mTier] + 1; + return ((long)mEUt * 2L) / V[mTier] + 1L; } @Override @@ -451,7 +452,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B if (allowToCheckRecipe()) { if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { - if (checkRecipe() == 2) { + if (checkRecipe() == FOUND_AND_SUCCESSFULLY_USED_RECIPE) { if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; @@ -514,16 +515,44 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B calculateOverclockedNess(aRecipe.mEUt, aRecipe.mDuration); } + /** + * Calcualtes overclocked ness using long integers + * @param aEUt - recipe EUt + * @param aDuration - recipe Duration + */ protected void calculateOverclockedNess(int aEUt, int aDuration) { - if (aEUt <= 16) { - mEUt = aEUt * (1 << (mTier - 1)) * (1 << (mTier - 1)); - mMaxProgresstime = aDuration / (1 << (mTier - 1)); - } else { - mEUt = aEUt; + if(mTier==0){ + //Long time calculation + long xMaxProgresstime = (long)aDuration*2L; + if(xMaxProgresstime>Integer.MAX_VALUE-1){ + //make impossible if too long + mEUt=Integer.MAX_VALUE-1; + mMaxProgresstime=Integer.MAX_VALUE-1; + }else{ + mEUt=aEUt/4; + mMaxProgresstime=(int)xMaxProgresstime; + } + }else{ + //Long EUt calculation + long xEUt=aEUt; + //Isnt too low EUt check? + long tempEUt = xEUt<V[1] ? V[1] : xEUt; + mMaxProgresstime = aDuration; - while (mEUt <= V[mTier - 1] * mAmperage) { - mEUt *= 4; - mMaxProgresstime /= 2; + + while (tempEUt <= V[mTier -1] * (long)mAmperage) { + tempEUt *= 4;//this actually controls overclocking + //xEUt *= 4;//this is effect of everclocking + mMaxProgresstime /= 2;//this is effect of overclocking + xEUt = mMaxProgresstime==0 ? (long)(xEUt/1.1D) : xEUt*4;//U know, if the time is less than 1 tick make the machine use 2x less power + } + if(xEUt>Integer.MAX_VALUE-1){ + mEUt = Integer.MAX_VALUE-1; + mMaxProgresstime = Integer.MAX_VALUE-1; + }else{ + mEUt = (int)xEUt; + mEUt = mEUt == 0 ? 1 : mEUt; + mMaxProgresstime = mMaxProgresstime<1 ? 1 : mMaxProgresstime;//set time to 1 tick } } } @@ -659,12 +688,17 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public String[] getInfoData() { return new String[]{ - mNEIName, - "Progress:", (mProgresstime / 20) + " secs", - (mMaxProgresstime / 20) + " secs", + EnumChatFormatting.BLUE + mNEIName + EnumChatFormatting.RESET, + "Progress:", + EnumChatFormatting.GREEN + Integer.toString(mProgresstime/20) + EnumChatFormatting.RESET +" s / "+ + EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime/20) + EnumChatFormatting.RESET +" s", "Stored Energy:", - getBaseMetaTileEntity().getStoredEU() + "EU", - getBaseMetaTileEntity().getEUCapacity() + "EU"}; + EnumChatFormatting.GREEN + Long.toString(getBaseMetaTileEntity().getStoredEU()) + EnumChatFormatting.RESET +" EU / "+ + EnumChatFormatting.YELLOW + Long.toString(getBaseMetaTileEntity().getEUCapacity()) + EnumChatFormatting.RESET +" EU", + "Probably uses: " + + EnumChatFormatting.RED + Integer.toString(mEUt) + EnumChatFormatting.RESET + " EU/t at " + + EnumChatFormatting.RED + Integer.toString(mEUt==0?0:mAmperage) + EnumChatFormatting.RESET +" A" + }; } @Override @@ -716,6 +750,15 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B * @return see constants above */ public int checkRecipe() { + return checkRecipe(false); + } + + /** + * + * @param skipOC disables OverclockedNess calculation and check - if you do you must implement your own method... + * @return + */ + public int checkRecipe(boolean skipOC){ GT_Recipe_Map tMap = getRecipeList(); if (tMap == null) return DID_NOT_FIND_RECIPE; GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); @@ -732,7 +775,12 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) mOutputItems[i] = tRecipe.getOutput(i); mOutputFluid = tRecipe.getFluidOutput(0); - calculateOverclockedNess(tRecipe); + if(!skipOC) { + calculateOverclockedNess(tRecipe); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + } return FOUND_AND_SUCCESSFULLY_USED_RECIPE; } @@ -791,4 +839,4 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B public ITexture[] getSideFacingPipeInactive(byte aColor) { return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; } -}
\ No newline at end of file +} 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 9b0e386df4..1362d9581a 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,5 +1,7 @@ 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; @@ -17,9 +19,6 @@ 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; @@ -36,7 +35,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(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"))}); + 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"))}); mSharedTank = aSharedTank; mTankCapacity = aTankCapacity; mSpecialEffect = aSpecialEffect; @@ -46,6 +45,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ mGUIParameterA = (byte) aGUIParameterA; mGUIParameterB = (byte) aGUIParameterB; + + //TODO: CHECK if (aRecipe != null) { for (int i = 3; i < aRecipe.length; i++) { if (aRecipe[i] == X.CIRCUIT) { @@ -74,6 +75,13 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ case 6: case 7: case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: aRecipe[i] = Ic2Items.reinforcedGlass; break; default: @@ -111,7 +119,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ aRecipe[i] = OrePrefixes.plate.get(Materials.Neutronium); break; default: - aRecipe[i] = OrePrefixes.plate.get(Materials.TungstenSteel); + aRecipe[i] = OrePrefixes.plate.get(Materials.Neutronium); break; } continue; @@ -145,7 +153,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ aRecipe[i] = OrePrefixes.pipeLarge.get(Materials.Ultimate); break; default: - aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.TungstenSteel); + aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Ultimate); break; } continue; @@ -179,7 +187,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ aRecipe[i] = OrePrefixes.wireGt02.get(Materials.NaquadahAlloy); break; default: - aRecipe[i] = OrePrefixes.wireGt08.get(Materials.Nichrome); + aRecipe[i] = OrePrefixes.wireGt08.get(Materials.NaquadahAlloy); break; } continue; @@ -213,7 +221,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ aRecipe[i] = OrePrefixes.wireGt04.get(Materials.NaquadahAlloy); break; default: - aRecipe[i] = OrePrefixes.wireGt16.get(Materials.Nichrome); + aRecipe[i] = OrePrefixes.wireGt16.get(Materials.NaquadahAlloy); break; } continue; @@ -687,5 +695,5 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ return !mSharedTank; } - public static enum X {PUMP, WIRE, WIRE4, HULL, PIPE, GLASS, PLATE, MOTOR, ROTOR, SENSOR, PISTON, CIRCUIT, EMITTER, CONVEYOR, ROBOT_ARM, COIL_HEATING, COIL_ELECTRIC, STICK_MAGNETIC, STICK_DISTILLATION, BETTER_CIRCUIT, FIELD_GENERATOR, COIL_HEATING_DOUBLE, STICK_ELECTROMAGNETIC;} + public static enum X {PUMP, WIRE, WIRE4, HULL, PIPE, GLASS, PLATE, MOTOR, ROTOR, SENSOR, PISTON, CIRCUIT, EMITTER, CONVEYOR, ROBOT_ARM, COIL_HEATING, COIL_ELECTRIC, STICK_MAGNETIC, STICK_DISTILLATION, BETTER_CIRCUIT, FIELD_GENERATOR, COIL_HEATING_DOUBLE, STICK_ELECTROMAGNETIC} } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index cffa88837e..f4dd133aa1 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -137,12 +137,12 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM @Override public long getMinimumStoredEU() { - return 512; + return 512L; } @Override public long maxEUStore() { - return 512 + V[mTier] * 50; + return 512L + V[mTier] * 50L; } @Override @@ -152,7 +152,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM @Override public long maxEUOutput() { - return bOutput ? V[mTier] : 0; + return bOutput ? V[mTier] : 0L; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java index 2eda016f37..545dd34f57 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java @@ -70,7 +70,7 @@ public class GT_MetaTileEntity_Hatch_Dynamo extends GT_MetaTileEntity_Hatch { @Override public long maxEUStore() { - return 512 + V[mTier + 1] * 2; + return 512L + V[mTier + 1] * 2L; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java index 91bf149ea1..66ea9f8a07 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java @@ -70,7 +70,7 @@ public class GT_MetaTileEntity_Hatch_Energy extends GT_MetaTileEntity_Hatch { @Override public long maxEUStore() { - return 512 + V[mTier] * 8; + return 512L + V[mTier] * 8L; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java index b092df1e0c..1bb1e6fa48 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java @@ -8,11 +8,12 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.common.GT_Pollution; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.ChunkPosition; public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Muffler(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 0, "Outputs the Pollution (Pollution might come later)"); + super(aID, aName, aNameRegional, aTier, 0, "Outputs the Pollution (Might cause acidic rains and poisoning)"); } public GT_MetaTileEntity_Hatch_Muffler(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -60,7 +61,7 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { } public boolean polluteEnvironment() { - GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 1000 - (95*mTier)); + GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 10000 - (600*(mTier-1))); return (mTier > 1 && getBaseMetaTileEntity().getRandomNumber(mTier) != 0) || getBaseMetaTileEntity().getAirAtSide(getBaseMetaTileEntity().getFrontFacing()); } @@ -73,4 +74,16 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return false; } + + //@Override + //public String[] getInfoData() { + // return new String[]{ + // "Reduces pollution by: "+ EnumChatFormatting.GREEN + (6*(mTier-1))+ EnumChatFormatting.RESET+" %" + // }; + //} + + public int getPollutionReduction() { + return 6*(mTier-1); + } + } 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 14c324a8ee..8a53a0510a 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 @@ -12,15 +12,20 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.XSTR; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Pollution; import gregtech.common.items.GT_MetaGenerated_Tool_01; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; @@ -188,6 +193,10 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + //TODO FIX + // (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { + // pollutionParticles(aBaseMetaTileEntity); + //} if (aBaseMetaTileEntity.isServerSide()) { if (mEfficiency < 0) mEfficiency = 0; if (--mUpdate == 0 || --mStartUpCheck == 0) { @@ -302,6 +311,36 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { return mPollution < 10000; } + //MAKE THE POLLUTION ROLL!!! TODO Fix? + public void pollutionParticles(IGregTechTileEntity aBaseMetaTileEntity){ + int xPos; + int yPos; + int zPos; + IGregTechTileEntity muffler; + World aWorld =aBaseMetaTileEntity.getWorld(); + for (MetaTileEntity tTileEntity : mMufflerHatches) { + muffler = tTileEntity.getBaseMetaTileEntity(); + xPos = ForgeDirection.getOrientation(muffler.getFrontFacing()).offsetX+muffler.getXCoord(); + yPos = ForgeDirection.getOrientation(muffler.getFrontFacing()).offsetY+muffler.getYCoord(); + zPos = ForgeDirection.getOrientation(muffler.getFrontFacing()).offsetZ+muffler.getZCoord(); + System.out.print("x:"+xPos); + System.out.print("y:"+yPos); + System.out.print("z:"+zPos); + aWorld.spawnParticle("largesmoke", xPos + (new XSTR()).nextFloat(), yPos + (new XSTR()).nextFloat(), zPos + (new XSTR()).nextFloat(), 0.0D, 0.3D, 0.0D); + } + if(!GT_Mod.gregtechproxy.mPollution)return; + if(GT_Pollution.getPollutionAtCoords(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getZCoord())>GT_Mod.gregtechproxy.mPollutionSmogLimit){ + for (MetaTileEntity tTileEntity : mMufflerHatches) { + muffler = tTileEntity.getBaseMetaTileEntity(); + xPos = ForgeDirection.getOrientation(muffler.getFrontFacing()).offsetX+muffler.getXCoord(); + yPos = ForgeDirection.getOrientation(muffler.getFrontFacing()).offsetY+muffler.getYCoord(); + zPos = ForgeDirection.getOrientation(muffler.getFrontFacing()).offsetZ+muffler.getZCoord(); + aWorld.spawnParticle("largesmoke", xPos + (new XSTR()).nextFloat(), yPos + (new XSTR()).nextFloat(), zPos + (new XSTR()).nextFloat(), 0.0D, 0.3D + (new XSTR()).nextFloat(), 0.0D); + aWorld.spawnParticle("largesmoke", xPos + (new XSTR()).nextFloat(), yPos + (new XSTR()).nextFloat(), zPos + (new XSTR()).nextFloat(), 0.0D, 0.3D + (new XSTR()).nextFloat(), 0.0D); + } + } + } + /** * Called every tick the Machine runs */ @@ -340,7 +379,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public abstract int getMaxEfficiency(ItemStack aStack); /** - * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pullution Block) + * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pollution Block) */ public abstract int getPollutionPerTick(ItemStack aStack); @@ -506,6 +545,50 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { return rVoltage; } + /** + * Calcualtes overclocked ness using long integers + * @param aEUt - recipe EUt + * @param aDuration - recipe Duration + * @param mAmperage - should be 1 ? + */ + protected void calculateOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { + byte mTier=(byte)Math.max(0,GT_Utility.getTier(maxInputVoltage)); + if(mTier==0){ + //Long time calculation + long xMaxProgresstime = (long)aDuration*2L; + if(xMaxProgresstime>Integer.MAX_VALUE-1){ + //make impossible if too long + mEUt=Integer.MAX_VALUE-1; + mMaxProgresstime=Integer.MAX_VALUE-1; + }else{ + mEUt=aEUt/4; + mMaxProgresstime=(int)xMaxProgresstime; + } + }else{ + //Long EUt calculation + long xEUt=aEUt; + //Isnt too low EUt check? + long tempEUt = xEUt<V[1] ? V[1] : xEUt; + + mMaxProgresstime = aDuration; + + while (tempEUt <= V[mTier -1] * mAmperage) { + tempEUt *= 4;//this actually controls overclocking + //xEUt *= 4;//this is effect of everclocking + mMaxProgresstime /= 2;//this is effect of overclocking + xEUt = mMaxProgresstime==0 ? (long)(xEUt/1.1D) : xEUt*4;//U know, if the time is less than 1 tick make the machine use less power + } + if(xEUt>Integer.MAX_VALUE-1){ + mEUt = Integer.MAX_VALUE-1; + mMaxProgresstime = Integer.MAX_VALUE-1; + }else{ + mEUt = (int)xEUt; + mEUt = mEUt == 0 ? 1 : mEUt; + mMaxProgresstime = mMaxProgresstime<1 ? 1 : mMaxProgresstime;//set time to 1 tick + } + } + } + public boolean drainEnergyInput(long aEU) { if (aEU <= 0) return true; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) @@ -788,7 +871,30 @@ 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:", String.valueOf((getIdealStatus() - getRepairStatus()))}; + int mPollutionReduction=0; + for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { + if (isValidMetaTileEntity(tHatch)) { + mPollutionReduction+=tHatch.getPollutionReduction(); + } + } + + return new String[]{ + "Progress:", + EnumChatFormatting.GREEN + Integer.toString(mProgresstime/20) + EnumChatFormatting.RESET +" s / "+ + EnumChatFormatting.YELLOW + Integer.toString(mMaxProgresstime/20) + EnumChatFormatting.RESET +" s", + "Stored Energy:", + EnumChatFormatting.GREEN + Long.toString(getBaseMetaTileEntity().getStoredEU()) + EnumChatFormatting.RESET +" EU / "+ + EnumChatFormatting.YELLOW + Long.toString(getBaseMetaTileEntity().getEUCapacity()) + EnumChatFormatting.RESET +" EU", + "Probably uses: "+ + EnumChatFormatting.RED + Integer.toString(mEUt) + EnumChatFormatting.RESET + " EU/t", + "Maximum total EU/t (to all Energy Hatches, not single ones)", + EnumChatFormatting.YELLOW+Long.toString(getMaxInputVoltage())+EnumChatFormatting.RESET, + "Problems: "+ + EnumChatFormatting.RED+ (getIdealStatus() - getRepairStatus())+EnumChatFormatting.RESET+ + " Efficiency: "+ + EnumChatFormatting.YELLOW+Float.toString(mEfficiency / 100.0F)+EnumChatFormatting.RESET + " %", + "Pollution reduced by: "+ EnumChatFormatting.GREEN + mPollutionReduction+ EnumChatFormatting.RESET+" %" + }; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java index a37bacff14..54cede85c3 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java @@ -1,5 +1,6 @@ package gregtech.api.metatileentity.implementations; +import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.ITexture; import gregtech.api.metatileentity.MetaTileEntity; @@ -8,6 +9,7 @@ import static gregtech.api.enums.GT_Values.GT; public abstract class GT_MetaTileEntity_TieredMachineBlock extends MetaTileEntity { /** * Value between [0 - 9] to describe the Tier of this Machine. + * PLZ [0-15] works - READ! GT_Values class. */ public final byte mTier; @@ -23,7 +25,7 @@ public abstract class GT_MetaTileEntity_TieredMachineBlock extends MetaTileEntit public GT_MetaTileEntity_TieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, aInvSlotCount); - mTier = (byte) Math.max(0, Math.min(aTier, 9)); + mTier = (byte) Math.max(0, Math.min(aTier, 15)); mDescription = aDescription; // must always be the last call! diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java index d91aafaacc..27472e7623 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java @@ -112,7 +112,7 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi @Override public long maxEUStore() { - return 512 + V[mTier + 1] * 2; + return 512L + V[mTier + 1] * 2L; } @Override @@ -127,12 +127,12 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi @Override public long maxAmperesOut() { - return getBaseMetaTileEntity().isAllowedToWork() ? V[mTier + 1] / V[mTier] : 1; + return getBaseMetaTileEntity().isAllowedToWork() ? (V[mTier + 1] / V[mTier] < 4 ? 4 : V[mTier + 1] / V[mTier]) : 1; } @Override public long maxAmperesIn() { - return getBaseMetaTileEntity().isAllowedToWork() ? 1 : V[mTier + 1] / V[mTier]; + return getBaseMetaTileEntity().isAllowedToWork() ? 1 : (V[mTier + 1] / V[mTier] < 4 ? 4 : V[mTier + 1] / V[mTier]); } @Override @@ -147,22 +147,22 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi ((IEnergySource) tTileEntity).drawEnergy(tEU); aBaseMetaTileEntity.injectEnergyUnits((byte) 6, tEU, 1); } else if (GregTech_API.mInputRF && tTileEntity instanceof IEnergyProvider && ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), 1, true) == 1) { - long tEU = (long) ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), (int) maxEUInput() * 100 / GregTech_API.mRFtoEU, false); + long tEU = (long) ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false); tEU = tEU * GregTech_API.mRFtoEU / 100; aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); } else if (GregTech_API.mInputRF && tTileEntity instanceof IEnergyStorage && ((IEnergyStorage) tTileEntity).extractEnergy(1, true) == 1) { - long tEU = (long) ((IEnergyStorage) tTileEntity).extractEnergy((int) maxEUInput() * 100 / GregTech_API.mRFtoEU, false); + long tEU = (long) ((IEnergyStorage) tTileEntity).extractEnergy(GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false); tEU = tEU * GregTech_API.mRFtoEU / 100; aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); } else if (GregTech_API.mInputRF && GregTech_API.meIOLoaded && tTileEntity instanceof IPowerContainer && ((IPowerContainer) tTileEntity).getEnergyStored() > 0) { int storedRF = ((IPowerContainer) tTileEntity).getEnergyStored(); - int extractRF = (int) maxEUInput() * 100 / GregTech_API.mRFtoEU; + int extractRF = GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU); long tEU = 0; if (tTileEntity instanceof TileCapBank) { ICapBankNetwork network = ((TileCapBank) tTileEntity).getNetwork(); if (network != null && network.getEnergyStoredL() > 0) { - tEU = Math.min((Math.min(Math.min(network.getEnergyStoredL(), storedRF - extractRF), network.getMaxOutput())) * GregTech_API.mRFtoEU / 100, maxEUInput()); - network.addEnergy((int) -(tEU * 100 / GregTech_API.mRFtoEU)); + tEU = Math.min((Math.min(Math.min(network.getEnergyStoredL(), storedRF - extractRF), network.getMaxOutput())) * (long)GregTech_API.mRFtoEU / 100L, maxEUInput()); + network.addEnergy(GT_Utility.safeInt(-(tEU * 100 / GregTech_API.mRFtoEU))); } } else { if (storedRF > extractRF) { @@ -170,7 +170,7 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi tEU = maxEUInput(); } else { ((IPowerContainer) tTileEntity).setEnergyStored(0); - tEU = storedRF * GregTech_API.mRFtoEU / 100; + tEU = storedRF * (long)GregTech_API.mRFtoEU / 100L; } } aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); |