From 6f31720697bcc351421a4d86ba3bf749375dd12c Mon Sep 17 00:00:00 2001 From: Raven Szewczyk Date: Sat, 27 Aug 2022 10:19:57 +0100 Subject: Update buildscript & apply spotless (#1306) * Update dependencies * Update buildscript, apply spotless --- .../api/metatileentity/BaseMetaPipeEntity.java | 450 ++++++++--- .../api/metatileentity/BaseMetaTileEntity.java | 879 ++++++++++++++------- .../api/metatileentity/BaseTileEntity.java | 57 +- .../api/metatileentity/CommonMetaTileEntity.java | 7 +- .../api/metatileentity/CoverableTileEntity.java | 211 +++-- .../api/metatileentity/MetaPipeEntity.java | 409 +++++++--- .../api/metatileentity/MetaTileEntity.java | 370 ++++++--- .../api/metatileentity/TileIC2EnergySink.java | 51 +- .../examples/GT_MetaTileEntity_E_Furnace.java | 76 +- .../implementations/GT_MetaPipeEntity_Cable.java | 421 ++++++---- .../implementations/GT_MetaPipeEntity_Fluid.java | 325 +++++--- .../implementations/GT_MetaPipeEntity_Frame.java | 55 +- .../implementations/GT_MetaPipeEntity_Item.java | 275 +++++-- .../GT_MetaTileEntity_BasicBatteryBuffer.java | 101 ++- .../GT_MetaTileEntity_BasicGenerator.java | 98 ++- .../GT_MetaTileEntity_BasicHull.java | 50 +- .../GT_MetaTileEntity_BasicHull_NonElectric.java | 17 +- .../GT_MetaTileEntity_BasicMachine.java | 460 +++++++---- .../GT_MetaTileEntity_BasicMachine_Bronze.java | 235 ++++-- .../GT_MetaTileEntity_BasicMachine_GT_Recipe.java | 441 ++++++++--- .../GT_MetaTileEntity_BasicMachine_Steel.java | 128 ++- .../GT_MetaTileEntity_BasicTank.java | 82 +- .../implementations/GT_MetaTileEntity_Buffer.java | 156 ++-- .../GT_MetaTileEntity_CubicMultiBlockBase.java | 171 ++-- .../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 347 ++++---- .../implementations/GT_MetaTileEntity_Hatch.java | 111 ++- .../GT_MetaTileEntity_Hatch_DataAccess.java | 35 +- .../GT_MetaTileEntity_Hatch_Dynamo.java | 15 +- .../GT_MetaTileEntity_Hatch_Energy.java | 18 +- .../GT_MetaTileEntity_Hatch_Input.java | 47 +- .../GT_MetaTileEntity_Hatch_InputBus.java | 118 +-- .../GT_MetaTileEntity_Hatch_Maintenance.java | 134 ++-- .../GT_MetaTileEntity_Hatch_Muffler.java | 43 +- .../GT_MetaTileEntity_Hatch_MultiInput.java | 40 +- .../GT_MetaTileEntity_Hatch_Output.java | 183 +++-- .../GT_MetaTileEntity_Hatch_OutputBus.java | 80 +- .../GT_MetaTileEntity_MultiBlockBase.java | 432 +++++----- .../GT_MetaTileEntity_SpecialFilter.java | 13 +- .../GT_MetaTileEntity_TieredMachineBlock.java | 32 +- .../GT_MetaTileEntity_TooltipMultiBlockBase.java | 9 +- .../GT_MetaTileEntity_Transformer.java | 192 +++-- .../GT_MetaTileEntity_Wireless_Dynamo.java | 21 +- .../GT_MetaTileEntity_Wireless_Hatch.java | 25 +- 43 files changed, 4964 insertions(+), 2456 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 16a8ec8cca..0fdaa90c1a 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -1,5 +1,8 @@ package gregtech.api.metatileentity; +import static gregtech.GT_Mod.GT_FML_LOGGER; +import static gregtech.api.enums.GT_Values.NW; + import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.SoundResource; @@ -19,6 +22,7 @@ import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; +import java.util.*; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -35,22 +39,24 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import java.util.*; - -import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.NW; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! *

* This is the main TileEntity for EVERYTHING. */ -public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTechTileEntity, IPipeRenderedTileEntity, IDebugableTileEntity { +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, mLagWarningCount = 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; protected NodePath nodePath; @@ -100,8 +106,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec } } - public BaseMetaPipeEntity() { - } + public BaseMetaPipeEntity() {} @Override public void writeToNBT(NBTTagCompound aNBT) { @@ -141,7 +146,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec 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); @@ -164,8 +169,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec oX = xCoord; oY = yCoord; oZ = zCoord; - if (isServerSide()) - checkDropCover(); + if (isServerSide()) checkDropCover(); else { requestCoverDataIfNeeded(); } @@ -186,15 +190,16 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec } } if (isServerSide() && mTickTimer > 10) { - if (!doCoverThings()) - return; + if (!doCoverThings()) return; final byte oldConnections = mConnections; // Mask-out connection direction bits to keep only Foam related connections mConnections = (byte) (mMetaTileEntity.mConnections | (mConnections & ~IConnectable.CONNECTED_ALL)); // 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); + if ((mConnections & IConnectable.HAS_FOAM) == IConnectable.HAS_FRESHFOAM + && getRandomNumber(1000) == 0) { + mConnections = + (byte) ((mConnections & ~IConnectable.HAS_FRESHFOAM) | IConnectable.HAS_HARDENEDFOAM); } if (mTickTimer > 12 && oldConnections != mConnections) GregTech_API.causeCableUpdate(worldObj, xCoord, yCoord, zCoord); @@ -230,7 +235,12 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec byte tData = mMetaTileEntity.getUpdateData(); if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData); if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor); - tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)); + tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) + | ((mSidedRedstone[1] > 0) ? 2 : 0) + | ((mSidedRedstone[2] > 0) ? 4 : 0) + | ((mSidedRedstone[3] > 0) ? 8 : 0) + | ((mSidedRedstone[4] > 0) ? 16 : 0) + | ((mSidedRedstone[5] > 0) ? 32 : 0)); if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData); } @@ -249,9 +259,16 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec 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) && 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()); + 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()); } mWorkUpdate = mInventoryChanged = false; @@ -260,20 +277,46 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec private void sendClientData() { if (mSendClientData) { NW.sendPacketToAllPlayersInRange( - worldObj, - new GT_Packet_TileEntity( - xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5], oTextureData = mConnections, - oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, - oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), - oColor = mColor - ), xCoord, zCoord - ); + worldObj, + new GT_Packet_TileEntity( + xCoord, + (short) yCoord, + zCoord, + mID, + mCoverSides[0], + mCoverSides[1], + mCoverSides[2], + mCoverSides[3], + mCoverSides[4], + mCoverSides[5], + oTextureData = mConnections, + oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, + oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) + | ((mSidedRedstone[1] > 0) ? 2 : 0) + | ((mSidedRedstone[2] > 0) ? 4 : 0) + | ((mSidedRedstone[3] > 0) ? 8 : 0) + | ((mSidedRedstone[4] > 0) ? 16 : 0) + | ((mSidedRedstone[5] > 0) ? 32 : 0)), + oColor = mColor), + xCoord, + zCoord); mSendClientData = false; } 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; @@ -347,7 +390,13 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec 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) { @@ -359,21 +408,27 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec 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"); + if (joinedIc2Enet) tList.add("Joined IC2 ENet"); - return mMetaTileEntity != null ? - mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList) : - new ArrayList<>(); + return mMetaTileEntity != null + ? mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList) + : new ArrayList<>(); } @Override @@ -382,7 +437,6 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec return false; } - @Override public byte getBackFacing() { return GT_Utility.getOppositeSide(getFrontFacing()); @@ -415,7 +469,8 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec markDirty(); mInventoryChanged = true; if (canAccessData()) - mMetaTileEntity.setInventorySlotContents(aIndex, worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack)); + mMetaTileEntity.setInventorySlotContents( + aIndex, worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack)); } @Override @@ -432,14 +487,22 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec } @Override - public void openInventory() {/*Do nothing*/} + public void openInventory() { + /*Do nothing*/ + } @Override - public void closeInventory() {/*Do nothing*/} + public void closeInventory() { + /*Do nothing*/ + } @Override public boolean isUseableByPlayer(EntityPlayer aPlayer) { - return hasValidMetaTileEntity() && mTickTimer > 40 && getTileEntityOffset(0, 0, 0) == this && aPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64 && mMetaTileEntity.isAccessAllowed(aPlayer); + return hasValidMetaTileEntity() + && mTickTimer > 40 + && getTileEntityOffset(0, 0, 0) == this + && aPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64 + && mMetaTileEntity.isAccessAllowed(aPlayer); } @Override @@ -541,7 +604,9 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec } @Override - public void setWorkDataValue(byte aValue) {/*Do nothing*/} + public void setWorkDataValue(byte aValue) { + /*Do nothing*/ + } @Override public int getMetaTileID() { @@ -559,7 +624,9 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec } @Override - public void setActive(boolean aActive) {/*Do nothing*/} + public void setActive(boolean aActive) { + /*Do nothing*/ + } @Override public long getTimer() { @@ -636,11 +703,10 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec return 0; } - @Override public ITexture[] getTexture(Block aBlock, byte aSide) { ITexture rIcon = getCoverTexture(aSide); - if (rIcon != null) return new ITexture[]{rIcon}; + if (rIcon != null) return new ITexture[] {rIcon}; return getTextureUncovered(aSide); } @@ -664,11 +730,18 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec if ((mConnections & IConnectable.HAS_HARDENEDFOAM) != 0) return Textures.BlockIcons.HARDENEDFOAMS[mColor]; if ((mConnections & IConnectable.HAS_FOAM) != 0) return Textures.BlockIcons.ERROR_RENDERING; byte tConnections = mConnections; - if (tConnections == IConnectable.CONNECTED_WEST || tConnections == IConnectable.CONNECTED_EAST) tConnections = (byte) (IConnectable.CONNECTED_WEST | IConnectable.CONNECTED_EAST); - else if (tConnections == IConnectable.CONNECTED_DOWN || tConnections == IConnectable.CONNECTED_UP) 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 (tConnections == IConnectable.CONNECTED_WEST || tConnections == IConnectable.CONNECTED_EAST) + tConnections = (byte) (IConnectable.CONNECTED_WEST | IConnectable.CONNECTED_EAST); + else if (tConnections == IConnectable.CONNECTED_DOWN || tConnections == IConnectable.CONNECTED_UP) + 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), + return mMetaTileEntity.getTexture( + this, + aSide, + tConnections, + (byte) (mColor - 1), tConnections == 0 || (tConnections & (1 << aSide)) != 0, getOutputRedstoneSignal(aSide) > 0); return Textures.BlockIcons.ERROR_RENDERING; @@ -679,7 +752,6 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec return mMetaTileEntity != null && mMetaTileEntity.getBaseMetaTileEntity() == this; } - @Override public void doExplosion(long aAmount) { if (canAccessData()) { @@ -697,12 +769,11 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec for (byte i = 0; i < mCoverSides.length; i++) { if (mCoverSides[i] != 0) { if (mCoverData[i] != null) // this really shouldn't be null if a cover is there already, but whatever - tNBT.setTag(COVER_DATA_NBT_KEYS[i], mCoverData[i].saveDataToNBT()); + tNBT.setTag(COVER_DATA_NBT_KEYS[i], mCoverData[i].saveDataToNBT()); hasCover = true; } } - if (hasCover) - tNBT.setIntArray("mCoverSides", mCoverSides); + if (hasCover) tNBT.setIntArray("mCoverSides", mCoverSides); if (hasValidMetaTileEntity()) mMetaTileEntity.setItemNBT(tNBT); if (!tNBT.hasNoTags()) rStack.setTagCompound(tNBT); return new ArrayList<>(Collections.singletonList(rStack)); @@ -711,9 +782,10 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec @Override public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { if (isClientSide()) { - //Configure Cover, sneak can also be: screwdriver, wrench, side cutter, soldering iron + // Configure Cover, sneak can also be: screwdriver, wrench, side cutter, soldering iron if (aPlayer.isSneaking()) { - byte tSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) : aSide; + byte tSide = + (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) : aSide; return (getCoverBehaviorAtSideNew(tSide).hasCoverGUI()); } else if (getCoverBehaviorAtSideNew(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) { return true; @@ -722,7 +794,8 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec if (isServerSide()) { ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); if (tCurrentItem != null) { - if (getColorization() >= 0 && GT_Utility.areStacksEqual(new ItemStack(Items.water_bucket, 1), tCurrentItem)) { + if (getColorization() >= 0 + && GT_Utility.areStacksEqual(new ItemStack(Items.water_bucket, 1), tCurrentItem)) { mMetaTileEntity.markDirty(); tCurrentItem.func_150996_a(Items.bucket); setColorization((byte) -1); @@ -733,33 +806,59 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec if (mMetaTileEntity.onWrenchRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { mMetaTileEntity.markDirty(); GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); - GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers( + worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } return true; } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) { if (getCoverIDAtSide(aSide) == 0 && getCoverIDAtSide(tSide) != 0) { if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) { - setCoverDataAtSide(tSide, getCoverBehaviorAtSideNew(tSide).onCoverScrewdriverClick(tSide, getCoverIDAtSide(tSide), getComplexCoverDataAtSide(tSide), this, aPlayer, 0.5F, 0.5F, 0.5F)); + setCoverDataAtSide( + tSide, + getCoverBehaviorAtSideNew(tSide) + .onCoverScrewdriverClick( + tSide, + getCoverIDAtSide(tSide), + getComplexCoverDataAtSide(tSide), + this, + aPlayer, + 0.5F, + 0.5F, + 0.5F)); mMetaTileEntity.onScrewdriverRightClick(tSide, aPlayer, aX, aY, aZ); mMetaTileEntity.markDirty(); - GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers( + worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } } else { if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - setCoverDataAtSide(aSide, getCoverBehaviorAtSideNew(aSide).onCoverScrewdriverClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)); + setCoverDataAtSide( + aSide, + getCoverBehaviorAtSideNew(aSide) + .onCoverScrewdriverClick( + aSide, + getCoverIDAtSide(aSide), + getComplexCoverDataAtSide(aSide), + this, + 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); + GT_Utility.sendSoundToPlayers( + worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } } return true; } 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, zCoord); - //} + // if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { + // GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(1), 1.0F, -1, xCoord, yCoord, + // zCoord); + // } return true; } @@ -768,8 +867,14 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec if (mWorks) disableWorking(); else enableWorking(); mMetaTileEntity.markDirty(); - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("090","Machine Processing: ") + (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); + GT_Utility.sendChatToPlayer( + aPlayer, + GT_Utility.trans("090", "Machine Processing: ") + + (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); } return true; } @@ -777,23 +882,33 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList)) { if (mMetaTileEntity.onWireCutterRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { mMetaTileEntity.markDirty(); - //logic handled internally - GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); + // logic handled internally + GT_Utility.sendSoundToPlayers( + worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } doEnetUpdate(); return true; } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) { - if (mMetaTileEntity.onSolderingToolRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { + if (mMetaTileEntity.onSolderingToolRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { mMetaTileEntity.markDirty(); - //logic handled internally - GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_BATTERY_USE, 1.0F, -1, xCoord, yCoord, zCoord); + // logic handled internally + GT_Utility.sendSoundToPlayers( + 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("092"," set to: ") + ((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); + GT_Utility.sendChatToPlayer( + aPlayer, + GT_Utility.trans("091", "Redstone Output at Side ") + + tSide + + GT_Utility.trans("092", " set to: ") + + ((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); issueBlockUpdate(); } doEnetUpdate(); @@ -805,43 +920,59 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec if (getCoverIDAtSide(coverSide) == 0) { if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCovers.keySet())) { - if (GregTech_API.getCoverBehaviorNew(tCurrentItem).isCoverPlaceable(coverSide, tCurrentItem, this) && - mMetaTileEntity.allowCoverOnSide(coverSide, new GT_ItemStack(tCurrentItem))) - { + if (GregTech_API.getCoverBehaviorNew(tCurrentItem) + .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); + GT_Utility.sendSoundToPlayers( + worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord); } return true; } } else { 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); + GT_Utility.sendSoundToPlayers( + worldObj, SoundResource.RANDOM_BREAK, 1.0F, -1, xCoord, yCoord, zCoord); dropCover(coverSide, aSide, false); mMetaTileEntity.markDirty(); } return true; } } - } - else if (aPlayer.isSneaking()) { //Sneak click, no tool -> open cover config or turn back. + } else if (aPlayer.isSneaking()) { // Sneak click, no tool -> open cover config or turn back. aSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) : aSide; - return getCoverIDAtSide(aSide) > 0 && getCoverBehaviorAtSideNew(aSide).onCoverShiftRightClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer); + return getCoverIDAtSide(aSide) > 0 + && getCoverBehaviorAtSideNew(aSide) + .onCoverShiftRightClick( + aSide, + getCoverIDAtSide(aSide), + getComplexCoverDataAtSide(aSide), + this, + aPlayer); } - if (getCoverBehaviorAtSideNew(aSide).onCoverRightClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)) - return true; + if (getCoverBehaviorAtSideNew(aSide) + .onCoverRightClick( + aSide, + getCoverIDAtSide(aSide), + getComplexCoverDataAtSide(aSide), + this, + aPlayer, + aX, + aY, + aZ)) return true; } - if (!getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) - return false; + if (!getCoverBehaviorAtSideNew(aSide) + .isGUIClickable(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) return false; try { if (!aPlayer.isSneaking() && hasValidMetaTileEntity()) { boolean handled = mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ); - if(handled) { + if (handled) { mMetaTileEntity.markDirty(); } return handled; @@ -896,8 +1027,21 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec */ @Override public int[] getAccessibleSlotsFromSide(int aSide) { - if (canAccessData() && (getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), -1, this) || getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), -1, this))) - return mMetaTileEntity.getAccessibleSlotsFromSide(aSide); + if (canAccessData() + && (getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsOut( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getComplexCoverDataAtSide((byte) aSide), + -1, + this) + || getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsIn( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getComplexCoverDataAtSide((byte) aSide), + -1, + this))) return mMetaTileEntity.getAccessibleSlotsFromSide(aSide); return GT_Values.emptyIntArray; } @@ -906,7 +1050,15 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec */ @Override public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide); + return canAccessData() + && getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsIn( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getComplexCoverDataAtSide((byte) aSide), + aIndex, + this) + && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide); } /** @@ -914,7 +1066,15 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec */ @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 @@ -997,9 +1157,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec } @Override - public void setOwnerUuid(UUID uuid) { - - } + public void setOwnerUuid(UUID uuid) {} @Override public byte getComparatorValue(byte aSide) { @@ -1039,42 +1197,63 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec } private boolean canMoveFluidOnSide(ForgeDirection aSide, Fluid aFluid, boolean isFill) { - if (aSide == ForgeDirection.UNKNOWN) - return true; + if (aSide == ForgeDirection.UNKNOWN) return true; IFluidHandler tTileEntity = getITankContainerAtSide((byte) aSide.ordinal()); - // Only require a connection if there's something to connect to - Allows fluid cells & buckets to interact with the pipe - if (tTileEntity != null && !mMetaTileEntity.isConnectedAtSide((byte) aSide.ordinal())) - return false; - - if(isFill && mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) - && getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)) - return true; - - if (!isFill && mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) - && getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()),aFluid, this)) - return true; + // Only require a connection if there's something to connect to - Allows fluid cells & buckets to interact with + // the pipe + if (tTileEntity != null && !mMetaTileEntity.isConnectedAtSide((byte) aSide.ordinal())) return false; + + if (isFill + && mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) + && getCoverBehaviorAtSideNew((byte) aSide.ordinal()) + .letsFluidIn( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getComplexCoverDataAtSide((byte) aSide.ordinal()), + aFluid, + this)) return true; + + if (!isFill + && mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) + && getCoverBehaviorAtSideNew((byte) aSide.ordinal()) + .letsFluidOut( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getComplexCoverDataAtSide((byte) aSide.ordinal()), + aFluid, + this)) return true; return false; } @Override public int fill(ForgeDirection aSide, FluidStack aFluidStack, boolean doFill) { - if (mTickTimer > 5 && canAccessData() && canMoveFluidOnSide(aSide, aFluidStack == null ? null : aFluidStack.getFluid(), true)) + if (mTickTimer > 5 + && canAccessData() + && canMoveFluidOnSide(aSide, aFluidStack == null ? null : aFluidStack.getFluid(), true)) return mMetaTileEntity.fill(aSide, aFluidStack, doFill); return 0; } @Override public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { - if (mTickTimer > 5 && canAccessData() && canMoveFluidOnSide(aSide, mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid().getFluid(), false)) - return mMetaTileEntity.drain(aSide, maxDrain, doDrain); + if (mTickTimer > 5 + && canAccessData() + && canMoveFluidOnSide( + aSide, + 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() && canMoveFluidOnSide(aSide, aFluidStack == null ? null : aFluidStack.getFluid(), false)) + if (mTickTimer > 5 + && canAccessData() + && canMoveFluidOnSide(aSide, aFluidStack == null ? null : aFluidStack.getFluid(), false)) return mMetaTileEntity.drain(aSide, aFluidStack, doDrain); return null; } @@ -1096,15 +1275,26 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec @Override public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { if (canAccessData() - && (aSide == ForgeDirection.UNKNOWN - || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) - && getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), null, this)) - || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), null, this)) - // Doesn't need to be connected to get Tank Info -- otherwise things can't connect - ) - ) - return mMetaTileEntity.getTankInfo(aSide); - return new FluidTankInfo[]{}; + && (aSide == ForgeDirection.UNKNOWN + || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) + && getCoverBehaviorAtSideNew((byte) aSide.ordinal()) + .letsFluidIn( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getComplexCoverDataAtSide((byte) aSide.ordinal()), + null, + this)) + || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) + && getCoverBehaviorAtSideNew((byte) aSide.ordinal()) + .letsFluidOut( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getComplexCoverDataAtSide((byte) aSide.ordinal()), + null, + this)) + // Doesn't need to be connected to get Tank Info -- otherwise things can't connect + )) return mMetaTileEntity.getTankInfo(aSide); + return new FluidTankInfo[] {}; } @Override @@ -1117,7 +1307,9 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec 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; @@ -1183,7 +1375,7 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec public String[] getInfoData() { { if (canAccessData()) return getMetaTileEntity().getInfoData(); - return new String[]{}; + return new String[] {}; } } @@ -1196,7 +1388,8 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec if (canAccessData()) { final IMetaTileEntity meta = getMetaTileEntity(); if (meta instanceof MetaPipeEntity) { - // Trigger a checking of connections in case someone placed down a block that the pipe/wire shouldn't be connected to. + // 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. ((MetaPipeEntity) meta).setCheckConnections(); @@ -1210,7 +1403,14 @@ public class BaseMetaPipeEntity extends CommonMetaTileEntity implements IGregTec } @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 b68715770c..911c1cabcb 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -1,5 +1,10 @@ package gregtech.api.metatileentity; +import static gregtech.GT_Mod.GT_FML_LOGGER; +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 appeng.api.networking.IGridNode; import appeng.api.networking.security.IActionHost; import appeng.api.util.AECableType; @@ -9,11 +14,9 @@ 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.IAlignmentLimits; import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructableProvider; -import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; import cpw.mods.fml.common.Optional; import cpw.mods.fml.relauncher.ReflectionHelper; import gregtech.GT_Mod; @@ -38,6 +41,9 @@ import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.*; import gregtech.common.GT_Pollution; 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; @@ -61,27 +67,34 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import javax.annotation.Nullable; -import java.lang.reflect.Field; -import java.util.*; - -import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.NW; -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.objects.XSTR.XSTR_INSTANCE; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! *

* This is the main TileEntity for EVERYTHING. */ -@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.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}; private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; public long mLastSoundTick = 0; public boolean mWasShutdown = false; @@ -89,12 +102,29 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec 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, oTexturePage = 0; - private byte oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0; + private byte mColor = 0, + oColor = 0, + oStrongRedstone = 0, + oRedstoneData = 63, + oTextureData = 0, + oUpdateData = 0, + oTexturePage = 0; + private byte oLightValueClient = -1, + 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; private long mLastCheckTick = 0; @@ -103,8 +133,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec private NBTTagCompound mRecipeStuff = new NBTTagCompound(); private int cableUpdateDelay = 30; - public BaseMetaTileEntity() { - } + public BaseMetaTileEntity() {} @Override public void writeToNBT(NBTTagCompound aNBT) { @@ -152,7 +181,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (aID > 0) mID = aID; 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}); + mSidedRedstone = (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior() + ? 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; @@ -175,7 +206,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec 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"); @@ -184,11 +216,11 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } if (mCoverData == null || mCoverData.length != 6) mCoverData = new ISerializableObject[6]; - if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; + if (mCoverSides.length != 6) mCoverSides = new int[] {0, 0, 0, 0, 0, 0}; 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(); } @@ -205,14 +237,29 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec * Called when trying to charge Items */ public void chargeItem(ItemStack aStack) { - decreaseStoredEU(GT_ModHandler.chargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getOutputTier()), false, false), true); + decreaseStoredEU( + GT_ModHandler.chargeElectricItem( + aStack, + (int) Math.min(Integer.MAX_VALUE, getStoredEU()), + (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getOutputTier()), + false, + false), + true); } /** * Called when trying to discharge Items */ public void dischargeItem(ItemStack aStack) { - increaseStoredEnergyUnits(GT_ModHandler.dischargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, getEUCapacity() - getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()), false, false, false), true); + increaseStoredEnergyUnits( + GT_ModHandler.dischargeElectricItem( + aStack, + (int) Math.min(Integer.MAX_VALUE, getEUCapacity() - getStoredEU()), + (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()), + false, + false, + false), + true); } protected boolean isRainPossible() { @@ -274,7 +321,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (mNeedsUpdate) { worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - //worldObj.func_147479_m(xCoord, yCoord, zCoord); + // worldObj.func_147479_m(xCoord, yCoord, zCoord); mNeedsUpdate = false; } } @@ -340,12 +387,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } } - if (mMetaTileEntity.isEnetOutput() && oOutput > 0) { - 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); + 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); } @@ -362,26 +412,46 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } if (getRandomNumber(1000) == 0 && isRainPossible()) { - final int precipitationHeightAtSide2 = worldObj.getPrecipitationHeight(xCoord, zCoord - 1); - final int precipitationHeightAtSide3 = worldObj.getPrecipitationHeight(xCoord, zCoord + 1); - final int precipitationHeightAtSide4 = worldObj.getPrecipitationHeight(xCoord - 1, zCoord); - final int precipitationHeightAtSide5 = worldObj.getPrecipitationHeight(xCoord + 1, zCoord); - - if ((getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHei