From 0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Mon, 30 Jan 2023 10:56:42 -0800 Subject: [ci skip] spotlessApply with the new settings --- .../api/metatileentity/BaseMetaPipeEntity.java | 336 +++++----- .../api/metatileentity/BaseMetaTileEntity.java | 746 +++++++++++---------- .../api/metatileentity/BaseTileEntity.java | 319 ++++----- .../api/metatileentity/CommonMetaTileEntity.java | 15 +- .../api/metatileentity/CoverableTileEntity.java | 272 ++++---- .../metatileentity/GregTechTileClientEvents.java | 1 + .../api/metatileentity/MetaPipeEntity.java | 293 ++++---- .../api/metatileentity/MetaTileEntity.java | 236 ++++--- .../api/metatileentity/TileIC2EnergySink.java | 55 +- .../examples/GT_MetaTileEntity_E_Furnace.java | 61 +- .../implementations/GT_MetaPipeEntity_Cable.java | 371 +++++----- .../implementations/GT_MetaPipeEntity_Fluid.java | 343 +++++----- .../implementations/GT_MetaPipeEntity_Frame.java | 43 +- .../implementations/GT_MetaPipeEntity_Item.java | 305 ++++----- .../GT_MetaTileEntity_BasicBatteryBuffer.java | 220 +++--- .../GT_MetaTileEntity_BasicGenerator.java | 91 ++- .../GT_MetaTileEntity_BasicHull.java | 58 +- .../GT_MetaTileEntity_BasicHull_NonElectric.java | 22 +- .../GT_MetaTileEntity_BasicMachine.java | 641 ++++++++---------- .../GT_MetaTileEntity_BasicMachine_Bronze.java | 254 +++---- .../GT_MetaTileEntity_BasicMachine_GT_Recipe.java | 418 +++++------- .../GT_MetaTileEntity_BasicMachine_Steel.java | 151 ++--- .../GT_MetaTileEntity_BasicTank.java | 120 ++-- .../implementations/GT_MetaTileEntity_Buffer.java | 258 ++++--- .../GT_MetaTileEntity_CubicMultiBlockBase.java | 81 +-- .../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 225 +++---- ...MetaTileEntity_ExtendedPowerMultiBlockBase.java | 93 ++- .../implementations/GT_MetaTileEntity_Hatch.java | 80 +-- .../GT_MetaTileEntity_Hatch_DataAccess.java | 28 +- .../GT_MetaTileEntity_Hatch_Dynamo.java | 24 +- .../GT_MetaTileEntity_Hatch_Energy.java | 41 +- .../GT_MetaTileEntity_Hatch_Input.java | 53 +- .../GT_MetaTileEntity_Hatch_InputBus.java | 44 +- .../GT_MetaTileEntity_Hatch_Maintenance.java | 178 +++-- .../GT_MetaTileEntity_Hatch_Muffler.java | 62 +- .../GT_MetaTileEntity_Hatch_MultiInput.java | 71 +- .../GT_MetaTileEntity_Hatch_Output.java | 182 +++-- .../GT_MetaTileEntity_Hatch_OutputBus.java | 52 +- .../GT_MetaTileEntity_MultiBlockBase.java | 493 +++++++------- .../GT_MetaTileEntity_SpecialFilter.java | 144 ++-- .../GT_MetaTileEntity_TieredMachineBlock.java | 54 +- .../GT_MetaTileEntity_TooltipMultiBlockBase.java | 11 +- .../GT_MetaTileEntity_Transformer.java | 253 ++++--- .../GT_MetaTileEntity_Wireless_Dynamo.java | 27 +- .../GT_MetaTileEntity_Wireless_Hatch.java | 30 +- 45 files changed, 3614 insertions(+), 4241 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 31a341040e..335639c9e3 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -3,6 +3,24 @@ package gregtech.api.metatileentity; import static gregtech.GT_Mod.GT_FML_LOGGER; import static gregtech.api.enums.GT_Values.NW; +import java.util.*; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +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; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.SoundResource; @@ -23,22 +41,6 @@ import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; import gregtech.common.covers.CoverInfo; -import java.util.*; -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -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; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -47,16 +49,12 @@ import net.minecraftforge.fluids.IFluidHandler; */ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTechTileEntity, IPipeRenderedTileEntity, IDebugableTileEntity { + public byte mConnections = IConnectable.NO_CONNECTION; protected MetaPipeEntity mMetaTileEntity; private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; private boolean mWorkUpdate = false, mWorks = true; - private byte mColor = 0, - oColor = 0, - oStrongRedstone = 0, - oRedstoneData = 63, - oTextureData = 0, - oUpdateData = 0, + private byte mColor = 0, oColor = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0; private int oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0; protected Node node; @@ -147,7 +145,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity mColor = aNBT.getByte("mColor"); mWorks = !aNBT.getBoolean("mWorks"); - if (mSidedRedstone.length != 6) mSidedRedstone = new byte[] {0, 0, 0, 0, 0, 0}; + if (mSidedRedstone.length != 6) mSidedRedstone = new byte[] { 0, 0, 0, 0, 0, 0 }; readCoverNBT(aNBT); loadMetaTileNBT(aNBT); @@ -199,8 +197,8 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity // If foam not hardened, tries roll chance to harden if ((mConnections & IConnectable.HAS_FOAM) == IConnectable.HAS_FRESHFOAM && getRandomNumber(1000) == 0) { - mConnections = - (byte) ((mConnections & ~IConnectable.HAS_FRESHFOAM) | IConnectable.HAS_HARDENEDFOAM); + mConnections = (byte) ((mConnections & ~IConnectable.HAS_FRESHFOAM) + | IConnectable.HAS_HARDENEDFOAM); } if (mTickTimer > 12 && oldConnections != mConnections) GregTech_API.causeCableUpdate(worldObj, xCoord, yCoord, zCoord); @@ -236,8 +234,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity byte tData = mMetaTileEntity.getUpdateData(); if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData); if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor); - tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) - | ((mSidedRedstone[1] > 0) ? 2 : 0) + tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) @@ -259,17 +256,24 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity if (isServerSide() && hasValidMetaTileEntity()) { tTime = System.nanoTime() - tTime; - if (mTimeStatistics.length > 0) - mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = - (int) tTime; - if (tTime > 0 - && tTime > (GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING * 1000000L) + if (mTimeStatistics.length > 0) mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) + % mTimeStatistics.length] = (int) tTime; + if (tTime > 0 && tTime > (GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING * 1000000L) && mTickTimer > 1000 && getMetaTileEntity().doTickProfilingMessageDuringThisTick() && mLagWarningCount++ < 10) - GT_FML_LOGGER.warn("WARNING: Possible Lag Source at [" + xCoord + "," + yCoord + "," + zCoord - + "] in Dimension " + worldObj.provider.dimensionId + " with " + tTime - + " ns caused by an instance of " + getMetaTileEntity().getClass()); + GT_FML_LOGGER.warn( + "WARNING: Possible Lag Source at [" + xCoord + + "," + + yCoord + + "," + + zCoord + + "] in Dimension " + + worldObj.provider.dimensionId + + " with " + + tTime + + " ns caused by an instance of " + + getMetaTileEntity().getClass()); } mWorkUpdate = mInventoryChanged = false; @@ -306,18 +310,8 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity sendCoverDataIfNeeded(); } - 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) { + 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) { mID = aID; @@ -391,13 +385,15 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity public ArrayList getDebugInfo(EntityPlayer aPlayer, int aLogLevel) { final ArrayList tList = new ArrayList<>(); if (aLogLevel > 3) { - tList.add("Meta-ID: " + EnumChatFormatting.BLUE + mID + EnumChatFormatting.RESET - + (hasValidMetaTileEntity() - ? EnumChatFormatting.GREEN + " valid" + EnumChatFormatting.RESET - : EnumChatFormatting.RED + " invalid" + EnumChatFormatting.RESET) - + (mMetaTileEntity == null - ? EnumChatFormatting.RED + " MetaTileEntity == null!" + EnumChatFormatting.RESET - : " ")); + tList.add( + "Meta-ID: " + EnumChatFormatting.BLUE + + mID + + EnumChatFormatting.RESET + + (hasValidMetaTileEntity() ? 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) { @@ -409,26 +405,30 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity tWorstTime = tTime; } } - tList.add("Average CPU-load of ~" + (tAverageTime / mTimeStatistics.length) + "ns since " - + mTimeStatistics.length + " ticks with worst time of " + tWorstTime + "ns."); + tList.add( + "Average CPU-load of ~" + (tAverageTime / mTimeStatistics.length) + + "ns since " + + mTimeStatistics.length + + " ticks with worst time of " + + tWorstTime + + "ns."); } if (mLagWarningCount > 0) { - 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( + "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."); } if (mMetaTileEntity != null) { - tList.add("Is" - + (mMetaTileEntity.isAccessAllowed(aPlayer) - ? " " - : EnumChatFormatting.RED + " not " + EnumChatFormatting.RESET) - + "accessible for you"); + tList.add( + "Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " + : EnumChatFormatting.RED + " not " + EnumChatFormatting.RESET) + "accessible for you"); } } if (joinedIc2Enet) tList.add("Joined IC2 ENet"); - return mMetaTileEntity != null - ? mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList) + return mMetaTileEntity != null ? mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList) : new ArrayList<>(); } @@ -469,9 +469,9 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity public void setInventorySlotContents(int aIndex, ItemStack aStack) { markDirty(); mInventoryChanged = true; - if (canAccessData()) - mMetaTileEntity.setInventorySlotContents( - aIndex, worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack)); + if (canAccessData()) mMetaTileEntity.setInventorySlotContents( + aIndex, + worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack)); } @Override @@ -489,18 +489,17 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity @Override public void openInventory() { - /*Do nothing*/ + /* Do nothing */ } @Override public void closeInventory() { - /*Do nothing*/ + /* Do nothing */ } @Override public boolean isUseableByPlayer(EntityPlayer aPlayer) { - return hasValidMetaTileEntity() - && mTickTimer > 40 + return hasValidMetaTileEntity() && mTickTimer > 40 && getTileEntityOffset(0, 0, 0) == this && aPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64 && mMetaTileEntity.isAccessAllowed(aPlayer); @@ -606,7 +605,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity @Override public void setWorkDataValue(byte aValue) { - /*Do nothing*/ + /* Do nothing */ } @Override @@ -626,7 +625,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity @Override public void setActive(boolean aActive) { - /*Do nothing*/ + /* Do nothing */ } @Override @@ -707,7 +706,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity @Override public ITexture[] getTexture(Block aBlock, byte aSide) { final ITexture rIcon = getCoverTexture(aSide); - if (rIcon != null) return new ITexture[] {rIcon}; + if (rIcon != null) return new ITexture[] { rIcon }; return getTextureUncovered(aSide); } @@ -737,14 +736,13 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity tConnections = (byte) (IConnectable.CONNECTED_DOWN | IConnectable.CONNECTED_UP); else if (tConnections == IConnectable.CONNECTED_NORTH || tConnections == IConnectable.CONNECTED_SOUTH) tConnections = (byte) (IConnectable.CONNECTED_NORTH | IConnectable.CONNECTED_SOUTH); - if (hasValidMetaTileEntity()) - return mMetaTileEntity.getTexture( - this, - aSide, - tConnections, - (byte) (mColor - 1), - tConnections == 0 || (tConnections & (1 << aSide)) != 0, - getOutputRedstoneSignal(aSide) > 0); + if (hasValidMetaTileEntity()) return mMetaTileEntity.getTexture( + this, + aSide, + tConnections, + (byte) (mColor - 1), + tConnections == 0 || (tConnections & (1 << aSide)) != 0, + getOutputRedstoneSignal(aSide) > 0); return Textures.BlockIcons.ERROR_RENDERING; } @@ -785,8 +783,8 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity if (isClientSide()) { // Configure Cover, sneak can also be: screwdriver, wrench, side cutter, soldering iron if (aPlayer.isSneaking()) { - final byte tSide = - (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) : aSide; + final byte tSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) + : aSide; return (getCoverInfoAtSide(tSide).hasCoverGUI()); } else if (getCoverBehaviorAtSideNew(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) { return true; @@ -808,7 +806,13 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity mMetaTileEntity.markDirty(); GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); GT_Utility.sendSoundToPlayers( - worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); + worldObj, + SoundResource.IC2_TOOLS_WRENCH, + 1.0F, + -1, + xCoord, + yCoord, + zCoord); } return true; } @@ -821,16 +825,29 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity mMetaTileEntity.onScrewdriverRightClick(tSide, aPlayer, aX, aY, aZ); mMetaTileEntity.markDirty(); GT_Utility.sendSoundToPlayers( - worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); + worldObj, + SoundResource.IC2_TOOLS_WRENCH, + 1.0F, + -1, + xCoord, + yCoord, + zCoord); } } else { if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { setCoverDataAtSide( - aSide, getCoverInfoAtSide(aSide).onCoverScrewdriverClick(aPlayer, aX, aY, aZ)); + aSide, + getCoverInfoAtSide(aSide).onCoverScrewdriverClick(aPlayer, aX, aY, aZ)); mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); mMetaTileEntity.markDirty(); GT_Utility.sendSoundToPlayers( - worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); + worldObj, + SoundResource.IC2_TOOLS_WRENCH, + 1.0F, + -1, + xCoord, + yCoord, + zCoord); } } return true; @@ -838,7 +855,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList)) { // if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - // GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(1), 1.0F, -1, xCoord, yCoord, + // GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(1), 1.0F, -1, xCoord, yCoord, // zCoord); // } return true; @@ -852,11 +869,16 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity GT_Utility.sendChatToPlayer( aPlayer, GT_Utility.trans("090", "Machine Processing: ") - + (isAllowedToWork() - ? GT_Utility.trans("088", "Enabled") + + (isAllowedToWork() ? GT_Utility.trans("088", "Enabled") : GT_Utility.trans("087", "Disabled"))); GT_Utility.sendSoundToPlayers( - worldObj, SoundResource.IC2_TOOLS_RUBBER_TRAMPOLINE, 1.0F, -1, xCoord, yCoord, zCoord); + worldObj, + SoundResource.IC2_TOOLS_RUBBER_TRAMPOLINE, + 1.0F, + -1, + xCoord, + yCoord, + zCoord); } return true; } @@ -866,7 +888,13 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity mMetaTileEntity.markDirty(); // logic handled internally GT_Utility.sendSoundToPlayers( - worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); + worldObj, + SoundResource.IC2_TOOLS_WRENCH, + 1.0F, + -1, + xCoord, + yCoord, + zCoord); } doEnetUpdate(); return true; @@ -877,20 +905,30 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity mMetaTileEntity.markDirty(); // logic handled internally GT_Utility.sendSoundToPlayers( - worldObj, SoundResource.IC2_TOOLS_BATTERY_USE, 1.0F, -1, xCoord, yCoord, zCoord); + worldObj, + SoundResource.IC2_TOOLS_BATTERY_USE, + 1.0F, + -1, + xCoord, + yCoord, + zCoord); } else if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) { mMetaTileEntity.markDirty(); mStrongRedstone ^= (1 << tSide); GT_Utility.sendChatToPlayer( aPlayer, - GT_Utility.trans("091", "Redstone Output at Side ") - + tSide + GT_Utility.trans("091", "Redstone Output at Side ") + tSide + GT_Utility.trans("092", " set to: ") - + ((mStrongRedstone & (1 << tSide)) != 0 - ? GT_Utility.trans("093", "Strong") + + ((mStrongRedstone & (1 << tSide)) != 0 ? GT_Utility.trans("093", "Strong") : GT_Utility.trans("094", "Weak"))); GT_Utility.sendSoundToPlayers( - worldObj, SoundResource.IC2_TOOLS_BATTERY_USE, 3.0F, -1, xCoord, yCoord, zCoord); + worldObj, + SoundResource.IC2_TOOLS_BATTERY_USE, + 3.0F, + -1, + xCoord, + yCoord, + zCoord); issueBlockUpdate(); } doEnetUpdate(); @@ -905,13 +943,19 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity if (coverInfo.getCoverID() == 0) { if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCovers.keySet())) { if (GregTech_API.getCoverBehaviorNew(tCurrentItem) - .isCoverPlaceable(coverSide, tCurrentItem, this) + .isCoverPlaceable(coverSide, tCurrentItem, this) && mMetaTileEntity.allowCoverOnSide(coverSide, new GT_ItemStack(tCurrentItem))) { setCoverItemAtSide(coverSide, tCurrentItem); mMetaTileEntity.markDirty(); if (!aPlayer.capabilities.isCreativeMode) tCurrentItem.stackSize--; GT_Utility.sendSoundToPlayers( - worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); + worldObj, + SoundResource.IC2_TOOLS_WRENCH, + 1.0F, + -1, + xCoord, + yCoord, + zCoord); } return true; } @@ -919,7 +963,13 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList)) { if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { GT_Utility.sendSoundToPlayers( - worldObj, SoundResource.RANDOM_BREAK, 1.0F, -1, xCoord, yCoord, zCoord); + worldObj, + SoundResource.RANDOM_BREAK, + 1.0F, + -1, + xCoord, + yCoord, + zCoord); dropCover(coverSide, aSide, false); mMetaTileEntity.markDirty(); } @@ -990,8 +1040,8 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity } /** - * returns all valid Inventory Slots, no matter which Side (Unless it's covered). - * The Side Stuff is done in the following two Functions. + * returns all valid Inventory Slots, no matter which Side (Unless it's covered). The Side Stuff is done in the + * following two Functions. */ @Override public int[] getAccessibleSlotsFromSide(int aSide) { @@ -1006,8 +1056,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity */ @Override public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() - && getCoverInfoAtSide((byte) aSide).letsItemsIn(aIndex) + return canAccessData() && getCoverInfoAtSide((byte) aSide).letsItemsIn(aIndex) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide); } @@ -1016,15 +1065,12 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity */ @Override public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() - && getCoverBehaviorAtSideNew((byte) aSide) - .letsItemsOut( - (byte) aSide, - getCoverIDAtSide((byte) aSide), - getComplexCoverDataAtSide((byte) aSide), - aIndex, - this) - && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide); + return canAccessData() && getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getComplexCoverDataAtSide((byte) aSide), + aIndex, + this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide); } @Override @@ -1154,21 +1200,20 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity // the pipe if (tTileEntity != null && !mMetaTileEntity.isConnectedAtSide((byte) aSide.ordinal())) return false; - if (isFill - && mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) - && getCoverInfoAtSide((byte) aSide.ordinal()).letsFluidIn(aFluid)) return true; + if (isFill && mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) + && getCoverInfoAtSide((byte) aSide.ordinal()).letsFluidIn(aFluid)) + return true; - if (!isFill - && mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) - && getCoverInfoAtSide((byte) aSide.ordinal()).letsFluidOut(aFluid)) return true; + if (!isFill && mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) + && getCoverInfoAtSide((byte) aSide.ordinal()).letsFluidOut(aFluid)) + return true; return false; } @Override public int fill(ForgeDirection aSide, FluidStack aFluidStack, boolean doFill) { - if (mTickTimer > 5 - && canAccessData() + if (mTickTimer > 5 && canAccessData() && canMoveFluidOnSide(aSide, aFluidStack == null ? null : aFluidStack.getFluid(), true)) return mMetaTileEntity.fill(aSide, aFluidStack, doFill); return 0; @@ -1176,21 +1221,18 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity @Override public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { - if (mTickTimer > 5 - && canAccessData() + if (mTickTimer > 5 && canAccessData() && canMoveFluidOnSide( aSide, - mMetaTileEntity.getFluid() == null - ? null - : mMetaTileEntity.getFluid().getFluid(), - false)) return mMetaTileEntity.drain(aSide, maxDrain, doDrain); + mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid().getFluid(), + false)) + return mMetaTileEntity.drain(aSide, maxDrain, doDrain); return null; } @Override public FluidStack drain(ForgeDirection aSide, FluidStack aFluidStack, boolean doDrain) { - if (mTickTimer > 5 - && canAccessData() + if (mTickTimer > 5 && canAccessData() && canMoveFluidOnSide(aSide, aFluidStack == null ? null : aFluidStack.getFluid(), false)) return mMetaTileEntity.drain(aSide, aFluidStack, doDrain); return null; @@ -1213,12 +1255,11 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity @Override public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { final CoverInfo coverInfo = getCoverInfoAtSide((byte) aSide.ordinal()); - if (canAccessData() - && (aSide == ForgeDirection.UNKNOWN - || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && coverInfo.letsFluidIn(null)) - || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && coverInfo.letsFluidOut(null)) - // Doesn't need to be connected to get Tank Info -- otherwise things can't connect - )) return mMetaTileEntity.getTankInfo(aSide); + if (canAccessData() && (aSide == ForgeDirection.UNKNOWN + || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && coverInfo.letsFluidIn(null)) + || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && coverInfo.letsFluidOut(null)) + // Doesn't need to be connected to get Tank Info -- otherwise things can't connect + )) return mMetaTileEntity.getTankInfo(aSide); return new FluidTankInfo[] {}; } @@ -1232,9 +1273,8 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity return true; } aStack = GT_OreDictUnificator.get(aStack); - if (GT_Utility.areStacksEqual(tStack, aStack) - && tStack.stackSize + aStack.stackSize - <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) { + if (GT_Utility.areStacksEqual(tStack, aStack) && tStack.stackSize + aStack.stackSize + <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) { markDirty(); tStack.stackSize += aStack.stackSize; return true; @@ -1321,7 +1361,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity // Trigger a checking of connections in case someone placed down a block that the pipe/wire shouldn't be // connected to. // However; don't do it immediately in case the world isn't finished loading - // (This caused issues with AE2 GTEU p2p connections. + // (This caused issues with AE2 GTEU p2p connections. ((MetaPipeEntity) meta).setCheckConnections(); } } @@ -1333,14 +1373,8 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity } @Override - public void addCollisionBoxesToList( - World aWorld, - int aX, - int aY, - int aZ, - AxisAlignedBB inputAABB, - List outputAABB, - Entity collider) { + public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, + List outputAABB, Entity collider) { mMetaTileEntity.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 1e8ffa0994..7408701f16 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -6,6 +6,35 @@ import static gregtech.api.enums.GT_Values.NW; import static gregtech.api.enums.GT_Values.V; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; +import java.lang.reflect.Field; +import java.util.*; + +import javax.annotation.Nullable; + +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFire; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.server.MinecraftServer; +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.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; + import appeng.api.networking.IGridNode; import appeng.api.networking.security.IActionHost; import appeng.api.util.AECableType; @@ -14,10 +43,12 @@ import appeng.me.helpers.AENetworkProxy; import appeng.me.helpers.IGridProxyable; import appeng.tile.TileEvent; import appeng.tile.events.TileEventType; + import com.gtnewhorizon.structurelib.alignment.IAlignment; import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructableProvider; + import cpw.mods.fml.common.Optional; import cpw.mods.fml.relauncher.ReflectionHelper; import gregtech.GT_Mod; @@ -43,31 +74,6 @@ import gregtech.api.util.*; import gregtech.common.GT_Pollution; import gregtech.common.covers.CoverInfo; import ic2.api.Direction; -import java.lang.reflect.Field; -import java.util.*; -import javax.annotation.Nullable; -import mcp.mobius.waila.api.IWailaConfigHandler; -import mcp.mobius.waila.api.IWailaDataAccessor; -import net.minecraft.block.Block; -import net.minecraft.block.BlockFire; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.server.MinecraftServer; -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.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -76,27 +82,21 @@ import net.minecraftforge.fluids.FluidTankInfo; */ @Optional.InterfaceList( value = { - @Optional.Interface( - iface = "appeng.api.networking.security.IActionHost", - modid = "appliedenergistics2", - striprefs = true), - @Optional.Interface( - iface = "appeng.me.helpers.IGridProxyable", - modid = "appliedenergistics2", - striprefs = true) - }) -public class BaseMetaTileEntity extends CommonMetaTileEntity - implements IGregTechTileEntity, - IActionHost, - IGridProxyable, - IAlignmentProvider, - IConstructableProvider, - IDebugableTileEntity, - IGregtechWailaProvider { - private static final Field ENTITY_ITEM_HEALTH_FIELD = - ReflectionHelper.findField(EntityItem.class, "health", "field_70291_e"); - private final boolean[] mActiveEUInputs = new boolean[] {false, false, false, false, false, false}; - private final boolean[] mActiveEUOutputs = new boolean[] {false, false, false, false, false, false}; + @Optional.Interface( + iface = "appeng.api.networking.security.IActionHost", + modid = "appliedenergistics2", + striprefs = true), + @Optional.Interface( + iface = "appeng.me.helpers.IGridProxyable", + modid = "appliedenergistics2", + striprefs = true) }) +public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTechTileEntity, IActionHost, + IGridProxyable, IAlignmentProvider, IConstructableProvider, IDebugableTileEntity, IGregtechWailaProvider { + + private static final Field ENTITY_ITEM_HEALTH_FIELD = ReflectionHelper + .findField(EntityItem.class, "health", "field_70291_e"); + private final boolean[] mActiveEUInputs = new boolean[] { false, false, false, false, false, false }; + private final boolean[] mActiveEUOutputs = new boolean[] { false, false, false, false, false, false }; private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; public long mLastSoundTick = 0; public boolean mWasShutdown = false; @@ -104,28 +104,14 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity protected long mStoredEnergy = 0, mStoredSteam = 0; protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; protected boolean mReleaseEnergy = false; - protected long[] mAverageEUInput = new long[] {0, 0, 0, 0, 0}, mAverageEUOutput = new long[] {0, 0, 0, 0, 0}; - private boolean mHasEnoughEnergy = true, - mRunningThroughTick = false, - mInputDisabled = false, - mOutputDisabled = false, - mMuffler = false, - mLockUpgrade = false; + protected long[] mAverageEUInput = new long[] { 0, 0, 0, 0, 0 }, mAverageEUOutput = new long[] { 0, 0, 0, 0, 0 }; + private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, + mOutputDisabled = false, mMuffler = false, mLockUpgrade = false; private boolean mActive = false, mWorkUpdate = false, mSteamConverter = false, mWorks = true; private boolean oRedstone = false; - private byte mColor = 0, - oColor = 0, - oStrongRedstone = 0, - oRedstoneData = 63, - oTextureData = 0, - oUpdateData = 0, + private byte mColor = 0, oColor = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage = 0; - private byte oLightValueClient = 0, - oLightValue = -1, - mLightValue = 0, - mOtherUpgrades = 0, - mFacing = 0, - oFacing = 0, + private byte oLightValueClient = 0, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0; private long oOutput = 0, mAcceptedAmperes = Long.MAX_VALUE; @@ -184,8 +170,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity else mID = mID > 0 ? mID : 0; if (mID != 0) createNewMetatileEntity(mID); mSidedRedstone = (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior() - ? new byte[] {0, 0, 0, 0, 0, 0} - : new byte[] {15, 15, 15, 15, 15, 15}); + ? new byte[] { 0, 0, 0, 0, 0, 0 } + : new byte[] { 15, 15, 15, 15, 15, 15 }); } else { if (aID <= 0) mID = (short) aNBT.getInteger("mID"); else mID = aID; @@ -208,8 +194,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity mWorks = !aNBT.getBoolean("mWorks"); mInputDisabled = aNBT.getBoolean("mInputDisabled"); mOutputDisabled = aNBT.getBoolean("mOutputDisabled"); - mOtherUpgrades = - (byte) (aNBT.getByte("mOtherUpgrades") + aNBT.getByte("mBatteries") + aNBT.getByte("mLiBatteries")); + mOtherUpgrades = (byte) (aNBT.getByte("mOtherUpgrades") + aNBT.getByte("mBatteries") + + aNBT.getByte("mLiBatteries")); mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); final int nbtVersion = aNBT.getInteger("nbtVersion"); @@ -219,15 +205,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity if (mSidedRedstone.length != 6) if (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior()) - mSidedRedstone = new byte[] {0, 0, 0, 0, 0, 0}; - else mSidedRedstone = new byte[] {15, 15, 15, 15, 15, 15}; + mSidedRedstone = new byte[] { 0, 0, 0, 0, 0, 0 }; + else mSidedRedstone = new byte[] { 15, 15, 15, 15, 15, 15 }; updateCoverBehavior(); } /** - * Used for ticking special BaseMetaTileEntities, which need that for Energy Conversion - * It's called right before onPostTick() + * Used for ticking special BaseMetaTileEntities, which need that for Energy Conversion It's called right before + * onPostTick() */ public void updateStatus() { // @@ -279,17 +265,13 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity final int precipitationHeightAtSide4 = worldObj.getPrecipitationHeight(xCoord - 1, zCoord); final int precipitationHeightAtSide5 = worldObj.getPrecipitationHeight(xCoord + 1, zCoord); return (getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord) - || (getCoverIDAtSide((byte) 2) == 0 - && precipitationHeightAtSide2 - 1 < yCoord + || (getCoverIDAtSide((byte) 2) == 0 && precipitationHeightAtSide2 - 1 < yCoord && precipitationHeightAtSide2 > -1) - || (getCoverIDAtSide((byte) 3) == 0 - && precipitationHeightAtSide3 - 1 < yCoord + || (getCoverIDAtSide((byte) 3) == 0 && precipitationHeightAtSide3 - 1 < yCoord && precipitationHeightAtSide3 > -1) - || (getCoverIDAtSide((byte) 4) == 0 - && precipitationHeightAtSide4 - 1 < yCoord + || (getCoverIDAtSide((byte) 4) == 0 && precipitationHeightAtSide4 - 1 < yCoord && precipitationHeightAtSide4 > -1) - || (getCoverIDAtSide((byte) 5) == 0 - && precipitationHeightAtSide5 - 1 < yCoord + || (getCoverIDAtSide((byte) 5) == 0 && precipitationHeightAtSide5 - 1 < yCoord && precipitationHeightAtSide5 > -1); } @@ -413,14 +395,14 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity } if (mMetaTileEntity.isEnetOutput() && oOutput > 0) { - final long tOutputVoltage = - Math.max(oOutput, oOutput + (1L << Math.max(0, GT_Utility.getTier(oOutput) - 1))); + final long tOutputVoltage = Math + .max(oOutput, oOutput + (1L << Math.max(0, GT_Utility.getTier(oOutput) - 1))); final long tUsableAmperage = Math.min( getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); if (tUsableAmperage > 0) { - final long tEU = - tOutputVoltage * Util.emitEnergyToNetwork(oOutput, tUsableAmperage, this); + final long tEU = tOutputVoltage + * Util.emitEnergyToNetwork(oOutput, tUsableAmperage, this); mAverageEUOutput[mAverageEUOutputIndex] += tEU; decreaseStoredEU(tEU, true); } @@ -444,21 +426,29 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity if (getRandomNumber(10) == 0) { try { GT_Mod.achievements.issueAchievement( - this.getWorldObj() - .getPlayerEntityByName(mOwnerName), + this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); - } catch (Exception ignored) { - } - GT_Log.exp.println("Machine at: " + this.getXCoord() + " | " - + this.getYCoord() + " | " + this.getZCoord() + " DIMID: " - + this.worldObj.provider.dimensionId - + " explosion due to rain!"); + } catch (Exception ignored) {} + GT_Log.exp.println( + "Machine at: " + this.getXCoord() + + " | " + + this.getYCoord() + + " | " + + this.getZCoord() + + " DIMID: " + + this.worldObj.provider.dimensionId + + " explosion due to rain!"); doEnergyExplosion(); } else { - GT_Log.exp.println("Machine at: " + this.getXCoord() + " | " - + this.getYCoord() + " | " + this.getZCoord() + " DIMID: " - + this.worldObj.provider.dimensionId - + " set to Fire due to rain!"); + GT_Log.exp.println( + "Machine at: " + this.getXCoord() + + " | " + + this.getYCoord() + + " | " + + this.getZCoord() + + " DIMID: " + + this.worldObj.provider.dimensionId + + " set to Fire due to rain!"); setOnFire(); } } @@ -466,18 +456,20 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity mRunningThroughTick = false; return; } - if (GregTech_API.sMachineThunderExplosions - && worldObj.isThundering() + if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getRandomNumber(3) == 0) { try { GT_Mod.achievements.issueAchievement( this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} GT_Log.exp.println( - "Machine at: " + this.getXCoord() + " | " + this.getYCoord() - + " | " + this.getZCoord() + " DIMID: " + "Machine at: " + this.getXCoord() + + " | " + + this.getYCoord() + + " | " + + this.getZCoord() + + " DIMID: " + this.worldObj.provider.dimensionId + " explosion due to Thunderstorm!"); doEnergyExplosion(); @@ -497,19 +489,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity if (aSideServer) { if (mMetaTileEntity.dechargerSlotCount() > 0 && getStoredEU() < getEUCapacity()) { for (int i = mMetaTileEntity.dechargerSlotStartIndex(), - k = mMetaTileEntity.dechargerSlotCount() + i; - i < k; - i++) { + k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) { dischargeItem(mMetaTileEntity.mInventory[i]); if (ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i]) > 0) { - if ((getStoredEU() - + ic2.api.info.Info.itemEnergy.getEnergyValue( - mMetaTileEntity.mInventory[i])) - < getEUCapacity()) { + if ((getStoredEU() + ic2.api.info.Info.itemEnergy + .getEnergyValue(mMetaTileEntity.mInventory[i])) < getEUCapacity()) { increaseStoredEnergyUnits( - (long) ic2.api.info.Info.itemEnergy.getEnergyValue( - mMetaTileEntity.mInventory[i]), + (long) ic2.api.info.Info.itemEnergy + .getEnergyValue(mMetaTileEntity.mInventory[i]), false); mMetaTileEntity.mInventory[i].stackSize--; mInventoryChanged = true; @@ -526,9 +514,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity if (aSideServer) { if (mMetaTileEntity.rechargerSlotCount() > 0 && getStoredEU() > 0) { for (int i = mMetaTileEntity.rechargerSlotStartIndex(), - k = mMetaTileEntity.rechargerSlotCount() + i; - i < k; - i++) { + k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { if (getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) { chargeItem(mMetaTileEntity.mInventory[i]); if (mMetaTileEntity.mInventory[i].stackSize <= 0) { @@ -559,8 +545,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity } if (mTickTimer > 10) { - byte tData = (byte) ((mFacing & 7) - | (mActive ? 8 : 0) + byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0) | (mWorks ? 64 : 0)); @@ -572,13 +557,12 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity sendBlockEvent(GregTechTileClientEvents.CHANGE_CUSTOM_DATA, oUpdateData = tData); if (mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { tData = ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage(); - if (tData != oTexturePage) - sendBlockEvent(GregTechTileClientEvents.CHANGE_CUSTOM_DATA, (byte) - ((oTexturePage = tData) | 0x80)); // set last bit as a flag for page + if (tData != oTexturePage) sendBlockEvent( + GregTechTileClientEvents.CHANGE_CUSTOM_DATA, + (byte) ((oTexturePage = tData) | 0x80)); // set last bit as a flag for page } if (mColor != oColor) sendBlockEvent(GregTechTileClientEvents.CHANGE_COLOR, oColor = mColor); - tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) - | ((mSidedRedstone[1] > 0) ? 2 : 0) + tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) @@ -613,25 +597,32 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity if (aSideServer && hasValidMetaTileEntity()) { tTime = System.nanoTime() - tTime; - if (mTimeStatistics.length > 0) - mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = - (int) tTime; - if (tTime > 0 - && tTime > (GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING * 1000000L) + if (mTimeStatistics.length > 0) mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) + % mTimeStatistics.length] = (int) tTime; + if (tTime > 0 && tTime > (GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING * 1000000L) && mTickTimer > 1000 && getMetaTileEntity().doTickProfilingMessageDuringThisTick() && mLagWarningCount++ < 10) - GT_FML_LOGGER.warn("WARNING: Possible Lag Source at [" + xCoord + ", " + yCoord + ", " + zCoord - + "] in Dimension " + worldObj.provider.dimensionId + " with " + tTime - + "ns caused by an instance of " + getMetaTileEntity().getClass()); + GT_FML_LOGGER.warn( + "WARNING: Possible Lag Source at [" + xCoord + + ", " + + yCoord + + ", " + + zCoord + + "] in Dimension " + + worldObj.provider.dimensionId + + " with " + + tTime + + "ns caused by an instance of " + + getMetaTileEntity().getClass()); } mWorkUpdate = mInventoryChanged = mRunningThroughTick = false; } @Override - public void getWailaBody( - ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + public void getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { if (hasValidMetaTileEntity()) { getMetaTileEntity().getWailaBody(itemStack, currenttip, accessor, config); } @@ -639,8 +630,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity } @Override - public void getWailaNBTData( - EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, int z) { + public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, + int z) { super.getWailaNBTData(player, tile, tag, world, x, y, z); if (hasValidMetaTileEntity()) { getMetaTileEntity().getWailaNBTData(player, tile, tag, world, x, y, z); @@ -662,13 +653,12 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity getCoverInfoAtSide((byte) 3).getCoverID(), getCoverInfoAtSide((byte) 4).getCoverID(), getCoverInfoAtSide((byte) 5).getCoverID(), - oTextureData = (byte) ((mFacing & 7) - | (mActive ? 8 : 0) + oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0) | (mWorks ? 64 : 0)), - oTexturePage = - (hasValidMetaTileEntity() && mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) + oTexturePage = (hasValidMetaTileEntity() + && mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) ? ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage() : 0, oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, @@ -686,18 +676,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity sendCoverDataIfNeeded(); } - public final void receiveMetaTileEntityData( - short aID, - int aCover0, - int aCover1, - int aCover2, - int aCover3, - int aCover4, - int aCover5, - byte aTextureData, - byte aTexturePage, - byte aUpdateData, - byte aRedstoneData, + public final void receiveMetaTileEntityData(short aID, int aCover0, int aCover1,