diff options
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity')
43 files changed, 4964 insertions, 2456 deletions
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!!! * <p/> * 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<String> getDebugInfo(EntityPlayer aPlayer, int aLogLevel) { final ArrayList<String> 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<AxisAlignedBB> outputAABB, Entity collider) { + public void addCollisionBoxesToList( + World aWorld, + int aX, + int aY, + int aZ, + AxisAlignedBB inputAABB, + List<AxisAlignedBB> 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!!! * <p/> * 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.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord) - || (getCoverIDAtSide((byte) 2) == 0 && precipitationHeightAtSide2 - 1 < yCoord && precipitationHeightAtSide2 > -1) - || (getCoverIDAtSide((byte) 3) == 0 && precipitationHeightAtSide3 - 1 < yCoord && precipitationHeightAtSide3 > -1) - || (getCoverIDAtSide((byte) 4) == 0 && precipitationHeightAtSide4 - 1 < yCoord && precipitationHeightAtSide4 > -1) - || (getCoverIDAtSide((byte) 5) == 0 && precipitationHeightAtSide5 - 1 < yCoord && precipitationHeightAtSide5 > -1)) { + 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.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord) + || (getCoverIDAtSide((byte) 2) == 0 + && precipitationHeightAtSide2 - 1 < yCoord + && precipitationHeightAtSide2 > -1) + || (getCoverIDAtSide((byte) 3) == 0 + && precipitationHeightAtSide3 - 1 < yCoord + && precipitationHeightAtSide3 > -1) + || (getCoverIDAtSide((byte) 4) == 0 + && precipitationHeightAtSide4 - 1 < yCoord + && precipitationHeightAtSide4 > -1) + || (getCoverIDAtSide((byte) 5) == 0 + && precipitationHeightAtSide5 - 1 < yCoord + && precipitationHeightAtSide5 > -1)) { if (GregTech_API.sMachineRainExplosions && worldObj.isRaining()) { if (getRandomNumber(10) == 0) { try { - GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); + GT_Mod.achievements.issueAchievement( + 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!"); + 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(); } } @@ -389,12 +459,18 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec mRunningThroughTick = false; return; } - if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getRandomNumber(3) == 0) { + if (GregTech_API.sMachineThunderExplosions + && worldObj.isThundering() + && getRandomNumber(3) == 0) { try { - GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather"); + GT_Mod.achievements.issueAchievement( + 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 Thunderstorm!"); + GT_Log.exp.println("Machine at: " + this.getXCoord() + " | " + this.getYCoord() + + " | " + this.getZCoord() + " DIMID: " + + this.worldObj.provider.dimensionId + + " explosion due to Thunderstorm!"); doEnergyExplosion(); } } @@ -409,12 +485,21 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } if (aSideServer) { if (mMetaTileEntity.dechargerSlotCount() > 0 && getStoredEU() < getEUCapacity()) { - for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { + for (int i = mMetaTileEntity.dechargerSlotStartIndex(), + k = mMetaTileEntity.dechargerSlotCount() + i; + i < k; + i++) { if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) { dischargeItem(mMetaTileEntity.mInventory[i]); if (ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i]) > 0) { - if ((getStoredEU() + ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i])) < getEUCapacity()) { - increaseStoredEnergyUnits((long) ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i]), false); + if ((getStoredEU() + + ic2.api.info.Info.itemEnergy.getEnergyValue( + mMetaTileEntity.mInventory[i])) + < getEUCapacity()) { + increaseStoredEnergyUnits( + (long) ic2.api.info.Info.itemEnergy.getEnergyValue( + mMetaTileEntity.mInventory[i]), + false); mMetaTileEntity.mInventory[i].stackSize--; mInventoryChanged = true; } @@ -429,7 +514,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } if (aSideServer) { if (mMetaTileEntity.rechargerSlotCount() > 0 && getStoredEU() > 0) { - for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { + for (int i = mMetaTileEntity.rechargerSlotStartIndex(), + k = mMetaTileEntity.rechargerSlotCount() + i; + i < k; + i++) { if (getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) { chargeItem(mMetaTileEntity.mInventory[i]); if (mMetaTileEntity.mInventory[i].stackSize <= 0) { @@ -460,7 +548,11 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } if (mTickTimer > 10) { - byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0) | (mWorks ? 64 : 0)); + byte tData = (byte) ((mFacing & 7) + | (mActive ? 8 : 0) + | (mRedstone ? 16 : 0) + | (mLockUpgrade ? 32 : 0) + | (mWorks ? 64 : 0)); if (tData != oTextureData) sendBlockEvent(GregTechTileClientEvents.CHANGE_COMMON_DATA, oTextureData = tData); @@ -470,10 +562,16 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec 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 + 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) | ((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(GregTechTileClientEvents.CHANGE_REDSTONE_OUTPUT, oRedstoneData = tData); if (mLightValue != oLightValue) { @@ -505,16 +603,24 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec 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) && 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 = mRunningThroughTick = false; } @Override - public void getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + public void getWailaBody( + ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { if (hasValidMetaTileEntity() && getMetaTileEntity() != null) { getMetaTileEntity().getWailaBody(itemStack, currenttip, accessor, config); } @@ -522,7 +628,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } @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() != null) { getMetaTileEntity().getWailaNBTData(player, tile, tag, world, x, y, z); @@ -532,22 +639,55 @@ public class BaseMetaTileEntity 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 = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0) | (mWorks ? 64 : 0)), - oTexturePage = (hasValidMetaTileEntity() && mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) ? ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage() : 0, - oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, - oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)), - oColor = mColor), - xCoord, zCoord - ); + worldObj, + new GT_Packet_TileEntity( + xCoord, + (short) yCoord, + zCoord, + mID, + mCoverSides[0], + mCoverSides[1], + mCoverSides[2], + mCoverSides[3], + mCoverSides[4], + mCoverSides[5], + oTextureData = (byte) ((mFacing & 7) + | (mActive ? 8 : 0) + | (mRedstone ? 16 : 0) + | (mLockUpgrade ? 32 : 0) + | (mWorks ? 64 : 0)), + oTexturePage = + (hasValidMetaTileEntity() && mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) + ? ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage() + : 0, + oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0, + oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) + | ((mSidedRedstone[1] > 0) ? 2 : 0) + | ((mSidedRedstone[2] > 0) ? 4 : 0) + | ((mSidedRedstone[3] > 0) ? 8 : 0) + | ((mSidedRedstone[4] > 0) ? 16 : 0) + | ((mSidedRedstone[5] > 0) ? 32 : 0)), + oColor = mColor), + xCoord, + zCoord); mSendClientData = false; } 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, byte aColorData) { + 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, + byte aColorData) { issueTextureUpdate(); if (mID != aID && aID > 0) { mID = aID; @@ -569,11 +709,33 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } @Deprecated - 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) { - receiveMetaTileEntityData(aID, aCover0, aCover1, aCover2, aCover3, aCover4, aCover5, aTextureData, (byte) 0, aUpdateData, aRedstoneData, 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) { + receiveMetaTileEntityData( + aID, + aCover0, + aCover1, + aCover2, + aCover3, + aCover4, + aCover5, + aTextureData, + (byte) 0, + aUpdateData, + aRedstoneData, + aColorData); } - @Override public boolean receiveClientEvent(int aEventID, int aValue) { super.receiveClientEvent(aEventID, aValue); @@ -582,7 +744,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec try { mMetaTileEntity.receiveClientEvent((byte) aEventID, (byte) aValue); } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); + GT_Log.err.println( + "Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } } @@ -594,15 +757,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec mFacing = (byte) (aValue & 7); mActive = ((aValue & 8) != 0); mRedstone = ((aValue & 16) != 0); - //mLockUpgrade = ((aValue&32) != 0); + // mLockUpgrade = ((aValue&32) != 0); mWorks = ((aValue & 64) != 0); break; case GregTechTileClientEvents.CHANGE_CUSTOM_DATA: if (hasValidMetaTileEntity()) { - if ((aValue & 0x80) == 0) //Is texture index - mMetaTileEntity.onValueUpdate((byte) (aValue & 0x7F)); - else if (mMetaTileEntity instanceof GT_MetaTileEntity_Hatch)//is texture page and hatch - ((GT_MetaTileEntity_Hatch) mMetaTileEntity).onTexturePageUpdate((byte) (aValue & 0x7F)); + if ((aValue & 0x80) == 0) // Is texture index + mMetaTileEntity.onValueUpdate((byte) (aValue & 0x7F)); + else if (mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) // is texture page and hatch + ((GT_MetaTileEntity_Hatch) mMetaTileEntity).onTexturePageUpdate((byte) (aValue & 0x7F)); } break; case GregTechTileClientEvents.CHANGE_COLOR: @@ -641,7 +804,13 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aLogLevel) { final ArrayList<String> tList = new ArrayList<>(); if (aLogLevel > 2) { - tList.add("Meta-ID: " + EnumChatFormatting.BLUE + mID + EnumChatFormatting.RESET + (canAccessData() ? EnumChatFormatting.GREEN + " valid" + EnumChatFormatting.RESET : EnumChatFormatting.RED + " invalid" + EnumChatFormatting.RESET) + (mMetaTileEntity == null ? EnumChatFormatting.RED + " MetaTileEntity == null!" + EnumChatFormatting.RESET : " ")); + tList.add("Meta-ID: " + EnumChatFormatting.BLUE + mID + EnumChatFormatting.RESET + + (canAccessData() + ? EnumChatFormatting.GREEN + " valid" + EnumChatFormatting.RESET + : EnumChatFormatting.RED + " invalid" + EnumChatFormatting.RESET) + + (mMetaTileEntity == null + ? EnumChatFormatting.RED + " MetaTileEntity == null!" + EnumChatFormatting.RESET + : " ")); } if (aLogLevel > 1) { if (mTimeStatistics.length > 0) { @@ -653,27 +822,40 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec tWorstTime = tTime; } // Uncomment this line to print out tick-by-tick times. - //tList.add("tTime " + tTime); + // tList.add("tTime " + tTime); } - tList.add("Average CPU load of ~" + GT_Utility.formatNumbers(tAverageTime / mTimeStatistics.length) + "ns over " + GT_Utility.formatNumbers(mTimeStatistics.length) + " ticks with worst time of " + GT_Utility.formatNumbers(tWorstTime) + "ns."); - tList.add("Recorded " + GT_Utility.formatNumbers(mMetaTileEntity.mSoundRequests) + " sound requests in " + GT_Utility.formatNumbers(mTickTimer - mLastCheckTick) + " ticks."); + tList.add("Average CPU load of ~" + GT_Utility.formatNumbers(tAverageTime / mTimeStatistics.length) + + "ns over " + GT_Utility.formatNumbers(mTimeStatistics.length) + " ticks with worst time of " + + GT_Utility.formatNumbers(tWorstTime) + "ns."); + tList.add("Recorded " + GT_Utility.formatNumbers(mMetaTileEntity.mSoundRequests) + " sound requests in " + + GT_Utility.formatNumbers(mTickTimer - mLastCheckTick) + " ticks."); mLastCheckTick = mTickTimer; mMetaTileEntity.mSoundRequests = 0; } 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."); } - 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 (aLogLevel > 0) { if (getSteamCapacity() > 0 && hasSteamEngineUpgrade()) - tList.add(GT_Utility.formatNumbers(getStoredSteam()) + " of " + GT_Utility.formatNumbers(getSteamCapacity()) + " Steam"); - tList.add("Machine is " + (mActive ? EnumChatFormatting.GREEN + "active" + EnumChatFormatting.RESET : EnumChatFormatting.RED + "inactive" + EnumChatFormatting.RESET)); + tList.add(GT_Utility.formatNumbers(getStoredSteam()) + " of " + + GT_Utility.formatNumbers(getSteamCapacity()) + " Steam"); + tList.add("Machine is " + + (mActive + ? EnumChatFormatting.GREEN + "active" + EnumChatFormatting.RESET + : EnumChatFormatting.RED + "inactive" + EnumChatFormatting.RESET)); if (!mHasEnoughEnergy) - tList.add(EnumChatFormatting.RED + "ATTENTION: This Device needs more power." + EnumChatFormatting.RESET); + tList.add( + EnumChatFormatting.RED + "ATTENTION: This Device needs more power." + EnumChatFormatting.RESET); } - if (joinedIc2Enet) - tList.add("Joined IC2 ENet"); + if (joinedIc2Enet) tList.add("Joined IC2 ENet"); return mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); } @@ -729,7 +911,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec mInventoryChanged = true; if (canAccessData()) { markDirty(); - mMetaTileEntity.setInventorySlotContents(aIndex, worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack)); + mMetaTileEntity.setInventorySlotContents( + aIndex, worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack)); } } @@ -758,9 +941,12 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public boolean isUseableByPlayer(EntityPlayer aPlayer) { - return canAccessData() && playerOwnsThis(aPlayer, false) && mTickTimer > 40 && - getTileEntityOffset(0, 0, 0) == this && - aPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64 && mMetaTileEntity.isAccessAllowed(aPlayer); + return canAccessData() + && playerOwnsThis(aPlayer, false) + && mTickTimer > 40 + && getTileEntityOffset(0, 0, 0) == this + && aPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64 + && mMetaTileEntity.isAccessAllowed(aPlayer); } @Override @@ -774,8 +960,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec tileEntityInvalid = false; leaveEnet(); if (canAccessData()) { - if (GregTech_API.mAE2) - invalidateAE(); + if (GregTech_API.mAE2) invalidateAE(); mMetaTileEntity.onRemoval(); mMetaTileEntity.setBaseMetaTileEntity(null); } @@ -785,8 +970,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public void onChunkUnload() { super.onChunkUnload(); - if (GregTech_API.mAE2) - onChunkUnloadAE(); + if (GregTech_API.mAE2) onChunkUnloadAE(); } @Override @@ -898,7 +1082,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) { if (!canAccessData()) return false; - return mHasEnoughEnergy = decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) || decreaseStoredSteam(aEnergy, false) || (aIgnoreTooLessEnergy && (decreaseStoredSteam(aEnergy, true))); + return mHasEnoughEnergy = decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) + || decreaseStoredSteam(aEnergy, false) + || (aIgnoreTooLessEnergy && (decreaseStoredSteam(aEnergy, true))); } @Override @@ -1039,9 +1225,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public ITexture[] getTexture(Block aBlock, byte aSide) { final ITexture coverTexture = getCoverTexture(aSide); - final ITexture[] textureUncovered = hasValidMetaTileEntity() ? - mMetaTileEntity.getTexture(this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0) : - Textures.BlockIcons.ERROR_RENDERING; + final ITexture[] textureUncovered = hasValidMetaTileEntity() + ? mMetaTileEntity.getTexture( + this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0) + : Textures.BlockIcons.ERROR_RENDERING; final ITexture[] textureCovered; if (coverTexture != null) { textureCovered = Arrays.copyOf(textureUncovered, textureUncovered.length + 1); @@ -1054,8 +1241,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec private boolean isEnergyInputSide(byte aSide) { if (aSide >= 0 && aSide < 6) { - if (!getCoverBehaviorAtSideNew(aSide).letsEnergyIn(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) - return false; + if (!getCoverBehaviorAtSideNew(aSide) + .letsEnergyIn(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) return false; if (isInvalid() || mReleaseEnergy) return false; if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetInput()) return mMetaTileEntity.isInputFacing(aSide); @@ -1065,7 +1252,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec private boolean isEnergyOutputSide(byte aSide) { if (aSide >= 0 && aSide < 6) { - if (!getCoverBehaviorAtSideNew(aSide).letsEnergyOut(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) + if (!getCoverBehaviorAtSideNew(aSide) + .letsEnergyOut(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) return false; if (isInvalid() || mReleaseEnergy) return mReleaseEnergy; if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput()) @@ -1133,7 +1321,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec setOwnerName(aPlayer.getDisplayName()); setOwnerUuid(aPlayer.getUniqueID()); } else - return !privateAccess() || aPlayer.getDisplayName().equals("Player") || mOwnerName.equals("Player") || mOwnerName.equals(aPlayer.getDisplayName()); + return !privateAccess() + || aPlayer.getDisplayName().equals("Player") + || mOwnerName.equals("Player") + || mOwnerName.equals(aPlayer.getDisplayName()); return true; } @@ -1144,10 +1335,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec public void doEnergyExplosion() { if (getUniversalEnergyCapacity() > 0 && getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 5) { - GT_Log.exp.println("Energy Explosion, injected " + getUniversalEnergyStored() + "EU >= " + getUniversalEnergyCapacity() / 5D + "Capacity of the Machine!"); - - doExplosion(oOutput * (getUniversalEnergyStored() >= getUniversalEnergyCapacity() ? 4 : getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 2 ? 2 : 1)); - GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "electricproblems"); + GT_Log.exp.println("Energy Explosion, injected " + getUniversalEnergyStored() + "EU >= " + + getUniversalEnergyCapacity() / 5D + "Capacity of the Machine!"); + + doExplosion(oOutput + * (getUniversalEnergyStored() >= getUniversalEnergyCapacity() + ? 4 + : getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 2 ? 2 : 1)); + GT_Mod.achievements.issueAchievement( + this.getWorldObj().getPlayerEntityByName(mOwnerName), "electricproblems"); } } @@ -1189,9 +1385,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec public void dropItems(ItemStack tItem) { if (tItem == null) return; - final EntityItem tItemEntity = new EntityItem(this.worldObj, this.xCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, this.yCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, this.zCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); + final EntityItem tItemEntity = new EntityItem( + this.worldObj, + this.xCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, + this.yCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, + this.zCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, + new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); if (tItem.hasTagCompound()) { - tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy()); + tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) + tItem.getTagCompound().copy()); } tItemEntity.motionX = (XSTR_INSTANCE.nextGaussian() * 0.0500000007450581D); tItemEntity.motionY = (XSTR_INSTANCE.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D); @@ -1199,8 +1401,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec tItemEntity.hurtResistantTime = 999999; tItemEntity.lifespan = 60000; try { - if (ENTITY_ITEM_HEALTH_FIELD != null) - ENTITY_ITEM_HEALTH_FIELD.setInt(tItemEntity, 99999999); + if (ENTITY_ITEM_HEALTH_FIELD != null) ENTITY_ITEM_HEALTH_FIELD.setInt(tItemEntity, 99999999); } catch (Exception ignored) { } this.worldObj.spawnEntityInWorld(tItemEntity); @@ -1232,34 +1433,43 @@ public class BaseMetaTileEntity 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()) { - 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 (getCoverBehaviorAtSideNew(tSide).hasCoverGUI()); } else if (getCoverBehaviorAtSideNew(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) { return true; } - if (!getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) + if (!getCoverBehaviorAtSideNew(aSide) + .isGUIClickable(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) return false; } if (isServerSide()) { if (!privateAccess() || aPlayer.getDisplayName().equalsIgnoreCase(getOwnerName())) { final 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)) { tCurrentItem.func_150996_a(Items.bucket); setColorization((byte) (getColorization() >= 16 ? -2 : -1)); return true; } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { - if (aPlayer.isSneaking() && mMetaTileEntity instanceof GT_MetaTileEntity_BasicMachine && ((GT_MetaTileEntity_BasicMachine) mMetaTileEntity).setMainFacing(GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ))) { + if (aPlayer.isSneaking() + && mMetaTileEntity instanceof GT_MetaTileEntity_BasicMachine + && ((GT_MetaTileEntity_BasicMachine) mMetaTileEntity) + .setMainFacing(GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ))) { 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); cableUpdateDelay = 10; - } else if (mMetaTileEntity.onWrenchRightClick(aSide, GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ), aPlayer, aX, aY, aZ)) { + } else if (mMetaTileEntity.onWrenchRightClick( + aSide, GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ), aPlayer, aX, aY, aZ)) { 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); cableUpdateDelay = 10; } return true; @@ -1267,9 +1477,21 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) { if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, 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); - 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; } @@ -1278,8 +1500,18 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { mInputDisabled = !mInputDisabled; if (mInputDisabled) mOutputDisabled = !mOutputDisabled; - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("086", "Auto-Input: ") + (mInputDisabled ? GT_Utility.trans("087", "Disabled") : GT_Utility.trans("088", "Enabled") + GT_Utility.trans("089", " Auto-Output: ") + (mOutputDisabled ? GT_Utility.trans("087", "Disabled") : GT_Utility.trans("088", "Enabled")))); - GT_Utility.sendSoundToPlayers(worldObj, SoundResource.RANDOM_ANVIL_USE, 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendChatToPlayer( + aPlayer, + GT_Utility.trans("086", "Auto-Input: ") + + (mInputDisabled + ? GT_Utility.trans("087", "Disabled") + : GT_Utility.trans("088", "Enabled") + + GT_Utility.trans("089", " Auto-Output: ") + + (mOutputDisabled + ? GT_Utility.trans("087", "Disabled") + : GT_Utility.trans("088", "Enabled")))); + GT_Utility.sendSoundToPlayers( + worldObj, SoundResource.RANDOM_ANVIL_USE, 1.0F, -1, xCoord, yCoord, zCoord); } return true; } @@ -1289,12 +1521,23 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (mWorks) disableWorking(); else enableWorking(); { - String tChat = GT_Utility.trans("090", "Machine Processing: ") + (isAllowedToWork() ? GT_Utility.trans("088", "Enabled") : GT_Utility.trans("087", "Disabled")); - if (getMetaTileEntity() != null && getMetaTileEntity().hasAlternativeModeText()) + String tChat = GT_Utility.trans("090", "Machine Processing: ") + + (isAllowedToWork() + ? GT_Utility.trans("088", "Enabled") + : GT_Utility.trans("087", "Disabled")); + if (getMetaTileEntity() != null + && getMetaTileEntity().hasAlternativeModeText()) tChat = getMetaTileEntity().getAlternativeModeText(); GT_Utility.sendChatToPlayer(aPlayer, tChat); } - GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_RUBBER_TRAMPOLINE, 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers( + worldObj, + SoundResource.IC2_TOOLS_RUBBER_TRAMPOLINE, + 1.0F, + -1, + xCoord, + yCoord, + zCoord); } return true; } @@ -1302,12 +1545,21 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) { final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); if (mMetaTileEntity.onSolderingToolRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { - //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)) { 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(); @@ -1318,8 +1570,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList)) { final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); if (mMetaTileEntity.onWireCutterRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { - //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(); cableUpdateDelay = 10; @@ -1331,38 +1584,60 @@ public class BaseMetaTileEntity 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); 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); } return true; } } - } else if (aPlayer.isSneaking()) { //Sneak click, no tool -> open cover config if possible. - 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); + } else if (aPlayer.isSneaking()) { // Sneak click, no tool -> open cover config if possible. + 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); } - 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)) + 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 (isUpgradable() && tCurrentItem != null) { if (ItemList.Upgrade_Muffler.isStackEqual(aPlayer.inventory.getCurrentItem())) { if (addMufflerUpgrade()) { - GT_Utility.sendSoundToPlayers(worldObj, SoundResource.RANDOM_CLICK, 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers( + worldObj, SoundResource.RANDOM_CLICK, 1.0F, -1, xCoord, yCoord, zCoord); if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; } return true; @@ -1372,7 +1647,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec mLockUpgrade = true; setOwnerName(aPlayer.getDisplayName()); setOwnerUuid(aPlayer.getUniqueID()); - GT_Utility.sendSoundToPlayers(worldObj, SoundResource.RANDOM_CLICK, 1.0F, -1, xCoord, yCoord, zCoord); + GT_Utility.sendSoundToPlayers( + worldObj, SoundResource.RANDOM_CLICK, 1.0F, -1, xCoord, yCoord, zCoord); if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; } return true; @@ -1385,7 +1661,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec if (!aPlayer.isSneaking() && hasValidMetaTileEntity()) return mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ); } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); + GT_Log.err.println( + "Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } @@ -1397,7 +1674,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec try { if (aPlayer != null && hasValidMetaTileEntity()) mMetaTileEntity.onLeftclick(this, aPlayer); } catch (Throwable e) { - GT_Log.err.println("Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); + GT_Log.err.println( + "Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!"); e.printStackTrace(GT_Log.err); } } @@ -1439,8 +1717,21 @@ public class BaseMetaTileEntity 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; } @@ -1449,7 +1740,16 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec */ @Override public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && (mRunningThroughTick || !mInputDisabled) && getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide); + return canAccessData() + && (mRunningThroughTick || !mInputDisabled) + && getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsIn( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getComplexCoverDataAtSide((byte) aSide), + aIndex, + this) + && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide); } /** @@ -1457,7 +1757,16 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec */ @Override public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && (mRunningThroughTick || !mOutputDisabled) && getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide); + return canAccessData() + && (mRunningThroughTick || !mOutputDisabled) + && getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsOut( + (byte) aSide, + getCoverIDAtSide((byte) aSide), + getComplexCoverDataAtSide((byte) aSide), + aIndex, + this) + && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide); } @Override @@ -1471,7 +1780,6 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec return mMetaTileEntity.allowGeneralRedstoneOutput() ? mSidedRedstone[aSide] : 0; } - @Override public boolean isSteamEngineUpgradable() { return isUpgradable() && !hasSteamEngineUpgrade() && getSteamCapacity() > 0; @@ -1546,22 +1854,17 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public long getAverageElectricInput() { long rEU = 0; - for (int i = 0; i < mAverageEUInput.length; ++i) - if (i != mAverageEUInputIndex) - rEU += mAverageEUInput[i]; + for (int i = 0; i < mAverageEUInput.length; ++i) if (i != mAverageEUInputIndex) rEU += mAverageEUInput[i]; return rEU / (mAverageEUInput.length - 1); } @Override public long getAverageElectricOutput() { long rEU = 0; - for (int i = 0; i < mAverageEUOutput.length; ++i) - if (i != mAverageEUOutputIndex) - rEU += mAverageEUOutput[i]; + for (int i = 0; i < mAverageEUOutput.length; ++i) if (i != mAverageEUOutputIndex) rEU += mAverageEUOutput[i]; return rEU / (mAverageEUOutput.length - 1); } - @Override protected void updateOutputRedstoneSignal(byte aSide) { if (mMetaTileEntity.hasSidedRedstoneOutputBehavior()) { @@ -1598,7 +1901,6 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec return canAccessData() ? mMetaTileEntity.getComparatorValue(aSide) : 0; } - @Override public ItemStack decrStackSize(int aIndex, int aAmount) { if (canAccessData()) { @@ -1610,14 +1912,27 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!canAccessData() || !mMetaTileEntity.isElectric() || !inputEnergyFrom(aSide) || aAmperage <= 0 || aVoltage <= 0 || getStoredEU() >= getEUCapacity() || mMetaTileEntity.maxAmperesIn() <= mAcceptedAmperes) - return 0; + if (!canAccessData() + || !mMetaTileEntity.isElectric() + || !inputEnergyFrom(aSide) + || aAmperage <= 0 + || aVoltage <= 0 + || getStoredEU() >= getEUCapacity() + || mMetaTileEntity.maxAmperesIn() <= mAcceptedAmperes) return 0; if (aVoltage > getInputVoltage()) { - GT_Log.exp.println("Energy Explosion, injected " + aVoltage + "EU/t in a " + getInputVoltage() + "EU/t Machine!"); + GT_Log.exp.println( + "Energy Explosion, injected " + aVoltage + "EU/t in a " + getInputVoltage() + "EU/t Machine!"); doExplosion(aVoltage); return 0; } - if (increaseStoredEnergyUnits(aVoltage * (aAmperage = Math.min(aAmperage, Math.min(mMetaTileEntity.maxAmperesIn() - mAcceptedAmperes, 1 + ((getEUCapacity() - getStoredEU()) / aVoltage)))), true)) { + if (increaseStoredEnergyUnits( + aVoltage + * (aAmperage = Math.min( + aAmperage, + Math.min( + mMetaTileEntity.maxAmperesIn() - mAcceptedAmperes, + 1 + ((getEUCapacity() - getStoredEU()) / aVoltage)))), + true)) { mAverageEUInput[mAverageEUInputIndex] += aVoltage * aAmperage; mAcceptedAmperes += aAmperage; return aAmperage; @@ -1627,8 +1942,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!canAccessData() || !mMetaTileEntity.isElectric() || !outputsEnergyTo(aSide) || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU()) - return false; + if (!canAccessData() + || !mMetaTileEntity.isElectric() + || !outputsEnergyTo(aSide) + || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU()) return false; if (decreaseStoredEU(aVoltage * aAmperage, false)) { mAverageEUOutput[mAverageEUOutputIndex] += aVoltage * aAmperage; return true; @@ -1650,81 +1967,90 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (mTickTimer > 5 && canAccessData() && - (mRunningThroughTick || !mInputDisabled) && - ( - aSide == ForgeDirection.UNKNOWN || - ( - mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && - getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this) - ) - ) - ) - return mMetaTileEntity.fill(aSide, aFluid, doFill); + if (mTickTimer > 5 + && canAccessData() + && (mRunningThroughTick || !mInputDisabled) + && (aSide == ForgeDirection.UNKNOWN + || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) + && getCoverBehaviorAtSideNew((byte) aSide.ordinal()) + .letsFluidIn( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getComplexCoverDataAtSide((byte) aSide.ordinal()), + aFluid == null ? null : aFluid.getFluid(), + this)))) return mMetaTileEntity.fill(aSide, aFluid, doFill); return 0; } @Override public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { - if (mTickTimer > 5 && canAccessData() && - (mRunningThroughTick || !mOutputDisabled) && - ( - aSide == ForgeDirection.UNKNOWN || - ( - mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && - getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid().getFluid(), this) - ) - ) - ) - return mMetaTileEntity.drain(aSide, maxDrain, doDrain); + if (mTickTimer > 5 + && canAccessData() + && (mRunningThroughTick || !mOutputDisabled) + && (aSide == ForgeDirection.UNKNOWN + || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) + && getCoverBehaviorAtSideNew((byte) aSide.ordinal()) + .letsFluidOut( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getComplexCoverDataAtSide((byte) aSide.ordinal()), + mMetaTileEntity.getFluid() == null + ? null + : mMetaTileEntity + .getFluid() + .getFluid(), + this)))) return mMetaTileEntity.drain(aSide, maxDrain, doDrain); return null; } @Override public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { - if (mTickTimer > 5 && canAccessData() && - (mRunningThroughTick || !mOutputDisabled) && - ( - aSide == ForgeDirection.UNKNOWN || - ( - mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && - getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this) - ) - ) - ) - return mMetaTileEntity.drain(aSide, aFluid, doDrain); + if (mTickTimer > 5 + && canAccessData() + && (mRunningThroughTick || !mOutputDisabled) + && (aSide == ForgeDirection.UNKNOWN + || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) + && getCoverBehaviorAtSideNew((byte) aSide.ordinal()) + .letsFluidOut( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getComplexCoverDataAtSide((byte) aSide.ordinal()), + aFluid == null ? null : aFluid.getFluid(), + this)))) return mMetaTileEntity.drain(aSide, aFluid, doDrain); return null; } @Override public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - if (mTickTimer > 5 && canAccessData() && - (mRunningThroughTick || !mInputDisabled) && - ( - aSide == ForgeDirection.UNKNOWN || - ( - mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && - getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid, this) - ) - ) - ) - return mMetaTileEntity.canFill(aSide, aFluid); + if (mTickTimer > 5 + && canAccessData() + && (mRunningThroughTick || !mInputDisabled) + && (aSide == ForgeDirection.UNKNOWN + || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) + && getCoverBehaviorAtSideNew((byte) aSide.ordinal()) + .letsFluidIn( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getComplexCoverDataAtSide((byte) aSide.ordinal()), + aFluid, + this)))) return mMetaTileEntity.canFill(aSide, aFluid); return false; } @Override public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - if (mTickTimer > 5 && canAccessData() && - (mRunningThroughTick || !mOutputDisabled) && - ( - aSide == ForgeDirection.UNKNOWN || - ( - mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && - getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid, this) - ) - ) - ) - return mMetaTileEntity.canDrain(aSide, aFluid); + if (mTickTimer > 5 + && canAccessData() + && (mRunningThroughTick || !mOutputDisabled) + && (aSide == ForgeDirection.UNKNOWN + || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) + && getCoverBehaviorAtSideNew((byte) aSide.ordinal()) + .letsFluidOut( + (byte) aSide.ordinal(), + getCoverIDAtSide((byte) aSide.ordinal()), + getComplexCoverDataAtSide((byte) aSide.ordinal()), + aFluid, + this)))) return mMetaTileEntity.canDrain(aSide, aFluid); return false; } @@ -1732,17 +2058,25 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { final byte tSide = (byte) aSide.ordinal(); - if (canAccessData() && - ( - aSide == ForgeDirection.UNKNOWN || - ( - mMetaTileEntity.isLiquidInput(tSide) && getCoverBehaviorAtSideNew(tSide).letsFluidIn(tSide, getCoverIDAtSide(tSide), getComplexCoverDataAtSide(tSide), null, this)) || - (mMetaTileEntity.isLiquidOutput(tSide) && getCoverBehaviorAtSideNew(tSide).letsFluidOut(tSide, getCoverIDAtSide(tSide), getComplexCoverDataAtSide(tSide), null, this) - ) - ) - ) - return mMetaTileEntity.getTankInfo(aSide); - return new FluidTankInfo[]{}; + if (canAccessData() + && (aSide == ForgeDirection.UNKNOWN + || (mMetaTileEntity.isLiquidInput(tSide) + && getCoverBehaviorAtSideNew(tSide) + .letsFluidIn( + tSide, + getCoverIDAtSide(tSide), + getComplexCoverDataAtSide(tSide), + null, + this)) + || (mMetaTileEntity.isLiquidOutput(tSide) + && getCoverBehaviorAtSideNew(tSide) + .letsFluidOut( + tSide, + getCoverIDAtSide(tSide), + getComplexCoverDataAtSide(tSide), + null, + this)))) return mMetaTileEntity.getTankInfo(aSide); + return new FluidTankInfo[] {}; } public double getOutputEnergyUnitsPerTick() { @@ -1771,7 +2105,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } public double getOfferedEnergy() { - return (canAccessData() && getStoredEU() - mMetaTileEntity.getMinimumStoredEU() >= oOutput) ? Math.max(0, oOutput) : 0; + return (canAccessData() && getStoredEU() - mMetaTileEntity.getMinimumStoredEU() >= oOutput) + ? Math.max(0, oOutput) + : 0; } public void drawEnergy(double amount) { @@ -1785,10 +2121,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec public int addEnergy(int aEnergy) { if (!canAccessData()) return 0; - if (aEnergy > 0) - increaseStoredEnergyUnits(aEnergy, true); - else - decreaseStoredEU(-aEnergy, true); + if (aEnergy > 0) increaseStoredEnergyUnits(aEnergy, true); + else decreaseStoredEU(-aEnergy, true); return (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getEUVar()); } @@ -1852,7 +2186,9 @@ public class BaseMetaTileEntity 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())) { tStack.stackSize += aStack.stackSize; markDirty(); return true; @@ -1894,7 +2230,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec public String[] getInfoData() { { if (canAccessData()) return getMetaTileEntity().getInfoData(); - return new String[]{}; + return new String[] {}; } } @@ -1904,7 +2240,14 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) { + public void addCollisionBoxesToList( + World aWorld, + int aX, + int aY, + int aZ, + AxisAlignedBB inputAABB, + List<AxisAlignedBB> outputAABB, + Entity collider) { mMetaTileEntity.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); } @@ -1935,9 +2278,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec final int chemistryUpdateVersion = GT_Mod.calculateTotalGTVersion(509, 31); final int configCircuitAdditionVersion = GT_Mod.calculateTotalGTVersion(509, 40); // 4 is old GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT - if (nbtVersion < configCircuitAdditionVersion && getMetaTileEntity() instanceof GT_MetaTileEntity_BasicMachine && slotIndex >= 4) - slotIndex += 1; - if (mID >= 211 && mID <= 218) {//Assembler + if (nbtVersion < configCircuitAdditionVersion + && getMetaTileEntity() instanceof GT_MetaTileEntity_BasicMachine + && slotIndex >= 4) slotIndex += 1; + if (mID >= 211 && mID <= 218) { // Assembler if (nbtVersion < chemistryUpdateVersion) { oldInputSize = 2; oldOutputSize = 1; @@ -1947,8 +2291,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec newInputSize = 6; newOutputSize = 1; - - } else if (mID >= 421 && mID <= 428) {//Chemical Reactor + } else if (mID >= 421 && mID <= 428) { // Chemical Reactor if (nbtVersion < chemistryUpdateVersion) { oldInputSize = 2; oldOutputSize = 1; @@ -1958,7 +2301,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec newInputSize = 2; newOutputSize = 2; - } else if (mID >= 531 && mID <= 538) {//Distillery + } else if (mID >= 531 && mID <= 538) { // Distillery if (nbtVersion < chemistryUpdateVersion) { oldInputSize = 1; oldOutputSize = 0; @@ -1967,7 +2310,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec } newInputSize = 1; newOutputSize = 1; - } else if (mID >= 581 && mID <= 588) {//Mixer + } else if (mID >= 581 && mID <= 588) { // Mixer if (nbtVersion < chemistryUpdateVersion) { oldInputSize = 4; oldOutputSize = 1; @@ -1994,8 +2337,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override @Optional.Method(modid = "appliedenergistics2") public IGridNode getGridNode(ForgeDirection forgeDirection) { - if (mFacing != forgeDirection.ordinal()) - return null; + if (mFacing != forgeDirection.ordinal()) return null; final AENetworkProxy gp = getProxy(); return gp != null ? gp.getNode() : null; } @@ -2008,8 +2350,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override @Optional.Method(modid = "appliedenergistics2") - public void securityBreak() { - } + public void securityBreak() {} @Override @Optional.Method(modid = "appliedenergistics2") @@ -2033,38 +2374,33 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override @Optional.Method(modid = "appliedenergistics2") public void gridChanged() { - if (mMetaTileEntity != null) - mMetaTileEntity.gridChanged(); + if (mMetaTileEntity != null) mMetaTileEntity.gridChanged(); } @TileEvent(TileEventType.WORLD_NBT_READ) @Optional.Method(modid = "appliedenergistics2") public void readFromNBT_AENetwork(final NBTTagCompound data) { final AENetworkProxy gp = getProxy(); - if (gp != null) - getProxy().readFromNBT(data); + if (gp != null) getProxy().readFromNBT(data); } @TileEvent(TileEventType.WORLD_NBT_WRITE) @Optional.Method(modid = "appliedenergistics2") public void writeToNBT_AENetwork(final NBTTagCompound data) { final AENetworkProxy gp = getProxy(); - if (gp != null) - gp.writeToNBT(data); + if (gp != null) gp.writeToNBT(data); } @Optional.Method(modid = "appliedenergistics2") void onChunkUnloadAE() { final AENetworkProxy gp = getProxy(); - if (gp != null) - gp.onChunkUnload(); + if (gp != null) gp.onChunkUnload(); } @Optional.Method(modid = "appliedenergistics2") void invalidateAE() { final AENetworkProxy gp = getProxy(); - if (gp != null) - gp.invalidate(); + if (gp != null) gp.invalidate(); } @Override @@ -2079,8 +2415,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec @Override public IAlignment getAlignment() { - return getMetaTileEntity() instanceof IAlignmentProvider ? ((IAlignmentProvider) getMetaTileEntity()).getAlignment() : - getMetaTileEntity() instanceof IAlignment ? (IAlignment) getMetaTileEntity() : null; + return getMetaTileEntity() instanceof IAlignmentProvider + ? ((IAlignmentProvider) getMetaTileEntity()).getAlignment() + : getMetaTileEntity() instanceof IAlignment ? (IAlignment) getMetaTileEntity() : null; } @Nullable diff --git a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java index 8e6206f612..1f6fb0c68d 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java @@ -1,14 +1,22 @@ package gregtech.api.metatileentity; +import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; +import static gregtech.api.enums.GT_Values.COMPASS_DIRECTIONS; +import static gregtech.api.enums.GT_Values.GT; +import static gregtech.api.enums.GT_Values.NW; +import static gregtech.api.enums.GT_Values.SIDE_DOWN; +import static gregtech.api.enums.GT_Values.SIDE_UP; + import gregtech.api.interfaces.tileentity.IGTEnet; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; import gregtech.api.interfaces.tileentity.IIC2Enet; import gregtech.api.net.GT_Packet_Block_Event; -import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; +import java.util.Arrays; +import java.util.concurrent.ThreadLocalRandom; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -25,16 +33,6 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidHandler; -import java.util.Arrays; -import java.util.concurrent.ThreadLocalRandom; - -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; -import static gregtech.api.enums.GT_Values.COMPASS_DIRECTIONS; -import static gregtech.api.enums.GT_Values.GT; -import static gregtech.api.enums.GT_Values.NW; -import static gregtech.api.enums.GT_Values.SIDE_DOWN; -import static gregtech.api.enums.GT_Values.SIDE_UP; - /** * The Functions my old TileEntities and my BaseMetaTileEntities have in common. * <p/> @@ -63,17 +61,17 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje private final ChunkCoordinates mReturnedCoordinates = new ChunkCoordinates(); public static byte getSideForPlayerPlacing(Entity aPlayer, byte aDefaultFacing, boolean[] aAllowedFacings) { - if(aPlayer != null) { + if (aPlayer != null) { if (aPlayer.rotationPitch >= 65 && aAllowedFacings[SIDE_UP]) return SIDE_UP; if (aPlayer.rotationPitch <= -65 && aAllowedFacings[SIDE_DOWN]) return SIDE_DOWN; - final byte rFacing = COMPASS_DIRECTIONS[MathHelper.floor_double(0.5D + 4.0F * aPlayer.rotationYaw / 360.0F) & 0x3]; + final byte rFacing = + COMPASS_DIRECTIONS[MathHelper.floor_double(0.5D + 4.0F * aPlayer.rotationYaw / 360.0F) & 0x3]; if (aAllowedFacings[rFacing]) return rFacing; } for (final byte tSide : ALL_VALID_SIDES) if (aAllowedFacings[tSide]) return tSide; return aDefaultFacing; } - private void clearNullMarkersFromTileEntityBuffer() { for (int i = 0; i < mBufferedTileEntities.length; i++) if (mBufferedTileEntities[i] == this) mBufferedTileEntities[i] = null; @@ -364,7 +362,9 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje public Block getBlock(ChunkCoordinates aCoords) { if (worldObj == null) return Blocks.air; - if (ignoreUnloadedChunks && crossedChunkBorder(aCoords) && !worldObj.blockExists(aCoords.posX, aCoords.posY, aCoords.posZ)) return Blocks.air; + if (ignoreUnloadedChunks + && crossedChunkBorder(aCoords) + && !worldObj.blockExists(aCoords.posX, aCoords.posY, aCoords.posZ)) return Blocks.air; return worldObj.getBlock(aCoords.posX, aCoords.posY, aCoords.posZ); } @@ -426,7 +426,9 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje mBufferedTileEntities[aSide] = null; return getTileEntityAtSide(aSide); } - if (mBufferedTileEntities[aSide].xCoord == tX && mBufferedTileEntities[aSide].yCoord == tY && mBufferedTileEntities[aSide].zCoord == tZ) { + if (mBufferedTileEntities[aSide].xCoord == tX + && mBufferedTileEntities[aSide].yCoord == tY + && mBufferedTileEntities[aSide].zCoord == tZ) { return mBufferedTileEntities[aSide]; } return null; @@ -482,8 +484,11 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje worldObj.notifyBlockOfNeighborChange(x1, y1, z1, thisBlock); // update if it was / is strong powered. - if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0 ) && getBlock(x1, y1, z1).isNormalCube()) { - final int skipUpdateSide = dir.getOpposite().ordinal(); //Don't update this block. Still updates diagonal blocks twice if conditions meet. + if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0) + && getBlock(x1, y1, z1).isNormalCube()) { + final int skipUpdateSide = dir.getOpposite() + .ordinal(); // Don't update this block. Still updates diagonal blocks twice if conditions + // meet. for (final ForgeDirection dir2 : ForgeDirection.VALID_DIRECTIONS) { final int x2 = x1 + dir2.offsetX, y2 = y1 + dir2.offsetY, z2 = z1 + dir2.offsetZ; @@ -497,7 +502,8 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje @Override public final void sendBlockEvent(byte aID, byte aValue) { - NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_Block_Event(xCoord, (short) yCoord, zCoord, aID, aValue), xCoord, zCoord); + NW.sendPacketToAllPlayersInRange( + worldObj, new GT_Packet_Block_Event(xCoord, (short) yCoord, zCoord, aID, aValue), xCoord, zCoord); } protected boolean crossedChunkBorder(int aX, int aZ) { @@ -520,14 +526,14 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje public void markDirty() { // Avoid sending neighbor updates, just mark the chunk as dirty to make sure it gets saved final Chunk chunk = worldObj.getChunkFromBlockCoords(xCoord, zCoord); - if(chunk != null) { + if (chunk != null) { chunk.setChunkModified(); } } @Deprecated - public String trans(String aKey, String aEnglish){ - return GT_Utility.trans(aKey, aEnglish); + public String trans(String aKey, String aEnglish) { + return GT_Utility.trans(aKey, aEnglish); } /* @@ -537,8 +543,8 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje protected boolean joinedIc2Enet = false; protected void createIc2Sink() { - if(ic2EnergySink == null && isServerSide() && shouldJoinIc2Enet()) { - ic2EnergySink = new TileIC2EnergySink((IGregTechTileEntity)this); + if (ic2EnergySink == null && isServerSide() && shouldJoinIc2Enet()) { + ic2EnergySink = new TileIC2EnergySink((IGregTechTileEntity) this); } } @@ -551,7 +557,7 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje protected void joinEnet() { if (joinedIc2Enet || !shouldJoinIc2Enet()) return; - if(ic2EnergySink == null) createIc2Sink(); + if (ic2EnergySink == null) createIc2Sink(); if (ic2EnergySink != null) { MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(ic2EnergySink)); @@ -565,5 +571,4 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(ic2EnergySink)); } } - } diff --git a/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java index 766110d227..7e35f2e2c1 100644 --- a/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity; +import static gregtech.GT_Mod.GT_FML_LOGGER; + import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -12,9 +14,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.Packet; -import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.ALL_SIDES; - public abstract class CommonMetaTileEntity extends CoverableTileEntity implements IGregTechTileEntity { protected boolean mNeedsBlockUpdate = true, mNeedsUpdate = true, mSendClientData = false, mInventoryChanged = false; @@ -30,6 +29,7 @@ public abstract class CommonMetaTileEntity extends CoverableTileEntity implement } return false; } + protected void saveMetaTileNBT(NBTTagCompound aNBT) { try { if (hasValidMetaTileEntity()) { @@ -158,5 +158,4 @@ public abstract class CommonMetaTileEntity extends CoverableTileEntity implement final IMetaTileEntity meta = getMetaTileEntity(); return meta != null && meta.shouldJoinIc2Enet(); } - } diff --git a/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java b/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java index f7104c9b93..6c61ae8599 100644 --- a/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/CoverableTileEntity.java @@ -1,10 +1,16 @@ package gregtech.api.metatileentity; +import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; +import static gregtech.api.enums.GT_Values.E; +import static gregtech.api.enums.GT_Values.NW; +import static gregtech.api.util.GT_LanguageManager.FACES; +import static gregtech.api.util.GT_LanguageManager.getTranslation; + import gregtech.GT_Mod; import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ICoverable; -import gregtech.api.enums.Textures; import gregtech.api.interfaces.tileentity.IGregtechWailaProvider; import gregtech.api.net.GT_Packet_RequestCoverData; import gregtech.api.net.GT_Packet_SendCoverData; @@ -14,6 +20,10 @@ import gregtech.api.util.GT_CoverBehaviorBase; import gregtech.api.util.ISerializableObject; import gregtech.common.GT_Client; import gregtech.common.covers.GT_Cover_Fluidfilter; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import java.util.stream.IntStream; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.minecraft.entity.item.EntityItem; @@ -25,27 +35,26 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; -import java.util.Arrays; -import java.util.Objects; -import java.util.stream.IntStream; -import java.util.List; - -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; -import static gregtech.api.enums.GT_Values.E; -import static gregtech.api.enums.GT_Values.NW; -import static gregtech.api.util.GT_LanguageManager.FACES; -import static gregtech.api.util.GT_LanguageManager.getTranslation; - public abstract class CoverableTileEntity extends BaseTileEntity implements ICoverable, IGregtechWailaProvider { - public static final String[] COVER_DATA_NBT_KEYS = Arrays.stream(ForgeDirection.VALID_DIRECTIONS).mapToInt(Enum::ordinal).mapToObj(i -> "mCoverData" + i).toArray(String[]::new); - protected final GT_CoverBehaviorBase<?>[] mCoverBehaviors = new GT_CoverBehaviorBase<?>[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior}; - protected byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; + public static final String[] COVER_DATA_NBT_KEYS = Arrays.stream(ForgeDirection.VALID_DIRECTIONS) + .mapToInt(Enum::ordinal) + .mapToObj(i -> "mCoverData" + i) + .toArray(String[]::new); + protected final GT_CoverBehaviorBase<?>[] mCoverBehaviors = new GT_CoverBehaviorBase<?>[] { + GregTech_API.sNoBehavior, + GregTech_API.sNoBehavior, + GregTech_API.sNoBehavior, + GregTech_API.sNoBehavior, + GregTech_API.sNoBehavior, + GregTech_API.sNoBehavior + }; + protected byte[] mSidedRedstone = new byte[] {15, 15, 15, 15, 15, 15}; protected boolean mRedstone = false; protected byte mStrongRedstone = 0; - protected int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; + protected int[] mCoverSides = new int[] {0, 0, 0, 0, 0, 0}; protected ISerializableObject[] mCoverData = new ISerializableObject[6]; - protected final boolean[] mCoverNeedUpdate = new boolean[]{false, false, false, false, false, false}; + protected final boolean[] mCoverNeedUpdate = new boolean[] {false, false, false, false, false, false}; protected short mID = 0; public long mTickTimer = 0; @@ -60,18 +69,18 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov if (mStrongRedstone > 0) aNBT.setByte("mStrongRedstone", mStrongRedstone); if (hasCover) aNBT.setIntArray("mCoverSides", mCoverSides); - if(!isDrop) { + if (!isDrop) { aNBT.setByteArray("mRedstoneSided", mSidedRedstone); aNBT.setBoolean("mRedstone", mRedstone); } - } - protected void readCoverNBT(NBTTagCompound aNBT) { - mCoverSides = aNBT.hasKey("mCoverSides") ? aNBT.getIntArray("mCoverSides") : new int[]{0, 0, 0, 0, 0, 0}; + mCoverSides = aNBT.hasKey("mCoverSides") ? aNBT.getIntArray("mCoverSides") : new int[] {0, 0, 0, 0, 0, 0}; mRedstone = aNBT.getBoolean("mRedstone"); - mSidedRedstone = aNBT.hasKey("mRedstoneSided") ? aNBT.getByteArray("mRedstoneSided") : new byte[]{15, 15, 15, 15, 15, 15}; + mSidedRedstone = aNBT.hasKey("mRedstoneSided") + ? aNBT.getByteArray("mRedstoneSided") + : new byte[] {15, 15, 15, 15, 15, 15}; mStrongRedstone = aNBT.getByte("mStrongRedstone"); for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehaviorNew(mCoverSides[i]); @@ -81,10 +90,11 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov if (aNBT.hasKey("mCoverData", 11) && aNBT.getIntArray("mCoverData").length == 6) { final int[] tOldData = aNBT.getIntArray("mCoverData"); for (int i = 0; i < tOldData.length; i++) { - if(mCoverBehaviors[i] instanceof GT_Cover_Fluidfilter) { + if (mCoverBehaviors[i] instanceof GT_Cover_Fluidfilter) { final String filterKey = String.format("fluidFilter%d", i); if (aNBT.hasKey(filterKey)) { - mCoverData[i] = mCoverBehaviors[i].createDataObject((tOldData[i] & 7) | (FluidRegistry.getFluidID(aNBT.getString(filterKey)) << 3)); + mCoverData[i] = mCoverBehaviors[i].createDataObject( + (tOldData[i] & 7) | (FluidRegistry.getFluidID(aNBT.getString(filterKey)) << 3)); } } else if (mCoverBehaviors[i] != null && mCoverBehaviors[i] != GregTech_API.sNoBehavior) { mCoverData[i] = mCoverBehaviors[i].createDataObject(tOldData[i]); @@ -92,18 +102,17 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov } } else { // no old data - for (byte i = 0; i<6; i++) { + for (byte i = 0; i < 6; i++) { if (mCoverBehaviors[i] == null) continue; if (aNBT.hasKey(COVER_DATA_NBT_KEYS[i])) mCoverData[i] = mCoverBehaviors[i].createDataObject(aNBT.getTag(COVER_DATA_NBT_KEYS[i])); - else - mCoverData[i] = mCoverBehaviors[i].createDataObject(); + else mCoverData[i] = mCoverBehaviors[i].createDataObject(); if (mCoverBehaviors[i].isDataNeededOnClient(i, mCoverSides[i], mCoverData[i], this)) issueCoverUpdate(i); } } - } + public abstract boolean isStillValid(); protected boolean doCoverThings() { @@ -112,8 +121,12 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov final GT_CoverBehaviorBase<?> tCover = getCoverBehaviorAtSideNew(i); final int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this); if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) { - final byte tRedstone = tCover.isRedstoneSensitive(i, getCoverIDAtSide(i), mCoverData[i], this, mTickTimer) ? getInputRedstoneSignal(i) : 0; - mCoverData[i] = tCover.doCoverThings(i, tRedstone, getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); + final byte tRedstone = + tCover.isRedstoneSensitive(i, getCoverIDAtSide(i), mCoverData[i], this, mTickTimer) + ? getInputRedstoneSignal(i) + : 0; + mCoverData[i] = + tCover.doCoverThings(i, tRedstone, getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); if (!isStillValid()) return false; } } @@ -126,43 +139,50 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov protected void checkDropCover() { for (byte i : ALL_VALID_SIDES) if (getCoverIDAtSide(i) != 0) - if (!allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) - dropCover(i, i, true); + if (!allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) dropCover(i, i, true); } protected void updateCoverBehavior() { - for (byte i : ALL_VALID_SIDES) - mCoverBehaviors[i] = GregTech_API.getCoverBehaviorNew(mCoverSides[i]); + for (byte i : ALL_VALID_SIDES) mCoverBehaviors[i] = GregTech_API.getCoverBehaviorNew(mCoverSides[i]); } @Override public void issueCoverUpdate(byte aSide) { - // If we've got a null worldObj we're getting called as a part of readingNBT from a non tickable MultiTileEntity on chunk load before the world is set + // If we've got a null worldObj we're getting called as a part of readingNBT from a non tickable MultiTileEntity + // on chunk load before the world is set // so we'll want to send a cover update. - if (worldObj == null || (isServerSide() && getCoverBehaviorAtSideNew(aSide).isDataNeededOnClient(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))) + if (worldObj == null + || (isServerSide() + && getCoverBehaviorAtSideNew(aSide) + .isDataNeededOnClient( + aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))) mCoverNeedUpdate[aSide] = true; } - public final ITexture getCoverTexture(byte aSide) { - if (getCoverIDAtSide(aSide) == 0) return null; - if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x1) != 0) { - return Textures.BlockIcons.HIDDEN_TEXTURE[0]; // See through - } - final ITexture coverTexture = getCoverBehaviorAtSideNew(aSide).getSpecialCoverTexture(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this); - return coverTexture != null ? coverTexture : GregTech_API.sCovers.get(new GT_ItemStack(getCoverIDAtSide(aSide))); + public final ITexture getCoverTexture(byte aSide) { + if (getCoverIDAtSide(aSide) == 0) return null; + if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x1) != 0) { + return Textures.BlockIcons.HIDDEN_TEXTURE[0]; // See through + } + final ITexture coverTexture = getCoverBehaviorAtSideNew(aSide) + .getSpecialCoverTexture(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this); + return coverTexture != null + ? coverTexture + : GregTech_API.sCovers.get(new GT_ItemStack(getCoverIDAtSide(aSide))); } protected void requestCoverDataIfNeeded() { - if(worldObj == null || !worldObj.isRemote) return; + if (worldObj == null || !worldObj.isRemote) return; for (byte i : ALL_VALID_SIDES) { - if (getCoverBehaviorAtSideNew(i).isDataNeededOnClient(i, getCoverIDAtSide(i), getComplexCoverDataAtSide(i), this)) + if (getCoverBehaviorAtSideNew(i) + .isDataNeededOnClient(i, getCoverIDAtSide(i), getComplexCoverDataAtSide(i), this)) NW.sendToServer(new GT_Packet_RequestCoverData(i, getCoverIDAtSide(i), this)); } } @Override public void setCoverIdAndDataAtSide(byte aSide, int aId, ISerializableObject aData) { - if(setCoverIDAtSideNoUpdate(aSide, aId)) { + if (setCoverIDAtSideNoUpdate(aSide, aId)) { setCoverDataAtSide(aSide, aData); issueCoverUpdate(aSide); issueBlockUpdate(); @@ -199,11 +219,12 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov @Override public void setCoverDataAtSide(byte aSide, ISerializableObject aData) { - if (aSide >= 0 && aSide < 6 && getCoverBehaviorAtSideNew(aSide) != null && getCoverBehaviorAtSideNew(aSide).cast(aData) != null) - mCoverData[aSide] = aData; + if (aSide >= 0 + && aSide < 6 + && getCoverBehaviorAtSideNew(aSide) != null + && getCoverBehaviorAtSideNew(aSide).cast(aData) != null) mCoverData[aSide] = aData; } - @Override @Deprecated public GT_CoverBehavior getCoverBehaviorAtSide(byte aSide) { @@ -225,7 +246,8 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov @Override public ItemStack getCoverItemAtSide(byte aSide) { - return getCoverBehaviorAtSideNew(aSide).getDisplayStack(getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide)); + return getCoverBehaviorAtSideNew(aSide) + .getDisplayStack(getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide)); } @Override @@ -248,25 +270,32 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov @Override public ISerializableObject getComplexCoverDataAtSide(byte aSide) { - if (aSide >= 0 && aSide < 6 && getCoverBehaviorAtSideNew(aSide) != null) - return mCoverData[aSide]; + if (aSide >= 0 && aSide < 6 && getCoverBehaviorAtSideNew(aSide) != null) return mCoverData[aSide]; return GregTech_API.sNoBehavior.createDataObject(); } @Override public GT_CoverBehaviorBase<?> getCoverBehaviorAtSideNew(byte aSide) { - if (aSide >= 0 && aSide < 6) - return mCoverBehaviors[aSide]; + if (aSide >= 0 && aSide < 6) return mCoverBehaviors[aSide]; return GregTech_API.sNoBehavior; } @Override public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) { - if (getCoverBehaviorAtSideNew(aSide).onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) { - final ItemStack tStack = getCoverBehaviorAtSideNew(aSide).getDrop(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this); + if (getCoverBehaviorAtSideNew(aSide) + .onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) + || aForced) { + final ItemStack tStack = getCoverBehaviorAtSideNew(aSide) + .getDrop(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this); if (tStack != null) { - getCoverBehaviorAtSideNew(aSide).onDropped(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this); - final EntityItem tEntity = new EntityItem(worldObj, getOffsetX(aDroppedSide, 1) + 0.5, getOffsetY(aDroppedSide, 1) + 0.5, getOffsetZ(aDroppedSide, 1) + 0.5, tStack); + getCoverBehaviorAtSideNew(aSide) + .onDropped(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this); + final EntityItem tEntity = new EntityItem( + worldObj, + getOffsetX(aDroppedSide, 1) + 0.5, + getOffsetY(aDroppedSide, 1) + 0.5, + getOffsetZ(aDroppedSide, 1) + 0.5, + tStack); tEntity.motionX = 0; tEntity.motionY = 0; tEntity.motionZ = 0; @@ -295,10 +324,10 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov setOutputRedstoneSignal(aSide, aStrength); } - @Override public void setInternalOutputRedstoneSignal(byte aSide, byte aStrength) { - if (!getCoverBehaviorAtSideNew(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) + if (!getCoverBehaviorAtSideNew(aSide) + .manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) setOutputRedstoneSignal(aSide, aStrength); } @@ -314,12 +343,17 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov @Override public byte getStrongestRedstone() { - return (byte) IntStream.range(1, 6).map(i -> getInternalInputRedstoneSignal((byte) i)).max().orElse(0); + return (byte) IntStream.range(1, 6) + .map(i -> getInternalInputRedstoneSignal((byte) i)) + .max() + .orElse(0); } @Override public byte getStrongOutputRedstoneSignal(byte aSide) { - return aSide >= 0 && aSide < 6 && (mStrongRedstone & (1 << aSide)) != 0 ? (byte) (mSidedRedstone[aSide] & 15) : 0; + return aSide >= 0 && aSide < 6 && (mStrongRedstone & (1 << aSide)) != 0 + ? (byte) (mSidedRedstone[aSide] & 15) + : 0; } @Override @@ -329,17 +363,30 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov @Override public byte getInternalInputRedstoneSignal(byte aSide) { - return (byte) (getCoverBehaviorAtSideNew(aSide).getRedstoneInput(aSide, getInputRedstoneSignal(aSide), getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this) & 15); + return (byte) (getCoverBehaviorAtSideNew(aSide) + .getRedstoneInput( + aSide, + getInputRedstoneSignal(aSide), + getCoverIDAtSide(aSide), + getComplexCoverDataAtSide(aSide), + this) + & 15); } @Override public byte getInputRedstoneSignal(byte aSide) { - return (byte) (worldObj.getIndirectPowerLevelTo(getOffsetX(aSide, 1), getOffsetY(aSide, 1), getOffsetZ(aSide, 1), aSide) & 15); + return (byte) (worldObj.getIndirectPowerLevelTo( + getOffsetX(aSide, 1), getOffsetY(aSide, 1), getOffsetZ(aSide, 1), aSide) + & 15); } @Override public byte getOutputRedstoneSignal(byte aSide) { - return getCoverBehaviorAtSideNew(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this) ? mSidedRedstone[aSide] : getGeneralRS(aSide); + return getCoverBehaviorAtSideNew(aSide) + .manipulatesSidedRedstoneOutput( + aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this) + ? mSidedRedstone[aSide] + : getGeneralRS(aSide); } protected void updateOutputRedstoneSignal(byte aSide) { @@ -348,13 +395,13 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov @Override public void receiveCoverData(byte aCoverSide, int aCoverID, int aCoverData) { - if ((aCoverSide >= 0 && aCoverSide < 6)) - setCoverIDAtSideNoUpdate(aCoverSide, aCoverID); + if ((aCoverSide >= 0 && aCoverSide < 6)) setCoverIDAtSideNoUpdate(aCoverSide, aCoverID); setCoverDataAtSide(aCoverSide, aCoverData); } @Override - public void receiveCoverData(byte aCoverSide, int aCoverID, ISerializableObject aCoverData, EntityPlayerMP aPlayer) { + public void receiveCoverData( + byte aCoverSide, int aCoverID, ISerializableObject aCoverData, EntityPlayerMP aPlayer) { if ((aCoverSide >= 0 && aCoverSide < 6)) { setCoverIDAtSideNoUpdate(aCoverSide, aCoverID); setCoverDataAtSide(aCoverSide, aCoverData); @@ -365,24 +412,25 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov } protected void sendCoverDataIfNeeded() { - if(worldObj == null || worldObj.isRemote) return; + if (worldObj == null || worldObj.isRemote) return; final int mCoverNeedUpdateLength = mCoverNeedUpdate.length; for (byte i = 0; i < mCoverNeedUpdateLength; i++) { if (mCoverNeedUpdate[i]) { NW.sendPacketToAllPlayersInRange( worldObj, new GT_Packet_SendCoverData(i, getCoverIDAtSide(i), getComplexCoverDataAtSide(i), this), - xCoord, zCoord - ); + xCoord, + zCoord); mCoverNeedUpdate[i] = false; } } } @Override - public void getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + public void getWailaBody( + ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { final NBTTagCompound tag = accessor.getNBTData(); - final byte side = (byte)accessor.getSide().ordinal(); + final byte side = (byte) accessor.getSide().ordinal(); final int[] coverSides = tag.getIntArray("mCoverSides"); // Not all data is available on the client, so get it from the NBT packet @@ -391,7 +439,8 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov final GT_CoverBehaviorBase<?> behavior = GregTech_API.getCoverBehaviorNew(coverId); if (behavior != null && behavior != GregTech_API.sNoBehavior) { if (tag.hasKey(CoverableTileEntity.COVER_DATA_NBT_KEYS[side])) { - final ISerializableObject dataObject = behavior.createDataObject(tag.getTag(CoverableTileEntity.COVER_DATA_NBT_KEYS[side])); + final ISerializableObject dataObject = + behavior.createDataObject(tag.getTag(CoverableTileEntity.COVER_DATA_NBT_KEYS[side])); final ItemStack coverStack = behavior.getDisplayStack(coverId, dataObject); if (coverStack != null) currenttip.add(String.format("Cover: %s", coverStack.getDisplayName())); final String behaviorDesc = behavior.getDescription(side, coverId, dataObject, null); @@ -405,11 +454,13 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov } @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) { // No super implementation // super.getWailaNBTData(player, tile, tag, world, x, y, z); - // While we have some cover data on the client (enough to render it); we don't have all the information we want, such as + // While we have some cover data on the client (enough to render it); we don't have all the information we want, + // such as // details on the fluid filter, so send it all here. writeCoverNBT(tag, false); } @@ -420,7 +471,7 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov * @param aList - List to add the information to */ public static void addInstalledCoversInformation(NBTTagCompound aNBT, List<String> aList) { - if (aNBT.hasKey("mCoverSides")){ + if (aNBT.hasKey("mCoverSides")) { final int[] mCoverSides = aNBT.getIntArray("mCoverSides"); if (mCoverSides != null && mCoverSides.length == 6) { for (byte tSide : ALL_VALID_SIDES) { @@ -429,10 +480,12 @@ public abstract class CoverableTileEntity extends BaseTileEntity implements ICov final GT_CoverBehaviorBase<?> behavior = GregTech_API.getCoverBehaviorNew(coverId); if (behavior == null || behavior == GregTech_API.sNoBehavior) continue; if (!aNBT.hasKey(CoverableTileEntity.COVER_DATA_NBT_KEYS[tSide])) continue; - final ISerializableObject dataObject = behavior.createDataObject(aNBT.getTag(CoverableTileEntity.COVER_DATA_NBT_KEYS[tSide])); + final ISerializableObject dataObject = + behavior.createDataObject(aNBT.getTag(CoverableTileEntity.COVER_DATA_NBT_KEYS[tSide])); final ItemStack coverStack = behavior.getDisplayStack(coverId, dataObject); if (coverStack != null) { - aList.add(String.format("Cover on %s side: %s", getTranslation(FACES[tSide]), coverStack.getDisplayName())); + aList.add(String.format( + "Cover on %s side: %s", getTranslation(FACES[tSide]), coverStack.getDisplayName())); } } } diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index 9d07b1f9ba..96cca4ba1d 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -1,5 +1,8 @@ package gregtech.api.metatileentity; +import static gregtech.api.enums.GT_Values.GT; +import static gregtech.api.enums.GT_Values.V; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gnu.trove.list.TIntList; @@ -13,6 +16,10 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.*; import gregtech.common.GT_Client; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.texture.IIconRegister; @@ -32,14 +39,6 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import static gregtech.api.enums.GT_Values.GT; -import static gregtech.api.enums.GT_Values.V; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -59,11 +58,13 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { * This variable tells, which directions the Block is connected to. It is a Bitmask. */ public byte mConnections = 0; + protected boolean mCheckConnections = false; /** * Only assigned for the MetaTileEntity in the List! Also only used to get the localized Name for the ItemStack and for getInvName. */ public String mName; + public boolean doTickProfilingInThisTick = true; /** * accessibility to this Field is no longer given, see below @@ -83,7 +84,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { * } */ public MetaPipeEntity(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { - this(aID, aBasicName, aRegionalName, aInvSlotCount, true); + this(aID, aBasicName, aRegionalName, aInvSlotCount, true); } public MetaPipeEntity(int aID, String aBasicName, String aRegionalName, int aInvSlotCount, boolean aAddInfo) { @@ -101,13 +102,13 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { mInventory = new ItemStack[aInvSlotCount]; if (aAddInfo && GT.isClientSide()) { - addInfo(aID); + addInfo(aID); } } protected final void addInfo(int aID) { - if(!GT.isClientSide()) return; - + if (!GT.isClientSide()) return; + ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID); tStack.getItem().addInformation(tStack, null, new ArrayList<String>(), true); } @@ -153,7 +154,10 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { @Override public ItemStack getStackForm(long aAmount) { - return new ItemStack(GregTech_API.sBlockMachines, (int) aAmount, getBaseMetaTileEntity().getMetaTileID()); + return new ItemStack( + GregTech_API.sBlockMachines, + (int) aAmount, + getBaseMetaTileEntity().getMetaTileID()); } public boolean isCoverOnSide(BaseMetaPipeEntity aPipe, EntityLivingBase aEntity) { @@ -183,32 +187,44 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { if (aSide < 6 && mBaseMetaTileEntity.getCoverIDAtSide(aSide) > 0) { tCovered = true; } - if(isConnectedAtSide(aSide)){ - tCovered = true; + if (isConnectedAtSide(aSide)) { + tCovered = true; } - //GT_FML_LOGGER.info("Cover: "+mBaseMetaTileEntity.getCoverIDAtSide(aSide)); - //toDo: filter cover ids that actually protect against temperature (rubber/plastic maybe?, more like asbestos) + // GT_FML_LOGGER.info("Cover: "+mBaseMetaTileEntity.getCoverIDAtSide(aSide)); + // toDo: filter cover ids that actually protect against temperature (rubber/plastic maybe?, more like asbestos) return tCovered; } @Override - public void onServerStart() {/*Do nothing*/} + public void onServerStart() { + /*Do nothing*/ + } @Override - public void onWorldSave(File aSaveDirectory) {/*Do nothing*/} + public void onWorldSave(File aSaveDirectory) { + /*Do nothing*/ + } @Override - public void onWorldLoad(File aSaveDirectory) {/*Do nothing*/} + public void onWorldLoad(File aSaveDirectory) { + /*Do nothing*/ + } @Override - public void onConfigLoad(GT_Config aConfig) {/*Do nothing*/} + public void onConfigLoad(GT_Config aConfig) { + /*Do nothing*/ + } @Override - public void setItemNBT(NBTTagCompound aNBT) {/*Do nothing*/} + public void setItemNBT(NBTTagCompound aNBT) { + /*Do nothing*/ + } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister aBlockIconRegister) {/*Do nothing*/} + public void registerIcons(IIconRegister aBlockIconRegister) { + /*Do nothing*/ + } @Override public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { @@ -216,31 +232,42 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {/*Do nothing*/} + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + /*Do nothing*/ + } @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public boolean onWrenchRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { return false; } @Override - public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public boolean onWireCutterRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { return false; } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public boolean onSolderingToolRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { return false; } @Override - public void onExplosion() {/*Do nothing*/} + public void onExplosion() { + /*Do nothing*/ + } @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {/*Do nothing*/} + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + /*Do nothing*/ + } @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + /*Do nothing*/ + } @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { @@ -254,38 +281,53 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { } @Override - public void inValidate() {/*Do nothing*/} + public void inValidate() { + /*Do nothing*/ + } @Override - public void onRemoval() {/*Do nothing*/} + public void onRemoval() { + /*Do nothing*/ + } @Override - public void initDefaultModes(NBTTagCompound aNBT) {/*Do nothing*/} + public void initDefaultModes(NBTTagCompound aNBT) { + /*Do nothing*/ + } /** * When a GUI is opened */ - public void onOpenGUI() {/*Do nothing*/} + public void onOpenGUI() { + /*Do nothing*/ + } /** * When a GUI is closed */ - public void onCloseGUI() {/*Do nothing*/} + public void onCloseGUI() { + /*Do nothing*/ + } /** * a Player rightclicks the Machine * Sneaky rightclicks are not getting passed to this! */ @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + public boolean onRightclick( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { return false; } @Override - public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {/*Do nothing*/} + public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + /*Do nothing*/ + } @Override - public void onValueUpdate(byte aValue) {/*Do nothing*/} + public void onValueUpdate(byte aValue) { + /*Do nothing*/ + } @Override public byte getUpdateData() { @@ -293,13 +335,19 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { } @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/} + public void doSound(byte aIndex, double aX, double aY, double aZ) { + /*Do nothing*/ + } @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/} + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + /*Do nothing*/ + } @Override - public void stopSoundLoop(byte aValue, double aX, double aY, double aZ) {/*Do nothing*/} + public void stopSoundLoop(byte aValue, double aX, double aY, double aZ) { + /*Do nothing*/ + } @Override public final void sendSound(byte aIndex) { @@ -340,7 +388,8 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { } @Override - public ArrayList<String> getSpecialDebugInfo(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, int aLogLevel, ArrayList<String> aList) { + public ArrayList<String> getSpecialDebugInfo( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, int aLogLevel, ArrayList<String> aList) { return aList; } @@ -415,10 +464,14 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { } @Override - public void onMachineBlockUpdate() {/*Do nothing*/} + public void onMachineBlockUpdate() { + /*Do nothing*/ + } @Override - public void receiveClientEvent(byte aEventID, byte aValue) {/*Do nothing*/} + public void receiveClientEvent(byte aEventID, byte aValue) { + /*Do nothing*/ + } @Override public boolean isSimpleMachine() { @@ -452,7 +505,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { @Override public String[] getInfoData() { - return new String[]{}; + return new String[] {}; } public boolean isDigitalChest() { @@ -463,7 +516,9 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { return null; } - public void setItemCount(int aCount) {/*Do nothing*/} + public void setItemCount(int aCount) { + /*Do nothing*/ + } public int getMaxItemCount() { return 0; @@ -522,21 +577,59 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { public int[] getAccessibleSlotsFromSide(int aSide) { TIntList tList = new TIntArrayList(); IGregTechTileEntity tTileEntity = getBaseMetaTileEntity(); - boolean tSkip = tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), -2, tTileEntity); + boolean tSkip = tTileEntity + .getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsIn( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getComplexCoverDataAtSide((byte) aSide), + -2, + tTileEntity) + || tTileEntity + .getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsOut( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getComplexCoverDataAtSide((byte) aSide), + -2, + tTileEntity); for (int i = 0; i < getSizeInventory(); i++) - if (isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), i, tTileEntity))) - tList.add(i); + if (isValidSlot(i) + && (tSkip + || tTileEntity + .getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsOut( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getComplexCoverDataAtSide((byte) aSide), + i, + tTileEntity) + || tTileEntity + .getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsIn( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getComplexCoverDataAtSide((byte) aSide), + i, + tTileEntity))) tList.add(i); return tList.toArray(); } @Override public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && (mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, mInventory[aIndex])) && allowPutStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); + return isValidSlot(aIndex) + && aStack != null + && aIndex < mInventory.length + && (mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, mInventory[aIndex])) + && allowPutStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); } @Override public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && allowPullStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); + return isValidSlot(aIndex) + && aStack != null + && aIndex < mInventory.length + && allowPullStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); } @Override @@ -551,8 +644,8 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { @Override public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[]{}; - return new FluidTankInfo[]{getInfo()}; + if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[] {}; + return new FluidTankInfo[] {getInfo()}; } public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { @@ -683,30 +776,66 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { @Override public void doExplosion(long aExplosionPower) { - float tStrength = - aExplosionPower < V[0] ? 1.0F : - aExplosionPower < V[1] ? 2.0F : - aExplosionPower < V[2] ? 3.0F : - aExplosionPower < V[3] ? 4.0F : - aExplosionPower < V[4] ? 5.0F : - aExplosionPower < V[4] * 2 ? 6.0F : - aExplosionPower < V[5] ? 7.0F : - aExplosionPower < V[6] ? 8.0F : - aExplosionPower < V[7] ? 9.0F : - aExplosionPower < V[8] ? 10.0F : - aExplosionPower < V[8] * 2 ? 11.0F : - aExplosionPower < V[9] ? 12.0F : - aExplosionPower < V[10] ? 13.0F : - aExplosionPower < V[11] ? 14.0F : - aExplosionPower < V[12] ? 15.0F : - aExplosionPower < V[12] * 2 ? 16.0F : - aExplosionPower < V[13] ? 17.0F : - aExplosionPower < V[14] ? 18.0F : - aExplosionPower < V[15] ? 19.0F : 20.0F; - int tX = getBaseMetaTileEntity().getXCoord(), tY = getBaseMetaTileEntity().getYCoord(), tZ = getBaseMetaTileEntity().getZCoord(); + float tStrength = aExplosionPower < V[0] + ? 1.0F + : aExplosionPower < V[1] + ? 2.0F + : aExplosionPower < V[2] + ? 3.0F + : aExplosionPower < V[3] + ? 4.0F + : aExplosionPower < V[4] + ? 5.0F + : aExplosionPower < V[4] * 2 + ? 6.0F + : aExplosionPower < V[5] + ? 7.0F + : aExplosionPower < V[6] + ? 8.0F + : aExplosionPower < V[7] + ? 9.0F + : aExplosionPower < V[8] + ? 10.0F + : aExplosionPower < V[8] * 2 + ? 11.0F + : aExplosionPower < V[9] + ? 12.0F + : aExplosionPower + < V[ + 10] + ? 13.0F + : aExplosionPower + < V[ + 11] + ? 14.0F + : aExplosionPower + < V[ + 12] + ? 15.0F + : aExplosionPower + < V[ + 12] + * 2 + ? 16.0F + : aExplosionPower + < V[ + 13] + ? 17.0F + : aExplosionPower + < V[ + 14] + ? 18.0F + : aExplosionPower + < V[ + 15] + ? 19.0F + : 20.0F; + int tX = getBaseMetaTileEntity().getXCoord(), + tY = getBaseMetaTileEntity().getYCoord(), + tZ = getBaseMetaTileEntity().getZCoord(); World tWorld = getBaseMetaTileEntity().getWorld(); tWorld.setBlock(tX, tY, tZ, Blocks.air); - if (GregTech_API.sMachineExplosions){ + if (GregTech_API.sMachineExplosions) { new WorldSpawnedEventBuilder.ExplosionEffectEventBuilder() .setStrength(tStrength) .setSmoking(true) @@ -722,7 +851,14 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { } @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) { + public void addCollisionBoxesToList( + World aWorld, + int aX, + int aY, + int aZ, + AxisAlignedBB inputAABB, + List<AxisAlignedBB> outputAABB, + Entity collider) { AxisAlignedBB axisalignedbb1 = getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); if (axisalignedbb1 != null && inputAABB.intersectsWith(axisalignedbb1)) outputAABB.add(axisalignedbb1); } @@ -743,23 +879,23 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { } @Override - public boolean allowGeneralRedstoneOutput(){ + public boolean allowGeneralRedstoneOutput() { return false; } - @Override - public boolean hasAlternativeModeText() { - return false; - } + @Override + public boolean hasAlternativeModeText() { + return false; + } - @Override - public String getAlternativeModeText() { - return ""; - } + @Override + public String getAlternativeModeText() { + return ""; + } @Deprecated - public String trans(String aKey, String aEnglish){ - return GT_Utility.trans(aKey, aEnglish); + public String trans(String aKey, String aEnglish) { + return GT_Utility.trans(aKey, aEnglish); } private boolean connectableColor(TileEntity tTileEntity) { @@ -776,13 +912,13 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { return true; } - @Override - public int connect(byte aSide) { - if (aSide >= 6) return 0; + @Override + public int connect(byte aSide) { + if (aSide >= 6) return 0; - final byte tSide = GT_Utility.getOppositeSide(aSide); - final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity(); - if (baseMetaTile == null || !baseMetaTile.isServerSide()) return 0; + final byte tSide = GT_Utility.getOppositeSide(aSide); + final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity(); + if (baseMetaTile == null || !baseMetaTile.isServerSide()) return 0; final GT_CoverBehaviorBase<?> coverBehavior = baseMetaTile.getCoverBehaviorAtSideNew(aSide); final int coverId = baseMetaTile.getCoverIDAtSide(aSide); @@ -796,30 +932,36 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { TileEntity tTileEntity = baseMetaTile.getTileEntityAtSide(aSide); if (!connectableColor(tTileEntity)) return 0; - if ((alwaysLookConnected || letsIn || letsOut)) { + if ((alwaysLookConnected || letsIn || letsOut)) { // Are we trying to connect to a pipe? let's do it! - IMetaTileEntity tPipe = tTileEntity instanceof IGregTechTileEntity ? ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() : null; - if (getClass().isInstance(tPipe) || (tPipe != null && tPipe.getClass().isInstance(this))) { + IMetaTileEntity tPipe = tTileEntity instanceof IGregTechTileEntity + ? ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() + : null; + if (getClass().isInstance(tPipe) + || (tPipe != null && tPipe.getClass().isInstance(this))) { connectAtSide(aSide); if (!((MetaPipeEntity) tPipe).isConnectedAtSide(tSide)) { // Make sure pipes all get together -- connect back to us if we're connecting to a pipe ((MetaPipeEntity) tPipe).connect(tSide); } return 1; - } - else if((getGT6StyleConnection() && baseMetaTile.getAirAtSide(aSide)) || canConnect(aSide, tTileEntity)) { - // Allow open connections to Air, if the GT6 style pipe/cables are enabled, so that it'll connect to the next block placed down next to it + } else if ((getGT6StyleConnection() && baseMetaTile.getAirAtSide(aSide)) + || canConnect(aSide, tTileEntity)) { + // Allow open connections to Air, if the GT6 style pipe/cables are enabled, so that it'll connect to the + // next block placed down next to it connectAtSide(aSide); return 1; } - if (!baseMetaTile.getWorld().getChunkProvider().chunkExists(baseMetaTile.getOffsetX(aSide, 1) >> 4, baseMetaTile.getOffsetZ(aSide, 1) >> 4)) { + if (!baseMetaTile + .getWorld() + .getChunkProvider() + .chunkExists(baseMetaTile.getOffsetX(aSide, 1) >> 4, baseMetaTile.getOffsetZ(aSide, 1) >> 4)) { // Target chunk unloaded return -1; } - } - return 0; - } + return 0; + } protected void checkConnections() { // Verify connections around us. If GT6 style cables are not enabled then revert to old behavior and try @@ -832,32 +974,54 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { mCheckConnections = false; } - private void connectAtSide(byte aSide) { + private void connectAtSide(byte aSide) { mConnections |= (1 << aSide); } - @Override - public void disconnect(byte aSide) { - if (aSide >= 6) return; - mConnections &= ~(1 << aSide); - byte tSide = GT_Utility.getOppositeSide(aSide); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSide(aSide); - IMetaTileEntity tPipe = tTileEntity == null ? null : tTileEntity.getMetaTileEntity(); - if ((this.getClass().isInstance(tPipe) || (tPipe != null && tPipe.getClass().isInstance(this))) && ((MetaPipeEntity) tPipe).isConnectedAtSide(tSide)) - ((MetaPipeEntity) tPipe).disconnect(tSide); - } + @Override + public void disconnect(byte aSide) { + if (aSide >= 6) return; + mConnections &= ~(1 << aSide); + byte tSide = GT_Utility.getOppositeSide(aSide); + IGregTechTileEntity tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSide(aSide); + IMetaTileEntity tPipe = tTileEntity == null ? null : tTileEntity.getMetaTileEntity(); + if ((this.getClass().isInstance(tPipe) + || (tPipe != null && tPipe.getClass().isInstance(this))) + && ((MetaPipeEntity) tPipe).isConnectedAtSide(tSide)) ((MetaPipeEntity) tPipe).disconnect(tSide); + } - @Override + @Override public boolean isConnectedAtSide(int aSide) { - return (mConnections & (1 << aSide)) != 0; - } + return (mConnections & (1 << aSide)) != 0; + } + + public boolean letsIn( + GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return false; + } + public boolean letsOut( + GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return false; + } - public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } - public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } + public boolean letsIn( + GT_CoverBehaviorBase<?> coverBehavior, + byte aSide, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity) { + return false; + } - public boolean letsIn(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return false; } - public boolean letsOut(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { return false; } + public boolean letsOut( + GT_CoverBehaviorBase<?> coverBehavior, + byte aSide, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity) { + return false; + } public boolean canConnect(byte aSide, TileEntity tTileEntity) { return false; @@ -877,6 +1041,5 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { return false; } - public void reloadLocks() { - } + public void reloadLocks() {} } diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 13ea66e7d2..1e77057be9 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity; +import static gregtech.api.enums.GT_Values.V; + import appeng.api.networking.energy.IEnergyGrid; import appeng.api.networking.pathing.IPathingGrid; import appeng.api.util.AECableType; @@ -23,6 +25,10 @@ import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Client; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.minecraft.block.Block; @@ -44,13 +50,6 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; - -import static gregtech.api.enums.GT_Values.V; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -71,6 +70,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac * The Inventory of the MetaTileEntity. Amount of Slots can be larger than 256. HAYO! */ public final ItemStack[] mInventory; + public boolean doTickProfilingInThisTick = true; private MetaTileEntity mCallBackTile; @@ -80,7 +80,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac */ private IGregTechTileEntity mBaseMetaTileEntity; - public long mSoundRequests=0; + public long mSoundRequests = 0; /** * This registers your Machine at the List. @@ -145,7 +145,10 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac @Override public ItemStack getStackForm(long aAmount) { - return new ItemStack(GregTech_API.sBlockMachines, (int) aAmount, getBaseMetaTileEntity().getMetaTileID()); + return new ItemStack( + GregTech_API.sBlockMachines, + (int) aAmount, + getBaseMetaTileEntity().getMetaTileID()); } public String getLocalName() { @@ -153,23 +156,35 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } @Override - public void onServerStart() {/*Do nothing*/} + public void onServerStart() { + /*Do nothing*/ + } @Override - public void onWorldSave(File aSaveDirectory) {/*Do nothing*/} + public void onWorldSave(File aSaveDirectory) { + /*Do nothing*/ + } @Override - public void onWorldLoad(File aSaveDirectory) {/*Do nothing*/} + public void onWorldLoad(File aSaveDirectory) { + /*Do nothing*/ + } @Override - public void onConfigLoad(GT_Config aConfig) {/*Do nothing*/} + public void onConfigLoad(GT_Config aConfig) { + /*Do nothing*/ + } @Override - public void setItemNBT(NBTTagCompound aNBT) {/*Do nothing*/} + public void setItemNBT(NBTTagCompound aNBT) { + /*Do nothing*/ + } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister aBlockIconRegister) {/*Do nothing*/} + public void registerIcons(IIconRegister aBlockIconRegister) { + /*Do nothing*/ + } @Override public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) { @@ -177,10 +192,13 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {/*Do nothing*/} + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + /*Do nothing*/ + } @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public boolean onWrenchRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (getBaseMetaTileEntity().isValidFacing(aWrenchingSide)) { getBaseMetaTileEntity().setFrontFacing(aWrenchingSide); return true; @@ -189,39 +207,54 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } @Override - public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if(!aPlayer.isSneaking()) return false; + public boolean onWireCutterRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (!aPlayer.isSneaking()) return false; byte tSide = GT_Utility.getOppositeSide(aWrenchingSide); TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(aWrenchingSide); - if ((tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable)) { + if ((tTileEntity instanceof IGregTechTileEntity) + && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable)) { // The tile entity we're facing is a cable, let's try to connect to it - return ((IGregTechTileEntity) tTileEntity).getMetaTileEntity().onWireCutterRightClick(aWrenchingSide, tSide, aPlayer, aX, aY, aZ); + return ((IGregTechTileEntity) tTileEntity) + .getMetaTileEntity() + .onWireCutterRightClick(aWrenchingSide, tSide, aPlayer, aX, aY, aZ); } return false; } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if(!aPlayer.isSneaking()) return false; + public boolean onSolderingToolRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (!aPlayer.isSneaking()) return false; byte tSide = GT_Utility.getOppositeSide(aWrenchingSide); TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(aWrenchingSide); - if ((tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable)) { + if ((tTileEntity instanceof IGregTechTileEntity) + && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable)) { // The tile entity we're facing is a cable, let's try to connect to it - return ((IGregTechTileEntity) tTileEntity).getMetaTileEntity().onSolderingToolRightClick(aWrenchingSide, tSide, aPlayer, aX, aY, aZ); + return ((IGregTechTileEntity) tTileEntity) + .getMetaTileEntity() + .onSolderingToolRightClick(aWrenchingSide, tSide, aPlayer, aX, aY, aZ); } return false; } @Override public void onExplosion() { - GT_Log.exp.println("Machine at "+this.getBaseMetaTileEntity().getXCoord()+" | "+this.getBaseMetaTileEntity().getYCoord()+" | "+this.getBaseMetaTileEntity().getZCoord()+" DIMID: "+ this.getBaseMetaTileEntity().getWorld().provider.dimensionId+ " exploded."); + GT_Log.exp.println("Machine at " + this.getBaseMetaTileEntity().getXCoord() + " | " + + this.getBaseMetaTileEntity().getYCoord() + " | " + + this.getBaseMetaTileEntity().getZCoord() + " DIMID: " + + this.getBaseMetaTileEntity().getWorld().provider.dimensionId + " exploded."); } @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {/*Do nothing*/} + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + /*Do nothing*/ + } @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + /*Do nothing*/ + } @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { @@ -235,23 +268,33 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } @Override - public void inValidate() {/*Do nothing*/} + public void inValidate() { + /*Do nothing*/ + } @Override - public void onRemoval() {/*Do nothing*/} + public void onRemoval() { + /*Do nothing*/ + } @Override - public void initDefaultModes(NBTTagCompound aNBT) {/*Do nothing*/} + public void initDefaultModes(NBTTagCompound aNBT) { + /*Do nothing*/ + } /** * When a GUI is opened */ - public void onOpenGUI() {/*Do nothing*/} + public void onOpenGUI() { + /*Do nothing*/ + } /** * When a GUI is closed */ - public void onCloseGUI() {/*Do nothing*/} + public void onCloseGUI() { + /*Do nothing*/ + } /** * a Player rightclicks the Machine @@ -262,15 +305,20 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + public boolean onRightclick( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { return onRightclick(aBaseMetaTileEntity, aPlayer); } @Override - public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {/*Do nothing*/} + public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + /*Do nothing*/ + } @Override - public void onValueUpdate(byte aValue) {/*Do nothing*/} + public void onValueUpdate(byte aValue) { + /*Do nothing*/ + } @Override public byte getUpdateData() { @@ -278,13 +326,19 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/} + public void doSound(byte aIndex, double aX, double aY, double aZ) { + /*Do nothing*/ + } @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/} + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + /*Do nothing*/ + } @Override - public void stopSoundLoop(byte aValue, double aX, double aY, double aZ) {/*Do nothing*/} + public void stopSoundLoop(byte aValue, double aX, double aY, double aZ) { + /*Do nothing*/ + } @Override public MetaTileEntity getCallbackBase() { @@ -460,7 +514,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac * This is used to set the internal Steam Energy to the given Parameter. */ public void setSteamVar(long aSteam) { - if(((BaseMetaTileEntity) mBaseMetaTileEntity).mStoredSteam != aSteam){ + if (((BaseMetaTileEntity) mBaseMetaTileEntity).mStoredSteam != aSteam) { markDirty(); ((BaseMetaTileEntity) mBaseMetaTileEntity).mStoredSteam = aSteam; } @@ -531,7 +585,8 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } @Override - public ArrayList<String> getSpecialDebugInfo(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, int aLogLevel, ArrayList<String> aList) { + public ArrayList<String> getSpecialDebugInfo( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, int aLogLevel, ArrayList<String> aList) { return aList; } @@ -585,10 +640,14 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } @Override - public void onMachineBlockUpdate() {/*Do nothing*/} + public void onMachineBlockUpdate() { + /*Do nothing*/ + } @Override - public void receiveClientEvent(byte aEventID, byte aValue) {/*Do nothing*/} + public void receiveClientEvent(byte aEventID, byte aValue) { + /*Do nothing*/ + } @Override public boolean isSimpleMachine() { @@ -641,13 +700,17 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac /** * When the Facing gets changed. */ - public void onFacingChange() {/*Do nothing*/} + public void onFacingChange() { + /*Do nothing*/ + } /** * if the IC2 Teleporter can drain from this. */ public boolean isTeleporterCompatible() { - return isEnetOutput() && getBaseMetaTileEntity().getOutputVoltage() >= 128 && getBaseMetaTileEntity().getUniversalEnergyCapacity() >= 500000; + return isEnetOutput() + && getBaseMetaTileEntity().getOutputVoltage() >= 128 + && getBaseMetaTileEntity().getUniversalEnergyCapacity() >= 500000; } /** @@ -680,7 +743,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac @Override public String[] getInfoData() { - return new String[]{}; + return new String[] {}; } public boolean isDigitalChest() { @@ -691,7 +754,9 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac return null; } - public void setItemCount(int aCount) {/*Do nothing*/} + public void setItemCount(int aCount) { + /*Do nothing*/ + } public int getMaxItemCount() { return 0; @@ -712,14 +777,13 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac public void setInventorySlotContents(int aIndex, ItemStack aStack) { markDirty(); if (this instanceof IConfigurationCircuitSupport) { - IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport)this; + IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport) this; if (ccs.allowSelectCircuit() && aIndex == ccs.getCircuitSlot() && aStack != null) { mInventory[aIndex] = GT_Utility.copyAmount(0, aStack); return; } } - if (aIndex >= 0 && aIndex < mInventory.length) - mInventory[aIndex] = aStack; + if (aIndex >= 0 && aIndex < mInventory.length) mInventory[aIndex] = aStack; } @Override @@ -747,8 +811,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac if (setStackToZeroInsteadOfNull(aIndex)) { tStack.stackSize = 0; markDirty(); - } - else setInventorySlotContents(aIndex, null); + } else setInventorySlotContents(aIndex, null); } else { rStack = tStack.splitStack(aAmount); markDirty(); @@ -763,21 +826,59 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac public int[] getAccessibleSlotsFromSide(int aSide) { TIntList tList = new TIntArrayList(); IGregTechTileEntity tTileEntity = getBaseMetaTileEntity(); - boolean tSkip = tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), -2, tTileEntity); + boolean tSkip = tTileEntity + .getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsIn( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getComplexCoverDataAtSide((byte) aSide), + -2, + tTileEntity) + || tTileEntity + .getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsOut( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getComplexCoverDataAtSide((byte) aSide), + -2, + tTileEntity); for (int i = 0; i < getSizeInventory(); i++) - if (isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), i, tTileEntity))) - tList.add(i); + if (isValidSlot(i) + && (tSkip + || tTileEntity + .getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsOut( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getComplexCoverDataAtSide((byte) aSide), + i, + tTileEntity) + || tTileEntity + .getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsIn( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getComplexCoverDataAtSide((byte) aSide), + i, + tTileEntity))) tList.add(i); return tList.toArray(); } @Override public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && (mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, mInventory[aIndex])) && allowPutStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); + return isValidSlot(aIndex) + && aStack != null + && aIndex < mInventory.length + && (mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, mInventory[aIndex])) + && allowPutStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); } @Override public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && allowPullStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); + return isValidSlot(aIndex) + && aStack != null + && aIndex < mInventory.length + && allowPullStack(getBaseMetaTileEntity(), aIndex, (byte) aSide, aStack); } @Override @@ -792,8 +893,8 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac @Override public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[]{}; - return new FluidTankInfo[]{getInfo()}; + if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[] {}; + return new FluidTankInfo[] {getInfo()}; } public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { @@ -804,7 +905,12 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac @Override public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { if (getBaseMetaTileEntity().hasSteamEngineUpgrade() && GT_ModHandler.isSteam(aFluid) && aFluid.amount > 1) { - int tSteam = (int) Math.min(Integer.MAX_VALUE, Math.min(aFluid.amount / 2, getBaseMetaTileEntity().getSteamCapacity() - getBaseMetaTileEntity().getStoredSteam())); + int tSteam = (int) Math.min( + Integer.MAX_VALUE, + Math.min( + aFluid.amount / 2, + getBaseMetaTileEntity().getSteamCapacity() + - getBaseMetaTileEntity().getStoredSteam())); if (tSteam > 0) { markDirty(); if (doFill) getBaseMetaTileEntity().increaseStoredSteam(tSteam, true); @@ -909,7 +1015,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac public void onColorChangeServer(byte aColor) { final IGregTechTileEntity meta = getBaseMetaTileEntity(); final int aX = meta.getXCoord(), aY = meta.getYCoord(), aZ = meta.getZCoord(); - for (byte aSide = 0; aSide < 6 ; aSide++ ) { + for (byte aSide = 0; aSide < 6; aSide++) { // Flag surrounding pipes/cables to revaluate their connection with us if we got painted final TileEntity tTileEntity = meta.getTileEntityAtSide(aSide); if ((tTileEntity instanceof BaseMetaPipeEntity)) { @@ -937,27 +1043,63 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac @Override public void doExplosion(long aExplosionPower) { - float tStrength = - aExplosionPower < V[0] ? 1.0F : - aExplosionPower < V[1] ? 2.0F : - aExplosionPower < V[2] ? 3.0F : - aExplosionPower < V[3] ? 4.0F : - aExplosionPower < V[4] ? 5.0F : - aExplosionPower < V[4] * 2 ? 6.0F : - aExplosionPower < V[5] ? 7.0F : - aExplosionPower < V[6] ? 8.0F : - aExplosionPower < V[7] ? 9.0F : - aExplosionPower < V[8] ? 10.0F : - aExplosionPower < V[8] * 2 ? 11.0F : - aExplosionPower < V[9] ? 12.0F : - aExplosionPower < V[10] ? 13.0F : - aExplosionPower < V[11] ? 14.0F : - aExplosionPower < V[12] ? 15.0F : - aExplosionPower < V[12] * 2 ? 16.0F : - aExplosionPower < V[13] ? 17.0F : - aExplosionPower < V[14] ? 18.0F : - aExplosionPower < V[15] ? 19.0F : 20.0F; - int tX = getBaseMetaTileEntity().getXCoord(), tY = getBaseMetaTileEntity().getYCoord(), tZ = getBaseMetaTileEntity().getZCoord(); + float tStrength = aExplosionPower < V[0] + ? 1.0F + : aExplosionPower < V[1] + ? 2.0F + : aExplosionPower < V[2] + ? 3.0F + : aExplosionPower < V[3] + ? 4.0F + : aExplosionPower < V[4] + ? 5.0F + : aExplosionPower < V[4] * 2 + ? 6.0F + : aExplosionPower < V[5] + ? 7.0F + : aExplosionPower < V[6] + ? 8.0F + : aExplosionPower < V[7] + ? 9.0F + : aExplosionPower < V[8] + ? 10.0F + : aExplosionPower < V[8] * 2 + ? 11.0F + : aExplosionPower < V[9] + ? 12.0F + : aExplosionPower + < V[ + 10] + ? 13.0F + : aExplosionPower + < V[ + 11] + ? 14.0F + : aExplosionPower + < V[ + 12] + ? 15.0F + : aExplosionPower + < V[ + 12] + * 2 + ? 16.0F + : aExplosionPower + < V[ + 13] + ? 17.0F + : aExplosionPower + < V[ + 14] + ? 18.0F + : aExplosionPower + < V[ + 15] + ? 19.0F + : 20.0F; + int tX = getBaseMetaTileEntity().getXCoord(), + tY = getBaseMetaTileEntity().getYCoord(), + tZ = getBaseMetaTileEntity().getZCoord(); World tWorld = getBaseMetaTileEntity().getWorld(); GT_Utility.sendSoundToPlayers(tWorld, SoundResource.IC2_MACHINES_MACHINE_OVERLOAD, 1.0F, -1, tX, tY, tZ); tWorld.setBlock(tX, tY, tZ, Blocks.air); @@ -971,7 +1113,14 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) { + public void addCollisionBoxesToList( + World aWorld, + int aX, + int aY, + int aZ, + AxisAlignedBB inputAABB, + List<AxisAlignedBB> outputAABB, + Entity collider) { AxisAlignedBB axisalignedbb1 = getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); if (axisalignedbb1 != null && inputAABB.intersectsWith(axisalignedbb1)) outputAABB.add(axisalignedbb1); } @@ -992,29 +1141,33 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac } @Override - public boolean allowGeneralRedstoneOutput(){ - return false; + public boolean allowGeneralRedstoneOutput() { + return false; } @Deprecated - public String trans(String aKey, String aEnglish){ - return GT_Utility.trans(aKey, aEnglish); + public String trans(String aKey, String aEnglish) { + return GT_Utility.trans(aKey, aEnglish); } @Override - public boolean hasAlternativeModeText(){ - return false; + public boolean hasAlternativeModeText() { + return false; } @Override - public String getAlternativeModeText(){ - return ""; + public String getAlternativeModeText() { + return ""; } @Override - public boolean shouldJoinIc2Enet() { return false; } + public boolean shouldJoinIc2Enet() { + return false; + } - public boolean shouldTriggerBlockUpdate() { return false; } + public boolean shouldTriggerBlockUpdate() { + return false; + } @Optional.Method(modid = "appliedenergistics2") public AECableType getCableConnectionType(ForgeDirection forgeDirection) { @@ -1030,33 +1183,32 @@ public abstract class MetaTileEntity implements IMetaTileEntity, IMachineCallbac public void gridChanged() {} @Override - public void getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - currenttip.add(String.format("Facing: %s", ForgeDirection.getOrientation(mBaseMetaTileEntity.getFrontFacing()).name())); + public void getWailaBody( + ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + currenttip.add(String.format( + "Facing: %s", + ForgeDirection.getOrientation(mBaseMetaTileEntity.getFrontFacing()) + .name())); } @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) { /* Empty */ } @Optional.Method(modid = "appliedenergistics2") protected String getAEDiagnostics() { try { - if (getProxy() == null) - return "(proxy)"; - if (getProxy().getNode() == null) - return "(node)"; - if (getProxy().getNode().getGrid() == null) - return "(grid)"; - if (!getProxy().getNode().meetsChannelRequirements()) - return "(channels)"; + if (getProxy() == null) return "(proxy)"; + if (getProxy().getNode() == null) return "(node)"; + if (getProxy().getNode().getGrid() == null) return "(grid)"; + if (!getProxy().getNode().meetsChannelRequirements()) return "(channels)"; IPathingGrid pg = getProxy().getNode().getGrid().getCache(IPathingGrid.class); - if (!pg.isNetworkBooting()) - return "(booting)"; + if (!pg.isNetworkBooting()) return "(booting)"; IEnergyGrid eg = getProxy().getNode().getGrid().getCache(IEnergyGrid.class); - if (!eg.isNetworkPowered()) - return "(power)"; - } catch(Throwable ex) { + if (!eg.isNetworkPowered()) return "(power)"; + } catch (Throwable ex) { ex.printStackTrace(); } return ""; diff --git a/src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java b/src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java index 16af004957..661dad730f 100644 --- a/src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java +++ b/src/main/java/gregtech/api/metatileentity/TileIC2EnergySink.java @@ -44,19 +44,18 @@ public class TileIC2EnergySink extends TileEntity implements IEnergySink { */ @Override public double getDemandedEnergy() { - if(cableMeta != null) { - // We don't want everything to join the enet (treating the cable as a conductor) so we join it as a ink. We don't want to traverse all cables - // connected to this (like we would during distribution) to see if it actually needs any EU... so we just always say we want it all. If there - // are more than two things attached, and one of them is a GT cable that doesn't have anywhere to send it's energy, the distribution will be a bit + if (cableMeta != null) { + // We don't want everything to join the enet (treating the cable as a conductor) so we join it as a ink. We + // don't want to traverse all cables + // connected to this (like we would during distribution) to see if it actually needs any EU... so we just + // always say we want it all. If there + // are more than two things attached, and one of them is a GT cable that doesn't have anywhere to send it's + // energy, the distribution will be a bit // weird. In that case only use one cable, or use a transformer. return (cableMeta.mVoltage * cableMeta.mAmperage); - } - else - return myMeta.getEUCapacity() - myMeta.getStoredEU(); + } else return myMeta.getEUCapacity() - myMeta.getStoredEU(); } - - /** * Determine the tier of this energy sink. * 1 = LV, 2 = MV, 3 = HV, 4 = EV etc. @@ -82,20 +81,26 @@ public class TileIC2EnergySink extends TileEntity implements IEnergySink { @Override public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { - final long amps =(long)Math.max(amount / (cableMeta != null ? cableMeta.mVoltage : myMeta.getInputVoltage() * 1.0), 1.0); - final long euPerAmp = (long)(amount / (amps * 1.0)); + final long amps = (long) + Math.max(amount / (cableMeta != null ? cableMeta.mVoltage : myMeta.getInputVoltage() * 1.0), 1.0); + final long euPerAmp = (long) (amount / (amps * 1.0)); final IMetaTileEntity metaTile = myMeta.getMetaTileEntity(); if (metaTile == null) return amount; final long usedAmps; - if(cableMeta != null) { - usedAmps = ((IMetaTileEntityCable) metaTile).transferElectricity((byte) directionFrom.ordinal(), Math.min(euPerAmp, cableMeta.mVoltage), amps, Sets.newHashSet((TileEntity) myMeta)); - - } - else - usedAmps = myMeta.injectEnergyUnits((byte) directionFrom.ordinal(), Math.min(euPerAmp, myMeta.getInputVoltage()), amps); - return amount - ( usedAmps * euPerAmp); + if (cableMeta != null) { + usedAmps = ((IMetaTileEntityCable) metaTile) + .transferElectricity( + (byte) directionFrom.ordinal(), + Math.min(euPerAmp, cableMeta.mVoltage), + amps, + Sets.newHashSet((TileEntity) myMeta)); + + } else + usedAmps = myMeta.injectEnergyUnits( + (byte) directionFrom.ordinal(), Math.min(euPerAmp, myMeta.getInputVoltage()), amps); + return amount - (usedAmps * euPerAmp); // transferElectricity for cables } @@ -112,11 +117,9 @@ public class TileIC2EnergySink extends TileEntity implements IEnergySink { @Override public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { final IMetaTileEntity metaTile = myMeta.getMetaTileEntity(); - if(metaTile instanceof IMetaTileEntityCable && (direction == ForgeDirection.UNKNOWN || ((IConnectable)metaTile).isConnectedAtSide(direction.ordinal()))) - return true; - else - return myMeta.inputEnergyFrom((byte) direction.ordinal(), false); - + if (metaTile instanceof IMetaTileEntityCable + && (direction == ForgeDirection.UNKNOWN + || ((IConnectable) metaTile).isConnectedAtSide(direction.ordinal()))) return true; + else return myMeta.inputEnergyFrom((byte) direction.ordinal(), false); } - } diff --git a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java index 431ed3cc30..be1904aaf5 100644 --- a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java +++ b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.examples; +import static gregtech.api.enums.Textures.BlockIcons.*; + import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -10,45 +12,84 @@ import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import net.minecraft.item.ItemStack; -import static gregtech.api.enums.Textures.BlockIcons.*; - /** * This Example Implementation still works, however I use something completely different in my own Code. */ public class GT_MetaTileEntity_E_Furnace extends GT_MetaTileEntity_BasicMachine { public GT_MetaTileEntity_E_Furnace(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, "Not like using a Commodore 64", 1, 1, "E_Furnace.png", "smelting", + super( + aID, + aName, + aNameRegional, + aTier, + 1, + "Not like using a Commodore 64", + 1, + 1, + "E_Furnace.png", + "smelting", TextureFactory.of( TextureFactory.of(OVERLAY_SIDE_STEAM_FURNACE_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_SIDE_STEAM_FURNACE_ACTIVE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_SIDE_STEAM_FURNACE_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_SIDE_STEAM_FURNACE), - TextureFactory.builder().addIcon(OVERLAY_SIDE_STEAM_FURNACE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_SIDE_STEAM_FURNACE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_FRONT_STEAM_FURNACE_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_STEAM_FURNACE_ACTIVE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_STEAM_FURNACE_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_FRONT_STEAM_FURNACE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_STEAM_FURNACE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_STEAM_FURNACE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_TOP_STEAM_FURNACE_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_TOP_STEAM_FURNACE_ACTIVE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_TOP_STEAM_FURNACE_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_TOP_STEAM_FURNACE), - TextureFactory.builder().addIcon(OVERLAY_TOP_STEAM_FURNACE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_TOP_STEAM_FURNACE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_BOTTOM_STEAM_FURNACE_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_BOTTOM_STEAM_FURNACE_ACTIVE_GLOW).glow().build()), + TextureFactory.builder() + .addIcon(OVERLAY_BOTTOM_STEAM_FURNACE_ACTIVE_GLOW) + .glow() + .build()), TextureFactory.of( TextureFactory.of(OVERLAY_BOTTOM_STEAM_FURNACE), - TextureFactory.builder().addIcon(OVERLAY_BOTTOM_STEAM_FURNACE_GLOW).glow().build())); + TextureFactory.builder() + .addIcon(OVERLAY_BOTTOM_STEAM_FURNACE_GLOW) + .glow() + .build())); } - public GT_MetaTileEntity_E_Furnace(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + public GT_MetaTileEntity_E_Furnace( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); } - public GT_MetaTileEntity_E_Furnace(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { + public GT_MetaTileEntity_E_Furnace( + String aName, + int aTier, + String[] aDescription, + ITexture[][][] aTextures, + String aGUIName, + String aNEIName) { super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); } @@ -69,14 +110,17 @@ public class GT_MetaTileEntity_E_Furnace extends GT_MetaTileEntity_BasicMachine } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64, aStack), false, null) != null; + protected boolean allowPutStackValidated( + IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) + && GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64, aStack), false, null) != null; } @Override public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) GT_Utility.doSoundAtClient(SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP, 10, 1.0F, aX, aY, aZ); + if (aIndex == 1) + GT_Utility.doSoundAtClient(SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP, 10, 1.0F, aX, aY, aZ); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index e92f61f1b9..fd3fe175c9 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.VN; + import cofh.api.energy.IEnergyReceiver; import cpw.mods.fml.common.Loader; import gregtech.GT_Mod; @@ -34,6 +36,9 @@ import ic2.api.energy.tile.IEnergySink; import ic2.api.energy.tile.IEnergySource; import ic2.api.energy.tile.IEnergyTile; import ic2.api.reactor.IReactorChamber; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -45,27 +50,37 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import static gregtech.api.enums.GT_Values.VN; - public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTileEntityCable { public final float mThickNess; public final Materials mMaterial; public final long mCableLossPerMeter, mAmperage, mVoltage; public final boolean mInsulated, mCanShock; - public int mTransferredAmperage = 0, mTransferredAmperageLast20 = 0,mTransferredAmperageLast20OK=0,mTransferredAmperageOK=0; - public long mTransferredVoltageLast20 = 0, mTransferredVoltage = 0,mTransferredVoltageLast20OK=0,mTransferredVoltageOK=0; + public int mTransferredAmperage = 0, + mTransferredAmperageLast20 = 0, + mTransferredAmperageLast20OK = 0, + mTransferredAmperageOK = 0; + public long mTransferredVoltageLast20 = 0, + mTransferredVoltage = 0, + mTransferredVoltageLast20OK = 0, + mTransferredVoltageOK = 0; public long mRestRF; public int mOverheat; - public static short mMaxOverheat=(short) (GT_Mod.gregtechproxy.mWireHeatingTicks * 100); + public static short mMaxOverheat = (short) (GT_Mod.gregtechproxy.mWireHeatingTicks * 100); private int[] lastAmperage; private long lastWorldTick; - public GT_MetaPipeEntity_Cable(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { + public GT_MetaPipeEntity_Cable( + int aID, + String aName, + String aNameRegional, + float aThickNess, + Materials aMaterial, + long aCableLossPerMeter, + long aAmperage, + long aVoltage, + boolean aInsulated, + boolean aCanShock) { super(aID, aName, aNameRegional, 0); mThickNess = aThickNess; mMaterial = aMaterial; @@ -76,7 +91,15 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile mCableLossPerMeter = aCableLossPerMeter; } - public GT_MetaPipeEntity_Cable(String aName, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { + public GT_MetaPipeEntity_Cable( + String aName, + float aThickNess, + Materials aMaterial, + long aCableLossPerMeter, + long aAmperage, + long aVoltage, + boolean aInsulated, + boolean aCanShock) { super(aName, 0); mThickNess = aThickNess; mMaterial = aMaterial; @@ -94,36 +117,88 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaPipeEntity_Cable(mName, mThickNess, mMaterial, mCableLossPerMeter, mAmperage, mVoltage, mInsulated, mCanShock); + return new GT_MetaPipeEntity_Cable( + mName, mThickNess, mMaterial, mCableLossPerMeter, mAmperage, mVoltage, mInsulated, mCanShock); } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aConnections, + byte aColorIndex, + boolean aConnected, + boolean aRedstone) { if (!mInsulated) - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], Dyes.getModulation(aColorIndex, mMaterial.mRGBa) )}; + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) + }; if (aConnected) { float tThickNess = getThickNess(); if (tThickNess < 0.124F) - return new ITexture[]{TextureFactory.of(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.374F)//0.375 x1 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), TextureFactory.of(Textures.BlockIcons.INSULATION_TINY, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.499F)//0.500 x2 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), TextureFactory.of(Textures.BlockIcons.INSULATION_SMALL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.624F)//0.625 x4 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), TextureFactory.of(Textures.BlockIcons.INSULATION_MEDIUM, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.749F)//0.750 x8 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), TextureFactory.of(Textures.BlockIcons.INSULATION_MEDIUM_PLUS, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.874F)//0.825 x12 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), TextureFactory.of(Textures.BlockIcons.INSULATION_LARGE, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), TextureFactory.of(Textures.BlockIcons.INSULATION_HUGE, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + Textures.BlockIcons.INSULATION_FULL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.374F) // 0.375 x1 + return new ITexture[] { + TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), + TextureFactory.of( + Textures.BlockIcons.INSULATION_TINY, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.499F) // 0.500 x2 + return new ITexture[] { + TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), + TextureFactory.of( + Textures.BlockIcons.INSULATION_SMALL, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.624F) // 0.625 x4 + return new ITexture[] { + TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), + TextureFactory.of( + Textures.BlockIcons.INSULATION_MEDIUM, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.749F) // 0.750 x8 + return new ITexture[] { + TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), + TextureFactory.of( + Textures.BlockIcons.INSULATION_MEDIUM_PLUS, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + if (tThickNess < 0.874F) // 0.825 x12 + return new ITexture[] { + TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), + TextureFactory.of( + Textures.BlockIcons.INSULATION_LARGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; + return new ITexture[] { + TextureFactory.of(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), + TextureFactory.of( + Textures.BlockIcons.INSULATION_HUGE, + Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; } - return new ITexture[]{TextureFactory.of(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa)) + }; } @Override public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) { - if (mCanShock && (((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase && !isCoverOnSide((BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity)) - GT_Utility.applyElectricityDamage((EntityLivingBase) aEntity, mTransferredVoltageLast20, mTransferredAmperageLast20); + if (mCanShock + && (((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections & -128) == 0 + && aEntity instanceof EntityLivingBase + && !isCoverOnSide((BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity)) + GT_Utility.applyElectricityDamage( + (EntityLivingBase) aEntity, mTransferredVoltageLast20, mTransferredAmperageLast20); } @Override @@ -158,34 +233,37 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @Override public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!isConnectedAtSide(aSide) && aSide != 6) - return 0; - if (!getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), getBaseMetaTileEntity())) - return 0; + if (!isConnectedAtSide(aSide) && aSide != 6) return 0; + if (!getBaseMetaTileEntity() + .getCoverBehaviorAtSideNew(aSide) + .letsEnergyIn( + aSide, + getBaseMetaTileEntity().getCoverIDAtSide(aSide), + getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), + getBaseMetaTileEntity())) return 0; HashSet<TileEntity> nul = null; - return transferElectricity(aSide, aVoltage, aAmperage,nul); + return transferElectricity(aSide, aVoltage, aAmperage, nul); } @Override @Deprecated - public long transferElectricity(byte aSide, long aVoltage, long aAmperage, ArrayList<TileEntity> aAlreadyPassedTileEntityList) { + public long transferElectricity( + byte aSide, long aVoltage, long aAmperage, ArrayList<TileEntity> aAlreadyPassedTileEntityList) { return transferElectricity(aSide, aVoltage, aAmperage, new HashSet<>(aAlreadyPassedTileEntityList)); } @Override public long transferElectricity(byte aSide, long aVoltage, long aAmperage, HashSet<TileEntity> aAlreadyPassedSet) { if (!getBaseMetaTileEntity().isServerSide() || !isConnectedAtSide(aSide) && aSide != 6) return 0; - BaseMetaPipeEntity tBase =(BaseMetaPipeEntity) getBaseMetaTileEntity(); - if (!(tBase.getNode() instanceof PowerNode)) - return 0; - PowerNode tNode =(PowerNode) tBase.getNode(); + BaseMetaPipeEntity tBase = (BaseMetaPipeEntity) getBaseMetaTileEntity(); + if (!(tBase.getNode() instanceof PowerNode)) return 0; + PowerNode tNode = (PowerNode) tBase.getNode(); if (tNode != null) { int tPlace = 0; Node[] tToPower = new Node[tNode.mConsumers.size()]; if (tNode.mHadVoltage) { for (ConsumerNode consumer : tNode.mConsumers) { - if (consumer.needsEnergy()) - tToPower[tPlace++] = consumer; + if (consumer.needsEnergy()) tToPower[tPlace++] = consumer; } } else { tNode.mHadVoltage = true; @@ -193,35 +271,39 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile tToPower[tPlace++] = consumer; } } - return PowerNodes.powerNode(tNode,null,new NodeList(tToPower),(int)aVoltage,(int)aAmperage); + return PowerNodes.powerNode(tNode, null, new NodeList(tToPower), (int) aVoltage, (int) aAmperage); } return 0; } @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - if(aBaseMetaTileEntity.isServerSide()) { + if (aBaseMetaTileEntity.isServerSide()) { lastAmperage = new int[16]; - lastWorldTick = aBaseMetaTileEntity.getWorld().getTotalWorldTime() - 1;//sets initial value -1 since it is in the same tick as first on post tick + lastWorldTick = aBaseMetaTileEntity.getWorld().getTotalWorldTime() + - 1; // sets initial value -1 since it is in the same tick as first on post tick } } - @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); - if (aTick%20 == 0 && aBaseMetaTileEntity.isServerSide() && (!GT_Mod.gregtechproxy.gt6Cable || mCheckConnections)) { + if (aTick % 20 == 0 + && aBaseMetaTileEntity.isServerSide() + && (!GT_Mod.gregtechproxy.gt6Cable || mCheckConnections)) { checkConnections(); } } @Override - public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (GT_Mod.gregtechproxy.gt6Cable && GT_ModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { - if(isConnectedAtSide(aWrenchingSide)) { + public boolean onWireCutterRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (GT_Mod.gregtechproxy.gt6Cable + && GT_ModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { + if (isConnectedAtSide(aWrenchingSide)) { disconnect(aWrenchingSide); GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("215", "Disconnected")); - }else if(!GT_Mod.gregtechproxy.costlyCableConnection){ + } else if (!GT_Mod.gregtechproxy.costlyCableConnection) { if (connect(aWrenchingSide) > 0) GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("214", "Connected")); } @@ -231,8 +313,10 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (GT_Mod.gregtechproxy.gt6Cable && GT_ModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { + public boolean onSolderingToolRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (GT_Mod.gregtechproxy.gt6Cable + && GT_ModHandler.damageOrDechargeItem(aPlayer.inventory.getCurrentItem(), 1, 500, aPlayer)) { if (isConnectedAtSide(aWrenchingSide)) { disconnect(aWrenchingSide); GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("215", "Disconnected")); @@ -246,26 +330,37 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile } @Override - public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsIn( + GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsEnergyIn(aSide, aCoverID, aCoverVariable, aTileEntity); } @Override - public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsOut( + GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsEnergyOut(aSide, aCoverID, aCoverVariable, aTileEntity); } @Override - public boolean letsIn(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public boolean letsIn( + GT_CoverBehaviorBase<?> coverBehavior, + byte aSide, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity) { return coverBehavior.letsEnergyIn(aSide, aCoverID, aCoverVariable, aTileEntity); } @Override - public boolean letsOut(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public boolean letsOut( + GT_CoverBehaviorBase<?> coverBehavior, + byte aSide, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity) { return coverBehavior.letsEnergyOut(aSide, aCoverID, aCoverVariable, aTileEntity); } - @Override public boolean canConnect(byte aSide, TileEntity tTileEntity) { final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity(); @@ -274,20 +369,21 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile final ForgeDirection tDir = ForgeDirection.getOrientation(tSide); // GT Machine handling - if ((tTileEntity instanceof IEnergyConnected) && - (((IEnergyConnected) tTileEntity).inputEnergyFrom(tSide, false) || ((IEnergyConnected) tTileEntity).outputsEnergyTo(tSide, false))) - return true; + if ((tTileEntity instanceof IEnergyConnected) + && (((IEnergyConnected) tTileEntity).inputEnergyFrom(tSide, false) + || ((IEnergyConnected) tTileEntity).outputsEnergyTo(tSide, false))) return true; // Solar Panel Compat if (coverBehavior instanceof GT_Cover_SolarPanel) return true; - // ((tIsGregTechTileEntity && tIsTileEntityCable) && (tAlwaysLookConnected || tLetEnergyIn || tLetEnergyOut) ) --> Not needed - if (Loader.isModLoaded("GalacticraftCore") && GT_GC_Compat.canConnect(tTileEntity,tDir)) - return true; + // ((tIsGregTechTileEntity && tIsTileEntityCable) && (tAlwaysLookConnected || tLetEnergyIn || tLetEnergyOut) ) + // --> Not needed + if (Loader.isModLoaded("GalacticraftCore") && GT_GC_Compat.canConnect(tTileEntity, tDir)) return true; // AE2-p2p Compat if (GT_Mod.gregtechproxy.mAE2Integration) { - if (tTileEntity instanceof appeng.tile.powersink.IC2 && ((appeng.tile.powersink.IC2)tTileEntity).acceptsEnergyFrom((TileEntity)baseMetaTile, tDir)) + if (tTileEntity instanceof appeng.tile.powersink.IC2 + && ((appeng.tile.powersink.IC2) tTileEntity).acceptsEnergyFrom((TileEntity) baseMetaTile, tDir)) return true; } @@ -298,12 +394,14 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile if (tTileEntity instanceof IReactorChamber) ic2Energy = (TileEntity) ((IReactorChamber) tTileEntity).getReactor(); else - ic2Energy = (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) ? tTileEntity : - EnergyNet.instance.getTileEntity(tTileEntity.getWorldObj(), tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord); + ic2Energy = (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) + ? tTileEntity + : EnergyNet.instance.getTileEntity( + tTileEntity.getWorldObj(), tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord); // IC2 Sink Compat - if ((ic2Energy instanceof IEnergySink) && ((IEnergySink) ic2Energy).acceptsEnergyFrom((TileEntity) baseMetaTile, tDir)) - return true; + if ((ic2Energy instanceof IEnergySink) + && ((IEnergySink) ic2Energy).acceptsEnergyFrom((TileEntity) baseMetaTile, tDir)) return true; // IC2 Source Compat if (GT_Mod.gregtechproxy.ic2EnergySourceCompat && (ic2Energy instanceof IEnergySource)) { @@ -313,11 +411,14 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile } } // RF Output Compat - if (GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver) tTileEntity).canConnectEnergy(tDir)) - return true; + if (GregTech_API.mOutputRF + && tTileEntity instanceof IEnergyReceiver + && ((IEnergyReceiver) tTileEntity).canConnectEnergy(tDir)) return true; // RF Input Compat - return GregTech_API.mInputRF && (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter) tTileEntity).emitsEnergyTo((TileEntity) baseMetaTile, tDir)); + return GregTech_API.mInputRF + && (tTileEntity instanceof IEnergyEmitter + && ((IEnergyEmitter) tTileEntity).emitsEnergyTo((TileEntity) baseMetaTile, tDir)); } @Override @@ -326,7 +427,6 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile return GT_Mod.gregtechproxy.gt6Cable; } - @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return false; @@ -339,29 +439,32 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @Override public String[] getDescription() { - return new String[]{ - "Max Voltage: %%%" + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mVoltage) + " (" + GT_Values.TIER_COLORS[GT_Utility.getTier(mVoltage)] + VN[GT_Utility.getTier(mVoltage)] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY, - "Max Amperage: %%%" + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mAmperage) + EnumChatFormatting.GRAY, - "Loss/Meter/Ampere: %%%" + EnumChatFormatting.RED + GT_Utility.formatNumbers(mCableLossPerMeter) + EnumChatFormatting.GRAY + "%%% EU-Volt" + return new String[] { + "Max Voltage: %%%" + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mVoltage) + " (" + + GT_Values.TIER_COLORS[GT_Utility.getTier(mVoltage)] + VN[GT_Utility.getTier(mVoltage)] + + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY, + "Max Amperage: %%%" + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mAmperage) + + EnumChatFormatting.GRAY, + "Loss/Meter/Ampere: %%%" + EnumChatFormatting.RED + GT_Utility.formatNumbers(mCableLossPerMeter) + + EnumChatFormatting.GRAY + "%%% EU-Volt" }; } @Override public float getThickNess() { - if(GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x1) != 0) return 0.0625F; + if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x1) != 0) return 0.0625F; return mThickNess; } @Override public void saveNBTData(NBTTagCompound aNBT) { - if (GT_Mod.gregtechproxy.gt6Cable) - aNBT.setByte("mConnections", mConnections); + if (GT_Mod.gregtechproxy.gt6Cable) aNBT.setByte("mConnections", mConnections); } @Override public void loadNBTData(NBTTagCompound aNBT) { if (GT_Mod.gregtechproxy.gt6Cable) { - mConnections = aNBT.getByte("mConnections"); + mConnections = aNBT.getByte("mConnections"); } } @@ -373,73 +476,98 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @Override public String[] getInfoData() { BaseMetaPipeEntity base = (BaseMetaPipeEntity) getBaseMetaTileEntity(); - PowerNodePath path =(PowerNodePath) base.getNodePath(); + PowerNodePath path = (PowerNodePath) base.getNodePath(); long amps = 0; long volts = 0; if (path != null) { amps = path.getAmps(); volts = path.getVoltage(this); } - return new String[]{ - //EnumChatFormatting.BLUE + mName + EnumChatFormatting.RESET, - "Heat: " + - EnumChatFormatting.RED + GT_Utility.formatNumbers(mOverheat) + EnumChatFormatting.RESET + " / " + - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMaxOverheat) + EnumChatFormatting.RESET, - "Max Load (1t):", - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(amps) + EnumChatFormatting.RESET + " A / " + - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mAmperage) + EnumChatFormatting.RESET + " A", - "Max EU/p (1t):", - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(volts) + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mVoltage) + EnumChatFormatting.RESET + " EU", - "Max Load (20t): " + - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mTransferredAmperageLast20OK) + EnumChatFormatting.RESET + " A", - "Max EU/p (20t): " + - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mTransferredVoltageLast20OK) + EnumChatFormatting.RESET + " EU" + return new String[] { + // EnumChatFormatting.BLUE + mName + EnumChatFormatting.RESET, + "Heat: " + EnumChatFormatting.RED + + GT_Utility.formatNumbers(mOverheat) + EnumChatFormatting.RESET + " / " + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(mMaxOverheat) + EnumChatFormatting.RESET, + "Max Load (1t):", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(amps) + EnumChatFormatting.RESET + " A / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mAmperage) + EnumChatFormatting.RESET + " A", + "Max EU/p (1t):", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(volts) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mVoltage) + EnumChatFormatting.RESET + " EU", + "Max Load (20t): " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mTransferredAmperageLast20OK) + + EnumChatFormatting.RESET + " A", + "Max EU/p (20t): " + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mTransferredVoltageLast20OK) + + EnumChatFormatting.RESET + " EU" }; } @Override public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) - return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1); - else - return getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) + return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1); + else return getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); } private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - float tSpace = (1f - mThickNess)/2; - float tSide0 = tSpace; - float tSide1 = 1f - tSpace; - float tSide2 = tSpace; - float tSide3 = 1f - tSpace; - float tSide4 = tSpace; - float tSide5 = 1f - tSpace; - - if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0){tSide0=tSide2=tSide4=0;tSide3=tSide5=1;} - if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0){tSide2=tSide4=0;tSide1=tSide3=tSide5=1;} - if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide5=1;} - if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0){tSide0=tSide4=0;tSide1=tSide3=tSide5=1;} - if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0){tSide0=tSide2=tSide4=0;tSide1=tSide3=1;} - if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0){tSide0=tSide2=0;tSide1=tSide3=tSide5=1;} - - byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections; - if((tConn & (1 << ForgeDirection.DOWN.ordinal()) ) != 0) tSide0 = 0f; - if((tConn & (1 << ForgeDirection.UP.ordinal()) ) != 0) tSide1 = 1f; - if((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f; - if((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f; - if((tConn & (1 << ForgeDirection.WEST.ordinal()) ) != 0) tSide4 = 0f; - if((tConn & (1 << ForgeDirection.EAST.ordinal()) ) != 0) tSide5 = 1f; - - return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); - } + float tSpace = (1f - mThickNess) / 2; + float tSide0 = tSpace; + float tSide1 = 1f - tSpace; + float tSide2 = tSpace; + float tSide3 = 1f - tSpace; + float tSide4 = tSpace; + float tSide5 = 1f - tSpace; + + if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 0) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 1) != 0) { + tSide2 = tSide4 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 2) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide1 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 3) != 0) { + tSide0 = tSide4 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 4) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide1 = tSide3 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0) { + tSide0 = tSide2 = 0; + tSide1 = tSide3 = tSide5 = 1; + } - @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) { - super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); - if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) { - AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb); - } + byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections; + if ((tConn & (1 << ForgeDirection.DOWN.ordinal())) != 0) tSide0 = 0f; + if ((tConn & (1 << ForgeDirection.UP.ordinal())) != 0) tSide1 = 1f; + if ((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f; + if ((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f; + if ((tConn & (1 << ForgeDirection.WEST.ordinal())) != 0) tSide4 = 0f; + if ((tConn & (1 << ForgeDirection.EAST.ordinal())) != 0) tSide5 = 1f; + + return AxisAlignedBB.getBoundingBox( + aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); + } + + @Override + public void addCollisionBoxesToList( + World aWorld, + int aX, + int aY, + int aZ, + AxisAlignedBB inputAABB, + List<AxisAlignedBB> outputAABB, + Entity collider) { + super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); + if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) { + AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb); + } } @Override @@ -448,15 +576,20 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile if (mConnections != 0) { final IGregTechTileEntity baseMeta = getBaseMetaTileEntity(); - for( byte aSide = 0 ; aSide < 6 ; aSide++) if(isConnectedAtSide(aSide)) { - final TileEntity tTileEntity = baseMeta.getTileEntityAtSide(aSide); - final TileEntity tEmitter = (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) ? tTileEntity : - EnergyNet.instance.getTileEntity(tTileEntity.getWorldObj(), tTileEntity.xCoord, tTileEntity.yCoord, tTileEntity.zCoord); - - if (tEmitter instanceof IEnergyEmitter) - return true; - - } + for (byte aSide = 0; aSide < 6; aSide++) + if (isConnectedAtSide(aSide)) { + final TileEntity tTileEntity = baseMeta.getTileEntityAtSide(aSide); + final TileEntity tEmitter = + (tTileEntity == null || tTileEntity instanceof IEnergyTile || EnergyNet.instance == null) + ? tTileEntity + : EnergyNet.instance.getTileEntity( + tTileEntity.getWorldObj(), + tTileEntity.xCoord, + tTileEntity.yCoord, + tTileEntity.zCoord); + + if (tEmitter instanceof IEnergyEmitter) return true; + } } return false; } @@ -471,7 +604,8 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile if (coverBehavior instanceof GT_Cover_None) continue; final int coverId = pipe.getCoverIDAtSide(i); ISerializableObject coverData = pipe.getComplexCoverDataAtSide(i); - if (!letsIn(coverBehavior, i, coverId, coverData, pipe) || !letsOut(coverBehavior, i, coverId, coverData, pipe)) { + if (!letsIn(coverBehavior, i, coverId, coverData, pipe) + || !letsOut(coverBehavior, i, coverId, coverData, pipe)) { pipe.addToLock(pipe, i); } else { pipe.removeFromLock(pipe, i); @@ -486,7 +620,8 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile if (coverBehavior instanceof GT_Cover_None) continue; final int coverId = pipe.getCoverIDAtSide(i); ISerializableObject coverData = pipe.getComplexCoverDataAtSide(i); - if (!letsIn(coverBehavior, i, coverId, coverData, pipe) || !letsOut(coverBehavior, i, coverId, coverData, pipe)) { + if (!letsIn(coverBehavior, i, coverId, coverData, pipe) + || !letsOut(coverBehavior, i, coverId, coverData, pipe)) { dontAllow = true; } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java index 5f91c2acd1..d25f92b58b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java @@ -1,10 +1,13 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.D1; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; + import cpw.mods.fml.common.Optional; import gregtech.GT_Mod; import gregtech.api.GregTech_API; -import gregtech.api.enums.ParticleFX; import gregtech.api.enums.*; +import gregtech.api.enums.ParticleFX; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; @@ -17,6 +20,8 @@ import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; import gregtech.common.GT_Client; import gregtech.common.covers.GT_Cover_Drain; import gregtech.common.covers.GT_Cover_FluidRegulator; +import java.util.ArrayList; +import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -32,12 +37,6 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import org.apache.commons.lang3.tuple.MutableTriple; -import java.util.ArrayList; -import java.util.List; - -import static gregtech.api.enums.GT_Values.D1; -import static gregtech.api.objects.XSTR.XSTR_INSTANCE; - public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { public final float mThickNess; public final Materials mMaterial; @@ -50,11 +49,28 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { */ public byte mDisableInput = 0; - public GT_MetaPipeEntity_Fluid(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof) { + public GT_MetaPipeEntity_Fluid( + int aID, + String aName, + String aNameRegional, + float aThickNess, + Materials aMaterial, + int aCapacity, + int aHeatResistance, + boolean aGasProof) { this(aID, aName, aNameRegional, aThickNess, aMaterial, aCapacity, aHeatResistance, aGasProof, 1); } - public GT_MetaPipeEntity_Fluid(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof, int aFluidTypes) { + public GT_MetaPipeEntity_Fluid( + int aID, + String aName, + String aNameRegional, + float aThickNess, + Materials aMaterial, + int aCapacity, + int aHeatResistance, + boolean aGasProof, + int aFluidTypes) { super(aID, aName, aNameRegional, 0, false); mThickNess = aThickNess; mMaterial = aMaterial; @@ -67,11 +83,24 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { } @Deprecated - public GT_MetaPipeEntity_Fluid(String aName, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof) { + public GT_MetaPipeEntity_Fluid( + String aName, + float aThickNess, + Materials aMaterial, + int aCapacity, + int aHeatResistance, + boolean aGasProof) { this(aName, aThickNess, aMaterial, aCapacity, aHeatResistance, aGasProof, 1); } - public GT_MetaPipeEntity_Fluid(String aName, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof, int aFluidTypes) { + public GT_MetaPipeEntity_Fluid( + String aName, + float aThickNess, + Materials aMaterial, + int aCapacity, + int aHeatResistance, + boolean aGasProof, + int aFluidTypes) { super(aName, 0); mThickNess = aThickNess; mMaterial = aMaterial; @@ -89,14 +118,27 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaPipeEntity_Fluid(mName, mThickNess, mMaterial, mCapacity, mHeatResistance, mGasProof, mPipeAmount); + return new GT_MetaPipeEntity_Fluid( + mName, mThickNess, mMaterial, mCapacity, mHeatResistance, mGasProof, mPipeAmount); } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aConnections, + byte aColorIndex, + boolean aConnected, + boolean aRedstone) { float tThickNess = getThickNess(); if (mDisableInput == 0) - return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; + return new ITexture[] { + aConnected + ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) + : TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) + }; byte tMask = 0; byte[][] sRestrictionArray = { {2, 3, 5, 4}, @@ -108,30 +150,51 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { }; if (aSide >= 0 && aSide < 6) { for (byte i = 0; i < 4; i++) if (isInputDisabledAtSide(sRestrictionArray[aSide][i])) tMask |= 1 << i; - //Full block size renderer flips side 5 and 2 textures, flip restrictor textures to compensate - if (aSide == 5 || aSide == 2) - if (tMask > 3 && tMask < 12) - tMask = (byte) (tMask ^ 12); - } - return new ITexture[]{aConnected ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) : TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), getRestrictorTexture(tMask)}; + // Full block size renderer flips side 5 and 2 textures, flip restrictor textures to compensate + if (aSide == 5 || aSide == 2) if (tMask > 3 && tMask < 12) tMask = (byte) (tMask ^ 12); + } + return new ITexture[] { + aConnected + ? getBaseTexture(tThickNess, mPipeAmount, mMaterial, aColorIndex) + : TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), + getRestrictorTexture(tMask) + }; } protected static ITexture getBaseTexture(float aThickNess, int aPipeAmount, Materials aMaterial, byte aColorIndex) { if (aPipeAmount >= 9) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeNonuple.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeNonuple.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); if (aPipeAmount >= 4) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeQuadruple.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeQuadruple.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); if (aThickNess < 0.124F) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); if (aThickNess < 0.374F) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); if (aThickNess < 0.499F) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); if (aThickNess < 0.749F) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); if (aThickNess < 0.874F) - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); - return TextureFactory.of(aMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); + return TextureFactory.of( + aMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], + Dyes.getModulation(aColorIndex, aMaterial.mRGBa)); } protected static ITexture getRestrictorTexture(byte aMask) { @@ -236,14 +299,19 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Override public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) { - if ((((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase) { + if ((((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections & -128) == 0 + && aEntity instanceof EntityLivingBase) { for (FluidStack tFluid : mFluids) { if (tFluid != null) { int tTemperature = tFluid.getFluid().getTemperature(tFluid); - if (tTemperature > 320 && !isCoverOnSide((BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity)) { + if (tTemperature > 320 + && !isCoverOnSide( + (BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity)) { GT_Utility.applyHeatDamage((EntityLivingBase) aEntity, (tTemperature - 300) / 50.0F); break; - } else if (tTemperature < 260 && !isCoverOnSide((BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity)) { + } else if (tTemperature < 260 + && !isCoverOnSide( + (BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity)) { GT_Utility.applyFrostDamage((EntityLivingBase) aEntity, (270 - tTemperature) / 25.0F); break; } @@ -278,7 +346,6 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { } oLastReceivedFrom = mLastReceivedFrom; - } } @@ -291,21 +358,36 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { if (tTemperature > mHeatResistance) { if (aBaseMetaTileEntity.getRandomNumber(100) == 0) { // Poof - GT_Log.exp.println("Set Pipe to Fire due to to low heat resistance at " + aBaseMetaTileEntity.getXCoord() + " | " + aBaseMetaTileEntity.getYCoord() + " | " + aBaseMetaTileEntity.getZCoord() + " DIMID: " + aBaseMetaTileEntity.getWorld().provider.dimensionId); + GT_Log.exp.println( + "Set Pipe to Fire due to to low heat resistance at " + aBaseMetaTileEntity.getXCoord() + + " | " + aBaseMetaTileEntity.getYCoord() + " | " + aBaseMetaTileEntity.getZCoord() + + " DIMID: " + aBaseMetaTileEntity.getWorld().provider.dimensionId); aBaseMetaTileEntity.setToFire(); return true; } // Mmhmm, Fire aBaseMetaTileEntity.setOnFire(); - GT_Log.exp.println("Set Blocks around Pipe to Fire due to to low heat resistance at " + aBaseMetaTileEntity.getXCoord() + " | " + aBaseMetaTileEntity.getYCoord() + " | " + aBaseMetaTileEntity.getZCoord() + " DIMID: " + aBaseMetaTileEntity.getWorld().provider.dimensionId); - + GT_Log.exp.println("Set Blocks around Pipe to Fire due to to low heat resistance at " + + aBaseMetaTileEntity.getXCoord() + " | " + aBaseMetaTileEntity.getYCoord() + " | " + + aBaseMetaTileEntity.getZCoord() + " DIMID: " + + aBaseMetaTileEntity.getWorld().provider.dimensionId); } if (!mGasProof && tFluid.getFluid().isGaseous(tFluid)) { tFluid.amount -= 5; sendSound((byte) 9); if (tTemperature > 320) { try { - for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getXCoord() - 2, getBaseMetaTileEntity().getYCoord() - 2, getBaseMetaTileEntity().getZCoord() - 2, getBaseMetaTileEntity().getXCoord() + 3, getBaseMetaTileEntity().getYCoord() + 3, getBaseMetaTileEntity().getZCoord() + 3))) { + for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity() + .getWorld() + .getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + getBaseMetaTileEntity().getXCoord() - 2, + getBaseMetaTileEntity().getYCoord() - 2, + getBaseMetaTileEntity().getZCoord() - 2, + getBaseMetaTileEntity().getXCoord() + 3, + getBaseMetaTileEntity().getYCoord() + 3, + getBaseMetaTileEntity().getZCoord() + 3))) { GT_Utility.applyHeatDamage(tLiving, (tTemperature - 300) / 25.0F); } } catch (Throwable e) { @@ -313,7 +395,17 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { } } else if (tTemperature < 260) { try { - for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getXCoord() - 2, getBaseMetaTileEntity().getYCoord() - 2, getBaseMetaTileEntity().getZCoord() - 2, getBaseMetaTileEntity().getXCoord() + 3, getBaseMetaTileEntity().getYCoord() + 3, getBaseMetaTileEntity().getZCoord() + 3))) { + for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity() + .getWorld() + .getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + getBaseMetaTileEntity().getXCoord() - 2, + getBaseMetaTileEntity().getYCoord() - 2, + getBaseMetaTileEntity().getZCoord() - 2, + getBaseMetaTileEntity().getXCoord() + 3, + getBaseMetaTileEntity().getYCoord() + 3, + getBaseMetaTileEntity().getZCoord() + 3))) { GT_Utility.applyFrostDamage(tLiving, (270 - tTemperature) / 12.5F); } } catch (Throwable e) { @@ -341,9 +433,25 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { final IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aSide); final IGregTechTileEntity gTank = tTank instanceof IGregTechTileEntity ? (IGregTechTileEntity) tTank : null; - if (isConnectedAtSide(aSide) && tTank != null && (mLastReceivedFrom & (1 << aSide)) == 0 && - getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).letsFluidOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), tFluid.getFluid(), getBaseMetaTileEntity()) && - (gTank == null || gTank.getCoverBehaviorAtSideNew(tSide).letsFluidIn(tSide, gTank.getCoverIDAtSide(tSide), gTank.getComplexCoverDataAtSide(tSide), tFluid.getFluid(), gTank))) { + if (isConnectedAtSide(aSide) + && tTank != null + && (mLastReceivedFrom & (1 << aSide)) == 0 + && getBaseMetaTileEntity() + .getCoverBehaviorAtSideNew(aSide) + .letsFluidOut( + aSide, + getBaseMetaTileEntity().getCoverIDAtSide(aSide), + getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), + tFluid.getFluid(), + getBaseMetaTileEntity()) + && (gTank == null + || gTank.getCoverBehaviorAtSideNew(tSide) + .letsFluidIn( + tSide, + gTank.getCoverIDAtSide(tSide), + gTank.getComplexCoverDataAtSide(tSide), + tFluid.getFluid(), + gTank))) { if (tTank.fill(ForgeDirection.getOrientation(tSide), tFluid, false) > 0) { tTanks.add(new MutableTriple<>(tTank, ForgeDirection.getOrientation(tSide), 0)); } @@ -366,9 +474,12 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { // Now distribute for (MutableTriple<IFluidHandler, ForgeDirection, Integer> tEntry : tTanks) { if (availableCapacity > tAmount) - tEntry.right = (int) Math.floor(tEntry.right * tAmount / availableCapacity); // Distribue fluids based on percentage available space at destination + tEntry.right = (int) Math.floor(tEntry.right + * tAmount + / availableCapacity); // Distribue fluids based on percentage available space at destination if (tEntry.right == 0) - tEntry.right = (int) Math.min(1, tAmount); // If the percent is not enough to give at least 1L, try to give 1L + tEntry.right = + (int) Math.min(1, tAmount); // If the percent is not enough to give at least 1L, try to give 1L if (tEntry.right <= 0) continue; int tFilledAmount = tEntry.left.fill(tEntry.middle, drainFromIndex(tEntry.right, false, index), false); @@ -377,11 +488,11 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { if (mFluids[index] == null || mFluids[index].amount <= 0) return; } - } @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public boolean onWrenchRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (GT_Mod.gregtechproxy.gt6Pipe) { byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); byte tMask = (byte) (1 << tSide); @@ -389,16 +500,14 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { if (isInputDisabledAtSide(tSide)) { mDisableInput &= ~tMask; GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("212", "Input enabled")); - if (!isConnectedAtSide(tSide)) - connect(tSide); + if (!isConnectedAtSide(tSide)) connect(tSide); } else { mDisableInput |= tMask; GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("213", "Input disabled")); } } else { if (!isConnectedAtSide(tSide)) { - if (connect(tSide) > 0) - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("214", "Connected")); + if (connect(tSide) > 0) GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("214", "Connected")); } else { disconnect(tSide); GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("215", "Disconnected")); @@ -410,37 +519,49 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { } @Override - public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsIn( + GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsFluidIn(aSide, aCoverID, aCoverVariable, null, aTileEntity); } @Override - public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsOut( + GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsFluidOut(aSide, aCoverID, aCoverVariable, null, aTileEntity); } @Override - public boolean letsIn(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public boolean letsIn( + GT_CoverBehaviorBase<?> coverBehavior, + byte aSide, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity) { return coverBehavior.letsFluidIn(aSide, aCoverID, aCoverVariable, null, aTileEntity); } @Override - public boolean letsOut(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public boolean letsOut( + GT_CoverBehaviorBase<?> coverBehavior, + byte aSide, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity) { return coverBehavior.letsFluidOut(aSide, aCoverID, aCoverVariable, null, aTileEntity); } @Override public boolean canConnect(byte aSide, TileEntity tTileEntity) { - if (tTileEntity == null) - return false; + if (tTileEntity == null) return false; - final byte tSide = (byte) ForgeDirection.getOrientation(aSide).getOpposite().ordinal(); + final byte tSide = + (byte) ForgeDirection.getOrientation(aSide).getOpposite().ordinal(); final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity(); - if (baseMetaTile == null) - return false; + if (baseMetaTile == null) return false; final GT_CoverBehaviorBase<?> coverBehavior = baseMetaTile.getCoverBehaviorAtSideNew(aSide); - final IGregTechTileEntity gTileEntity = (tTileEntity instanceof IGregTechTileEntity) ? (IGregTechTileEntity) tTileEntity : null; + final IGregTechTileEntity gTileEntity = + (tTileEntity instanceof IGregTechTileEntity) ? (IGregTechTileEntity) tTileEntity : null; if (coverBehavior instanceof GT_Cover_Drain || (GregTech_API.mTConstruct && isTConstructFaucet(tTileEntity))) return true; @@ -451,9 +572,9 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { final FluidTankInfo[] tInfo = fTileEntity.getTankInfo(ForgeDirection.getOrientation(tSide)); if (tInfo != null) { return tInfo.length > 0 - || (GregTech_API.mTranslocator && isTranslocator(tTileEntity)) - || gTileEntity != null && gTileEntity.getCoverBehaviorAtSideNew(tSide) instanceof GT_Cover_FluidRegulator; - + || (GregTech_API.mTranslocator && isTranslocator(tTileEntity)) + || gTileEntity != null + && gTileEntity.getCoverBehaviorAtSideNew(tSide) instanceof GT_Cover_FluidRegulator; } } return false; @@ -484,20 +605,17 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { GT_Utility.doSoundAtClient(SoundResource.RANDOM_FIZZ, 5, 1.0F, aX, aY, aZ); new ParticleEventBuilder() - .setIdentifier(ParticleFX.CLOUD) - .setWorld(getBaseMetaTileEntity().getWorld()) - .<ParticleEventBuilder>times(6, (x, i) -> x - .setMotion( - ForgeDirection.getOrientation(i).offsetX / 5.0, - ForgeDirection.getOrientation(i).offsetY / 5.0, - ForgeDirection.getOrientation(i).offsetZ / 5.0 - ) - .setPosition( - aX - 0.5 + XSTR_INSTANCE.nextFloat(), - aY - 0.5 + XSTR_INSTANCE.nextFloat(), - aZ - 0.5 + XSTR_INSTANCE.nextFloat() - ).run() - ); + .setIdentifier(ParticleFX.CLOUD) + .setWorld(getBaseMetaTileEntity().getWorld()) + .<ParticleEventBuilder>times(6, (x, i) -> x.setMotion( + ForgeDirection.getOrientation(i).offsetX / 5.0, + ForgeDirection.getOrientation(i).offsetY / 5.0, + ForgeDirection.getOrientation(i).offsetZ / 5.0) + .setPosition( + aX - 0.5 + XSTR_INSTANCE.nextFloat(), + aY - 0.5 + XSTR_INSTANCE.nextFloat(), + aZ - 0.5 + XSTR_INSTANCE.nextFloat()) + .run()); } } @@ -509,18 +627,16 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Override public FluidTankInfo getInfo() { for (FluidStack tFluid : mFluids) { - if (tFluid != null) - return new FluidTankInfo(tFluid, mCapacity * 20); + if (tFluid != null) return new FluidTankInfo(tFluid, mCapacity * 20); } return new FluidTankInfo(null, mCapacity * 20); } @Override public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[]{}; + if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[] {}; ArrayList<FluidTankInfo> tList = new ArrayList<>(); - for (FluidStack tFluid : mFluids) - tList.add(new FluidTankInfo(tFluid, mCapacity * 20)); + for (FluidStack tFluid : mFluids) tList.add(new FluidTankInfo(tFluid, mCapacity * 20)); return tList.toArray(new FluidTankInfo[mPipeAmount]); } @@ -537,8 +653,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Override public final FluidStack getFluid() { for (FluidStack tFluid : mFluids) { - if (tFluid != null) - return tFluid; + if (tFluid != null) return tFluid; } return null; } @@ -547,8 +662,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { public final int getFluidAmount() { int rAmount = 0; for (FluidStack tFluid : mFluids) { - if (tFluid != null) - rAmount += tFluid.amount; + if (tFluid != null) rAmount += tFluid.amount; } return rAmount; } @@ -611,8 +725,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { public final FluidStack drain(int maxDrain, boolean doDrain) { FluidStack drained; for (int i = 0; i < mPipeAmount; i++) { - if ((drained = drainFromIndex(maxDrain, doDrain, i)) != null) - return drained; + if ((drained = drainFromIndex(maxDrain, doDrain, i)) != null) return drained; } return null; } @@ -626,8 +739,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { } int used = maxDrain; - if (mFluids[index].amount < used) - used = mFluids[index].amount; + if (mFluids[index].amount < used) used = mFluids[index].amount; if (doDrain) { mFluids[index].amount -= used; @@ -651,14 +763,18 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Override public String[] getDescription() { if (mPipeAmount == 1) { - return new String[]{ - EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + GT_Utility.formatNumbers(mCapacity * 20L) + "%%% L/sec" + EnumChatFormatting.GRAY, - EnumChatFormatting.RED + "Heat Limit: %%%" + GT_Utility.formatNumbers(mHeatResistance) + "%%% K" + EnumChatFormatting.GRAY + return new String[] { + EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + GT_Utility.formatNumbers(mCapacity * 20L) + + "%%% L/sec" + EnumChatFormatting.GRAY, + EnumChatFormatting.RED + "Heat Limit: %%%" + GT_Utility.formatNumbers(mHeatResistance) + "%%% K" + + EnumChatFormatting.GRAY }; } else { - return new String[]{ - EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + GT_Utility.formatNumbers(mCapacity * 20L) + "%%% L/sec" + EnumChatFormatting.GRAY, - EnumChatFormatting.RED + "Heat Limit: %%%" + GT_Utility.formatNumbers(mHeatResistance) + "%%% K" + EnumChatFormatting.GRAY, + return new String[] { + EnumChatFormatting.BLUE + "Fluid Capacity: %%%" + GT_Utility.formatNumbers(mCapacity * 20L) + + "%%% L/sec" + EnumChatFormatting.GRAY, + EnumChatFormatting.RED + "Heat Limit: %%%" + GT_Utility.formatNumbers(mHeatResistance) + "%%% K" + + EnumChatFormatting.GRAY, EnumChatFormatting.AQUA + "Pipe Amount: %%%" + mPipeAmount + EnumChatFormatting.GRAY }; } @@ -688,8 +804,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1); - else - return getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + else return getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); } private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { @@ -734,11 +849,19 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { if ((tConn & (1 << ForgeDirection.WEST.ordinal())) != 0) tSide4 = 0f; if ((tConn & (1 << ForgeDirection.EAST.ordinal())) != 0) tSide5 = 1f; - return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); + return AxisAlignedBB.getBoundingBox( + aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); } @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) { + public void addCollisionBoxesToList( + World aWorld, + int aX, + int aY, + int aZ, + AxisAlignedBB inputAABB, + List<AxisAlignedBB> outputAABB, + Entity collider) { super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) { AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); @@ -748,12 +871,10 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Override public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { - if (aFluid == null) - return null; + if (aFluid == null) return null; for (int i = 0; i < mFluids.length; ++i) { final FluidStack f = mFluids[i]; - if (f == null || !f.isFluidEqual(aFluid)) - continue; + if (f == null || !f.isFluidEqual(aFluid)) continue; return drainFromIndex(aFluid.amount, doDrain, i); } return null; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java index e1677b1deb..dce130325c 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.RA; + import gregtech.api.enums.Dyes; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -16,12 +18,9 @@ import gregtech.api.util.GT_OreDictUnificator; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import static gregtech.api.enums.GT_Values.RA; - public class GT_MetaPipeEntity_Frame extends MetaPipeEntity { private static final String localizedDescFormat = GT_LanguageManager.addStringLocalization( - "gt.blockmachines.gt_frame.desc.format", - "Just something you can put covers on."); + "gt.blockmachines.gt_frame.desc.format", "Just something you can put covers on."); public final Materials mMaterial; public GT_MetaPipeEntity_Frame(int aID, String aName, String aNameRegional, Materials aMaterial) { @@ -29,8 +28,16 @@ public class GT_MetaPipeEntity_Frame extends MetaPipeEntity { mMaterial = aMaterial; GT_OreDictUnificator.registerOre(OrePrefixes.frameGt, aMaterial, getStackForm(1)); - GT_ModHandler.addCraftingRecipe(getStackForm(2), RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"SSS", "SwS", "SSS", 'S', OrePrefixes.stick.get(mMaterial)}); - RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.stick, aMaterial, 4), ItemList.Circuit_Integrated.getWithDamage(0, 4), getStackForm(1), 64, 8); + GT_ModHandler.addCraftingRecipe( + getStackForm(2), + RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.BUFFERED, + new Object[] {"SSS", "SwS", "SSS", 'S', OrePrefixes.stick.get(mMaterial)}); + RA.addAssemblerRecipe( + GT_OreDictUnificator.get(OrePrefixes.stick, aMaterial, 4), + ItemList.Circuit_Integrated.getWithDamage(0, 4), + getStackForm(1), + 64, + 8); } public GT_MetaPipeEntity_Frame(String aName, Materials aMaterial) { @@ -49,8 +56,18 @@ public class GT_MetaPipeEntity_Frame extends MetaPipeEntity { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aConnections, + byte aColorIndex, + boolean aConnected, + boolean aRedstone) { + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) + }; } @Override @@ -84,26 +101,36 @@ public class GT_MetaPipeEntity_Frame extends MetaPipeEntity { } @Override - public final void saveNBTData(NBTTagCompound aNBT) {/*Do nothing*/} + public final void saveNBTData(NBTTagCompound aNBT) { + /*Do nothing*/ + } @Override - public final void loadNBTData(NBTTagCompound aNBT) {/*Do nothing*/} + public final void loadNBTData(NBTTagCompound aNBT) { + /*Do nothing*/ + } @Override - public final boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public final boolean allowPutStack( + IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return false; } @Override - public final boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + public final boolean allowPullStack( + IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return false; } @Override - public int connect(byte aSide) {return 0;} + public int connect(byte aSide) { + return 0; + } @Override - public void disconnect(byte aSide) {/* Do nothing*/} + public void disconnect(byte aSide) { + /* Do nothing*/ + } @Override public boolean isMachineBlockUpdateRecursive() { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java index 218e064f71..c919187927 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.Textures.BlockIcons.PIPE_RESTRICTOR; + import gregtech.GT_Mod; import gregtech.api.enums.Dyes; import gregtech.api.enums.GT_Values; @@ -18,6 +20,9 @@ import gregtech.api.util.GT_CoverBehaviorBase; import gregtech.api.util.GT_Utility; import gregtech.api.util.ISerializableObject; import gregtech.common.GT_Client; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -31,12 +36,6 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import static gregtech.api.enums.Textures.BlockIcons.PIPE_RESTRICTOR; - public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileEntityItemPipe { public final float mThickNess; public final Materials mMaterial; @@ -47,7 +46,16 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE public boolean mIsRestrictive = false; private int[] cacheSides; - public GT_MetaPipeEntity_Item(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, int aInvSlotCount, int aStepSize, boolean aIsRestrictive, int aTickTime) { + public GT_MetaPipeEntity_Item( + int aID, + String aName, + String aNameRegional, + float aThickNess, + Materials aMaterial, + int aInvSlotCount, + int aStepSize, + boolean aIsRestrictive, + int aTickTime) { super(aID, aName, aNameRegional, aInvSlotCount, false); mIsRestrictive = aIsRestrictive; mThickNess = aThickNess; @@ -57,11 +65,26 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE addInfo(aID); } - public GT_MetaPipeEntity_Item(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, int aInvSlotCount, int aStepSize, boolean aIsRestrictive) { + public GT_MetaPipeEntity_Item( + int aID, + String aName, + String aNameRegional, + float aThickNess, + Materials aMaterial, + int aInvSlotCount, + int aStepSize, + boolean aIsRestrictive) { this(aID, aName, aNameRegional, aThickNess, aMaterial, aInvSlotCount, aStepSize, aIsRestrictive, 20); } - public GT_MetaPipeEntity_Item(String aName, float aThickNess, Materials aMaterial, int aInvSlotCount, int aStepSize, boolean aIsRestrictive, int aTickTime) { + public GT_MetaPipeEntity_Item( + String aName, + float aThickNess, + Materials aMaterial, + int aInvSlotCount, + int aStepSize, + boolean aIsRestrictive, + int aTickTime) { super(aName, aInvSlotCount); mIsRestrictive = aIsRestrictive; mThickNess = aThickNess; @@ -77,43 +100,113 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaPipeEntity_Item(mName, mThickNess, mMaterial, mInventory.length, mStepSize, mIsRestrictive, mTickTime); + return new GT_MetaPipeEntity_Item( + mName, mThickNess, mMaterial, mInventory.length, mStepSize, mIsRestrictive, mTickTime); } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aConnections, + byte aColorIndex, + boolean aConnected, + boolean aRedstone) { if (mIsRestrictive) { if (aConnected) { float tThickNess = getThickNess(); if (tThickNess < 0.124F) - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), TextureFactory.of(PIPE_RESTRICTOR)}; - if (tThickNess < 0.374F)//0.375 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), TextureFactory.of(PIPE_RESTRICTOR)}; - if (tThickNess < 0.499F)//0.500 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), TextureFactory.of(PIPE_RESTRICTOR)}; - if (tThickNess < 0.749F)//0.750 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), TextureFactory.of(PIPE_RESTRICTOR)}; - if (tThickNess < 0.874F)//0.825 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), TextureFactory.of(PIPE_RESTRICTOR)}; - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), TextureFactory.of(PIPE_RESTRICTOR)}; + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), + TextureFactory.of(PIPE_RESTRICTOR) + }; + if (tThickNess < 0.374F) // 0.375 + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), + TextureFactory.of(PIPE_RESTRICTOR) + }; + if (tThickNess < 0.499F) // 0.500 + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), + TextureFactory.of(PIPE_RESTRICTOR) + }; + if (tThickNess < 0.749F) // 0.750 + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), + TextureFactory.of(PIPE_RESTRICTOR) + }; + if (tThickNess < 0.874F) // 0.825 + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), + TextureFactory.of(PIPE_RESTRICTOR) + }; + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), + TextureFactory.of(PIPE_RESTRICTOR) + }; } - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), TextureFactory.of(PIPE_RESTRICTOR)}; + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), + TextureFactory.of(PIPE_RESTRICTOR) + }; } if (aConnected) { float tThickNess = getThickNess(); if (tThickNess < 0.124F) - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - if (tThickNess < 0.374F)//0.375 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - if (tThickNess < 0.499F)//0.500 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - if (tThickNess < 0.749F)//0.750 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - if (tThickNess < 0.874F)//0.825 - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) + }; + if (tThickNess < 0.374F) // 0.375 + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) + }; + if (tThickNess < 0.499F) // 0.500 + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) + }; + if (tThickNess < 0.749F) // 0.750 + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) + }; + if (tThickNess < 0.874F) // 0.825 + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) + }; + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) + }; } - return new ITexture[]{TextureFactory.of(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex], + Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) + }; } @Override @@ -149,8 +242,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE @Override public void saveNBTData(NBTTagCompound aNBT) { aNBT.setByte("mLastReceivedFrom", mLastReceivedFrom); - if (GT_Mod.gregtechproxy.gt6Pipe) - aNBT.setByte("mConnections", mConnections); + if (GT_Mod.gregtechproxy.gt6Pipe) aNBT.setByte("mConnections", mConnections); } @Override @@ -177,7 +269,9 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE for (boolean temp = true; temp && !isInventoryEmpty() && pipeCapacityCheck(); ) { temp = false; tPipeList.clear(); - for (IMetaTileEntityItemPipe tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes(this, new HashMap<>(), 0, false, false)).keySet()) { + for (IMetaTileEntityItemPipe tTileEntity : GT_Utility.sortMapByValuesAcending( + IMetaTileEntityItemPipe.Util.scanPipes(this, new HashMap<>(), 0, false, false)) + .keySet()) { if (temp) break; tPipeList.add(tTileEntity); while (!temp && !isInventoryEmpty() && tTileEntity.sendItemStack(aBaseMetaTileEntity)) @@ -193,15 +287,15 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE } @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public boolean onWrenchRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (GT_Mod.gregtechproxy.gt6Pipe) { byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); if (isConnectedAtSide(tSide)) { disconnect(tSide); GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("215", "Disconnected")); } else { - if (connect(tSide) > 0) - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("214", "Connected")); + if (connect(tSide) > 0) GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("214", "Connected")); } return true; } @@ -209,22 +303,34 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE } @Override - public boolean letsIn(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsIn( + GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsItemsIn(aSide, aCoverID, aCoverVariable, -1, aTileEntity); } @Override - public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + public boolean letsOut( + GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return coverBehavior.letsItemsOut(aSide, aCoverID, aCoverVariable, -1, aTileEntity); } @Override - public boolean letsIn(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public boolean letsIn( + GT_CoverBehaviorBase<?> coverBehavior, + byte aSide, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity) { return coverBehavior.letsItemsIn(aSide, aCoverID, aCoverVariable, -1, aTileEntity); } @Override - public boolean letsOut(GT_CoverBehaviorBase<?> coverBehavior, byte aSide, int aCoverID, ISerializableObject aCoverVariable, ICoverable aTileEntity) { + public boolean letsOut( + GT_CoverBehaviorBase<?> coverBehavior, + byte aSide, + int aCoverID, + ISerializableObject aCoverVariable, + ICoverable aTileEntity) { return coverBehavior.letsItemsOut(aSide, aCoverID, aCoverVariable, -1, aTileEntity); } @@ -235,7 +341,8 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE final byte tSide = GT_Utility.getOppositeSide(aSide); boolean connectable = GT_Utility.isConnectableNonInventoryPipe(tTileEntity, tSide); - final IGregTechTileEntity gTileEntity = (tTileEntity instanceof IGregTechTileEntity) ? (IGregTechTileEntity) tTileEntity : null; + final IGregTechTileEntity gTileEntity = + (tTileEntity instanceof IGregTechTileEntity) ? (IGregTechTileEntity) tTileEntity : null; if (gTileEntity != null) { if (gTileEntity.getMetaTileEntity() == null) return false; if (gTileEntity.getMetaTileEntity().connectsToItemPipe(tSide)) return true; @@ -261,7 +368,6 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE return GT_Mod.gregtechproxy.gt6Pipe; } - @Override public boolean incrementTransferCounter(int aIncrement) { mTransferredItems += aIncrement; @@ -274,7 +380,8 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE byte tOffset = (byte) getBaseMetaTileEntity().getRandomNumber(6), tSide = 0; for (byte i = 0; i < 6; i++) { tSide = (byte) ((i + tOffset) % 6); - if (isConnectedAtSide(tSide) && (isInventoryEmpty() || (tSide != mLastReceivedFrom || aSender != getBaseMetaTileEntity()))) { + if (isConnectedAtSide(tSide) + && (isInventoryEmpty() || (tSide != mLastReceivedFrom || aSender != getBaseMetaTileEntity()))) { if (insertItemStackIntoTileEntity(aSender, tSide)) return true; } } @@ -284,11 +391,31 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE @Override public boolean insertItemStackIntoTileEntity(Object aSender, byte aSide) { - if (getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).letsItemsOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), -1, getBaseMetaTileEntity())) { + if (getBaseMetaTileEntity() + .getCoverBehaviorAtSideNew(aSide) + .letsItemsOut( + aSide, + getBaseMetaTileEntity().getCoverIDAtSide(aSide), + getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), + -1, + getBaseMetaTileEntity())) { TileEntity tInventory = getBaseMetaTileEntity().getTileEntityAtSide(aSide); if (tInventory != null && !(tInventory instanceof BaseMetaPipeEntity)) { - if ((!(tInventory instanceof TileEntityHopper) && !(tInventory instanceof TileEntityDispenser)) || getBaseMetaTileEntity().getMetaIDAtSide(aSide) != GT_Utility.getOppositeSide(aSide)) { - return GT_Utility.moveMultipleItemStacks(aSender, tInventory, (byte) 6, GT_Utility.getOppositeSide(aSide), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1, 1) > 0; + if ((!(tInventory instanceof TileEntityHopper) && !(tInventory instanceof TileEntityDispenser)) + || getBaseMetaTileEntity().getMetaIDAtSide(aSide) != GT_Utility.getOppositeSide(aSide)) { + return GT_Utility.moveMultipleItemStacks( + aSender, + tInventory, + (byte) 6, + GT_Utility.getOppositeSide(aSide), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1, + 1) + > 0; } } } @@ -333,10 +460,24 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE @Override public int[] getAccessibleSlotsFromSide(int aSide) { IGregTechTileEntity tTileEntity = getBaseMetaTileEntity(); - boolean tAllow = tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, tTileEntity.getCoverIDAtSide((byte) aSide), tTileEntity.getComplexCoverDataAtSide((byte) aSide), -2, tTileEntity); + boolean tAllow = tTileEntity + .getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsIn( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getComplexCoverDataAtSide((byte) aSide), + -2, + tTileEntity) + || tTileEntity + .getCoverBehaviorAtSideNew((byte) aSide) + .letsItemsOut( + (byte) aSide, + tTileEntity.getCoverIDAtSide((byte) aSide), + tTileEntity.getComplexCoverDataAtSide((byte) aSide), + -2, + tTileEntity); if (tAllow) { - if (cacheSides == null) - cacheSides = super.getAccessibleSlotsFromSide(aSide); + if (cacheSides == null) cacheSides = super.getAccessibleSlotsFromSide(aSide); return cacheSides; } else { return GT_Values.emptyIntArray; @@ -358,11 +499,20 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE @Override public String[] getDescription() { if (mTickTime == 20) - return new String[]{"Item Capacity: %%%" + getMaxPipeCapacity() + "%%% Stacks/sec", "Routing Value: %%%" + GT_Utility.formatNumbers(mStepSize)}; + return new String[] { + "Item Capacity: %%%" + getMaxPipeCapacity() + "%%% Stacks/sec", + "Routing Value: %%%" + GT_Utility.formatNumbers(mStepSize) + }; else if (mTickTime % 20 == 0) - return new String[]{"Item Capacity: %%%" + getMaxPipeCapacity() + "%%% Stacks/%%%" + (mTickTime / 20) + "%%% sec", "Routing Value: %%%" + GT_Utility.formatNumbers(mStepSize)}; + return new String[] { + "Item Capacity: %%%" + getMaxPipeCapacity() + "%%% Stacks/%%%" + (mTickTime / 20) + "%%% sec", + "Routing Value: %%%" + GT_Utility.formatNumbers(mStepSize) + }; else - return new String[]{"Item Capacity: %%%" + getMaxPipeCapacity() + "%%% Stacks/%%%" + mTickTime + "%%% ticks", "Routing Value: %%%" + GT_Utility.formatNumbers(mStepSize)}; + return new String[] { + "Item Capacity: %%%" + getMaxPipeCapacity() + "%%% Stacks/%%%" + mTickTime + "%%% ticks", + "Routing Value: %%%" + GT_Utility.formatNumbers(mStepSize) + }; } private boolean isInventoryEmpty() { @@ -380,8 +530,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1); - else - return getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + else return getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); } private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { @@ -426,11 +575,19 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE if ((tConn & (1 << ForgeDirection.WEST.ordinal())) != 0) tSide4 = 0f; if ((tConn & (1 << ForgeDirection.EAST.ordinal())) != 0) tSide5 = 1f; - return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); + return AxisAlignedBB.getBoundingBox( + aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); } @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) { + public void addCollisionBoxesToList( + World aWorld, + int aX, + int aY, + int aZ, + AxisAlignedBB inputAABB, + List<AxisAlignedBB> outputAABB, + Entity collider) { super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x2) != 0) { AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java index 1a81e4d570..67c3c672ae 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.V; + import gregtech.api.enums.Textures; import gregtech.api.gui.*; import gregtech.api.interfaces.ITexture; @@ -15,8 +17,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; -import static gregtech.api.enums.GT_Values.V; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -30,38 +30,54 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier private long mStored = 0; private long mMax = 0; - public GT_MetaTileEntity_BasicBatteryBuffer(int aID, String aName, String aNameRegional, int aTier, String aDescription, int aSlotCount) { + public GT_MetaTileEntity_BasicBatteryBuffer( + int aID, String aName, String aNameRegional, int aTier, String aDescription, int aSlotCount) { super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); } - public GT_MetaTileEntity_BasicBatteryBuffer(String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) { + public GT_MetaTileEntity_BasicBatteryBuffer( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) { super(aName, aTier, aSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_BasicBatteryBuffer(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int aSlotCount) { + public GT_MetaTileEntity_BasicBatteryBuffer( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int aSlotCount) { super(aName, aTier, aSlotCount, aDescription, aTextures); } @Override public String[] getDescription() { - String[] desc = new String[mDescriptionArray.length + 1]; - System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); - desc[mDescriptionArray.length] = mInventory.length + " Slots"; - return desc; + String[] desc = new String[mDescriptionArray.length + 1]; + System.arraycopy(mDescriptionArray, 0, desc, 0, mDescriptionArray.length); + desc[mDescriptionArray.length] = mInventory.length + " Slots"; + return desc; } @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { ITexture[][][] rTextures = new ITexture[2][17][]; for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1]}; - rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], mInventory.length==16 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_POWER[mTier] : mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; + rTextures[0][i + 1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1]}; + rTextures[1][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], + mInventory.length == 16 + ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_POWER[mTier] + : mInventory.length > 4 + ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] + : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] + }; } return rTextures; } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { return mTextures[aSide == aFacing ? 1 : 0][aColorIndex + 1]; } @@ -247,14 +263,15 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { if (GT_ModHandler.isElectricItem(aStack) && aStack.getUnlocalizedName().startsWith("gt.metaitem.01.")) { String name = aStack.getUnlocalizedName(); - if (name.equals("gt.metaitem.01.32510") || - name.equals("gt.metaitem.01.32511") || - name.equals("gt.metaitem.01.32520") || - name.equals("gt.metaitem.01.32521") || - name.equals("gt.metaitem.01.32530") || - name.equals("gt.metaitem.01.32531")) { - if(ic2.api.item.ElectricItem.manager.getCharge(aStack)==0){ - return true;} + if (name.equals("gt.metaitem.01.32510") + || name.equals("gt.metaitem.01.32511") + || name.equals("gt.metaitem.01.32520") + || name.equals("gt.metaitem.01.32521") + || name.equals("gt.metaitem.01.32530") + || name.equals("gt.metaitem.01.32531")) { + if (ic2.api.item.ElectricItem.manager.getCharge(aStack) == 0) { + return true; + } } } return false; @@ -265,7 +282,7 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier if (!GT_Utility.isStackValid(aStack)) { return false; } - if (mInventory[aIndex]==null && GT_ModHandler.isElectricItem(aStack, this.mTier)) { + if (mInventory[aIndex] == null && GT_ModHandler.isElectricItem(aStack, this.mTier)) { return true; } return false; @@ -277,8 +294,8 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier } public long[] getStoredEnergy() { - boolean scaleOverflow =false; - boolean storedOverflow = false; + boolean scaleOverflow = false; + boolean storedOverflow = false; long tScale = getBaseMetaTileEntity().getEUCapacity(); long tStored = getBaseMetaTileEntity().getStoredEU(); long tStep = 0; @@ -289,10 +306,14 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier if (aStack.getItem() instanceof GT_MetaBase_Item) { Long[] stats = ((GT_MetaBase_Item) aStack.getItem()).getElectricStats(aStack); if (stats != null) { - if(stats[0]>Long.MAX_VALUE/2){scaleOverflow=true;} + if (stats[0] > Long.MAX_VALUE / 2) { + scaleOverflow = true; + } tScale = tScale + stats[0]; tStep = ((GT_MetaBase_Item) aStack.getItem()).getRealCharge(aStack); - if(tStep > Long.MAX_VALUE/2){storedOverflow=true;} + if (tStep > Long.MAX_VALUE / 2) { + storedOverflow = true; + } tStored = tStored + tStep; } } else if (aStack.getItem() instanceof IElectricItem) { @@ -301,11 +322,14 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier } } } - } - if(scaleOverflow){tScale=Long.MAX_VALUE;} - if(storedOverflow){tStored=Long.MAX_VALUE;} - return new long[]{tStored, tScale}; + if (scaleOverflow) { + tScale = Long.MAX_VALUE; + } + if (storedOverflow) { + tStored = Long.MAX_VALUE; + } + return new long[] {tStored, tScale}; } @Override @@ -317,15 +341,16 @@ public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_Tier count = 0; } - return new String[]{ - EnumChatFormatting.BLUE+getLocalName()+EnumChatFormatting.RESET, - "Stored Items:", - EnumChatFormatting.GREEN+GT_Utility.formatNumbers(mStored) +EnumChatFormatting.RESET+ " EU / "+ - EnumChatFormatting.YELLOW+GT_Utility.formatNumbers(mMax) +EnumChatFormatting.RESET+ " EU", - "Average input:", - GT_Utility.formatNumbers(getBaseMetaTileEntity().getAverageElectricInput())+" EU/t", - "Average output:", - GT_Utility.formatNumbers(getBaseMetaTileEntity().getAverageElectricOutput())+" EU/t"}; + return new String[] { + EnumChatFormatting.BLUE + getLocalName() + EnumChatFormatting.RESET, + "Stored Items:", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mStored) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMax) + EnumChatFormatting.RESET + " EU", + "Average input:", + GT_Utility.formatNumbers(getBaseMetaTileEntity().getAverageElectricInput()) + " EU/t", + "Average output:", + GT_Utility.formatNumbers(getBaseMetaTileEntity().getAverageElectricOutput()) + " EU/t" + }; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java index 8a626460fb..091c364b4f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.V; + import gregtech.api.enums.ItemList; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; @@ -18,14 +20,14 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -import static gregtech.api.enums.GT_Values.V; - public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity_BasicTank { - public GT_MetaTileEntity_BasicGenerator(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { + public GT_MetaTileEntity_BasicGenerator( + int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); } - public GT_MetaTileEntity_BasicGenerator(int aID, String aName, String aNameRegional, int aTier, String[] aDescription, ITexture... aTextures) { + public GT_MetaTileEntity_BasicGenerator( + int aID, String aName, String aNameRegional, int aTier, String[] aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); } @@ -56,8 +58,21 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[(aActive ? 5 : 0) + (aSide == aFacing ? 0 : aSide == GT_Utility.getOppositeSide(aFacing) ? 1 : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][aColorIndex + 1]; + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + return mTextures[ + (aActive ? 5 : 0) + + (aSide == aFacing + ? 0 + : aSide == GT_Utility.getOppositeSide(aFacing) + ? 1 + : aSide == 0 ? 2 : aSide == 1 ? 3 : 4)][ + aColorIndex + 1]; } @Override @@ -76,23 +91,23 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } public ITexture[] getFront(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getBack(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getBottom(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getTop(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getSides(byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getFrontActive(byte aColor) { @@ -158,7 +173,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public boolean doesFillContainers() { return getBaseMetaTileEntity().isAllowedToWork(); - //return false; + // return false; } @Override @@ -193,7 +208,7 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public boolean isLiquidOutput(byte aSide) { - //return super.isLiquidOutput(aSide); + // return super.isLiquidOutput(aSide); return false; } @@ -206,39 +221,50 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity } else { if (mInventory[getStackDisplaySlot()] == null) mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - mInventory[getStackDisplaySlot()].setStackDisplayName("Draining internal buffer: " + GT_Utility.formatNumbers(aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); + mInventory[getStackDisplaySlot()].setStackDisplayName("Draining internal buffer: " + + GT_Utility.formatNumbers( + aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + + " EU"); } } else { long tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount >= tConsumed) { - long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); - //long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);//TODO CHECK - if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) { + long tFluidAmountToUse = Math.min( + mFluid.amount / tConsumed, + (maxEUStore() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); + // long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + + // getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue);//TODO CHECK + if (tFluidAmountToUse > 0 + && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) { // divided by two because this is called every 10 ticks, not 20 - GT_Pollution.addPollution(getBaseMetaTileEntity(),getPollution()/2); + GT_Pollution.addPollution(getBaseMetaTileEntity(), getPollution() / 2); mFluid.amount -= tFluidAmountToUse * tConsumed; } } } - if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && ((GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) != null) || solidFuelOverride(mInventory[getInputSlot()]))) { + if (mInventory[getInputSlot()] != null + && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) + && ((GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) != null) + || solidFuelOverride(mInventory[getInputSlot()]))) { long tFuelValue = getFuelValue(mInventory[getInputSlot()]); if (tFuelValue <= 0) tFuelValue = getFuelValue(mInventory[getInputSlot()], true); - //System.out.println(" tFuelValue : " + tFuelValue ); + // System.out.println(" tFuelValue : " + tFuelValue ); if (tFuelValue > 0) { ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]); if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); // divided by two because this is called every 10 ticks, not 20 - GT_Pollution.addPollution(getBaseMetaTileEntity(),getPollution()/2); + GT_Pollution.addPollution(getBaseMetaTileEntity(), getPollution() / 2); } } } } if (aBaseMetaTileEntity.isServerSide()) - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); + aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() + && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); } /** @@ -246,18 +272,24 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity * @return if the stack is a solid fuel */ public boolean solidFuelOverride(ItemStack stack) { - //this could be used for a coal generator for example aswell... + // this could be used for a coal generator for example aswell... ItemData association = GT_OreDictUnificator.getAssociation(stack); - //if it is a gregtech Item, make sure its not a VOLUMETRIC_FLASK or any type of cell, else do vanilla checks + // if it is a gregtech Item, make sure its not a VOLUMETRIC_FLASK or any type of cell, else do vanilla checks if (association != null) { - return !OrePrefixes.CELL_TYPES.contains(association.mPrefix) && - !GT_Utility.areStacksEqual(ItemList.VOLUMETRIC_FLASK.get(1L), stack, true); + return !OrePrefixes.CELL_TYPES.contains(association.mPrefix) + && !GT_Utility.areStacksEqual(ItemList.VOLUMETRIC_FLASK.get(1L), stack, true); } else { - return stack != null && //when the stack is null its not a solid - stack.getItem() != null && //when the item in the stack is null its not a solid - !(stack.getItem() instanceof IFluidContainerItem) && //when the item is a fluid container its not a solid... - !(stack.getItem() instanceof IFluidHandler) && //when the item is a fluid handler its not a solid... - !stack.getItem().getUnlocalizedName().contains("bucket"); //since we cant really check for buckets... + return stack != null + && // when the stack is null its not a solid + stack.getItem() != null + && // when the item in the stack is null its not a solid + !(stack.getItem() instanceof IFluidContainerItem) + && // when the item is a fluid container its not a solid... + !(stack.getItem() instanceof IFluidHandler) + && // when the item is a fluid handler its not a solid... + !stack.getItem() + .getUnlocalizedName() + .contains("bucket"); // since we cant really check for buckets... } } @@ -309,7 +341,9 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack, true) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true), true) > 0); + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) + && (getFuelValue(aStack, true) > 0 + || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true), true) > 0); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull.java index f6535d2ddc..31420386ee 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.V; + import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -7,22 +9,30 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import static gregtech.api.enums.GT_Values.V; - public class GT_MetaTileEntity_BasicHull extends GT_MetaTileEntity_BasicTank { - public GT_MetaTileEntity_BasicHull(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { + public GT_MetaTileEntity_BasicHull( + int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, 1, aDescription, aTextures); } - public GT_MetaTileEntity_BasicHull(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + public GT_MetaTileEntity_BasicHull( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String aDescription, + ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_BasicHull(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_BasicHull( + String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } - - public GT_MetaTileEntity_BasicHull(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + + public GT_MetaTileEntity_BasicHull( + String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } @@ -107,7 +117,13 @@ public class GT_MetaTileEntity_BasicHull extends GT_MetaTileEntity_BasicTank { } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aConnected, boolean aRedstone) { + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aConnected, + boolean aRedstone) { return mTextures[Math.min(2, aSide) + (aSide == aFacing ? 3 : 0)][aColorIndex + 1]; } @@ -115,12 +131,18 @@ public class GT_MetaTileEntity_BasicHull extends GT_MetaTileEntity_BasicTank { public ITexture[][][] getTextureSet(ITexture[] aTextures) { ITexture[][][] rTextures = new ITexture[6][17][]; for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1]}; - rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1]}; - rTextures[2][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1]}; - rTextures[3][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; - rTextures[4][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; - rTextures[5][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; + rTextures[0][i + 1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1]}; + rTextures[1][i + 1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1]}; + rTextures[2][i + 1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1]}; + rTextures[3][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] + }; + rTextures[4][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] + }; + rTextures[5][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] + }; } return rTextures; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull_NonElectric.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull_NonElectric.java index 54fe2b32a6..716d9d2c12 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull_NonElectric.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull_NonElectric.java @@ -4,20 +4,29 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; public abstract class GT_MetaTileEntity_BasicHull_NonElectric extends GT_MetaTileEntity_BasicHull { - public GT_MetaTileEntity_BasicHull_NonElectric(int aID, String aName, String aNameRegional, int aTier, String aDescription) { + public GT_MetaTileEntity_BasicHull_NonElectric( + int aID, String aName, String aNameRegional, int aTier, String aDescription) { super(aID, aName, aNameRegional, aTier, aDescription); } - public GT_MetaTileEntity_BasicHull_NonElectric(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_BasicHull_NonElectric( + String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 1, aDescription, aTextures); } - public GT_MetaTileEntity_BasicHull_NonElectric(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_BasicHull_NonElectric( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, 1, aDescription, aTextures); } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aConnections, + byte aColorIndex, + boolean aConnected, + boolean aRedstone) { return mTextures[Math.min(2, aSide)][aColorIndex + 1]; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index ce5c1b9ee4..25c7c2991e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -1,5 +1,11 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.GT_Values.debugCleanroom; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; +import static gregtech.api.util.GT_Utility.moveMultipleItemStacks; + import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; @@ -16,6 +22,8 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.common.power.BasicMachineEUPower; import gregtech.common.power.Power; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom; +import java.util.Arrays; +import java.util.List; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.minecraft.entity.player.EntityPlayer; @@ -32,34 +40,32 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; -import java.util.Arrays; -import java.util.List; - -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.debugCleanroom; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; -import static gregtech.api.util.GT_Utility.moveMultipleItemStacks; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> * This is the main construct for my Basic Machines such as the Automatic Extractor * Extend this class to make a simple Machine */ -public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank implements IConfigurationCircuitSupport { +public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank + implements IConfigurationCircuitSupport { /** * return values for checkRecipe() */ - protected static final int - DID_NOT_FIND_RECIPE = 0, + protected static final int DID_NOT_FIND_RECIPE = 0, FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; + public static final int OTHER_SLOT_COUNT = 5; public final ItemStack[] mOutputItems; public final int mInputSlotCount, mAmperage; - public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; + public boolean mAllowInputFromOutputSide = false, + mFluidTransfer = false, + mItemTransfer = false, + mHasBeenUpdated = false, + mStuttering = false, + mCharge = false, + mDecharge = false; public boolean mDisableFilter = true; public boolean mDisableMultiStack = true; public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; @@ -71,6 +77,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B * Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered */ protected GT_Recipe mLastRecipe = null; + private FluidStack mFluidOut; /** @@ -90,8 +97,26 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B * 12 = SideFacingPipeActive * 13 = SideFacingPipeInactive */ - public GT_MetaTileEntity_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { - super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); + public GT_MetaTileEntity_BasicMachine( + int aID, + String aName, + String aNameRegional, + int aTier, + int aAmperage, + String aDescription, + int aInputSlotCount, + int aOutputSlotCount, + String aGUIName, + String aNEIName, + ITexture... aOverlays) { + super( + aID, + aName, + aNameRegional, + aTier, + OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, + aDescription, + aOverlays); mInputSlotCount = Math.max(0, aInputSlotCount); mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; mAmperage = aAmperage; @@ -100,8 +125,26 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B mPower = buildPower(); } - public GT_MetaTileEntity_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String[] aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { - super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aOverlays); + public GT_MetaTileEntity_BasicMachine( + int aID, + String aName, + String aNameRegional, + int aTier, + int aAmperage, + String[] aDescription, + int aInputSlotCount, + int aOutputSlotCount, + String aGUIName, + String aNEIName, + ITexture... aOverlays) { + super( + aID, + aName, + aNameRegional, + aTier, + OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, + aDescription, + aOverlays); mInputSlotCount = Math.max(0, aInputSlotCount); mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; mAmperage = aAmperage; @@ -109,7 +152,17 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B mNEIName = aNEIName; mPower = buildPower(); } - public GT_MetaTileEntity_BasicMachine(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { + + public GT_MetaTileEntity_BasicMachine( + String aName, + int aTier, + int aAmperage, + String aDescription, + ITexture[][][] aTextures, + int aInputSlotCount, + int aOutputSlotCount, + String aGUIName, + String aNEIName) { super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); mInputSlotCount = Math.max(0, aInputSlotCount); mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; @@ -119,7 +172,16 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B mPower = buildPower(); } - public GT_MetaTileEntity_BasicMachine(String aName, int aTier, int aAmperage, String[] aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { + public GT_MetaTileEntity_BasicMachine( + String aName, + int aTier, + int aAmperage, + String[] aDescription, + ITexture[][][] aTextures, + int aInputSlotCount, + int aOutputSlotCount, + String aGUIName, + String aNEIName) { super(aName, aTier, OTHER_SLOT_COUNT + aInputSlotCount + aOutputSlotCount + 1, aDescription, aTextures); mInputSlotCount = Math.max(0, aInputSlotCount); mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; @@ -137,18 +199,18 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } protected boolean isValidMainFacing(byte aSide) { - return aSide > 1; + return aSide > 1; } - public boolean setMainFacing(byte aSide){ - if (!isValidMainFacing(aSide)) return false; - mMainFacing = aSide; - if(getBaseMetaTileEntity().getFrontFacing() == mMainFacing){ - getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aSide)); - } + public boolean setMainFacing(byte aSide) { + if (!isValidMainFacing(aSide)) return false; + mMainFacing = aSide; + if (getBaseMetaTileEntity().getFrontFacing() == mMainFacing) { + getBaseMetaTileEntity().setFrontFacing(GT_Utility.getOppositeSide(aSide)); + } onFacingChange(); onMachineBlockUpdate(); - return true; + return true; } @Override @@ -157,10 +219,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B aTextures = Arrays.copyOf(aTextures, 14); for (int i = 0; i < aTextures.length; i++) - if (aTextures[i] != null) for (byte c = -1; c < 16; c++) { - if (rTextures[i][c + 1] == null) - rTextures[i][c + 1] = new ITexture[]{MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; - } + if (aTextures[i] != null) + for (byte c = -1; c < 16; c++) { + if (rTextures[i][c + 1] == null) + rTextures[i][c + 1] = new ITexture[] {MACHINE_CASINGS[mTier][c + 1], aTextures[i]}; + } for (byte c = -1; c < 16; c++) { if (rTextures[0][c + 1] == null) rTextures[0][c + 1] = getSideFacingActive(c); @@ -182,8 +245,28 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[mMainFacing < 2 ? aSide == aFacing ? aActive ? 2 : 3 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 : aSide == mMainFacing ? aActive ? 2 : 3 : (showPipeFacing() && aSide == aFacing) ? aSide == 0 ? aActive ? 8 : 9 : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][aColorIndex + 1]; + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + return mTextures[ + mMainFacing < 2 + ? aSide == aFacing + ? aActive ? 2 : 3 + : aSide == 0 ? aActive ? 6 : 7 : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1 + : aSide == mMainFacing + ? aActive ? 2 : 3 + : (showPipeFacing() && aSide == aFacing) + ? aSide == 0 + ? aActive ? 8 : 9 + : aSide == 1 ? aActive ? 10 : 11 : aActive ? 12 : 13 + : aSide == 0 + ? aActive ? 6 : 7 + : aSide == 1 ? aActive ? 4 : 5 : aActive ? 0 : 1][ + aColorIndex + 1]; } @Override @@ -208,7 +291,10 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public boolean isValidSlot(int aIndex) { - return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != getCircuitSlot() && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; + return aIndex > 0 + && super.isValidSlot(aIndex) + && aIndex != getCircuitSlot() + && aIndex != OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; } @Override @@ -238,7 +324,9 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public boolean isLiquidInput(byte aSide) { - return aSide != mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing()); + return aSide != mMainFacing + && (mAllowInputFromOutputSide + || aSide != getBaseMetaTileEntity().getFrontFacing()); } @Override @@ -268,7 +356,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public long maxAmperesIn() { - return ((long)mEUt * 2L) / V[mTier] + 1L; + return ((long) mEUt * 2L) / V[mTier] + 1L; } @Override @@ -329,7 +417,8 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public boolean isFluidInputAllowed(FluidStack aFluid) { - return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); + return getFillableStack() != null + || (getRecipeList() != null && getRecipeList().containsInput(aFluid)); } @Override @@ -392,17 +481,17 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; - if(!GT_Mod.gregtechproxy.mForceFreeFace) { - aBaseMetaTileEntity.openGUI(aPlayer); - return true; + if (!GT_Mod.gregtechproxy.mForceFreeFace) { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; } - for(byte i=0;i < 6; i++){ - if(aBaseMetaTileEntity.getAirAtSide(i)){ - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } + for (byte i = 0; i < 6; i++) { + if (aBaseMetaTileEntity.getAirAtSide(i)) { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } } - GT_Utility.sendChatToPlayer(aPlayer,"No free Side!"); + GT_Utility.sendChatToPlayer(aPlayer, "No free Side!"); return true; } @@ -413,14 +502,22 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); + return new GT_GUIContainer_BasicMachine( + aPlayerInventory, + aBaseMetaTileEntity, + getLocalName(), + mGUIName, + GT_Utility.isStringValid(mNEIName) + ? mNEIName + : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); } @Override public void initDefaultModes(NBTTagCompound aNBT) { mMainFacing = -1; if (!getBaseMetaTileEntity().getWorld().isRemote) { - GT_ClientPreference tPreference = GT_Mod.gregtechproxy.getClientPreference(getBaseMetaTileEntity().getOwnerUuid()); + GT_ClientPreference tPreference = GT_Mod.gregtechproxy.getClientPreference( + getBaseMetaTileEntity().getOwnerUuid()); if (tPreference != null) { mDisableFilter = !tPreference.isSingleBlockInitialFilterEnabled(); mDisableMultiStack = !tPreference.isSingleBlockInitialMultiStackEnabled(); @@ -487,8 +584,8 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B if (++mProgresstime >= mMaxProgresstime) { for (int i = 0; i < mOutputItems.length; i++) for (int j = 0; j < mOutputItems.length; j++) - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) - break; + if (aBaseMetaTileEntity.addStackToSlot( + getOutputSlot() + ((j + i) % mOutputItems.length), mOutputItems[i])) break; if (mOutputFluid != null) if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); else if (mOutputFluid.isFluidEqual(getDrainableStack())) @@ -503,8 +600,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B endProcess(); } if (mProgresstime > 5) mStuttering = false; - //XSTR aXSTR = new XSTR(); - //if(GT_Mod.gregtechproxy.mAprilFool && aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); + // XSTR aXSTR = new XSTR(); + // if(GT_Mod.gregtechproxy.mAprilFool && + // aXSTR.nextInt(5000)==0)GT_Utility.sendSoundToPlayers(aBaseMetaTileEntity.getWorld(), + // GregTech_API.sSoundList.get(5), 10.0F, -1.0F, aBaseMetaTileEntity.getXCoord(), + // aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()); } else { if (!mStuttering) { stutterProcess(); @@ -518,38 +618,72 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B boolean tRemovedOutputFluid = false; - if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick % 20 == 0)) { + if (doesAutoOutputFluids() + && getDrainableStack() != null + && aBaseMetaTileEntity.getFrontFacing() != mMainFacing + && (tSucceeded || aTick % 20 == 0)) { IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); if (tTank != null) { FluidStack tDrained = drain(1000, false); if (tDrained != null) { - int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + int tFilledAmount = tTank.fill( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); if (tFilledAmount > 0) - tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true); + tTank.fill( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), + drain(tFilledAmount, true), + true); } } if (getDrainableStack() == null) tRemovedOutputFluid = true; } - if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked % 300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0)) { + if (doesAutoOutput() + && !isOutputEmpty() + && aBaseMetaTileEntity.getFrontFacing() != mMainFacing + && (tSucceeded + || mOutputBlocked % 300 == 1 + || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTick % 600 == 0)) { TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); long tStoredEnergy = aBaseMetaTileEntity.getUniversalEnergyStored(); - int tMaxStacks = (int)(tStoredEnergy/64L); - if (tMaxStacks > mOutputItems.length) - tMaxStacks = mOutputItems.length; - - moveMultipleItemStacks(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1,tMaxStacks); -// for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { -// tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, (byte) 1, (byte) 64, (byte) 1); -// if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); -// } + int tMaxStacks = (int) (tStoredEnergy / 64L); + if (tMaxStacks > mOutputItems.length) tMaxStacks = mOutputItems.length; + + moveMultipleItemStacks( + aBaseMetaTileEntity, + tTileEntity2, + aBaseMetaTileEntity.getFrontFacing(), + aBaseMetaTileEntity.getBackFacing(), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1, + tMaxStacks); + // for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && + // aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { + // tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, + // aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte) 64, + // (byte) 1, (byte) 64, (byte) 1); + // if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); + // } } - if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; - else mOutputBlocked++; + if (mOutputBlocked != 0) + if (isOutputEmpty()) mOutputBlocked = 0; + else mOutputBlocked++; if (allowToCheckRecipe()) { - if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick % 600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { + if (mMaxProgresstime <= 0 + && aBaseMetaTileEntity.isAllowedToWork() + && (tRemovedOutputFluid + || tSucceeded + || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTick % 600 == 0 + || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) + && hasEnoughEnergyToCheckRecipe()) { if (checkRecipe() == FOUND_AND_SUCCESSFULLY_USED_RECIPE) { if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) @@ -584,7 +718,8 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B // Value | Class | Field // 1 | GT_MetaTileEntity_BasicMachine | mStuttering // 64 | GT_MetaTileEntity_BasicMachine_Bronze | mNeedsSteamVenting - aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127));// | (mStuttering ? 1 : 0)); + aBaseMetaTileEntity.setErrorDisplayID( + (aBaseMetaTileEntity.getErrorDisplayID() & ~127)); // | (mStuttering ? 1 : 0)); } protected void doDisplayThings() { @@ -606,7 +741,8 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) mInventory[tDisplayStackSlot] = null; } else { - mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), true, !displaysStackSize()); + mInventory[tDisplayStackSlot] = + GT_Utility.getFluidDisplayStack(getFillableStack(), true, !displaysStackSize()); } } } @@ -649,14 +785,20 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } protected boolean canOutput(GT_Recipe aRecipe) { - return aRecipe != null && (aRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); + return aRecipe != null + && (aRecipe.mNeedsEmptyOutput + ? isOutputEmpty() && getDrainableStack() == null + : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); } protected boolean canOutput(ItemStack... aOutputs) { if (aOutputs == null) return true; ItemStack[] tOutputSlots = getAllOutputs(); for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++) - if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { + if (tOutputSlots[i] != null + && aOutputs[i] != null + && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) + || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { mOutputBlocked++; return false; } @@ -664,7 +806,11 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } protected boolean canOutput(FluidStack aOutput) { - return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity())); + return getDrainableStack() == null + || aOutput == null + || (getDrainableStack().isFluidEqual(aOutput) + && (getDrainableStack().amount <= 0 + || getDrainableStack().amount + aOutput.amount <= getCapacity())); } protected ItemStack getInputAt(int aIndex) { @@ -675,8 +821,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B int tRealInputSlotCount = this.mInputSlotCount + (allowSelectCircuit() ? 1 : 0); ItemStack[] rInputs = new ItemStack[tRealInputSlotCount]; for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i); - if (allowSelectCircuit()) - rInputs[mInputSlotCount] = getStackInSlot(getCircuitSlot()); + if (allowSelectCircuit()) rInputs[mInputSlotCount] = getStackInSlot(getCircuitSlot()); return rInputs; } @@ -771,17 +916,21 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public String[] getInfoData() { - return new String[]{ - EnumChatFormatting.BLUE + mNEIName + EnumChatFormatting.RESET, - "Progress:", - EnumChatFormatting.GREEN + GT_Utility.formatNumbers((mProgresstime/20)) + EnumChatFormatting.RESET +" s / " + - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", - "Stored Energy:", - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(getBaseMetaTileEntity().getStoredEU()) + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getBaseMetaTileEntity().getEUCapacity()) + EnumChatFormatting.RESET + " EU", - "Probably uses: " + - EnumChatFormatting.RED + GT_Utility.formatNumbers(mEUt) + EnumChatFormatting.RESET + " EU/t at " + - EnumChatFormatting.RED + GT_Utility.formatNumbers(mEUt == 0 ? 0 : mAmperage) + EnumChatFormatting.RESET +" A" + return new String[] { + EnumChatFormatting.BLUE + mNEIName + EnumChatFormatting.RESET, + "Progress:", + EnumChatFormatting.GREEN + GT_Utility.formatNumbers((mProgresstime / 20)) + EnumChatFormatting.RESET + + " s / " + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMaxProgresstime / 20) + + EnumChatFormatting.RESET + " s", + "Stored Energy:", + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(getBaseMetaTileEntity().getStoredEU()) + EnumChatFormatting.RESET + + " EU / " + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(getBaseMetaTileEntity().getEUCapacity()) + EnumChatFormatting.RESET + + " EU", + "Probably uses: " + EnumChatFormatting.RED + + GT_Utility.formatNumbers(mEUt) + EnumChatFormatting.RESET + " EU/t at " + EnumChatFormatting.RED + + GT_Utility.formatNumbers(mEUt == 0 ? 0 : mAmperage) + EnumChatFormatting.RESET + " A" }; } @@ -793,24 +942,31 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { - if (aPlayer.isSneaking()){ + if (aPlayer.isSneaking()) { mDisableFilter = !mDisableFilter; - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableFilter." + mDisableFilter)); + GT_Utility.sendChatToPlayer( + aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableFilter." + mDisableFilter)); } else { mAllowInputFromOutputSide = !mAllowInputFromOutputSide; - GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide ? GT_Utility.trans("095", "Input from Output Side allowed") : GT_Utility.trans("096", "Input from Output Side forbidden")); + GT_Utility.sendChatToPlayer( + aPlayer, + mAllowInputFromOutputSide + ? GT_Utility.trans("095", "Input from Output Side allowed") + : GT_Utility.trans("096", "Input from Output Side forbidden")); } } } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if(!aPlayer.isSneaking()) return false; + public boolean onSolderingToolRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (!aPlayer.isSneaking()) return false; boolean click = super.onSolderingToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); if (click) return true; if (aWrenchingSide != mMainFacing) return false; mDisableMultiStack = !mDisableMultiStack; - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableMultiStack." + mDisableMultiStack)); + GT_Utility.sendChatToPlayer( + aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableMultiStack." + mDisableMultiStack)); return true; } @@ -818,7 +974,12 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { if (aSide != mMainFacing) return true; GT_CoverBehaviorBase<?> tBehavior = GregTech_API.getCoverBehaviorNew(aCoverID.toStack()); - return tBehavior.isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), tBehavior.createDataObject(), getBaseMetaTileEntity());} + return tBehavior.isGUIClickable( + aSide, + GT_Utility.stackToInt(aCoverID.toStack()), + tBehavior.createDataObject(), + getBaseMetaTileEntity()); + } @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { @@ -827,10 +988,13 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) - return false; + if (aSide == mMainFacing + || aIndex < getInputSlot() + || aIndex >= getInputSlot() + mInputSlotCount + || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) return false; for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) - if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i]) && mDisableMultiStack) return i == aIndex; + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i]) && mDisableMultiStack) + return i == aIndex; return mDisableFilter || allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack); } @@ -839,7 +1003,8 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B * If mDisableMultiStack is false, before execution of this method it is ensured there is no such kind of item inside any input slots already. * Otherwise, you don't need to check for it anyway. */ - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + protected boolean allowPutStackValidated( + IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return !mDisableMultiStack || mInventory[aIndex] == null; } @@ -866,7 +1031,9 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } @Override - public int getCircuitGUISlot() { return 3; } + public int getCircuitGUISlot() { + return 3; + } @Override public List<ItemStack> getConfigurationCircuits() { @@ -893,16 +1060,15 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B return checkRecipe(false); } - public static boolean isValidForLowGravity(GT_Recipe tRecipe, int dimId){ - return //TODO check or get a better solution - DimensionManager.getProvider(dimId).getClass().getName().contains("Orbit") || - DimensionManager.getProvider(dimId).getClass().getName().endsWith("Space") || - DimensionManager.getProvider(dimId).getClass().getName().endsWith("Asteroids") || - DimensionManager.getProvider(dimId).getClass().getName().endsWith("SS") || - DimensionManager.getProvider(dimId).getClass().getName().contains("SpaceStation"); + public static boolean isValidForLowGravity(GT_Recipe tRecipe, int dimId) { + return // TODO check or get a better solution + DimensionManager.getProvider(dimId).getClass().getName().contains("Orbit") + || DimensionManager.getProvider(dimId).getClass().getName().endsWith("Space") + || DimensionManager.getProvider(dimId).getClass().getName().endsWith("Asteroids") + || DimensionManager.getProvider(dimId).getClass().getName().endsWith("SS") + || DimensionManager.getProvider(dimId).getClass().getName().contains("SpaceStation"); } - /** * * @param skipOC disables OverclockedNess calculation and check - if you do you must implement your own method... @@ -910,43 +1076,53 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B * FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, * FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; */ - public int checkRecipe(boolean skipOC){ + public int checkRecipe(boolean skipOC) { GT_Recipe_Map tMap = getRecipeList(); if (tMap == null) return DID_NOT_FIND_RECIPE; - GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[]{getFillableStack()}, getSpecialSlot(), getAllInputs()); + GT_Recipe tRecipe = tMap.findRecipe( + getBaseMetaTileEntity(), + mLastRecipe, + false, + V[mTier], + new FluidStack[] {getFillableStack()}, + getSpecialSlot(), + getAllInputs()); if (tRecipe == null) return DID_NOT_FIND_RECIPE; - if (GT_Mod.gregtechproxy.mLowGravProcessing && (tRecipe.mSpecialValue == -100 || tRecipe.mSpecialValue == -300) && - !isValidForLowGravity(tRecipe,getBaseMetaTileEntity().getWorld().provider.dimensionId)) + if (GT_Mod.gregtechproxy.mLowGravProcessing + && (tRecipe.mSpecialValue == -100 || tRecipe.mSpecialValue == -300) + && !isValidForLowGravity(tRecipe, getBaseMetaTileEntity().getWorld().provider.dimensionId)) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; if (!canOutput(tRecipe)) { mOutputBlocked++; return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } - if (tRecipe.mSpecialValue == -200 && (getCallbackBase() == null || !(getCallbackBase() instanceof GT_MetaTileEntity_Cleanroom) || ((GT_MetaTileEntity_Cleanroom) getCallbackBase()).mEfficiency == 0)) + if (tRecipe.mSpecialValue == -200 + && (getCallbackBase() == null + || !(getCallbackBase() instanceof GT_MetaTileEntity_Cleanroom) + || ((GT_MetaTileEntity_Cleanroom) getCallbackBase()).mEfficiency == 0)) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - if (!tRecipe.isRecipeInputEqual(true, new FluidStack[]{getFillableStack()}, getAllInputs())) + if (!tRecipe.isRecipeInputEqual(true, new FluidStack[] {getFillableStack()}, getAllInputs())) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 0; i < mOutputItems.length; i++) if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) mOutputItems[i] = tRecipe.getOutput(i); if (tRecipe.mSpecialValue == -200 || tRecipe.mSpecialValue == -300) for (int i = 0; i < mOutputItems.length; i++) - if (mOutputItems[i] != null && getBaseMetaTileEntity().getRandomNumber(10000) > ((GT_MetaTileEntity_Cleanroom) getCallbackBase()).mEfficiency) - { - if (debugCleanroom) { - GT_Log.out.println( - "BasicMachine: Voiding output due to efficiency failure. mEfficiency = " + - ((GT_MetaTileEntity_Cleanroom) getCallbackBase()).mEfficiency - ); - } + if (mOutputItems[i] != null + && getBaseMetaTileEntity().getRandomNumber(10000) + > ((GT_MetaTileEntity_Cleanroom) getCallbackBase()).mEfficiency) { + if (debugCleanroom) { + GT_Log.out.println("BasicMachine: Voiding output due to efficiency failure. mEfficiency = " + + ((GT_MetaTileEntity_Cleanroom) getCallbackBase()).mEfficiency); + } mOutputItems[i] = null; } mOutputFluid = tRecipe.getFluidOutput(0); - if(!skipOC){ + if (!skipOC) { calculateOverclockedNess(tRecipe); - //In case recipe is too OP for that machine + // In case recipe is too OP for that machine if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; } @@ -954,75 +1130,79 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1]}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1]}; } public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; } public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; } public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; } public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; } public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; } public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[]{MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] {MACHINE_CASINGS[mTier][aColor + 1], TextureFactory.of(OVERLAY_PIPE_OUT)}; } @Override - public void getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + public void getWailaBody( + ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { final NBTTagCompound tag = accessor.getNBTData(); - currenttip.add(String.format("Progress: %d s / %d s", tag.getInteger("progressSingleBlock"), tag.getInteger("maxProgressSingleBlock"))); + currenttip.add(String.format( + "Progress: %d s / %d s", + tag.getInteger("progressSingleBlock"), tag.getInteger("maxProgressSingleBlock"))); super.getWailaBody(itemStack, currenttip, accessor, config); } @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); tag.setInteger("progressSingleBlock", mProgresstime / 20); - tag.setInteger("maxProgressSingleBlock", mMaxProgresstime / 20); + tag.setInteger("maxProgressSingleBlock", mMaxProgresstime / 20); } public Power getPower() { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java index f185a9c246..aa893c0bc2 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java @@ -1,8 +1,12 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.D1; +import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; + import gregtech.api.GregTech_API; -import gregtech.api.enums.ParticleFX; import gregtech.api.enums.Dyes; +import gregtech.api.enums.ParticleFX; import gregtech.api.enums.SoundResource; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -14,17 +18,12 @@ import gregtech.api.util.GT_Utility; import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; import gregtech.common.power.Power; import gregtech.common.power.SteamPower; +import java.util.ArrayList; import net.minecraft.entity.EntityLivingBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; -import java.util.ArrayList; - -import static gregtech.api.enums.GT_Values.D1; -import static gregtech.api.enums.Textures.BlockIcons.*; -import static gregtech.api.objects.XSTR.XSTR_INSTANCE; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -35,15 +34,44 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE private static final int NEEDS_STEAM_VENTING = 64; public boolean mNeedsSteamVenting = false; - public GT_MetaTileEntity_BasicMachine_Bronze(int aID, String aName, String aNameRegional, String aDescription, int aInputSlotCount, int aOutputSlotCount, boolean aHighPressure) { - super(aID, aName, aNameRegional, aHighPressure ? 2 : 1, 0, aDescription, aInputSlotCount, aOutputSlotCount, "", ""); - } - - public GT_MetaTileEntity_BasicMachine_Bronze(String aName, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, boolean aHighPressure) { + public GT_MetaTileEntity_BasicMachine_Bronze( + int aID, + String aName, + String aNameRegional, + String aDescription, + int aInputSlotCount, + int aOutputSlotCount, + boolean aHighPressure) { + super( + aID, + aName, + aNameRegional, + aHighPressure ? 2 : 1, + 0, + aDescription, + aInputSlotCount, + aOutputSlotCount, + "", + ""); + } + + public GT_MetaTileEntity_BasicMachine_Bronze( + String aName, + String aDescription, + ITexture[][][] aTextures, + int aInputSlotCount, + int aOutputSlotCount, + boolean aHighPressure) { super(aName, aHighPressure ? 2 : 1, 0, aDescription, aTextures, aInputSlotCount, aOutputSlotCount, "", ""); } - public GT_MetaTileEntity_BasicMachine_Bronze(String aName, String[] aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, boolean aHighPressure) { + public GT_MetaTileEntity_BasicMachine_Bronze( + String aName, + String[] aDescription, + ITexture[][][] aTextures, + int aInputSlotCount, + int aOutputSlotCount, + boolean aHighPressure) { super(aName, aHighPressure ? 2 : 1, 0, aDescription, aTextures, aInputSlotCount, aOutputSlotCount, "", ""); } @@ -140,11 +168,53 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE @Override public boolean allowToCheckRecipe() { - if (mNeedsSteamVenting && getBaseMetaTileEntity().getCoverIDAtSide(getBaseMetaTileEntity().getFrontFacing()) == 0 && !GT_Utility.hasBlockHitBox(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1), getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1), getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1))) { + if (mNeedsSteamVenting + && getBaseMetaTileEntity() + .getCoverIDAtSide(getBaseMetaTileEntity().getFrontFacing()) + == 0 + && !GT_Utility.hasBlockHitBox( + getBaseMetaTileEntity().getWorld(), + getBaseMetaTileEntity() + .getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1), + getBaseMetaTileEntity() + .getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1), + getBaseMetaTileEntity() + .getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1))) { sendSound((byte) 9); mNeedsSteamVenting = false; try { - for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1), getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1), getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1), getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1) + 1, getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1) + 1, getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1) + 1))) { + for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>) getBaseMetaTileEntity() + .getWorld() + .getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + getBaseMetaTileEntity() + .getOffsetX( + getBaseMetaTileEntity().getFrontFacing(), 1), + getBaseMetaTileEntity() + .getOffsetY( + getBaseMetaTileEntity().getFrontFacing(), 1), + getBaseMetaTileEntity() + .getOffsetZ( + getBaseMetaTileEntity().getFrontFacing(), 1), + getBaseMetaTileEntity() + .getOffsetX( + getBaseMetaTileEntity() + .getFrontFacing(), + 1) + + 1, + getBaseMetaTileEntity() + .getOffsetY( + getBaseMetaTileEntity() + .getFrontFacing(), + 1) + + 1, + getBaseMetaTileEntity() + .getOffsetZ( + getBaseMetaTileEntity() + .getFrontFacing(), + 1) + + 1))) { GT_Utility.applyHeatDamage(tLiving, getSteamDamage()); } } catch (Throwable e) { @@ -156,8 +226,12 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE @Override public int checkRecipe() { - GT_Recipe tRecipe = getRecipeList().findRecipe(getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[mTier], null, getAllInputs()); - if ((tRecipe != null) && (canOutput(tRecipe.mOutputs)) && (tRecipe.isRecipeInputEqual(true, null, getAllInputs()))) { + GT_Recipe tRecipe = getRecipeList() + .findRecipe( + getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[mTier], null, getAllInputs()); + if ((tRecipe != null) + && (canOutput(tRecipe.mOutputs)) + && (tRecipe.isRecipeInputEqual(true, null, getAllInputs()))) { this.mOutputItems[0] = tRecipe.getOutput(0); calculateOverclockedNess(tRecipe); return 2; @@ -184,20 +258,26 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE GT_Utility.doSoundAtClient(SoundResource.RANDOM_FIZZ, 5, 1.0F, aX, aY, aZ); new ParticleEventBuilder() - .setIdentifier(ParticleFX.CLOUD) - .setWorld(getBaseMetaTileEntity().getWorld()) - .setMotion( - ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX / 5.0, - ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetY / 5.0, - ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ / 5.0 - ) - .<ParticleEventBuilder>times(8, x -> x - .setPosition( - aX - 0.5 + XSTR_INSTANCE.nextFloat(), - aY - 0.5 + XSTR_INSTANCE.nextFloat(), - aZ - 0.5 + XSTR_INSTANCE.nextFloat() - ).run() - ); + .setIdentifier(ParticleFX.CLOUD) + .setWorld(getBaseMetaTileEntity().getWorld()) + .setMotion( + ForgeDirection.getOrientation( + getBaseMetaTileEntity().getFrontFacing()) + .offsetX + / 5.0, + ForgeDirection.getOrientation( + getBaseMetaTileEntity().getFrontFacing()) + .offsetY + / 5.0, + ForgeDirection.getOrientation( + getBaseMetaTileEntity().getFrontFacing()) + .offsetZ + / 5.0) + .<ParticleEventBuilder>times(8, x -> x.setPosition( + aX - 0.5 + XSTR_INSTANCE.nextFloat(), + aY - 0.5 + XSTR_INSTANCE.nextFloat(), + aZ - 0.5 + XSTR_INSTANCE.nextFloat()) + .run()); } } @@ -208,7 +288,8 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE @Override public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return GregTech_API.getCoverBehaviorNew(aCoverID.toStack()).isSimpleCover() && super.allowCoverOnSide(aSide, aCoverID); + return GregTech_API.getCoverBehaviorNew(aCoverID.toStack()).isSimpleCover() + && super.allowCoverOnSide(aSide, aCoverID); } public float getSteamDamage() { @@ -217,71 +298,133 @@ public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileE @Override public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_SIDE : MACHINE_BRONZE_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_SIDE : MACHINE_BRONZE_SIDE, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_SIDE : MACHINE_BRONZE_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_SIDE : MACHINE_BRONZE_SIDE, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_SIDE : MACHINE_BRONZE_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_SIDE : MACHINE_BRONZE_SIDE, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_SIDE : MACHINE_BRONZE_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_SIDE : MACHINE_BRONZE_SIDE, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_TOP : MACHINE_BRONZE_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_TOP : MACHINE_BRONZE_TOP, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_TOP : MACHINE_BRONZE_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_TOP : MACHINE_BRONZE_TOP, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_BOTTOM : MACHINE_BRONZE_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_BOTTOM : MACHINE_BRONZE_BOTTOM, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_BOTTOM : MACHINE_BRONZE_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_BOTTOM : MACHINE_BRONZE_BOTTOM, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_BOTTOM : MACHINE_BRONZE_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_BOTTOM : MACHINE_BRONZE_BOTTOM, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), + TextureFactory.of(OVERLAY_PIPE_OUT) + }; } @Override public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_BOTTOM : MACHINE_BRONZE_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_BOTTOM : MACHINE_BRONZE_BOTTOM, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), + TextureFactory.of(OVERLAY_PIPE_OUT) + }; } @Override public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_TOP : MACHINE_BRONZE_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_TOP : MACHINE_BRONZE_TOP, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), + TextureFactory.of(OVERLAY_PIPE_OUT) + }; } @Override public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_TOP : MACHINE_BRONZE_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_TOP : MACHINE_BRONZE_TOP, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), + TextureFactory.of(OVERLAY_PIPE_OUT) + }; } @Override public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_SIDE : MACHINE_BRONZE_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_SIDE : MACHINE_BRONZE_SIDE, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), + TextureFactory.of(OVERLAY_PIPE_OUT) + }; } @Override public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_BRONZEBRICKS_SIDE : MACHINE_BRONZE_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_BRONZEBRICKS_SIDE : MACHINE_BRONZE_SIDE, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), + TextureFactory.of(OVERLAY_PIPE_OUT) + }; } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java index b09639e292..419ab1fb14 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java @@ -1,10 +1,16 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.GT_Values.VN; +import static gregtech.api.enums.GT_Values.W; +import static gregtech.api.enums.GT_Values.ticksBetweenSounds; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; + import cpw.mods.fml.common.Loader; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.ParticleFX; import gregtech.api.enums.*; +import gregtech.api.enums.ParticleFX; import gregtech.api.enums.Textures.BlockIcons.CustomIcon; import gregtech.api.gui.GT_Container_BasicMachine; import gregtech.api.gui.GT_GUIContainer_BasicMachine; @@ -19,6 +25,7 @@ import gregtech.api.util.GT_Utility; import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; import ic2.core.Ic2Items; +import java.util.Locale; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; @@ -28,14 +35,6 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; -import java.util.Locale; - -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.VN; -import static gregtech.api.enums.GT_Values.W; -import static gregtech.api.enums.GT_Values.ticksBetweenSounds; -import static gregtech.api.objects.XSTR.XSTR_INSTANCE; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -51,36 +50,99 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ private final byte mGUIParameterA, mGUIParameterB; public GT_MetaTileEntity_BasicMachine_GT_Recipe( - int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, - int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, ResourceLocation aSound, boolean aSharedTank, - boolean aRequiresFluidForFiltering, SpecialEffects aSpecialEffect, String aOverlays, Object[] aRecipe - ) { - super(aID, aName, aNameRegional, aTier, aRecipes.mAmperage, aDescription, aInputSlots, aOutputSlots, aGUIName, aRecipes.mNEIName, + int aID, + String aName, + String aNameRegional, + int aTier, + String aDescription, + GT_Recipe.GT_Recipe_Map aRecipes, + int aInputSlots, + int aOutputSlots, + int aTankCapacity, + int aGUIParameterA, + int aGUIParameterB, + String aGUIName, + ResourceLocation aSound, + boolean aSharedTank, + boolean aRequiresFluidForFiltering, + SpecialEffects aSpecialEffect, + String aOverlays, + Object[] aRecipe) { + super( + aID, + aName, + aNameRegional, + aTier, + aRecipes.mAmperage, + aDescription, + aInputSlots, + aOutputSlots, + aGUIName, + aRecipes.mNEIName, TextureFactory.of( - TextureFactory.of(new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE_ACTIVE")), - TextureFactory.builder().addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE_ACTIVE_GLOW"))).glow().build()), + TextureFactory.of(new CustomIcon( + "basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE_ACTIVE")), + TextureFactory.builder() + .addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + + "/OVERLAY_SIDE_ACTIVE_GLOW"))) + .glow() + .build()), TextureFactory.of( - TextureFactory.of(new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE")), - TextureFactory.builder().addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE_GLOW"))).glow().build()), + TextureFactory.of(new CustomIcon( + "basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_SIDE")), + TextureFactory.builder() + .addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + + "/OVERLAY_SIDE_GLOW"))) + .glow() + .build()), TextureFactory.of( - TextureFactory.of(new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT_ACTIVE")), - TextureFactory.builder().addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT_ACTIVE_GLOW"))).glow().build()), + TextureFactory.of(new CustomIcon( + "basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT_ACTIVE")), + TextureFactory.builder() + .addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + + "/OVERLAY_FRONT_ACTIVE_GLOW"))) + .glow() + .build()), TextureFactory.of( - TextureFactory.of(new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT")), - TextureFactory.builder().addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT_GLOW"))).glow().build()), + TextureFactory.of(new CustomIcon( + "basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_FRONT")), + TextureFactory.builder() + .addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + + "/OVERLAY_FRONT_GLOW"))) + .glow() + .build()), TextureFactory.of( - TextureFactory.of(new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP_ACTIVE")), - TextureFactory.builder().addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP_ACTIVE_GLOW"))).glow().build()), + TextureFactory.of(new CustomIcon( + "basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP_ACTIVE")), + TextureFactory.builder() + .addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + + "/OVERLAY_TOP_ACTIVE_GLOW"))) + .glow() + .build()), TextureFactory.of( - TextureFactory.of(new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP")), - TextureFactory.builder().addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP_GLOW"))).glow().build()), + TextureFactory.of(new CustomIcon( + "basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_TOP")), + TextureFactory.builder() + .addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + + "/OVERLAY_TOP_GLOW"))) + .glow() + .build()), TextureFactory.of( - TextureFactory.of(new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM_ACTIVE")), - TextureFactory.builder().addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM_ACTIVE_GLOW"))).glow().build()), + TextureFactory.of(new CustomIcon( + "basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM_ACTIVE")), + TextureFactory.builder() + .addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + + "/OVERLAY_BOTTOM_ACTIVE_GLOW"))) + .glow() + .build()), TextureFactory.of( - TextureFactory.of(new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM")), - TextureFactory.builder().addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM_GLOW"))).glow().build()) - ); + TextureFactory.of(new CustomIcon( + "basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + "/OVERLAY_BOTTOM")), + TextureFactory.builder() + .addIcon((new CustomIcon("basicmachines/" + aOverlays.toLowerCase(Locale.ENGLISH) + + "/OVERLAY_BOTTOM_GLOW"))) + .glow() + .build())); this.mSharedTank = aSharedTank; this.mTankCapacity = aTankCapacity; this.mSpecialEffect = aSpecialEffect; @@ -90,8 +152,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ this.mGUIParameterA = (byte) aGUIParameterA; this.mGUIParameterB = (byte) aGUIParameterB; - - //TODO: CHECK + // TODO: CHECK if (aRecipe != null) { for (int i = 3; i < aRecipe.length; i++) { if (aRecipe[i] == GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT) { @@ -128,12 +189,12 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ case 6: case 7: case 8: - if (Loader.isModLoaded("bartworks")) {//todo remove via provider pattern on all enums? + if (Loader.isModLoaded("bartworks")) { // todo remove via provider pattern on all enums? aRecipe[i] = "blockGlass" + VN[aTier]; break; } default: - if (Loader.isModLoaded("bartworks")) {//todo remove via provider pattern on all enums? + if (Loader.isModLoaded("bartworks")) { // todo remove via provider pattern on all enums? aRecipe[i] = "blockGlass" + VN[8]; } else { aRecipe[i] = Ic2Items.reinforcedGlass; @@ -700,26 +761,57 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ throw new IllegalArgumentException("MISSING TIER MAPPING FOR: " + aRecipe[i] + " AT TIER " + mTier); } - if ( - !GT_ModHandler.addCraftingRecipe( + if (!GT_ModHandler.addCraftingRecipe( getStackForm(1), - GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE, aRecipe - ) - ) { - throw new IllegalArgumentException("INVALID CRAFTING RECIPE FOR: " + getStackForm(1).getDisplayName()); + GT_ModHandler.RecipeBits.DISMANTLEABLE + | GT_ModHandler.RecipeBits.BUFFERED + | GT_ModHandler.RecipeBits.NOT_REMOVABLE + | GT_ModHandler.RecipeBits.REVERSIBLE, + aRecipe)) { + throw new IllegalArgumentException( + "INVALID CRAFTING RECIPE FOR: " + getStackForm(1).getDisplayName()); } } } public GT_MetaTileEntity_BasicMachine_GT_Recipe( - int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, - int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, SoundResource aSound, boolean aSharedTank, - boolean aRequiresFluidForFiltering, SpecialEffects aSpecialEffect, String aOverlays, Object[] aRecipe - ) { + int aID, + String aName, + String aNameRegional, + int aTier, + String aDescription, + GT_Recipe.GT_Recipe_Map aRecipes, + int aInputSlots, + int aOutputSlots, + int aTankCapacity, + int aGUIParameterA, + int aGUIParameterB, + String aGUIName, + SoundResource aSound, + boolean aSharedTank, + boolean aRequiresFluidForFiltering, + SpecialEffects aSpecialEffect, + String aOverlays, + Object[] aRecipe) { this( - aID, aName, aNameRegional, aTier, aDescription, aRecipes, - aInputSlots, aOutputSlots, aTankCapacity, aGUIParameterA, aGUIParameterB, aGUIName, aSound.resourceLocation, aSharedTank, - aRequiresFluidForFiltering, aSpecialEffect, aOverlays, aRecipe); + aID, + aName, + aNameRegional, + aTier, + aDescription, + aRecipes, + aInputSlots, + aOutputSlots, + aTankCapacity, + aGUIParameterA, + aGUIParameterB, + aGUIName, + aSound.resourceLocation, + aSharedTank, + aRequiresFluidForFiltering, + aSpecialEffect, + aOverlays, + aRecipe); } /** @@ -731,20 +823,63 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ */ @Deprecated public GT_MetaTileEntity_BasicMachine_GT_Recipe( - int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, - int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, - boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe - ) { - this(aID, aName, aNameRegional, aTier, aDescription, aRecipes, - aInputSlots, aOutputSlots, aTankCapacity, aGUIParameterA, aGUIParameterB, aGUIName, new ResourceLocation(aSound), aSharedTank, - aRequiresFluidForFiltering, SpecialEffects.fromId(aSpecialEffect), aOverlays, aRecipe); + int aID, + String aName, + String aNameRegional, + int aTier, + String aDescription, + GT_Recipe.GT_Recipe_Map aRecipes, + int aInputSlots, + int aOutputSlots, + int aTankCapacity, + int aGUIParameterA, + int aGUIParameterB, + String aGUIName, + String aSound, + boolean aSharedTank, + boolean aRequiresFluidForFiltering, + int aSpecialEffect, + String aOverlays, + Object[] aRecipe) { + this( + aID, + aName, + aNameRegional, + aTier, + aDescription, + aRecipes, + aInputSlots, + aOutputSlots, + aTankCapacity, + aGUIParameterA, + aGUIParameterB, + aGUIName, + new ResourceLocation(aSound), + aSharedTank, + aRequiresFluidForFiltering, + SpecialEffects.fromId(aSpecialEffect), + aOverlays, + aRecipe); } public GT_MetaTileEntity_BasicMachine_GT_Recipe( - String aName, int aTier, String aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, - int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, - boolean aRequiresFluidForFiltering, int aSpecialEffect - ) { + String aName, + int aTier, + String aDescription, + GT_Recipe.GT_Recipe_Map aRecipes, + int aInputSlots, + int aOutputSlots, + int aTankCapacity, + int aAmperage, + int aGUIParameterA, + int aGUIParameterB, + ITexture[][][] aTextures, + String aGUIName, + String aNEIName, + String aSound, + boolean aSharedTank, + boolean aRequiresFluidForFiltering, + int aSpecialEffect) { super(aName, aTier, aAmperage, aDescription, aTextures, aInputSlots, aOutputSlots, aGUIName, aNEIName); this.mSharedTank = aSharedTank; this.mTankCapacity = aTankCapacity; @@ -757,10 +892,23 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ } public GT_MetaTileEntity_BasicMachine_GT_Recipe( - String aName, int aTier, String[] aDescription, GT_Recipe.GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, - int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, - boolean aRequiresFluidForFiltering, int aSpecialEffect - ) { + String aName, + int aTier, + String[] aDescription, + GT_Recipe.GT_Recipe_Map aRecipes, + int aInputSlots, + int aOutputSlots, + int aTankCapacity, + int aAmperage, + int aGUIParameterA, + int aGUIParameterB, + ITexture[][][] aTextures, + String aGUIName, + String aNEIName, + String aSound, + boolean aSharedTank, + boolean aRequiresFluidForFiltering, + int aSpecialEffect) { super(aName, aTier, aAmperage, aDescription, aTextures, aInputSlots, aOutputSlots, aGUIName, aNEIName); this.mSharedTank = aSharedTank; this.mTankCapacity = aTankCapacity; @@ -775,10 +923,23 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_BasicMachine_GT_Recipe( - this.mName, this.mTier, this.mDescriptionArray, this.mRecipes, this.mInputSlotCount, this.mOutputItems == null ? 0 : this.mOutputItems.length, - this.mTankCapacity, this.mAmperage, this.mGUIParameterA, this.mGUIParameterB, this.mTextures, this.mGUIName, this.mNEIName, this.mSoundResourceLocation.toString(), - this.mSharedTank, this.mRequiresFluidForFiltering, this.mSpecialEffect.ordinal() - ); + this.mName, + this.mTier, + this.mDescriptionArray, + this.mRecipes, + this.mInputSlotCount, + this.mOutputItems == null ? 0 : this.mOutputItems.length, + this.mTankCapacity, + this.mAmperage, + this.mGUIParameterA, + this.mGUIParameterB, + this.mTextures, + this.mGUIName, + this.mNEIName, + this.mSoundResourceLocation.toString(), + this.mSharedTank, + this.mRequiresFluidForFiltering, + this.mSpecialEffect.ordinal()); } @Override @@ -789,61 +950,74 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_BasicMachine( - aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), this.mGUIName, - GT_Utility.isStringValid(this.mNEIName) ? this.mNEIName : this.getRecipeList() != null ? this.getRecipeList().mUnlocalizedName : "", - this.mGUIParameterA, this.mGUIParameterB - ); + aPlayerInventory, + aBaseMetaTileEntity, + this.getLocalName(), + this.mGUIName, + GT_Utility.isStringValid(this.mNEIName) + ? this.mNEIName + : this.getRecipeList() != null ? this.getRecipeList().mUnlocalizedName : "", + this.mGUIParameterA, + this.mGUIParameterB); } @Override - protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + protected boolean allowPutStackValidated( + IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { if (!super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false; switch (this.mInputSlotCount) { case 0: return false; case 1: if (this.getFillableStack() == null) - return !this.mRequiresFluidForFiltering && this.getRecipeList().containsInput(aStack); + return !this.mRequiresFluidForFiltering + && this.getRecipeList().containsInput(aStack); else - return this.getRecipeList().findRecipe( - this.getBaseMetaTileEntity(), this.mLastRecipe, true, true, V[this.mTier], new FluidStack[]{this.getFillableStack()}, - this.getSpecialSlot(), appendSelectedCircuit(aStack) - ) != null; + return this.getRecipeList() + .findRecipe( + this.getBaseMetaTileEntity(), + this.mLastRecipe, + true, + true, + V[this.mTier], + new FluidStack[] {this.getFillableStack()}, + this.getSpecialSlot(), + appendSelectedCircuit(aStack)) + != null; case 2: - - return ( - !this.mRequiresFluidForFiltering || this.getFillableStack() != null) && - ( - ( - (this.getInputAt(0) != null && this.getInputAt(1) != null) || - ( - this.getInputAt(0) == null && this.getInputAt(1) == null ? - this.getRecipeList().containsInput(aStack) : - ( - this.getRecipeList().containsInput(aStack) && - this.getRecipeList().findRecipe( - this.getBaseMetaTileEntity(), this.mLastRecipe, true, true, V[this.mTier], - new FluidStack[]{this.getFillableStack()}, - this.getSpecialSlot(), aIndex == this.getInputSlot() ? - appendSelectedCircuit(aStack, this.getInputAt(1)) : - appendSelectedCircuit(this.getInputAt(0), aStack) - ) != null - ) - ) - ) - ); + return (!this.mRequiresFluidForFiltering || this.getFillableStack() != null) + && (((this.getInputAt(0) != null && this.getInputAt(1) != null) + || (this.getInputAt(0) == null && this.getInputAt(1) == null + ? this.getRecipeList().containsInput(aStack) + : (this.getRecipeList().containsInput(aStack) + && this.getRecipeList() + .findRecipe( + this.getBaseMetaTileEntity(), + this.mLastRecipe, + true, + true, + V[this.mTier], + new FluidStack[] {this.getFillableStack()}, + this.getSpecialSlot(), + aIndex == this.getInputSlot() + ? appendSelectedCircuit( + aStack, this.getInputAt(1)) + : appendSelectedCircuit( + this.getInputAt(0), aStack)) + != null)))); default: { int tID = this.getBaseMetaTileEntity().getMetaTileID(); - if (tID >= 211 && tID <= 218 || tID >= 1180 && tID <= 1187 || tID >= 10780 && tID <= 10786) { //assembler lv-iv; circuit asseblers lv - uv; assemblers luv-uev + if (tID >= 211 && tID <= 218 + || tID >= 1180 && tID <= 1187 + || tID >= 10780 + && tID <= 10786) { // assembler lv-iv; circuit asseblers lv - uv; assemblers luv-uev if (GT_Utility.isStackValid(aStack)) for (int oreID : OreDictionary.getOreIDs(aStack)) { - if (OreDictionary.getOreName(oreID).startsWith("circuit")) - return true; + if (OreDictionary.getOreName(oreID).startsWith("circuit")) return true; } } return this.getRecipeList().containsInput(aStack); } - } } @@ -859,23 +1033,21 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ //noinspection SwitchStatementWithTooFewBranches switch (this.mSpecialEffect) { case TOP_SMOKE: - final byte topFacing = (byte) ForgeDirection.UP.ordinal(); if (aBaseMetaTileEntity.getFrontFacing() != topFacing - && aBaseMetaTileEntity.getCoverIDAtSide(topFacing) == 0 - && !aBaseMetaTileEntity.getOpacityAtSide(topFacing)) { + && aBaseMetaTileEntity.getCoverIDAtSide(topFacing) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(topFacing)) { new WorldSpawnedEventBuilder.ParticleEventBuilder() - .setMotion(0.0D, 0.0D, 0.0D) - .setIdentifier(ParticleFX.SMOKE) - .setPosition( - aBaseMetaTileEntity.getXCoord() + 0.8F - XSTR_INSTANCE.nextFloat() * 0.6F, - aBaseMetaTileEntity.getYCoord() + 0.9F + XSTR_INSTANCE.nextFloat() * 0.2F, - aBaseMetaTileEntity.getZCoord() + 0.8F - XSTR_INSTANCE.nextFloat() * 0.6F - ) - .setWorld(aBaseMetaTileEntity.getWorld()) - .run(); + .setMotion(0.0D, 0.0D, 0.0D) + .setIdentifier(ParticleFX.SMOKE) + .setPosition( + aBaseMetaTileEntity.getXCoord() + 0.8F - XSTR_INSTANCE.nextFloat() * 0.6F, + aBaseMetaTileEntity.getYCoord() + 0.9F + XSTR_INSTANCE.nextFloat() * 0.2F, + aBaseMetaTileEntity.getZCoord() + 0.8F - XSTR_INSTANCE.nextFloat() * 0.6F) + .setWorld(aBaseMetaTileEntity.getWorld()) + .run(); } break; default: @@ -902,8 +1074,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ final byte mainFacing = (byte) this.mMainFacing; if (mainFacing > 1 - && aBaseMetaTileEntity.getCoverIDAtSide(mainFacing) == 0 - && !aBaseMetaTileEntity.getOpacityAtSide(mainFacing)) { + && aBaseMetaTileEntity.getCoverIDAtSide(mainFacing) == 0 + && !aBaseMetaTileEntity.getOpacityAtSide(mainFacing)) { final double oX = aBaseMetaTileEntity.getXCoord(); final double oY = aBaseMetaTileEntity.getYCoord(); @@ -938,8 +1110,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ mZ = .05D; } - ParticleEventBuilder particleEventBuilder = - (new ParticleEventBuilder()) + ParticleEventBuilder particleEventBuilder = (new ParticleEventBuilder()) .setMotion(mX, 0, mZ) .setPosition(x, y, z) .setWorld(getBaseMetaTileEntity().getWorld()); @@ -1001,7 +1172,31 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ return !this.mSharedTank; } - public enum X {PUMP, WIRE, WIRE4, HULL, PIPE, GLASS, PLATE, MOTOR, ROTOR, SENSOR, PISTON, CIRCUIT, EMITTER, CONVEYOR, ROBOT_ARM, COIL_HEATING, COIL_ELECTRIC, STICK_MAGNETIC, STICK_DISTILLATION, BETTER_CIRCUIT, FIELD_GENERATOR, COIL_HEATING_DOUBLE, STICK_ELECTROMAGNETIC} + public enum X { + PUMP, + WIRE, + WIRE4, + HULL, + PIPE, + GLASS, + PLATE, + MOTOR, + ROTOR, + SENSOR, + PISTON, + CIRCUIT, + EMITTER, + CONVEYOR, + ROBOT_ARM, + COIL_HEATING, + COIL_ELECTRIC, + STICK_MAGNETIC, + STICK_DISTILLATION, + BETTER_CIRCUIT, + FIELD_GENERATOR, + COIL_HEATING_DOUBLE, + STICK_ELECTROMAGNETIC + } /** * Special Effects @@ -1011,11 +1206,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ TOP_SMOKE, MAIN_RANDOM_SPARKS; - static final SpecialEffects[] VALID_SPECIAL_EFFECTS = { - NONE, - TOP_SMOKE, - MAIN_RANDOM_SPARKS - }; + static final SpecialEffects[] VALID_SPECIAL_EFFECTS = {NONE, TOP_SMOKE, MAIN_RANDOM_SPARKS}; static SpecialEffects fromId(int id) { return id >= 0 && id < VALID_SPECIAL_EFFECTS.length ? VALID_SPECIAL_EFFECTS[id] : NONE; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.java index a58cf6345d..d69ab3aa14 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.java @@ -1,11 +1,5 @@ package gregtech.api.metatileentity.implementations; -import gregtech.api.enums.Dyes; -import gregtech.api.interfaces.ITexture; -import gregtech.api.render.TextureFactory; -import gregtech.common.power.Power; -import gregtech.common.power.SteamPower; - import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEELBRICKS_BOTTOM; import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE; import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEELBRICKS_TOP; @@ -14,6 +8,11 @@ import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEEL_SIDE; import static gregtech.api.enums.Textures.BlockIcons.MACHINE_STEEL_TOP; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; +import gregtech.api.enums.Dyes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; +import gregtech.common.power.Power; +import gregtech.common.power.SteamPower; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! @@ -22,15 +21,34 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; * Extend this class to make a simple Machine */ public abstract class GT_MetaTileEntity_BasicMachine_Steel extends GT_MetaTileEntity_BasicMachine_Bronze { - public GT_MetaTileEntity_BasicMachine_Steel(int aID, String aName, String aNameRegional, String aDescription, int aInputSlotCount, int aOutputSlotCount, boolean aHighPressure) { + public GT_MetaTileEntity_BasicMachine_Steel( + int aID, + String aName, + String aNameRegional, + String aDescription, + int aInputSlotCount, + int aOutputSlotCount, + boolean aHighPressure) { super(aID, aName, aNameRegional, aDescription, aInputSlotCount, aOutputSlotCount, aHighPressure); } - public GT_MetaTileEntity_BasicMachine_Steel(String aName, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, boolean aHighPressure) { + public GT_MetaTileEntity_BasicMachine_Steel( + String aName, + String aDescription, + ITexture[][][] aTextures, + int aInputSlotCount, + int aOutputSlotCount, + boolean aHighPressure) { super(aName, aDescription, aTextures, aInputSlotCount, aOutputSlotCount, aHighPressure); } - - public GT_MetaTileEntity_BasicMachine_Steel(String aName, String[] aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, boolean aHighPressure) { + + public GT_MetaTileEntity_BasicMachine_Steel( + String aName, + String[] aDescription, + ITexture[][][] aTextures, + int aInputSlotCount, + int aOutputSlotCount, + boolean aHighPressure) { super(aName, aDescription, aTextures, aInputSlotCount, aOutputSlotCount, aHighPressure); } @@ -41,71 +59,133 @@ public abstract class GT_MetaTileEntity_BasicMachine_Steel extends GT_MetaTileEn @Override public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_SIDE : MACHINE_STEEL_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_SIDE : MACHINE_STEEL_SIDE, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_SIDE : MACHINE_STEEL_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_SIDE : MACHINE_STEEL_SIDE, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_SIDE : MACHINE_STEEL_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_SIDE : MACHINE_STEEL_SIDE, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_SIDE : MACHINE_STEEL_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_SIDE : MACHINE_STEEL_SIDE, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_TOP : MACHINE_STEEL_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_TOP : MACHINE_STEEL_TOP, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_TOP : MACHINE_STEEL_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_TOP : MACHINE_STEEL_TOP, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_BOTTOM : MACHINE_STEEL_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_BOTTOM : MACHINE_STEEL_BOTTOM, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_BOTTOM : MACHINE_STEEL_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_BOTTOM : MACHINE_STEEL_BOTTOM, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)) + }; } @Override public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_BOTTOM : MACHINE_STEEL_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_BOTTOM : MACHINE_STEEL_BOTTOM, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), + TextureFactory.of(OVERLAY_PIPE_OUT) + }; } @Override public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_BOTTOM : MACHINE_STEEL_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_BOTTOM : MACHINE_STEEL_BOTTOM, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), + TextureFactory.of(OVERLAY_PIPE_OUT) + }; } @Override public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_TOP : MACHINE_STEEL_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_TOP : MACHINE_STEEL_TOP, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), + TextureFactory.of(OVERLAY_PIPE_OUT) + }; } @Override public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_TOP : MACHINE_STEEL_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_TOP : MACHINE_STEEL_TOP, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), + TextureFactory.of(OVERLAY_PIPE_OUT) + }; } @Override public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_SIDE : MACHINE_STEEL_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_SIDE : MACHINE_STEEL_SIDE, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), + TextureFactory.of(OVERLAY_PIPE_OUT) + }; } @Override public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[]{TextureFactory.of(isBricked() ? MACHINE_STEELBRICKS_SIDE : MACHINE_STEEL_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), TextureFactory.of(OVERLAY_PIPE_OUT)}; + return new ITexture[] { + TextureFactory.of( + isBricked() ? MACHINE_STEELBRICKS_SIDE : MACHINE_STEEL_SIDE, + Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), + TextureFactory.of(OVERLAY_PIPE_OUT) + }; } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java index bc031e0e6f..c1b734baf6 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java @@ -19,7 +19,8 @@ import net.minecraftforge.fluids.FluidTankInfo; * * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually */ -public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_TieredMachineBlock implements IHasFluidDisplayItem { +public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_TieredMachineBlock + implements IHasFluidDisplayItem { public FluidStack mFluid; protected int mOpenerCount; @@ -27,19 +28,35 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier /** * @param aInvSlotCount should be 3 */ - public GT_MetaTileEntity_BasicTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + public GT_MetaTileEntity_BasicTank( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String aDescription, + ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_BasicTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription, ITexture... aTextures) { + public GT_MetaTileEntity_BasicTank( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String[] aDescription, + ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_BasicTank(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_BasicTank( + String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_BasicTank(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_BasicTank( + String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } @@ -138,8 +155,7 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier public void onOpenGUI() { super.onOpenGUI(); mOpenerCount++; - if (mOpenerCount == 1) - updateFluidDisplayItem(); + if (mOpenerCount == 1) updateFluidDisplayItem(); } @Override @@ -154,23 +170,29 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0) setFillableStack(null); - if (mOpenerCount > 0) - updateFluidDisplayItem(); + if (mOpenerCount > 0) updateFluidDisplayItem(); if (doesEmptyContainers()) { FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); if (tFluid != null && isFluidInputAllowed(tFluid)) { if (getFillableStack() == null) { if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerForFilledItem(mInventory[getInputSlot()], true), 1)) { + if (aBaseMetaTileEntity.addStackToSlot( + getOutputSlot(), + GT_Utility.getContainerForFilledItem(mInventory[getInputSlot()], true), + 1)) { setFillableStack(tFluid.copy()); this.onEmptyingContainerWhenEmpty(); aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); } } } else { - if (tFluid.isFluidEqual(getFillableStack()) && ((long)tFluid.amount + getFillableStack().amount) <= (long)getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerForFilledItem(mInventory[getInputSlot()], true), 1)) { + if (tFluid.isFluidEqual(getFillableStack()) + && ((long) tFluid.amount + getFillableStack().amount) <= (long) getCapacity()) { + if (aBaseMetaTileEntity.addStackToSlot( + getOutputSlot(), + GT_Utility.getContainerForFilledItem(mInventory[getInputSlot()], true), + 1)) { getFillableStack().amount += tFluid.amount; aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); } @@ -180,7 +202,8 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier } if (doesFillContainers()) { - ItemStack tOutput = GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); + ItemStack tOutput = + GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tOutput, 1)) { FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); @@ -198,7 +221,8 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) mInventory[getStackDisplaySlot()] = null; } else { - mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), true, !displaysStackSize()); + mInventory[getStackDisplaySlot()] = + GT_Utility.getFluidDisplayStack(getDisplayedFluid(), true, !displaysStackSize()); } } } @@ -215,8 +239,11 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier @Override public int fill(FluidStack aFluid, boolean doFill) { - if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) - return 0; + if (aFluid == null + || aFluid.getFluid().getID() <= 0 + || aFluid.amount <= 0 + || !canTankBeFilled() + || !isFluidInputAllowed(aFluid)) return 0; if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { if (aFluid.amount <= getCapacity()) { @@ -234,8 +261,7 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier return getCapacity(); } - if (!getFillableStack().isFluidEqual(aFluid)) - return 0; + if (!getFillableStack().isFluidEqual(aFluid)) return 0; int space = getCapacity() - getFillableStack().amount; if (aFluid.amount <= space) { @@ -245,8 +271,7 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier } return aFluid.amount; } - if (doFill) - getFillableStack().amount = getCapacity(); + if (doFill) getFillableStack().amount = getCapacity(); return space; } @@ -260,8 +285,7 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier } int used = maxDrain; - if (getDrainableStack().amount < used) - used = getDrainableStack().amount; + if (getDrainableStack().amount < used) used = getDrainableStack().amount; if (doDrain) { getDrainableStack().amount -= used; @@ -281,14 +305,14 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier @Override public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[]{}; + if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[] {}; if (isDrainableStackSeparate()) { - return new FluidTankInfo[]{ - new FluidTankInfo(getFillableStack(), getCapacity()), - new FluidTankInfo(getDrainableStack(), getCapacity()) + return new FluidTankInfo[] { + new FluidTankInfo(getFillableStack(), getCapacity()), + new FluidTankInfo(getDrainableStack(), getCapacity()) }; } else { - return new FluidTankInfo[]{new FluidTankInfo(this)}; + return new FluidTankInfo[] {new FluidTankInfo(this)}; } } @@ -302,7 +326,7 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier return aIndex == getInputSlot(); } - protected void onEmptyingContainerWhenEmpty(){ - //Do nothing + protected void onEmptyingContainerWhenEmpty() { + // Do nothing } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index 32067744d5..e249be541e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -1,19 +1,18 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.V; +import static gregtech.api.enums.Textures.BlockIcons.*; + import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Utility; +import java.util.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -import java.util.*; - -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.Textures.BlockIcons.*; - public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredMachineBlock { private static final int OUTPUT_INDEX = 0; private static final int ARROW_RIGHT_INDEX = 1; @@ -24,22 +23,30 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM public int mMaxStackSize = 64; public static int MAX = 8; - public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = false, bSortStacks = false; + public boolean bOutput = false, + bRedstoneIfFull = false, + bInvert = false, + bStockingMode = false, + bSortStacks = false; public int mSuccess = 0, mTargetStackSize = 0; - public GT_MetaTileEntity_Buffer(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) { + public GT_MetaTileEntity_Buffer( + int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); } - public GT_MetaTileEntity_Buffer(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); + public GT_MetaTileEntity_Buffer( + int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription) { + super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); } - public GT_MetaTileEntity_Buffer(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Buffer( + String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_Buffer(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Buffer( + String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } @@ -61,18 +68,24 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM TextureFactory.of(ARROW_RIGHT), TextureFactory.builder().addIcon(ARROW_RIGHT_GLOW).glow().build()); for (int i = 0; i < rTextures[0].length; i++) { - rTextures[OUTPUT_INDEX][i] = new ITexture[]{MACHINE_CASINGS[mTier][i], tOut}; - rTextures[ARROW_RIGHT_INDEX][i] = new ITexture[]{MACHINE_CASINGS[mTier][i], tRight, tIcon}; - rTextures[ARROW_DOWN_INDEX][i] = new ITexture[]{MACHINE_CASINGS[mTier][i], tDown, tIcon}; - rTextures[ARROW_LEFT_INDEX][i] = new ITexture[]{MACHINE_CASINGS[mTier][i], tLeft, tIcon}; - rTextures[ARROW_UP_INDEX][i] = new ITexture[]{MACHINE_CASINGS[mTier][i], tUp, tIcon}; - rTextures[FRONT_INDEX][i] = new ITexture[]{MACHINE_CASINGS[mTier][i], tIcon}; + rTextures[OUTPUT_INDEX][i] = new ITexture[] {MACHINE_CASINGS[mTier][i], tOut}; + rTextures[ARROW_RIGHT_INDEX][i] = new ITexture[] {MACHINE_CASINGS[mTier][i], tRight, tIcon}; + rTextures[ARROW_DOWN_INDEX][i] = new ITexture[] {MACHINE_CASINGS[mTier][i], tDown, tIcon}; + rTextures[ARROW_LEFT_INDEX][i] = new ITexture[] {MACHINE_CASINGS[mTier][i], tLeft, tIcon}; + rTextures[ARROW_UP_INDEX][i] = new ITexture[] {MACHINE_CASINGS[mTier][i], tUp, tIcon}; + rTextures[FRONT_INDEX][i] = new ITexture[] {MACHINE_CASINGS[mTier][i], tIcon}; } return rTextures; } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { int colorIndex = aColorIndex + 1; ForgeDirection side = ForgeDirection.VALID_DIRECTIONS[aSide]; ForgeDirection facing = ForgeDirection.VALID_DIRECTIONS[aFacing]; @@ -237,9 +250,9 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM if (aNBT.hasKey("bStockingMode")) { // Adding new key to existing NBT, need to protect if it is not there. bStockingMode = aNBT.getBoolean("bStockingMode"); } - if (aNBT.hasKey("bSortStacks")) { - bSortStacks = aNBT.getBoolean("bSortStacks"); - } + if (aNBT.hasKey("bSortStacks")) { + bSortStacks = aNBT.getBoolean("bSortStacks"); + } mTargetStackSize = aNBT.getInteger("mTargetStackSize"); } @@ -253,18 +266,22 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aSide == getBaseMetaTileEntity().getBackFacing()) { - mTargetStackSize = (byte) ((mTargetStackSize + (aPlayer.isSneaking()? -1 : 1)) % 65); - if(mTargetStackSize <0){mTargetStackSize = mMaxStackSize;} + mTargetStackSize = (byte) ((mTargetStackSize + (aPlayer.isSneaking() ? -1 : 1)) % 65); + if (mTargetStackSize < 0) { + mTargetStackSize = mMaxStackSize; + } if (mTargetStackSize == 0) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("098","Do not regulate Item Stack Size")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("098", "Do not regulate Item Stack Size")); } else { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("099","Regulate Item Stack Size to: ") + mTargetStackSize); + GT_Utility.sendChatToPlayer( + aPlayer, GT_Utility.trans("099", "Regulate Item Stack Size to: ") + mTargetStackSize); } } } @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public boolean onWrenchRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { aWrenchingSide = GT_Utility.getOppositeSide(aWrenchingSide); if (getBaseMetaTileEntity().isValidFacing(aWrenchingSide)) { getBaseMetaTileEntity().setFrontFacing(aWrenchingSide); @@ -282,20 +299,22 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM break; } } - if (bInvert) - hasEmptySlots = !hasEmptySlots; + if (bInvert) hasEmptySlots = !hasEmptySlots; for (byte b = 0; b < 6; b++) aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, hasEmptySlots ? (byte) 0 : (byte) 15); - } - else { - for(byte b = 0;b<6;b++) - aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte)0); + } else { + for (byte b = 0; b < 6; b++) aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte) 0); } } @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) { + if (aBaseMetaTileEntity.isAllowedToWork() + && aBaseMetaTileEntity.isServerSide() + && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() + || aBaseMetaTileEntity.hasInventoryBeenModified() + || aTimer % 200 == 0 + || mSuccess > 0)) { mSuccess--; updateSlots(); moveItems(aBaseMetaTileEntity, aTimer); @@ -305,8 +324,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - for(byte b = 0;b<6;b++) - aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b,(byte)0); + for (byte b = 0; b < 6; b++) aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b, (byte) 0); } protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { @@ -314,15 +332,37 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM } protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer, int stacks) { - int tCost; - if (bStockingMode) - tCost = GT_Utility.moveMultipleItemStacks(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1, stacks); - else - tCost = GT_Utility.moveMultipleItemStacks(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, (byte) 64, (byte) 1, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, stacks); - - if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { - mSuccess = 50; - } + int tCost; + if (bStockingMode) + tCost = GT_Utility.moveMultipleItemStacks( + aBaseMetaTileEntity, + aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), + aBaseMetaTileEntity.getBackFacing(), + aBaseMetaTileEntity.getFrontFacing(), + null, + false, + mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, + mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, + (byte) 64, + (byte) 1, + stacks); + else + tCost = GT_Utility.moveMultipleItemStacks( + aBaseMetaTileEntity, + aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), + aBaseMetaTileEntity.getBackFacing(), + aBaseMetaTileEntity.getFrontFacing(), + null, + false, + (byte) 64, + (byte) 1, + mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, + mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, + stacks); + + if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { + mSuccess = 50; + } } @Override @@ -336,15 +376,14 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM } @Override - public boolean allowGeneralRedstoneOutput(){ - return true; + public boolean allowGeneralRedstoneOutput() { + return true; } public void updateSlots() { for (int i = 0; i < mInventory.length; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; - if (bSortStacks) - fillStacksIntoFirstSlots(); + if (bSortStacks) fillStacksIntoFirstSlots(); } protected void fillStacksIntoFirstSlots() { @@ -353,24 +392,20 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM List<GT_Utility.ItemId> order = new ArrayList<>(mInventory.length); List<Integer> validSlots = new ArrayList<>(mInventory.length); for (int i = 0; i < mInventory.length - 1; i++) { - if (!isValidSlot(i)) - continue; + if (!isValidSlot(i)) continue; validSlots.add(i); ItemStack s = mInventory[i]; - if(s == null) - continue; + if (s == null) continue; GT_Utility.ItemId sID = GT_Utility.ItemId.createNoCopy(s); slots.merge(sID, s.stackSize, Integer::sum); - if(!stacks.containsKey(sID)) - stacks.put(sID, s); + if (!stacks.containsKey(sID)) stacks.put(sID, s); order.add(sID); mInventory[i] = null; } int slotindex = 0; for (GT_Utility.ItemId sID : order) { int toSet = slots.get(sID); - if (toSet == 0) - continue; + if (toSet == 0) continue; int slot = validSlots.get(slotindex); slotindex++; mInventory[slot] = stacks.get(sID).copy(); @@ -381,14 +416,15 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM } @Override - public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public boolean onSolderingToolRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { // I was so proud of all this but I literally just copied code from OutputBus bSortStacks = !bSortStacks; - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("200", "Sort mode: " + (bSortStacks ? "Enabled" : "Disabled"))); + GT_Utility.sendChatToPlayer( + aPlayer, GT_Utility.trans("200", "Sort mode: " + (bSortStacks ? "Enabled" : "Disabled"))); return true; } - return super.onSolderingToolRightClick(aSide,aWrenchingSide,aPlayer,aX,aY,aZ); + return super.onSolderingToolRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); } - } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java index c2212e331e..e9e2e8f575 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java @@ -1,5 +1,11 @@ package gregtech.api.metatileentity.implementations; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GT_HatchElement.*; + import com.google.common.collect.ImmutableList; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IItemSource; @@ -9,17 +15,10 @@ import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.interfaces.IHatchElement; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_StructureUtility; +import java.util.List; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; -import java.util.List; - -import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.GT_HatchElement.*; - /** * A simple 3x3x3 hollow cubic multiblock, that can be arbitrarily rotated, made of a single type of machine casing and accepts hatches everywhere. * Controller will be placed in front center of the structure. @@ -35,100 +34,102 @@ import static gregtech.api.enums.GT_HatchElement.*; * * @param <T> */ -public abstract class GT_MetaTileEntity_CubicMultiBlockBase<T extends GT_MetaTileEntity_CubicMultiBlockBase<T>> extends GT_MetaTileEntity_EnhancedMultiBlockBase<T> implements ISurvivalConstructable { - protected static final String STRUCTURE_PIECE_MAIN = "main"; - protected static final ClassValue<IStructureDefinition<GT_MetaTileEntity_CubicMultiBlockBase<?>>> STRUCTURE_DEFINITION = new ClassValue<IStructureDefinition<GT_MetaTileEntity_CubicMultiBlockBase<?>>>() { - @Override - protected IStructureDefinition<GT_MetaTileEntity_CubicMultiBlockBase<?>> computeValue(Class<?> type) { - return StructureDefinition.<GT_MetaTileEntity_CubicMultiBlockBase<?>>builder() - .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ - {"hhh", "hhh", "hhh"}, - {"h~h", "h-h", "hhh"}, - {"hhh", "hhh", "hhh"}, - })) - .addElement('h', ofChain( - lazy( - t -> GT_StructureUtility.<GT_MetaTileEntity_CubicMultiBlockBase<?>>buildHatchAdder() - .atLeastList(t.getAllowedHatches()) - .casingIndex(t.getHatchTextureIndex()) - .dot(1) - .build() - ), - onElementPass( - GT_MetaTileEntity_CubicMultiBlockBase::onCorrectCasingAdded, - lazy(GT_MetaTileEntity_CubicMultiBlockBase::getCasingElement) - ) - )) - .build(); - } - }; - private int mCasingAmount = 0; - - protected GT_MetaTileEntity_CubicMultiBlockBase(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } +public abstract class GT_MetaTileEntity_CubicMultiBlockBase<T extends GT_MetaTileEntity_CubicMultiBlockBase<T>> + extends GT_MetaTileEntity_EnhancedMultiBlockBase<T> implements ISurvivalConstructable { + protected static final String STRUCTURE_PIECE_MAIN = "main"; + protected static final ClassValue<IStructureDefinition<GT_MetaTileEntity_CubicMultiBlockBase<?>>> + STRUCTURE_DEFINITION = new ClassValue<IStructureDefinition<GT_MetaTileEntity_CubicMultiBlockBase<?>>>() { + @Override + protected IStructureDefinition<GT_MetaTileEntity_CubicMultiBlockBase<?>> computeValue(Class<?> type) { + return StructureDefinition.<GT_MetaTileEntity_CubicMultiBlockBase<?>>builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][] { + {"hhh", "hhh", "hhh"}, + {"h~h", "h-h", "hhh"}, + {"hhh", "hhh", "hhh"}, + })) + .addElement( + 'h', + ofChain( + lazy(t -> + GT_StructureUtility + .<GT_MetaTileEntity_CubicMultiBlockBase<?>>buildHatchAdder() + .atLeastList(t.getAllowedHatches()) + .casingIndex(t.getHatchTextureIndex()) + .dot(1) + .build()), + onElementPass( + GT_MetaTileEntity_CubicMultiBlockBase::onCorrectCasingAdded, + lazy(GT_MetaTileEntity_CubicMultiBlockBase::getCasingElement)))) + .build(); + } + }; + private int mCasingAmount = 0; + + protected GT_MetaTileEntity_CubicMultiBlockBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } - protected GT_MetaTileEntity_CubicMultiBlockBase(String aName) { - super(aName); - } + protected GT_MetaTileEntity_CubicMultiBlockBase(String aName) { + super(aName); + } - /** - * Create a simple 3x3x3 hollow cubic structure made of a single type of machine casing and accepts hatches everywhere. - * <p> - * The created definition contains a single piece named {@link #STRUCTURE_PIECE_MAIN}. - */ - @Override - @SuppressWarnings("unchecked") - public IStructureDefinition<T> getStructureDefinition() { - return (IStructureDefinition<T>) STRUCTURE_DEFINITION.get(getClass()); - } + /** + * Create a simple 3x3x3 hollow cubic structure made of a single type of machine casing and accepts hatches everywhere. + * <p> + * The created definition contains a single piece named {@link #STRUCTURE_PIECE_MAIN}. + */ + @Override + @SuppressWarnings("unchecked") + public IStructureDefinition<T> getStructureDefinition() { + return (IStructureDefinition<T>) STRUCTURE_DEFINITION.get(getClass()); + } - @Override - public void construct(ItemStack aStack, boolean aHintsOnly) { - buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 1, 1, 0); - } + @Override + public void construct(ItemStack aStack, boolean aHintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 1, 1, 0); + } @Override public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { if (mMachine) return -1; - return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 1, 1, 0, elementBudget, source, actor,false, true); + return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 1, 1, 0, elementBudget, source, actor, false, true); } @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - mCasingAmount = 0; - return checkPiece(STRUCTURE_PIECE_MAIN, 1, 1, 0) && - mCasingAmount >= getRequiredCasingCount() && - checkHatches(aBaseMetaTileEntity, aStack); - } + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasingAmount = 0; + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 1, 0) + && mCasingAmount >= getRequiredCasingCount() + && checkHatches(aBaseMetaTileEntity, aStack); + } - /** - * Called by {@link #checkMachine(IGregTechTileEntity, ItemStack)} to check if all required hatches are present. - * <p> - * Default implementation requires EXACTLY ONE maintenance hatch to be present, and ignore all other conditions. - * - * @param aBaseMetaTileEntity the tile entity of self - * @param aStack The item stack inside the controller - * @return true if the test passes, false otherwise - */ - protected boolean checkHatches(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - return mMaintenanceHatches.size() == 1; - } + /** + * Called by {@link #checkMachine(IGregTechTileEntity, ItemStack)} to check if all required hatches are present. + * <p> + * Default implementation requires EXACTLY ONE maintenance hatch to be present, and ignore all other conditions. + * + * @param aBaseMetaTileEntity the tile entity of self + * @param aStack The item stack inside the controller + * @return true if the test passes, false otherwise + */ + protected boolean checkHatches(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + return mMaintenanceHatches.size() == 1; + } - protected abstract IStructureElement<GT_MetaTileEntity_CubicMultiBlockBase<?>> getCasingElement(); + protected abstract IStructureElement<GT_MetaTileEntity_CubicMultiBlockBase<?>> getCasingElement(); protected List<IHatchElement<? super GT_MetaTileEntity_CubicMultiBlockBase<?>>> getAllowedHatches() { return ImmutableList.of(InputHatch, OutputHatch, InputBus, OutputBus, Muffler, Maintenance, Energy); } - /** - * The hatch's texture index. - */ - protected abstract int getHatchTextureIndex(); + /** + * The hatch's texture index. + */ + protected abstract int getHatchTextureIndex(); - protected abstract int getRequiredCasingCount(); + protected abstract int getRequiredCasingCount(); - protected void onCorrectCasingAdded() { - mCasingAmount++; - } + protected void onCorrectCasingAdded() { + mCasingAmount++; + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index 1e85933522..76787fcd32 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -19,7 +19,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; - /** * Enhanced multiblock base class, featuring following improvement over {@link GT_MetaTileEntity_MultiBlockBase} * <p> @@ -28,149 +27,225 @@ import net.minecraftforge.common.util.ForgeDirection; * * @param <T> type of this */ -public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase<T extends GT_MetaTileEntity_EnhancedMultiBlockBase<T>> extends GT_MetaTileEntity_TooltipMultiBlockBase implements IAlignment, IConstructable { - private ExtendedFacing mExtendedFacing = ExtendedFacing.DEFAULT; - private IAlignmentLimits mLimits = getInitialAlignmentLimits(); - - protected GT_MetaTileEntity_EnhancedMultiBlockBase(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - protected GT_MetaTileEntity_EnhancedMultiBlockBase(String aName) { - super(aName); - } - - @Override - public ExtendedFacing getExtendedFacing() { - return mExtendedFacing; - } - - @Override - public void setExtendedFacing(ExtendedFacing newExtendedFacing) { - if (mExtendedFacing != newExtendedFacing) { - if(mMachine) - stopMachine(); - mExtendedFacing = newExtendedFacing; - final IGregTechTileEntity base = getBaseMetaTileEntity(); - mMachine = false; - mUpdated = false; - mUpdate = 100; - if (getBaseMetaTileEntity().isServerSide()) { - StructureLibAPI.sendAlignment((IAlignmentProvider) base, - new NetworkRegistry.TargetPoint(base.getWorld().provider.dimensionId, base.getXCoord(), base.getYCoord(), base.getZCoord(), 512)); - } else { - base.issueTextureUpdate(); - } - } - } - - @Override - public final boolean isFacingValid(byte aFacing) { - return canSetToDirectionAny(ForgeDirection.getOrientation(aFacing)); - } - - @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aWrenchingSide != getBaseMetaTileEntity().getFrontFacing()) - return super.onWrenchRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); - if (aPlayer.isSneaking()) { - // we won't be allowing horizontal flips, as it can be perfectly emulated by rotating twice and flipping horizontally - // allowing an extra round of flip make it hard to draw meaningful flip markers in GT_Proxy#drawGrid - toolSetFlip(getFlip().isHorizontallyFlipped() ? Flip.NONE : Flip.HORIZONTAL); - } else { - toolSetRotation(null); - } - return true; - } - - @Override - public void onFacingChange() { - toolSetDirection(ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing())); - } - - @Override - public IAlignmentLimits getAlignmentLimits() { - return mLimits; - } - - protected void setAlignmentLimits(IAlignmentLimits mLimits) { - this.mLimits = mLimits; - } - - /** - * Due to limitation of Java type system, you might need to do an unchecked cast. - * HOWEVER, the returned IStructureDefinition is expected to be evaluated against current instance only, and should - * not be used against other instances, even for those of the same class. - */ - public abstract IStructureDefinition<T> getStructureDefinition(); - - protected abstract GT_Multiblock_Tooltip_Builder createTooltip(); - - @Override - public String[] getStructureDescription(ItemStack stackSize) { - return getTooltip().getStructureHint(); - } - - protected IAlignmentLimits getInitialAlignmentLimits() { - return (d, r, f) -> !f.isVerticallyFliped(); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setByte("eRotation", (byte) mExtendedFacing.getRotation().getIndex()); - aNBT.setByte("eFlip", (byte) mExtendedFacing.getFlip().getIndex()); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mExtendedFacing = ExtendedFacing.of(ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()), - Rotation.byIndex(aNBT.getByte("eRotation")), - Flip.byIndex(aNBT.getByte("eFlip"))); - } - - @SuppressWarnings("unchecked") - private IStructureDefinition<GT_MetaTileEntity_EnhancedMultiBlockBase<T>> getCastedStructureDefinition() { - return (IStructureDefinition<GT_MetaTileEntity_EnhancedMultiBlockBase<T>>) getStructureDefinition(); - } - - /** - * Explanation of the world coordinate these offset means: - * - * Imagine you stand in front of the controller, with controller facing towards you not rotated or flipped. - * - * The horizontalOffset would be the number of blocks on the left side of the controller, not counting controller itself. - * The verticalOffset would be the number of blocks on the top side of the controller, not counting controller itself. - * The depthOffset would be the number of blocks between you and controller, not counting controller itself. - * - * All these offsets can be negative. - */ - protected final boolean checkPiece(String piece, int horizontalOffset, int verticalOffset, int depthOffset) { - final IGregTechTileEntity tTile = getBaseMetaTileEntity(); - return getCastedStructureDefinition().check(this, piece, tTile.getWorld(), getExtendedFacing(), tTile.getXCoord(), tTile.getYCoord(), tTile.getZCoord(), horizontalOffset, verticalOffset, depthOffset, !mMachine); - } - - protected final boolean buildPiece(String piece, ItemStack trigger, boolean hintOnly, int horizontalOffset, int verticalOffset, int depthOffset) { +public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase<T extends GT_MetaTileEntity_EnhancedMultiBlockBase<T>> + extends GT_MetaTileEntity_TooltipMultiBlockBase implements IAlignment, IConstructable { + private ExtendedFacing mExtendedFacing = ExtendedFacing.DEFAULT; + private IAlignmentLimits mLimits = getInitialAlignmentLimits(); + + protected GT_MetaTileEntity_EnhancedMultiBlockBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + protected GT_MetaTileEntity_EnhancedMultiBlockBase(String aName) { + super(aName); + } + + @Override + public ExtendedFacing getExtendedFacing() { + return mExtendedFacing; + } + + @Override + public void setExtendedFacing(ExtendedFacing newExtendedFacing) { + if (mExtendedFacing != newExtendedFacing) { + if (mMachine) stopMachine(); + mExtendedFacing = newExtendedFacing; + final IGregTechTileEntity base = getBaseMetaTileEntity(); + mMachine = false; + mUpdated = false; + mUpdate = 100; + if (getBaseMetaTileEntity().isServerSide()) { + StructureLibAPI.sendAlignment( + (IAlignmentProvider) base, + new NetworkRegistry.TargetPoint( + base.getWorld().provider.dimensionId, + base.getXCoord(), + base.getYCoord(), + base.getZCoord(), + 512)); + } else { + base.issueTextureUpdate(); + } + } + } + + @Override + public final boolean isFacingValid(byte aFacing) { + return canSetToDirectionAny(ForgeDirection.getOrientation(aFacing)); + } + + @Override + public boolean onWrenchRightClick( + byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aWrenchingSide != getBaseMetaTileEntity().getFrontFacing()) + return super.onWrenchRightClick(aSide, aWrenchingSide, aPlayer, aX, aY, aZ); + if (aPlayer.isSneaking()) { + // we won't be allowing horizontal flips, as it can be perfectly emulated by rotating twice and flipping + // horizontally + // allowing an extra round of flip make it hard to draw meaningful flip markers in GT_Proxy#drawGrid + toolSetFlip(getFlip().isHorizontallyFlipped() ? Flip.NONE : Flip.HORIZONTAL); + } else { + toolSetRotation(null); + } + return true; + } + + @Override + public void onFacingChange() { + toolSetDirection(ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing())); + } + + @Override + public IAlignmentLimits getAlignmentLimits() { + return mLimits; + } + + protected void setAlignmentLimits(IAlignmentLimits mLimits) { + this.mLimits = mLimits; + } + + /** + * Due to limitation of Java type system, you might need to do an unchecked cast. + * HOWEVER, the returned IStructureDefinition is expected to be evaluated against current instance only, and should + * not be used against other instances, even for those of the same class. + */ + public abstract IStructureDefinition<T> getStructureDefinition(); + + protected abstract GT_Multiblock_Tooltip_Builder createTooltip(); + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return getTooltip().getStructureHint(); + } + + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> !f.isVerticallyFliped(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setByte("eRotation", (byte) mExtendedFacing.getRotation().getIndex()); + aNBT.setByte("eFlip", (byte) mExtendedFacing.getFlip().getIndex()); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mExtendedFacing = ExtendedFacing.of( + ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()), + Rotation.byIndex(aNBT.getByte("eRotation")), + Flip.byIndex(aNBT.getByte("eFlip"))); + } + + @SuppressWarnings("unchecked") + private IStructureDefinition<GT_MetaTileEntity_EnhancedMultiBlockBase<T>> getCastedStructureDefinition() { + return (IStructureDefinition<GT_MetaTileEntity_EnhancedMultiBlockBase<T>>) getStructureDefinition(); + } + + /** + * Explanation of the world coordinate these offset means: + * + * Imagine you stand in front of the controller, with controller facing towards you not rotated or flipped. + * + * The horizontalOffset would be the number of blocks on the left side of the controller, not counting controller itself. + * The verticalOffset would be the number of blocks on the top side of the controller, not counting controller itself. + * The depthOffset would be the number of blocks between you and controller, not counting controller itself. + * + * All these offsets can be negative. + */ + protected final boolean checkPiece(String piece, int horizontalOffset, int verticalOffset, int depthOffset) { final IGregTechTileEntity tTile = getBaseMetaTileEntity(); - return getCastedStructureDefinition().buildOrHints(this, trigger, piece, tTile.getWorld(), getExtendedFacing(), tTile.getXCoord(), tTile.getYCoord(), tTile.getZCoord(), horizontalOffset, verticalOffset, depthOffset, hintOnly); + return getCastedStructureDefinition() + .check( + this, + piece, + tTile.getWorld(), + getExtendedFacing(), + tTile.getXCoord(), + tTile.getYCoord(), + tTile.getZCoord(), + horizontalOffset, + verticalOffset, + depthOffset, + !mMachine); } - protected final int survivialBuildPiece(String piece, ItemStack trigger, int horizontalOffset, int verticalOffset, int depthOffset, int elementsBudget, IItemSource source, EntityPlayerMP actor, boolean check) { + protected final boolean buildPiece( + String piece, + ItemStack trigger, + boolean hintOnly, + int horizontalOffset, + int verticalOffset, + int depthOffset) { final IGregTechTileEntity tTile = getBaseMetaTileEntity(); - return getCastedStructureDefinition().survivalBuild(this, trigger, piece, tTile.getWorld(), getExtendedFacing(), tTile.getXCoord(), tTile.getYCoord(), tTile.getZCoord(), horizontalOffset, verticalOffset, depthOffset, elementsBudget, source, actor, check); + return getCastedStructureDefinition() + .buildOrHints( + this, + trigger, + piece, + tTile.getWorld(), + getExtendedFacing(), + tTile.getXCoord(), + tTile.getYCoord(), + tTile.getZCoord(), + horizontalOffset, + verticalOffset, + depthOffset, + hintOnly); } - protected final int survivialBuildPiece(String piece, ItemStack trigger, int horizontalOffset, int verticalOffset, int depthOffset, int elementsBudget, IItemSource source, EntityPlayerMP actor, boolean check, boolean checkIfPlaced) { - int built = survivialBuildPiece(piece, trigger, horizontalOffset, verticalOffset, depthOffset, elementsBudget, source, actor, check); + protected final int survivialBuildPiece( + String piece, + ItemStack trigger, + int horizontalOffset, + int verticalOffset, + int depthOffset, + int elementsBudget, + IItemSource source, + EntityPlayerMP actor, + boolean check) { + final IGregTechTileEntity tTile = getBaseMetaTileEntity(); + return getCastedStructureDefinition() + .survivalBuild( + this, + trigger, + piece, + tTile.getWorld(), + getExtendedFacing(), + tTile.getXCoord(), + tTile.getYCoord(), + tTile.getZCoord(), + horizontalOffset, + verticalOffset, + depthOffset, + elementsBudget, + source, + actor, + check); + } + + protected final int survivialBuildPiece( + String piece, + ItemStack trigger, + int horizontalOffset, + int verticalOffset, + int depthOffset, + int elementsBudget, + IItemSource source, + EntityPlayerMP actor, + boolean check, + boolean checkIfPlaced) { + int built = survivialBuildPiece( + piece, trigger, horizontalOffset, verticalOffset, depthOffset, elementsBudget, source, actor, check); if (checkIfPlaced && built > 0) checkStructure(true, getBaseMetaTileEntity()); return built; } - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - super.onFirstTick(aBaseMetaTileEntity); - if (aBaseMetaTileEntity.isClientSide()) - StructureLibAPI.queryAlignment((IAlignmentProvider) aBaseMetaTileEntity); - } + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + if (aBaseMetaTileEntity.isClientSide()) + StructureLibAPI.queryAlignment((IAlignmentProvider) aBaseMetaTileEntity); + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java index 82dbc3afd9..a92849a6d2 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java @@ -15,22 +15,39 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan */ @Deprecated public byte mMachineBlock = 0; + private byte mTexturePage = 0; private byte actualTexture = 0; - public GT_MetaTileEntity_Hatch(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + public GT_MetaTileEntity_Hatch( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String aDescription, + ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_Hatch(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription, ITexture... aTextures) { + public GT_MetaTileEntity_Hatch( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String[] aDescription, + ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_Hatch(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Hatch( + String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_Hatch(String aName, int aTier, int aInvSlotCount, String []aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Hatch( + String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } @@ -48,30 +65,35 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan public abstract ITexture[] getTexturesInactive(ITexture aBaseTexture); @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - int textureIndex = actualTexture | (mTexturePage << 7);//Shift seven since one page is 128 textures! - int texturePointer = (byte) (actualTexture & 0x7F);//just to be sure, from my testing the 8th bit cannot be set clientside + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + int textureIndex = actualTexture | (mTexturePage << 7); // Shift seven since one page is 128 textures! + int texturePointer = + (byte) (actualTexture & 0x7F); // just to be sure, from my testing the 8th bit cannot be set clientside try { if (aSide != aFacing) { if (textureIndex > 0) - return new ITexture[]{Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]}; - else - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]}; + return new ITexture[] {Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]}; + else return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]}; } else { if (textureIndex > 0) { if (aActive) return getTexturesActive(Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]); else - return getTexturesInactive(Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]); + return getTexturesInactive( + Textures.BlockIcons.casingTexturePages[mTexturePage][texturePointer]); } else { - if (aActive) - return getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]); - else - return getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]); + if (aActive) return getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]); + else return getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]); } } } catch (NullPointerException npe) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[0][0]}; + return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[0][0]}; } } @@ -85,21 +107,21 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - actualTexture=aNBT.getByte("mMachineBlock"); - mTexturePage=aNBT.getByte("mTexturePage"); + actualTexture = aNBT.getByte("mMachineBlock"); + mTexturePage = aNBT.getByte("mTexturePage"); - if(mTexturePage!=0 && GT_Values.GT.isServerSide()) - actualTexture|=0x80;//<- lets just hope no one needs the correct value for that on server - mMachineBlock=actualTexture; + if (mTexturePage != 0 && GT_Values.GT.isServerSide()) + actualTexture |= 0x80; // <- lets just hope no one needs the correct value for that on server + mMachineBlock = actualTexture; } /** * Sets texture with page and index, called on add to machine list * @param id (page<<7)+index of the texture */ - public final void updateTexture(int id){ + public final void updateTexture(int id) { onValueUpdate((byte) id); - onTexturePageUpdate((byte) (id>>7)); + onTexturePageUpdate((byte) (id >> 7)); } /** @@ -108,34 +130,35 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan * @param index index of texure */ @Deprecated - public final void updateTexture(byte page, byte index){ + public final void updateTexture(byte page, byte index) { onValueUpdate(index); onTexturePageUpdate(page); } @Override public final void onValueUpdate(byte aValue) { - actualTexture=(byte)(aValue & 0x7F); - mMachineBlock=actualTexture; - mTexturePage=0; + actualTexture = (byte) (aValue & 0x7F); + mMachineBlock = actualTexture; + mTexturePage = 0; } @Override public final byte getUpdateData() { - return (byte)(actualTexture & 0x7F); + return (byte) (actualTexture & 0x7F); } public final void onTexturePageUpdate(byte aValue) { - mTexturePage = (byte)(aValue & 0x7F); - if(mTexturePage!=0 && getBaseMetaTileEntity().isServerSide()) {//just to be sure - mMachineBlock|=0x80;//<- lets just hope no one needs the correct value for that on server - actualTexture=mMachineBlock; + mTexturePage = (byte) (aValue & 0x7F); + if (mTexturePage != 0 && getBaseMetaTileEntity().isServerSide()) { // just to be sure + mMachineBlock |= 0x80; // <- lets just hope no one needs the correct value for that on server + actualTexture = mMachineBlock; } - //set last bit to allow working of the page reset-er to 0 in rare case when texture id is the same but page changes to 0 + // set last bit to allow working of the page reset-er to 0 in rare case when texture id is the same but page + // changes to 0 } public final byte getTexturePage() { - return (byte)(mTexturePage & 0x7F); + return (byte) (mTexturePage & 0x7F); } @Override @@ -169,16 +192,22 @@ public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTan } @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {//in that method since it is usually not overriden, especially for hatches. - if(actualTexture!=mMachineBlock){//revert to page 0 on edition of the field - old code way - actualTexture=(byte)(mMachineBlock & 0x7F); - mMachineBlock=actualTexture;//clear last bit in mMachineBlock since now we are at page 0 after the direct field change - mTexturePage=0;//assuming old code only supports page 0 + public void onPreTick( + IGregTechTileEntity aBaseMetaTileEntity, + long aTick) { // in that method since it is usually not overriden, especially for hatches. + if (actualTexture != mMachineBlock) { // revert to page 0 on edition of the field - old code way + actualTexture = (byte) (mMachineBlock & 0x7F); + mMachineBlock = + actualTexture; // clear last bit in mMachineBlock since now we are at page 0 after the direct field + // change + mTexturePage = 0; // assuming old code only supports page 0 } super.onPreTick(aBaseMetaTileEntity, aTick); } - //To change to other page -> use the setter method -> updateTexture + // To change to other page -> use the setter method -> updateTexture - public int getCircuitSlot() { return -1; } + public int getCircuitSlot() { + return -1; + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java index ab6ba80f1b..bc4b82477d 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_DataAccess.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_DATA_ACCESS; + import gregtech.api.gui.GT_Container_2by2; import gregtech.api.gui.GT_Container_4by4; import gregtech.api.gui.GT_GUIContainer_2by2; @@ -14,33 +16,32 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_DATA_ACCESS; - public class GT_MetaTileEntity_Hatch_DataAccess extends GT_MetaTileEntity_Hatch { - private int timeout=4; + private int timeout = 4; public GT_MetaTileEntity_Hatch_DataAccess(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 16, new String[]{ - "Data Access for Multiblocks", - "Adds " + (aTier == 4 ? 4 : 16) + " extra slots for Data Sticks"}); + super(aID, aName, aNameRegional, aTier, 16, new String[] { + "Data Access for Multiblocks", "Adds " + (aTier == 4 ? 4 : 16) + " extra slots for Data Sticks" + }); } public GT_MetaTileEntity_Hatch_DataAccess(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aTier == 4 ? 4 : 16, aDescription, aTextures); } - public GT_MetaTileEntity_Hatch_DataAccess(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Hatch_DataAccess( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aTier == 4 ? 4 : 16, aDescription, aTextures); } @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_DATA_ACCESS)}; + return new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_DATA_ACCESS)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_DATA_ACCESS)}; + return new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_DATA_ACCESS)}; } @Override @@ -89,21 +90,24 @@ public class GT_MetaTileEntity_Hatch_DataAccess extends GT_MetaTileEntity_Hatch public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { switch (mTier) { case 4: - return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Data Access Hatch", "DataAccess"); + return new GT_GUIContainer_2by2( + aPlayerInventory, aBaseMetaTileEntity, "Data Access Hatch", "DataAccess"); default: - return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Data Access Hatch", "DataAccess"); + return new GT_GUIContainer_4by4( + aPlayerInventory, aBaseMetaTileEntity, "Data Access Hatch", "DataAccess"); } } @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return mTier>=8 && !aBaseMetaTileEntity.isActive(); + return mTier >= 8 && !aBaseMetaTileEntity.isActive(); } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return mTier>=8 && !aBaseMetaTileEntity.isActive(); + return mTier >= 8 && !aBaseMetaTileEntity.isActive(); } + @Override public int getInventoryStackLimit() { return 1; @@ -117,12 +121,11 @@ public class GT_MetaTileEntity_Hatch_DataAccess extends GT_MetaTileEntity_Hatch aBaseMetaTileEntity.setActive(false); } } - } - public void setActive(boolean mActive){ + public void setActive(boolean mActive) { getBaseMetaTileEntity().setActive(mActive); - timeout=mActive?4:0; + timeout = mActive ? 4 : 0; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java index ae2aea8e4a..e9ba5ec512 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.V; + import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -7,14 +9,15 @@ import gregtech.api.metatileentity.MetaTileEntity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import static gregtech.api.enums.GT_Values.V; - public class GT_MetaTileEntity_Hatch_Dynamo extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Dynamo(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 0, new String[]{"Generating electric Energy from Multiblocks", "Puts out up to 1 Amp"}); + super(aID, aName, aNameRegional, aTier, 0, new String[] { + "Generating electric Energy from Multiblocks", "Puts out up to 1 Amp" + }); } - public GT_MetaTileEntity_Hatch_Dynamo(int aID, String aName, String aNameRegional, int aTier, String[] aDescription) { + public GT_MetaTileEntity_Hatch_Dynamo( + int aID, String aName, String aNameRegional, int aTier, String[] aDescription) { super(aID, aName, aNameRegional, aTier, 0, aDescription); } @@ -28,12 +31,12 @@ public class GT_MetaTileEntity_Hatch_Dynamo extends GT_MetaTileEntity_Hatch { @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; + return new ITexture[] {aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; + return new ITexture[] {aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java index a6bdc6726c..acc302e903 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.V; + import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -7,16 +9,17 @@ import gregtech.api.metatileentity.MetaTileEntity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import static gregtech.api.enums.GT_Values.V; - public class GT_MetaTileEntity_Hatch_Energy extends GT_MetaTileEntity_Hatch { - public GT_MetaTileEntity_Hatch_Energy(int aID, String aName, String aNameRegional, int aTier, String[] aDescription) { + public GT_MetaTileEntity_Hatch_Energy( + int aID, String aName, String aNameRegional, int aTier, String[] aDescription) { super(aID, aName, aNameRegional, aTier, 0, aDescription); } public GT_MetaTileEntity_Hatch_Energy(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 0, new String[]{"Energy Injector for Multiblocks", "Accepts up to 2 Amps"}); + super(aID, aName, aNameRegional, aTier, 0, new String[] { + "Energy Injector for Multiblocks", "Accepts up to 2 Amps" + }); } public GT_MetaTileEntity_Hatch_Energy(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -27,18 +30,19 @@ public class GT_MetaTileEntity_Hatch_Energy extends GT_MetaTileEntity_Hatch { super(aName, aTier, 0, aDescription, aTextures); } - public GT_MetaTileEntity_Hatch_Energy(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Hatch_Energy( + String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); } @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; + return new ITexture[] {aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; + return new ITexture[] {aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java index 99c89e091a..cb2c869edc 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java @@ -1,5 +1,8 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.Textures.BlockIcons.FLUID_IN_SIGN; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_IN; + import gregtech.GT_Mod; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -12,23 +15,21 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; -import static gregtech.api.enums.Textures.BlockIcons.FLUID_IN_SIGN; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_IN; - public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { public GT_Recipe_Map mRecipeMap = null; public GT_MetaTileEntity_Hatch_Input(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, new String[]{ - "Fluid Input for Multiblocks", - "Capacity: " + GT_Utility.formatNumbers(8000*(1<<aTier)) + "L"}); + super(aID, aName, aNameRegional, aTier, 3, new String[] { + "Fluid Input for Multiblocks", "Capacity: " + GT_Utility.formatNumbers(8000 * (1 << aTier)) + "L" + }); } public GT_MetaTileEntity_Hatch_Input(int aID, int aSlot, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, aSlot, new String[]{ + super(aID, aName, aNameRegional, aTier, aSlot, new String[] { "Fluid Input for Multiblocks", - "Capacity: " + GT_Utility.formatNumbers(8000*(1<<aTier) / aSlot) + "L", - "Can hold " + aSlot + " types of fluid."}); + "Capacity: " + GT_Utility.formatNumbers(8000 * (1 << aTier) / aSlot) + "L", + "Can hold " + aSlot + " types of fluid." + }); } public GT_MetaTileEntity_Hatch_Input(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -39,22 +40,23 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { super(aName, aTier, 3, aDescription, aTextures); } - public GT_MetaTileEntity_Hatch_Input(String aName, int aSlots, int aTier, String[] aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Hatch_Input( + String aName, int aSlots, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aSlots, aDescription, aTextures); } @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(FLUID_IN_SIGN)} : - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch + ? new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(FLUID_IN_SIGN)} + : new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(FLUID_IN_SIGN)} : - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch + ? new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(FLUID_IN_SIGN)} + : new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; } @Override @@ -80,8 +82,7 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - if (mRecipeMap != null) - aNBT.setString("recipeMap", mRecipeMap.mUniqueIdentifier); + if (mRecipeMap != null) aNBT.setString("recipeMap", mRecipeMap.mUniqueIdentifier); } @Override @@ -99,7 +100,7 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { @Override public boolean doesFillContainers() { - //return true; + // return true; return false; } @@ -145,12 +146,16 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0 && (mRecipeMap == null || mRecipeMap.containsInput(aStack) || mRecipeMap.containsInput(GT_Utility.getFluidForFilledItem(aStack, true))); + return aSide == aBaseMetaTileEntity.getFrontFacing() + && aIndex == 0 + && (mRecipeMap == null + || mRecipeMap.containsInput(aStack) + || mRecipeMap.containsInput(GT_Utility.getFluidForFilledItem(aStack, true))); } @Override public int getCapacity() { - return 8000*(1<<mTier); + return 8000 * (1 << mTier); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java index ba6e1698b1..f37befb63b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.Textures.BlockIcons.*; + import gregtech.GT_Mod; import gregtech.api.gui.*; import gregtech.api.interfaces.ITexture; @@ -12,18 +14,15 @@ import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.api.util.extensions.ArrayExt; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import static gregtech.api.enums.Textures.BlockIcons.*; - public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch implements IConfigurationCircuitSupport { public GT_Recipe_Map mRecipeMap = null; public boolean disableSort; @@ -34,19 +33,27 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch im this(id, name, nameRegional, tier, getSlots(tier) + 1); } - protected GT_MetaTileEntity_Hatch_InputBus(int id, String name, String nameRegional, int tier, int slots, String[] description) { + protected GT_MetaTileEntity_Hatch_InputBus( + int id, String name, String nameRegional, int tier, int slots, String[] description) { super(id, name, nameRegional, tier, slots, description); } public GT_MetaTileEntity_Hatch_InputBus(int id, String name, String nameRegional, int tier, int slots) { - super(id, name, nameRegional, tier, slots, ArrayExt.of( - "Item Input for Multiblocks", - "Shift + right click with screwdriver to turn Sort mode on/off", - "Capacity: " + slots + " stack" + (slots >= 2 ? "s" : ""))); + super( + id, + name, + nameRegional, + tier, + slots, + ArrayExt.of( + "Item Input for Multiblocks", + "Shift + right click with screwdriver to turn Sort mode on/off", + "Capacity: " + slots + " stack" + (slots >= 2 ? "s" : ""))); } @Deprecated - // having too many constructors is bad, don't be so lazy, use GT_MetaTileEntity_Hatch_InputBus(String, int, String[], ITexture[][][]) + // having too many constructors is bad, don't be so lazy, use GT_MetaTileEntity_Hatch_InputBus(String, int, + // String[], ITexture[][][]) public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { this(aName, aTier, ArrayExt.of(aDescription), aTextures); } @@ -55,22 +62,23 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch im this(aName, aTier, getSlots(aTier) + 1, aDescription, aTextures); } - public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, int aSlots, String[] aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Hatch_InputBus( + String aName, int aTier, int aSlots, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aSlots, aDescription, aTextures); } @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(ITEM_IN_SIGN)} : - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch + ? new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(ITEM_IN_SIGN)} + : new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(ITEM_IN_SIGN)} : - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch + ? new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN), TextureFactory.of(ITEM_IN_SIGN)} + : new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_IN)}; } @Override @@ -129,13 +137,12 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch im return 63; } - @Override public void initDefaultModes(NBTTagCompound aNBT) { if (!getBaseMetaTileEntity().getWorld().isRemote) { - GT_ClientPreference tPreference = GT_Mod.gregtechproxy.getClientPreference(getBaseMetaTileEntity().getOwnerUuid()); - if (tPreference != null) - disableFilter = !tPreference.isInputBusInitialFilterEnabled(); + GT_ClientPreference tPreference = GT_Mod.gregtechproxy.getClientPreference( + getBaseMetaTileEntity().getOwnerUuid()); + if (tPreference != null) disableFilter = !tPreference.isInputBusInitialFilterEnabled(); } } @@ -164,10 +171,8 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch im public void updateSlots() { for (int i = 0; i < mInventory.length - 1; i++) - if (mInventory[i] != null && mInventory[i].stackSize <= 0) - mInventory[i] = null; - if (!disableSort) - fillStacksIntoFirstSlots(); + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + if (!disableSort) fillStacksIntoFirstSlots(); } protected void fillStacksIntoFirstSlots() { @@ -177,24 +182,20 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch im List<GT_Utility.ItemId> order = new ArrayList<>(L); List<Integer> validSlots = new ArrayList<>(L); for (int i = 0; i < L; i++) { - if (!isValidSlot(i)) - continue; + if (!isValidSlot(i)) continue; validSlots.add(i); ItemStack s = mInventory[i]; - if(s == null) - continue; + if (s == null) continue; GT_Utility.ItemId sID = GT_Utility.ItemId.createNoCopy(s); slots.merge(sID, s.stackSize, Integer::sum); - if(!stacks.containsKey(sID)) - stacks.put(sID, s); + if (!stacks.containsKey(sID)) stacks.put(sID, s); order.add(sID); mInventory[i] = null; } int slotindex = 0; for (GT_Utility.ItemId sID : order) { int toSet = slots.get(sID); - if (toSet == 0) - continue; + if (toSet == 0) continue; int slot = validSlots.get(slotindex); slotindex++; mInventory[slot] = stacks.get(sID).copy(); @@ -210,8 +211,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch im aNBT.setBoolean("disableSort", disableSort); aNBT.setBoolean("disableFilter", disableFilter); aNBT.setBoolean("disableLimited", disableLimited); - if (mRecipeMap != null) - aNBT.setString("recipeMap", mRecipeMap.mUniqueIdentifier); + if (mRecipeMap != null) aNBT.setString("recipeMap", mRecipeMap.mUniqueIdentifier); } @Override @@ -219,60 +219,64 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch im super.loadNBTData(aNBT); disableSort = aNBT.getBoolean("disableSort"); disableFilter = aNBT.getBoolean("disableFilter"); - if(aNBT.hasKey("disableLimited")) - disableLimited = aNBT.getBoolean("disableLimited"); + if (aNBT.hasKey("disableLimited")) disableLimited = aNBT.getBoolean("disableLimited"); mRecipeMap = GT_Recipe_Map.sIndexedMappings.getOrDefault(aNBT.getString("recipeMap"), null); } @Override public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (!getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), getBaseMetaTileEntity())) - return; + if (!getBaseMetaTileEntity() + .getCoverBehaviorAtSideNew(aSide) + .isGUIClickable( + aSide, + getBaseMetaTileEntity().getCoverIDAtSide(aSide), + getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), + getBaseMetaTileEntity())) return; if (aPlayer.isSneaking()) { - if(disableSort) { + if (disableSort) { disableSort = false; } else { - if(disableLimited) { + if (disableLimited) { disableLimited = false; } else { disableSort = true; disableLimited = true; } } - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableSort." + disableSort) + " " + - StatCollector.translateToLocal("GT5U.hatch.disableLimited." + disableLimited)); + GT_Utility.sendChatToPlayer( + aPlayer, + StatCollector.translateToLocal("GT5U.hatch.disableSort." + disableSort) + " " + + StatCollector.translateToLocal("GT5U.hatch.disableLimited." + disableLimited)); } else { disableFilter = !disableFilter; - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableFilter." + disableFilter)); + GT_Utility.sendChatToPlayer( + aPlayer, StatCollector.translateToLocal("GT5U.hatch.disableFilter." + disableFilter)); } } @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aIndex == getCircuitSlot()) - return false; + if (aIndex == getCircuitSlot()) return false; return aSide == getBaseMetaTileEntity().getFrontFacing(); } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == getBaseMetaTileEntity().getFrontFacing() && aIndex != getCircuitSlot() + return aSide == getBaseMetaTileEntity().getFrontFacing() + && aIndex != getCircuitSlot() && (mRecipeMap == null || disableFilter || mRecipeMap.containsInput(aStack)) && (disableLimited || limitedAllowPutStack(aIndex, aStack)); } protected boolean limitedAllowPutStack(int aIndex, ItemStack aStack) { for (int i = 0; i < getSizeInventory(); i++) - if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get_nocopy(aStack), mInventory[i])) - return i == aIndex; + if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get_nocopy(aStack), mInventory[i])) return i == aIndex; return mInventory[aIndex] == null; } - public void startRecipeProcessing() { - } + public void startRecipeProcessing() {} - public void endRecipeProcessing() { - } + public void endRecipeProcessing() {} @Override public boolean allowSelectCircuit() { @@ -280,5 +284,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch im } @Override - public int getCircuitSlot() { return getSlots(mTier); } + public int getCircuitSlot() { + return getSlots(mTier); + } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java index bdfd06c92f..fada5a9b7c 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java @@ -1,5 +1,12 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_IDLE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_IDLE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_DUCTTAPE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MAINTENANCE; + import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; @@ -27,16 +34,15 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.FakePlayer; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_IDLE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_AUTOMAINTENANCE_IDLE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_DUCTTAPE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MAINTENANCE; - public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch { private static ItemStack[] sAutoMaintenanceInputs; - public boolean mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, mCrowbar = false, mAuto; + public boolean mWrench = false, + mScrewdriver = false, + mSoftHammer = false, + mHardHammer = false, + mSolderingTool = false, + mCrowbar = false, + mAuto; public GT_MetaTileEntity_Hatch_Maintenance(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 1, "For maintaining Multiblocks"); @@ -48,24 +54,26 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch mAuto = aAuto; } - public GT_MetaTileEntity_Hatch_Maintenance(String aName, int aTier, String aDescription, ITexture[][][] aTextures, boolean aAuto) { + public GT_MetaTileEntity_Hatch_Maintenance( + String aName, int aTier, String aDescription, ITexture[][][] aTextures, boolean aAuto) { super(aName, aTier, aAuto ? 4 : 1, aDescription, aTextures); mAuto = aAuto; } - public GT_MetaTileEntity_Hatch_Maintenance(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, boolean aAuto) { + public GT_MetaTileEntity_Hatch_Maintenance( + String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, boolean aAuto) { super(aName, aTier, aAuto ? 4 : 1, aDescription, aTextures); mAuto = aAuto; } private static ItemStack[] getAutoMaintenanceInputs() { if (sAutoMaintenanceInputs == null) - sAutoMaintenanceInputs = new ItemStack[]{ - ItemList.Duct_Tape.get(4), - GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Lubricant, 2), - GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Steel, 4), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2) - }; + sAutoMaintenanceInputs = new ItemStack[] { + ItemList.Duct_Tape.get(4), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Lubricant, 2), + GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Steel, 4), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 2) + }; return sAutoMaintenanceInputs; } @@ -88,25 +96,31 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - if (mAuto) return new ITexture[]{ + if (mAuto) + return new ITexture[] { aBaseTexture, TextureFactory.of(OVERLAY_AUTOMAINTENANCE_IDLE), - TextureFactory.builder().addIcon(OVERLAY_AUTOMAINTENANCE_IDLE_GLOW).glow().build()}; - return new ITexture[]{ - aBaseTexture, - TextureFactory.of(OVERLAY_MAINTENANCE)}; + TextureFactory.builder() + .addIcon(OVERLAY_AUTOMAINTENANCE_IDLE_GLOW) + .glow() + .build() + }; + return new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_MAINTENANCE)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - if (mAuto) return new ITexture[]{ + if (mAuto) + return new ITexture[] { aBaseTexture, TextureFactory.of(OVERLAY_AUTOMAINTENANCE), - TextureFactory.builder().addIcon(OVERLAY_AUTOMAINTENANCE_GLOW).glow().build()}; - return new ITexture[]{ - aBaseTexture, - TextureFactory.of(OVERLAY_MAINTENANCE), - TextureFactory.of(OVERLAY_DUCTTAPE)}; + TextureFactory.builder() + .addIcon(OVERLAY_AUTOMAINTENANCE_GLOW) + .glow() + .build() + }; + return new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_MAINTENANCE), TextureFactory.of(OVERLAY_DUCTTAPE) + }; } @Override @@ -142,17 +156,17 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - if (aBaseMetaTileEntity.isClientSide()) - return true; + public boolean onRightclick( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + if (aBaseMetaTileEntity.isClientSide()) return true; if (aSide == aBaseMetaTileEntity.getFrontFacing()) { // only allow OC robot fake player - if (aPlayer instanceof FakePlayer && !aPlayer.getGameProfile().getName().endsWith(".robot")) - return false; - if (aPlayer.getCurrentEquippedItem() != null && aPlayer.getCurrentEquippedItem().getItem() instanceof ItemToolbox) + if (aPlayer instanceof FakePlayer + && !aPlayer.getGameProfile().getName().endsWith(".robot")) return false; + if (aPlayer.getCurrentEquippedItem() != null + && aPlayer.getCurrentEquippedItem().getItem() instanceof ItemToolbox) applyToolbox(aPlayer.getCurrentEquippedItem(), aPlayer); - else - aBaseMetaTileEntity.openGUI(aPlayer); + else aBaseMetaTileEntity.openGUI(aPlayer); return true; } return false; @@ -175,21 +189,20 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; } - @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); - if(aBaseMetaTileEntity.isServerSide() && mAuto && aTick % 100L ==0L){ + if (aBaseMetaTileEntity.isServerSide() && mAuto && aTick % 100L == 0L) { aBaseMetaTileEntity.setActive(!isRecipeInputEqual(false)); } } - public boolean autoMaintainance(){ + public boolean autoMaintainance() { return isRecipeInputEqual(true); } public boolean isRecipeInputEqual(boolean aDecreaseStacksizeBySuccess) { - ItemStack[] mInputs= getAutoMaintenanceInputs(); + ItemStack[] mInputs = getAutoMaintenanceInputs(); int amt; @@ -198,7 +211,9 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch amt = tStack.stackSize; boolean temp = true; for (ItemStack aStack : mInventory) { - if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { + if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) + || GT_Utility.areUnificationsEqual( + GT_OreDictUnificator.get(false, aStack), tStack, true))) { amt -= aStack.stackSize; if (amt < 1) { temp = false; @@ -215,7 +230,9 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch if (tStack != null) { amt = tStack.stackSize; for (ItemStack aStack : mInventory) { - if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { + if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) + || GT_Utility.areUnificationsEqual( + GT_OreDictUnificator.get(false, aStack), tStack, true))) { if (aStack.stackSize < amt) { amt -= aStack.stackSize; aStack.stackSize = 0; @@ -244,20 +261,25 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch // Allow IC2 Toolbox with tools to function for maint issues. if (aStack.getItem() instanceof ItemToolbox && aPlayer instanceof EntityPlayer) { - applyToolbox(aStack, (EntityPlayer)aPlayer); + applyToolbox(aStack, (EntityPlayer) aPlayer); return; } - if (GT_Utility.isStackInList(aStack, GregTech_API.sWrenchList) && !mWrench && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) - mWrench = true; - if (GT_Utility.isStackInList(aStack, GregTech_API.sScrewdriverList) && !mScrewdriver && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) - mScrewdriver = true; - if (GT_Utility.isStackInList(aStack, GregTech_API.sSoftHammerList) && !mSoftHammer && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) - mSoftHammer = true; - if (GT_Utility.isStackInList(aStack, GregTech_API.sHardHammerList) && !mHardHammer && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) - mHardHammer = true; - if (GT_Utility.isStackInList(aStack, GregTech_API.sCrowbarList) && !mCrowbar && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) - mCrowbar = true; + if (GT_Utility.isStackInList(aStack, GregTech_API.sWrenchList) + && !mWrench + && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) mWrench = true; + if (GT_Utility.isStackInList(aStack, GregTech_API.sScrewdriverList) + && !mScrewdriver + && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) mScrewdriver = true; + if (GT_Utility.isStackInList(aStack, GregTech_API.sSoftHammerList) + && !mSoftHammer + && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) mSoftHammer = true; + if (GT_Utility.isStackInList(aStack, GregTech_API.sHardHammerList) + && !mHardHammer + && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) mHardHammer = true; + if (GT_Utility.isStackInList(aStack, GregTech_API.sCrowbarList) + && !mCrowbar + && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) mCrowbar = true; if (!mSolderingTool && GT_ModHandler.useSolderingIron(aStack, aPlayer, aToolboxInventory)) mSolderingTool = true; if (GT_OreDictUnificator.isItemStackInstanceOf(aStack, "craftingDuctTape")) { @@ -281,7 +303,7 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch private void applyToolbox(ItemStack aStack, EntityPlayer aPlayer) { ItemToolbox aToolbox = (ItemToolbox) aStack.getItem(); IHasGui aToolboxGUI = aToolbox.getInventory(aPlayer, aStack); - for (int i = 0; i < aToolboxGUI.getSizeInventory(); i ++) { + for (int i = 0; i < aToolboxGUI.getSizeInventory(); i++) { if (aToolboxGUI.getStackInSlot(i) != null) { onToolClick(aToolboxGUI.getStackInSlot(i), aPlayer, aToolboxGUI); if (aToolboxGUI.getStackInSlot(i) != null && aToolboxGUI.getStackInSlot(i).stackSize <= 0) @@ -299,10 +321,12 @@ public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { if (mAuto && GT_Mod.gregtechproxy.mAMHInteraction) { for (int i = 0; i < getSizeInventory(); i++) - if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(false, aStack), GT_OreDictUnificator.get(false, getStackInSlot(i)))) + if (GT_Utility.areStacksEqual( + GT_OreDictUnificator.get(false, aStack), GT_OreDictUnificator.get(false, getStackInSlot(i)))) return i == aIndex; for (ItemStack tInput : getAutoMaintenanceInputs()) - if (GT_Utility.areUnificationsEqual(tInput, aStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tInput, true)) + if (GT_Utility.areUnificationsEqual(tInput, aStack, true) + || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tInput, true)) return true; } return false; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java index 6d59b4ff7f..d65370901b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java @@ -1,5 +1,8 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MUFFLER; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.GT_Mod; @@ -12,24 +15,19 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.common.GT_Pollution; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom; +import java.util.Arrays; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Arrays; - -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MUFFLER; -import static gregtech.api.objects.XSTR.XSTR_INSTANCE; - @SuppressWarnings("unused") // Unused API is expected within scope public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { private static final String localizedDescFormat = GT_LanguageManager.addStringLocalization( "gt.blockmachines.hatch.muffler.desc.format", - "Outputs the Pollution (Might cause ... things)%n" + - "DO NOT OBSTRUCT THE OUTPUT!%n" + - "Reduces Pollution to %d%%%n" + - "Recovers %d%% of CO2/CO/SO2"); + "Outputs the Pollution (Might cause ... things)%n" + "DO NOT OBSTRUCT THE OUTPUT!%n" + + "Reduces Pollution to %d%%%n" + + "Recovers %d%% of CO2/CO/SO2"); private final int pollutionReduction = calculatePollutionReduction(100); private final int pollutionRecover = 100 - pollutionReduction; private final String[] description = String.format(localizedDescFormat, pollutionReduction, pollutionRecover) @@ -41,7 +39,7 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { } public GT_MetaTileEntity_Hatch_Muffler(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - this(aName, aTier, new String[]{aDescription}, aTextures); + this(aName, aTier, new String[] {aDescription}, aTextures); } public GT_MetaTileEntity_Hatch_Muffler(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { @@ -56,12 +54,12 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_MUFFLER)}; + return new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_MUFFLER)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_MUFFLER)}; + return new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_MUFFLER)}; } @Override @@ -154,16 +152,25 @@ public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { .setMotion(xSpd, ySpd, zSpd); if (chk1) { - events.setPosition(xPos + ran1 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F) - .run(); + events.setPosition( + xPos + ran1 * 0.5F, + yPos + XSTR_INSTANCE.nextFloat() * 0.5F, + zPos + XSTR_INSTANCE.nextFloat() * 0.5F) + .run(); } if (chk2) { - events.setPosition(xPos + ran2 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F) - .run(); + events.setPosition( + xPos + ran2 * 0.5F, + yPos + XSTR_INSTANCE.nextFloat() * 0.5F, + zPos + XSTR_INSTANCE.nextFloat() * 0.5F) + .run(); } if (chk3) { - events.setPosition(xPos + ran3 * 0.5F, yPos + XSTR_INSTANCE.nextFloat() * 0.5F, zPos + XSTR_INSTANCE.nextFloat() * 0.5F) - .run(); + events.setPosition( + xPos + ran3 * 0.5F, + yPos + XSTR_INSTANCE.nextFloat() * 0.5F, + zPos + XSTR_INSTANCE.nextFloat() * 0.5F) + .run(); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_MultiInput.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_MultiInput.java index b16ec3c7c7..74c6ca2b96 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_MultiInput.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_MultiInput.java @@ -1,5 +1,7 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_INPUT_HATCH_2x2; + import gregtech.api.enums.ItemList; import gregtech.api.gui.GT_Container_2by2_Fluid; import gregtech.api.gui.GT_GUIContainer_2by2_Fluid; @@ -14,8 +16,6 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_INPUT_HATCH_2x2; - public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_Input { public FluidStack[] mStoredFluid; @@ -27,7 +27,8 @@ public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_ mCapacityPer = 8000 * (1 << aTier) / aSlot; } - public GT_MetaTileEntity_Hatch_MultiInput(String aName, int aSlot, int aTier, String[] aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Hatch_MultiInput( + String aName, int aSlot, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aSlot, aTier, aDescription, aTextures); this.mStoredFluid = new FluidStack[aSlot]; mCapacityPer = 8000 * (1 << aTier) / aSlot; @@ -67,12 +68,12 @@ public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_ @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_INPUT_HATCH_2x2)}; + return new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_INPUT_HATCH_2x2)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_INPUT_HATCH_2x2)}; + return new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_INPUT_HATCH_2x2)}; } public int getMaxType() { @@ -82,8 +83,7 @@ public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_ @Override public FluidStack getFluid() { for (FluidStack tFluid : mStoredFluid) { - if (tFluid != null && tFluid.amount > 0) - return tFluid; + if (tFluid != null && tFluid.amount > 0) return tFluid; } return null; } @@ -108,8 +108,7 @@ public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_ public int getFirstEmptySlot() { for (int i = 0; i < mStoredFluid.length; i++) { - if (mStoredFluid[i] == null || mStoredFluid[i].amount <= 0) - return i; + if (mStoredFluid[i] == null || mStoredFluid[i].amount <= 0) return i; } return -1; } @@ -117,8 +116,7 @@ public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_ public boolean hasFluid(FluidStack aFluid) { if (aFluid == null) return false; for (FluidStack tFluid : mStoredFluid) { - if (aFluid.isFluidEqual(tFluid)) - return true; + if (aFluid.isFluidEqual(tFluid)) return true; } return false; } @@ -126,8 +124,7 @@ public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_ public int getFluidSlot(FluidStack tFluid) { if (tFluid == null) return -1; for (int i = 0; i < mStoredFluid.length; i++) { - if (tFluid.equals(mStoredFluid[i])) - return i; + if (tFluid.equals(mStoredFluid[i])) return i; } return -1; } @@ -161,8 +158,11 @@ public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_ @Override public int fill(FluidStack aFluid, boolean doFill) { - if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) - return 0; + if (aFluid == null + || aFluid.getFluid().getID() <= 0 + || aFluid.amount <= 0 + || !canTankBeFilled() + || !isFluidInputAllowed(aFluid)) return 0; if (!hasFluid(aFluid) && getFirstEmptySlot() != -1) { int tFilled = Math.min(aFluid.amount, mCapacityPer); if (doFill) { @@ -261,7 +261,7 @@ public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_ @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide() && mStoredFluid != null) { - for (int i = 0; i < getMaxType(); i ++) { + for (int i = 0; i < getMaxType(); i++) { if (mStoredFluid[i] != null && mStoredFluid[i].amount <= 0) { mStoredFluid[i] = null; } @@ -277,12 +277,10 @@ public class GT_MetaTileEntity_Hatch_MultiInput extends GT_MetaTileEntity_Hatch_ @Override public void updateFluidDisplayItem() { - for (int i = 0; i < 4; i ++) { + for (int i = 0; i < 4; i++) { if (getFluid(i) == null || getFluid(i).amount <= 0) { - if (ItemList.Display_Fluid.isStackEqual(mInventory[i], true, true)) - mInventory[i] = null; - } - else { + if (ItemList.Display_Fluid.isStackEqual(mInventory[i], true, true)) mInventory[i] = null; + } else { mInventory[i] = GT_Utility.getFluidDisplayStack(getFluid(i), true, !displaysStackSize()); } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java index 7e04a5581f..43ccd2db7c 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java @@ -1,5 +1,8 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.Textures.BlockIcons.FLUID_OUT_SIGN; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; + import gregtech.GT_Mod; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -17,21 +20,19 @@ import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; -import static gregtech.api.enums.Textures.BlockIcons.FLUID_OUT_SIGN; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; - public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { private String lockedFluidName = null; private EntityPlayer playerThatLockedfluid = null; public byte mMode = 0; public GT_MetaTileEntity_Hatch_Output(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 4, new String[]{ - "Fluid Output for Multiblocks", - "Capacity: " + GT_Utility.formatNumbers(8000*(1<<aTier)) + "L", - "Right click with screwdriver to restrict output", - "Can be restricted to put out Items and/or Steam/No Steam/1 specific Fluid", - "Restricted Output Hatches are given priority for Multiblock Fluid output"}); + super(aID, aName, aNameRegional, aTier, 4, new String[] { + "Fluid Output for Multiblocks", + "Capacity: " + GT_Utility.formatNumbers(8000 * (1 << aTier)) + "L", + "Right click with screwdriver to restrict output", + "Can be restricted to put out Items and/or Steam/No Steam/1 specific Fluid", + "Restricted Output Hatches are given priority for Multiblock Fluid output" + }); } public GT_MetaTileEntity_Hatch_Output(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -44,16 +45,16 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(FLUID_OUT_SIGN)} : - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch + ? new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(FLUID_OUT_SIGN)} + : new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(FLUID_OUT_SIGN)} : - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch + ? new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(FLUID_OUT_SIGN)} + : new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; } @Override @@ -92,13 +93,24 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && mFluid != null) { - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); + IFluidHandler tTileEntity = + aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); if (tTileEntity != null) { - FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()), Math.max(1, mFluid.amount), false); + FluidStack tDrained = aBaseMetaTileEntity.drain( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()), + Math.max(1, mFluid.amount), + false); if (tDrained != null) { - int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); + int tFilledAmount = tTileEntity.fill( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); if (tFilledAmount > 0) { - tTileEntity.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()), tFilledAmount, true), true); + tTileEntity.fill( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), + aBaseMetaTileEntity.drain( + ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()), + tFilledAmount, + true), + true); } } } @@ -109,7 +121,8 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setByte("mMode", mMode); - if(lockedFluidName!=null && lockedFluidName.length()!=0) aNBT.setString("lockedFluidName", lockedFluidName); + if (lockedFluidName != null && lockedFluidName.length() != 0) + aNBT.setString("lockedFluidName", lockedFluidName); else aNBT.removeTag("lockedFluidName"); } @@ -120,7 +133,8 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { lockedFluidName = aNBT.getString("lockedFluidName"); lockedFluidName = lockedFluidName.length() == 0 ? null : lockedFluidName; if (GT_Utility.getFluidFromUnlocalizedName(lockedFluidName) != null) { - lockedFluidName = GT_Utility.getFluidFromUnlocalizedName(lockedFluidName).getName(); + lockedFluidName = + GT_Utility.getFluidFromUnlocalizedName(lockedFluidName).getName(); } } @@ -163,8 +177,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { // Because getStackDisplaySlot() only allow return one int, this place I only can manually set. if (tLockedFluid != null) { mInventory[3] = GT_Utility.getFluidDisplayStack(tLockedFluid, false, true); - } - else { + } else { mInventory[3] = null; } } @@ -198,13 +211,18 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { @Override public int getCapacity() { - return 8000*(1<<mTier); + return 8000 * (1 << mTier); } @Override public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (!getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), getBaseMetaTileEntity())) - return; + if (!getBaseMetaTileEntity() + .getCoverBehaviorAtSideNew(aSide) + .isGUIClickable( + aSide, + getBaseMetaTileEntity().getCoverIDAtSide(aSide), + getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), + getBaseMetaTileEntity())) return; if (aPlayer.isSneaking()) { mMode = (byte) ((mMode + 9) % 10); } else { @@ -213,85 +231,112 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { String inBrackets; switch (mMode) { case 0: - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("108","Outputs misc. Fluids, Steam and Items")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("108", "Outputs misc. Fluids, Steam and Items")); this.setLockedFluidName(null); break; case 1: - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("109","Outputs Steam and Items")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("109", "Outputs Steam and Items")); this.setLockedFluidName(null); break; case 2: - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("110","Outputs Steam and misc. Fluids")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("110", "Outputs Steam and misc. Fluids")); this.setLockedFluidName(null); break; case 3: - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("111","Outputs Steam")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("111", "Outputs Steam")); this.setLockedFluidName(null); break; case 4: - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("112","Outputs misc. Fluids and Items")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("112", "Outputs misc. Fluids and Items")); this.setLockedFluidName(null); break; case 5: - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("113","Outputs only Items")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("113", "Outputs only Items")); this.setLockedFluidName(null); break; case 6: - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("114","Outputs only misc. Fluids")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("114", "Outputs only misc. Fluids")); this.setLockedFluidName(null); break; case 7: - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("115","Outputs nothing")); + GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("115", "Outputs nothing")); this.setLockedFluidName(null); break; case 8: playerThatLockedfluid = aPlayer; if (mFluid == null) { this.setLockedFluidName(null); - inBrackets = GT_Utility.trans("115.3","currently none, will be locked to the next that is put in (or use fluid cell to lock)"); + inBrackets = GT_Utility.trans( + "115.3", + "currently none, will be locked to the next that is put in (or use fluid cell to lock)"); } else { this.setLockedFluidName(this.getDrainableStack().getFluid().getName()); inBrackets = this.getDrainableStack().getLocalizedName(); } - GT_Utility.sendChatToPlayer(aPlayer, String.format("%s (%s)", GT_Utility.trans("151.1", "Outputs items and 1 specific Fluid"), inBrackets)); + GT_Utility.sendChatToPlayer( + aPlayer, + String.format( + "%s (%s)", + GT_Utility.trans("151.1", "Outputs items and 1 specific Fluid"), inBrackets)); break; case 9: playerThatLockedfluid = aPlayer; if (mFluid == null) { this.setLockedFluidName(null); - inBrackets = GT_Utility.trans("115.3","currently none, will be locked to the next that is put in (or use fluid cell to lock)"); + inBrackets = GT_Utility.trans( + "115.3", + "currently none, will be locked to the next that is put in (or use fluid cell to lock)"); } else { this.setLockedFluidName(this.getDrainableStack().getFluid().getName()); inBrackets = this.getDrainableStack().getLocalizedName(); } - GT_Utility.sendChatToPlayer(aPlayer, String.format("%s (%s)", GT_Utility.trans("151.2", "Outputs 1 specific Fluid"), inBrackets)); + GT_Utility.sendChatToPlayer( + aPlayer, + String.format("%s (%s)", GT_Utility.trans("151.2", "Outputs 1 specific Fluid"), inBrackets)); break; } } private boolean tryToLockHatch(EntityPlayer aPlayer, byte aSide) { - if (!getBaseMetaTileEntity().getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), getBaseMetaTileEntity())) - return false; - if (!isFluidLocked()) - return false; + if (!getBaseMetaTileEntity() + .getCoverBehaviorAtSideNew(aSide) + .isGUIClickable( + aSide, + getBaseMetaTileEntity().getCoverIDAtSide(aSide), + getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), + getBaseMetaTileEntity())) return false; + if (!isFluidLocked()) return false; ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if (tCurrentItem == null) - return false; + if (tCurrentItem == null) return false; FluidStack tFluid = FluidContainerRegistry.getFluidForFilledItem(tCurrentItem); if (tFluid == null && tCurrentItem.getItem() instanceof IFluidContainerItem) - tFluid = ((IFluidContainerItem)tCurrentItem.getItem()).getFluid(tCurrentItem); + tFluid = ((IFluidContainerItem) tCurrentItem.getItem()).getFluid(tCurrentItem); if (tFluid != null) { - if (getLockedFluidName() != null && !getLockedFluidName().equals(tFluid.getFluid().getName())) { - GT_Utility.sendChatToPlayer(aPlayer, String.format("%s %s", GT_Utility.trans("151.3", - "Hatch is locked to a different fluid. To change the locking, empty it and made it locked to the next fluid with a screwdriver. Currently locked to") - , StatCollector.translateToLocal(getLockedFluidName()))); - } - else { + if (getLockedFluidName() != null + && !getLockedFluidName().equals(tFluid.getFluid().getName())) { + GT_Utility.sendChatToPlayer( + aPlayer, + String.format( + "%s %s", + GT_Utility.trans( + "151.3", + "Hatch is locked to a different fluid. To change the locking, empty it and made it locked to the next fluid with a screwdriver. Currently locked to"), + StatCollector.translateToLocal(getLockedFluidName()))); + } else { setLockedFluidName(tFluid.getFluid().getName()); if (mMode == 8) - GT_Utility.sendChatToPlayer(aPlayer, String.format("%s (%s)", GT_Utility.trans("151.1", "Outputs items and 1 specific Fluid"), tFluid.getLocalizedName())); + GT_Utility.sendChatToPlayer( + aPlayer, + String.format( + "%s (%s)", + GT_Utility.trans("151.1", "Outputs items and 1 specific Fluid"), + tFluid.getLocalizedName())); else - GT_Utility.sendChatToPlayer(aPlayer, String.format("%s (%s)", GT_Utility.trans("151.2", "Outputs 1 specific Fluid"), tFluid.getLocalizedName())); + GT_Utility.sendChatToPlayer( + aPlayer, + String.format( + "%s (%s)", + GT_Utility.trans("151.2", "Outputs 1 specific Fluid"), tFluid.getLocalizedName())); } return true; } @@ -303,9 +348,9 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - if (tryToLockHatch(aPlayer, aSide)) - return true; + public boolean onRightclick( + IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { + if (tryToLockHatch(aPlayer, aSide)) return true; return super.onRightclick(aBaseMetaTileEntity, aPlayer, aSide, aX, aY, aZ); } @@ -342,7 +387,10 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { protected void onEmptyingContainerWhenEmpty() { if (this.lockedFluidName == null && this.mFluid != null) { this.setLockedFluidName(this.mFluid.getFluid().getName()); - GT_Utility.sendChatToPlayer(playerThatLockedfluid, String.format(GT_Utility.trans("151.4","Sucessfully locked Fluid to %s"), mFluid.getLocalizedName())); + GT_Utility.sendChatToPlayer( + playerThatLockedfluid, + String.format( + GT_Utility.trans("151.4", "Sucessfully locked Fluid to %s"), mFluid.getLocalizedName())); } } @@ -353,13 +401,20 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { @Override public String[] getInfoData() { - return new String[]{ - EnumChatFormatting.BLUE + "Output Hatch" + EnumChatFormatting.RESET, - "Stored Fluid:", - EnumChatFormatting.GOLD + (mFluid == null ? "No Fluid" : mFluid.getLocalizedName()) + EnumChatFormatting.RESET, - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mFluid == null ? 0 : mFluid.amount) + " L" + EnumChatFormatting.RESET + " " + - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getCapacity()) + " L"+ EnumChatFormatting.RESET, - (!isFluidLocked() || lockedFluidName == null) ? "Not Locked" : ("Locked to " + StatCollector.translateToLocal(FluidRegistry.getFluidStack(lockedFluidName, 1).getUnlocalizedName())) + return new String[] { + EnumChatFormatting.BLUE + "Output Hatch" + EnumChatFormatting.RESET, + "Stored Fluid:", + EnumChatFormatting.GOLD + + (mFluid == null ? "No Fluid" : mFluid.getLocalizedName()) + + EnumChatFormatting.RESET, + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mFluid == null ? 0 : mFluid.amount) + " L" + + EnumChatFormatting.RESET + " " + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(getCapacity()) + " L" + EnumChatFormatting.RESET, + (!isFluidLocked() || lockedFluidName == null) + ? "Not Locked" + : ("Locked to " + + StatCollector.translateToLocal(FluidRegistry.getFluidStack(lockedFluidName, 1) + .getUnlocalizedName())) }; } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java index 8ee2f48b2d..5b08f7ae69 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java @@ -1,5 +1,9 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.Textures.BlockIcons.ITEM_OUT_SIGN; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; +import static gregtech.api.util.GT_Utility.moveMultipleItemStacks; + import gregtech.GT_Mod; import gregtech.api.gui.*; import gregtech.api.interfaces.ITexture; @@ -13,31 +17,36 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import static gregtech.api.enums.Textures.BlockIcons.ITEM_OUT_SIGN; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPE_OUT; -import static gregtech.api.util.GT_Utility.moveMultipleItemStacks; - public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier) { this(aID, aName, aNameRegional, aTier, getSlots(aTier)); } public GT_MetaTileEntity_Hatch_OutputBus(int id, String name, String nameRegional, int tier, int slots) { - super(id, name, nameRegional, tier, slots, ArrayExt.of( - "Item Output for Multiblocks", - "Capacity: " + getSlots(tier) + " stack" + (getSlots(tier) >= 2 ? "s" : ""))); - } - - public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier, String[] aDescription) { + super( + id, + name, + nameRegional, + tier, + slots, + ArrayExt.of( + "Item Output for Multiblocks", + "Capacity: " + getSlots(tier) + " stack" + (getSlots(tier) >= 2 ? "s" : ""))); + } + + public GT_MetaTileEntity_Hatch_OutputBus( + int aID, String aName, String aNameRegional, int aTier, String[] aDescription) { super(aID, aName, aNameRegional, aTier, getSlots(aTier), aDescription); } - public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier, String[] aDescription, int inventorySize) { + public GT_MetaTileEntity_Hatch_OutputBus( + int aID, String aName, String aNameRegional, int aTier, String[] aDescription, int inventorySize) { super(aID, aName, aNameRegional, aTier, inventorySize, aDescription); } @Deprecated - // having too many constructors is bad, don't be so lazy, use GT_MetaTileEntity_Hatch_OutputBus(String, int, String[], ITexture[][][]) + // having too many constructors is bad, don't be so lazy, use GT_MetaTileEntity_Hatch_OutputBus(String, int, + // String[], ITexture[][][]) public GT_MetaTileEntity_Hatch_OutputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { this(aName, aTier, getSlots(aTier), ArrayExt.of(aDescription), aTextures); } @@ -46,22 +55,23 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { super(aName, aTier, getSlots(aTier), aDescription, aTextures); } - public GT_MetaTileEntity_Hatch_OutputBus(String name, int tier, int slots, String[] description, ITexture[][][] textures) { + public GT_MetaTileEntity_Hatch_OutputBus( + String name, int tier, int slots, String[] description, ITexture[][][] textures) { super(name, tier, slots, description, textures); } @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(ITEM_OUT_SIGN)} : - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch + ? new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(ITEM_OUT_SIGN)} + : new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch ? - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(ITEM_OUT_SIGN)} : - new ITexture[]{aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; + return GT_Mod.gregtechproxy.mRenderIndicatorsOnHatch + ? new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT), TextureFactory.of(ITEM_OUT_SIGN)} + : new ITexture[] {aBaseTexture, TextureFactory.of(OVERLAY_PIPE_OUT)}; } @Override @@ -144,9 +154,9 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { mInventory[i] = aStack.splitStack(getInventoryStackLimit()); } else { int tRealStackLimit = Math.min(getInventoryStackLimit(), tSlot.getMaxStackSize()); - if (tSlot.stackSize < tRealStackLimit && - tSlot.isItemEqual(aStack) && - ItemStack.areItemStackTagsEqual(tSlot, aStack)) { + if (tSlot.stackSize < tRealStackLimit + && tSlot.isItemEqual(aStack) + && ItemStack.areItemStackTagsEqual(tSlot, aStack)) { if (aStack.stackSize + tSlot.stackSize <= tRealStackLimit) { mInventory[i].stackSize += aStack.stackSize; return true; @@ -174,15 +184,27 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && (aTick&0x7)==0) { - IInventory tTileEntity =aBaseMetaTileEntity.getIInventoryAtSide(aBaseMetaTileEntity.getFrontFacing()); - if(tTileEntity!=null){ - moveMultipleItemStacks(aBaseMetaTileEntity,tTileEntity,aBaseMetaTileEntity.getFrontFacing(),aBaseMetaTileEntity.getBackFacing(),null,false,(byte)64,(byte)1,(byte)64,(byte)1,mInventory.length); + if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && (aTick & 0x7) == 0) { + IInventory tTileEntity = aBaseMetaTileEntity.getIInventoryAtSide(aBaseMetaTileEntity.getFrontFacing()); + if (tTileEntity != null) { + moveMultipleItemStacks( + aBaseMetaTileEntity, + tTileEntity, + aBaseMetaTileEntity.getFrontFacing(), + aBaseMetaTileEntity.getBackFacing(), + null, + false, + (byte) 64, + (byte) 1, + (byte) 64, + (byte) 1, + mInventory.length); for (int i = 0; i < mInventory.length; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; -// GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity, -// aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), -// null, false, (byte) 64, (byte) 1, (byte)( 64 * aBaseMetaTileEntity.getSizeInventory()), (byte) 1); + // GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity, + // aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), + // null, false, (byte) 64, (byte) 1, (byte)( 64 * + // aBaseMetaTileEntity.getSizeInventory()), (byte) 1); } } } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index e29499b0b1..bd8daabfb9 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -1,5 +1,10 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.*; +import static mcp.mobius.waila.api.SpecialChars.GREEN; +import static mcp.mobius.waila.api.SpecialChars.RED; +import static mcp.mobius.waila.api.SpecialChars.RESET; + import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; @@ -18,6 +23,8 @@ import gregtech.api.util.GT_Single_Recipe_Check; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; import gregtech.common.items.GT_MetaGenerated_Tool_01; +import java.util.ArrayList; +import java.util.List; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.minecraft.entity.player.EntityPlayer; @@ -32,20 +39,26 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; -import java.util.ArrayList; -import java.util.List; - -import static gregtech.api.enums.GT_Values.*; -import static mcp.mobius.waila.api.SpecialChars.GREEN; -import static mcp.mobius.waila.api.SpecialChars.RED; -import static mcp.mobius.waila.api.SpecialChars.RESET; - public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public static boolean disableMaintenance; - public boolean mMachine = false, mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, mCrowbar = false, mRunningOnLoad = false; + public boolean mMachine = false, + mWrench = false, + mScrewdriver = false, + mSoftHammer = false, + mHardHammer = false, + mSolderingTool = false, + mCrowbar = false, + mRunningOnLoad = false; public boolean mStructureChanged = false; - public int mPollution = 0, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mEfficiencyIncrease = 0, mStartUpCheck = 100, mRuntime = 0, mEfficiency = 0; + public int mPollution = 0, + mProgresstime = 0, + mMaxProgresstime = 0, + mEUt = 0, + mEfficiencyIncrease = 0, + mStartUpCheck = 100, + mRuntime = 0, + mEfficiency = 0; public volatile boolean mUpdated = false; public int mUpdate = 0; public ItemStack[] mOutputItems = null; @@ -69,21 +82,29 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public GT_MetaTileEntity_MultiBlockBase(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 2); - GT_MetaTileEntity_MultiBlockBase.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); - this.damageFactorLow = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.damageFactorLow", 5); - this.damageFactorHigh = (float) GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.damageFactorHigh", 0.6f); + GT_MetaTileEntity_MultiBlockBase.disableMaintenance = GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); + this.damageFactorLow = + GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.damageFactorLow", 5); + this.damageFactorHigh = (float) GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, "MultiBlockMachines.damageFactorHigh", 0.6f); this.mNEI = ""; } public GT_MetaTileEntity_MultiBlockBase(String aName) { super(aName, 2); - GT_MetaTileEntity_MultiBlockBase.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); - this.damageFactorLow = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.damageFactorLow", 5); - this.damageFactorHigh = (float) GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.damageFactorHigh", 0.6f); + GT_MetaTileEntity_MultiBlockBase.disableMaintenance = GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); + this.damageFactorLow = + GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.damageFactorLow", 5); + this.damageFactorHigh = (float) GregTech_API.sMachineFile.get( + ConfigCategories.machineconfig, "MultiBlockMachines.damageFactorHigh", 0.6f); } public static boolean isValidMetaTileEntity(MetaTileEntity aMetaTileEntity) { - return aMetaTileEntity.getBaseMetaTileEntity() != null && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); + return aMetaTileEntity.getBaseMetaTileEntity() != null + && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity + && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); } @Override @@ -106,7 +127,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (supportsSingleRecipeLocking()) { mLockedToSingleRecipe = !mLockedToSingleRecipe; if (mLockedToSingleRecipe) { - GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("223", "Single recipe locking enabled. Will lock to next recipe.")); + GT_Utility.sendChatToPlayer( + aPlayer, GT_Utility.trans("223", "Single recipe locking enabled. Will lock to next recipe.")); } else { GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("220", "Single recipe locking disabled.")); mSingleRecipeCheck = null; @@ -234,7 +256,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MultiblockDisplay.png"); + return new GT_GUIContainer_MultiMachine( + aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MultiblockDisplay.png"); } @Override @@ -274,7 +297,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } public boolean checkStructure(boolean aForceReset, IGregTechTileEntity aBaseMetaTileEntity) { - if(!aBaseMetaTileEntity.isServerSide()) return mMachine; + if (!aBaseMetaTileEntity.isServerSide()) return mMachine; // Only trigger an update if forced (from onPostTick, generally), or if the structure has changed if ((mStructureChanged || aForceReset)) { clearHatches(); @@ -307,9 +330,16 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { stopMachine(); } } - aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64)); + aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) + | (mWrench ? 0 : 1) + | (mScrewdriver ? 0 : 2) + | (mSoftHammer ? 0 : 4) + | (mHardHammer ? 0 : 8) + | (mSolderingTool ? 0 : 16) + | (mCrowbar ? 0 : 32) + | (mMachine ? 0 : 64)); aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); - boolean active=aBaseMetaTileEntity.isActive() && mPollution>0; + boolean active = aBaseMetaTileEntity.isActive() && mPollution > 0; for (GT_MetaTileEntity_Hatch_Muffler aMuffler : mMufflerHatches) { IGregTechTileEntity iGTTileEntity = aMuffler.getBaseMetaTileEntity(); if (iGTTileEntity != null && !iGTTileEntity.isDead()) { @@ -332,7 +362,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) { if (isValidMetaTileEntity(tHatch)) { - if (tHatch.mAuto && !( mWrench && mScrewdriver && mSoftHammer && mHardHammer && mSolderingTool && mCrowbar)) tHatch.autoMaintainance(); + if (tHatch.mAuto + && !(mWrench && mScrewdriver && mSoftHammer && mHardHammer && mSolderingTool && mCrowbar)) + tHatch.autoMaintainance(); if (tHatch.mWrench) mWrench = true; if (tHatch.mScrewdriver) mScrewdriver = true; if (tHatch.mSoftHammer) mSoftHammer = true; @@ -350,8 +382,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } } - protected boolean checkRecipe() - { + protected boolean checkRecipe() { startRecipeProcessing(); boolean result = checkRecipe(mInventory[1]); endRecipeProcessing(); @@ -366,19 +397,27 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { stopMachine(); } if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { - if (mOutputItems != null) for (ItemStack tStack : mOutputItems) - if (tStack != null) { - try { - GT_Mod.achievements.issueAchivementHatch( - aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack); - } catch (Exception ignored) { + if (mOutputItems != null) + for (ItemStack tStack : mOutputItems) + if (tStack != null) { + try { + GT_Mod.achievements.issueAchivementHatch( + aBaseMetaTileEntity + .getWorld() + .getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), + tStack); + } catch (Exception ignored) { + } + addOutput(tStack); } - addOutput(tStack); - } if (mOutputFluids != null) { addFluidOutputs(mOutputFluids); } - mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + mEfficiency = Math.max( + 0, + Math.min( + mEfficiency + mEfficiencyIncrease, + getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); mOutputItems = null; mProgresstime = 0; mMaxProgresstime = 0; @@ -389,7 +428,11 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (mOutputFluids != null && mOutputFluids.length > 0) { if (mOutputFluids.length > 1) { try { - GT_Mod.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "oilplant"); + GT_Mod.achievements.issueAchievement( + aBaseMetaTileEntity + .getWorld() + .getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), + "oilplant"); } catch (Exception ignored) { } } @@ -397,7 +440,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } } } else { - if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { + if (aTick % 100 == 0 + || aBaseMetaTileEntity.hasWorkJustBeenEnabled() + || aBaseMetaTileEntity.hasInventoryBeenModified()) { if (aBaseMetaTileEntity.isAllowedToWork()) { if (checkRecipe()) { @@ -465,15 +510,15 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { /** * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pullution Block) */ - public int getPollutionPerTick(ItemStack aStack){ - return getPollutionPerSecond(aStack)/20; + public int getPollutionPerTick(ItemStack aStack) { + return getPollutionPerSecond(aStack) / 20; } /** * Gets the pollution produced per second by this multiblock, default to 0. Override this with * its actual value in the code of the multiblock. */ - public int getPollutionPerSecond(ItemStack aStack){ + public int getPollutionPerSecond(ItemStack aStack) { return 0; } @@ -503,18 +548,22 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } public int getRepairStatus() { - return (mWrench ? 1 : 0) + (mScrewdriver ? 1 : 0) + (mSoftHammer ? 1 : 0) + (mHardHammer ? 1 : 0) + (mSolderingTool ? 1 : 0) + (mCrowbar ? 1 : 0); + return (mWrench ? 1 : 0) + + (mScrewdriver ? 1 : 0) + + (mSoftHammer ? 1 : 0) + + (mHardHammer ? 1 : 0) + + (mSolderingTool ? 1 : 0) + + (mCrowbar ? 1 : 0); } public int getIdealStatus() { return 6; } - public int getCurrentEfficiency(ItemStack itemStack) { - int maxEff = getMaxEfficiency(itemStack); - return maxEff - (getIdealStatus() - getRepairStatus()) * maxEff / 10; - } + int maxEff = getMaxEfficiency(itemStack); + return maxEff - (getIdealStatus() - getRepairStatus()) * maxEff / 10; + } public boolean doRandomMaintenanceDamage() { if (!isCorrectMachinePart(mInventory[1]) || getRepairStatus() == 0) { @@ -545,10 +594,18 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { break; } } - if (mInventory[1] != null && getBaseMetaTileEntity().getRandomNumber(2) == 0 && !mInventory[1].getUnlocalizedName().startsWith("gt.blockmachines.basicmachine.")) { + if (mInventory[1] != null + && getBaseMetaTileEntity().getRandomNumber(2) == 0 + && !mInventory[1].getUnlocalizedName().startsWith("gt.blockmachines.basicmachine.")) { if (mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01) { NBTTagCompound tNBT = mInventory[1].getTagCompound(); - ((GT_MetaGenerated_Tool) mInventory[1].getItem()).doDamage(mInventory[1], (long)getDamageToComponent(mInventory[1]) * (long) Math.min(mEUt / this.damageFactorLow, Math.pow(mEUt, this.damageFactorHigh))); + ((GT_MetaGenerated_Tool) mInventory[1].getItem()) + .doDamage( + mInventory[1], + (long) getDamageToComponent(mInventory[1]) + * (long) Math.min( + mEUt / this.damageFactorLow, + Math.pow(mEUt, this.damageFactorHigh))); if (mInventory[1].stackSize == 0) mInventory[1] = null; } } @@ -558,18 +615,30 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public void explodeMultiblock() { - GT_Log.exp.println("MultiBlockExplosion at: " +this.getBaseMetaTileEntity().getXCoord()+" | "+this.getBaseMetaTileEntity().getYCoord()+" | "+this.getBaseMetaTileEntity().getZCoord()+" DIMID: "+ this.getBaseMetaTileEntity().getWorld().provider.dimensionId+"."); + GT_Log.exp.println( + "MultiBlockExplosion at: " + this.getBaseMetaTileEntity().getXCoord() + " | " + + this.getBaseMetaTileEntity().getYCoord() + " | " + + this.getBaseMetaTileEntity().getZCoord() + " DIMID: " + + this.getBaseMetaTileEntity().getWorld().provider.dimensionId + "."); GT_Pollution.addPollution(getBaseMetaTileEntity(), GT_Mod.gregtechproxy.mPollutionOnExplosion); mInventory[1] = null; - for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mInputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mOutputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mDynamoHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mMufflerHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mEnergyHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mMaintenanceHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mInputBusses) + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mOutputBusses) + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mInputHatches) + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mOutputHatches) + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mDynamoHatches) + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mMufflerHatches) + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mEnergyHatches) + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); + for (MetaTileEntity tTileEntity : mMaintenanceHatches) + tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); getBaseMetaTileEntity().doExplosion(V[8]); } @@ -582,13 +651,14 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } return false; } + public boolean addEnergyOutputMultipleDynamos(long aEU, boolean aAllowMixedVoltageDynamos) { int injected = 0; long totalOutput = 0; long aFirstVoltageFound = -1; boolean aFoundMixedDynamos = false; for (GT_MetaTileEntity_Hatch_Dynamo aDynamo : mDynamoHatches) { - if( aDynamo == null ) { + if (aDynamo == null) { return false; } if (isValidMetaTileEntity(aDynamo)) { @@ -597,8 +667,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { // Check against voltage to check when hatch mixing if (aFirstVoltageFound == -1) { aFirstVoltageFound = aVoltage; - } - else { + } else { if (aFirstVoltageFound != aVoltage) { aFoundMixedDynamos = true; } @@ -623,14 +692,14 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { aVoltage = aDynamo.maxEUOutput(); aAmpsToInject = (int) (leftToInject / aVoltage); aRemainder = (int) (leftToInject - (aAmpsToInject * aVoltage)); - ampsOnCurrentHatch= (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject); + ampsOnCurrentHatch = (int) Math.min(aDynamo.maxAmperesOut(), aAmpsToInject); for (int i = 0; i < ampsOnCurrentHatch; i++) { aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aVoltage, false); } - injected+=aVoltage*ampsOnCurrentHatch; - if(aRemainder>0 && ampsOnCurrentHatch<aDynamo.maxAmperesOut()){ + injected += aVoltage * ampsOnCurrentHatch; + if (aRemainder > 0 && ampsOnCurrentHatch < aDynamo.maxAmperesOut()) { aDynamo.getBaseMetaTileEntity().increaseStoredEnergyUnits(aRemainder, false); - injected+=aRemainder; + injected += aRemainder; } } } @@ -640,7 +709,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public long getMaxInputVoltage() { long rVoltage = 0; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); + if (isValidMetaTileEntity(tHatch)) + rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); return rVoltage; } @@ -652,23 +722,24 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { * @param maxInputVoltage - Multiblock Max input voltage * @param perfectOC - If the Multiblock OCs perfectly, i.e. the large Chemical Reactor */ - protected void calculateOverclockedNessMultiInternal(int aEUt, int aDuration, int mAmperage, long maxInputVoltage, boolean perfectOC) { + protected void calculateOverclockedNessMultiInternal( + int aEUt, int aDuration, int mAmperage, long maxInputVoltage, boolean perfectOC) { byte mTier = (byte) Math.max(0, GT_Utility.getTier(maxInputVoltage)); - if(mTier == 0){ - //Long time calculation - long xMaxProgresstime = ((long)aDuration)<<1; - if(xMaxProgresstime > Integer.MAX_VALUE - 1){ - //make impossible if too long + if (mTier == 0) { + // Long time calculation + long xMaxProgresstime = ((long) aDuration) << 1; + if (xMaxProgresstime > Integer.MAX_VALUE - 1) { + // make impossible if too long mEUt = Integer.MAX_VALUE - 1; mMaxProgresstime = Integer.MAX_VALUE - 1; - }else{ + } else { mEUt = aEUt >> 2; - mMaxProgresstime= (int) xMaxProgresstime; + mMaxProgresstime = (int) xMaxProgresstime; } - }else{ - //Long EUt calculation + } else { + // Long EUt calculation long xEUt = aEUt; - //Isnt too low EUt check? + // Isnt too low EUt check? long tempEUt = Math.max(xEUt, V[1]); mMaxProgresstime = aDuration; @@ -676,41 +747,35 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { final int ocTimeShift = perfectOC ? 2 : 1; while (tempEUt <= V[mTier - 1] * mAmperage) { - tempEUt <<= 2;//this actually controls overclocking - //xEUt *= 4;//this is effect of everclocking + tempEUt <<= 2; // this actually controls overclocking + // xEUt *= 4;//this is effect of everclocking int oldTime = mMaxProgresstime; - mMaxProgresstime >>= ocTimeShift;//this is effect of overclocking - if (mMaxProgresstime <1) - { - if(oldTime == 1) - break; - xEUt *= oldTime * (perfectOC ? 1:2); + mMaxProgresstime >>= ocTimeShift; // this is effect of overclocking + if (mMaxProgresstime < 1) { + if (oldTime == 1) break; + xEUt *= oldTime * (perfectOC ? 1 : 2); break; - } - else - { + } else { xEUt <<= 2; } } - if(xEUt > Integer.MAX_VALUE - 1) { + if (xEUt > Integer.MAX_VALUE - 1) { mEUt = Integer.MAX_VALUE - 1; mMaxProgresstime = Integer.MAX_VALUE - 1; } else { mEUt = (int) xEUt; - if(mEUt == 0) - mEUt = 1; - if(mMaxProgresstime == 0) - mMaxProgresstime = 1;//set time to 1 tick + if (mEUt == 0) mEUt = 1; + if (mMaxProgresstime == 0) mMaxProgresstime = 1; // set time to 1 tick } } } protected void calculateOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { - calculateOverclockedNessMultiInternal(aEUt,aDuration,mAmperage,maxInputVoltage,false); + calculateOverclockedNessMultiInternal(aEUt, aDuration, mAmperage, maxInputVoltage, false); } protected void calculatePerfectOverclockedNessMulti(int aEUt, int aDuration, int mAmperage, long maxInputVoltage) { - calculateOverclockedNessMultiInternal(aEUt,aDuration,mAmperage,maxInputVoltage,true); + calculateOverclockedNessMultiInternal(aEUt, aDuration, mAmperage, maxInputVoltage, true); } public boolean drainEnergyInput(long aEU) { @@ -722,27 +787,33 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { return false; } - protected static boolean dumpFluid(List<GT_MetaTileEntity_Hatch_Output> aOutputHatches, FluidStack copiedFluidStack, boolean restrictiveHatchesOnly){ + protected static boolean dumpFluid( + List<GT_MetaTileEntity_Hatch_Output> aOutputHatches, + FluidStack copiedFluidStack, + boolean restrictiveHatchesOnly) { for (GT_MetaTileEntity_Hatch_Output tHatch : aOutputHatches) { - if (!isValidMetaTileEntity(tHatch) || (restrictiveHatchesOnly && tHatch.mMode == 0)) { - continue; - } - if (GT_ModHandler.isSteam(copiedFluidStack)) { - if (!tHatch.outputsSteam()) { - continue; - } - } else { - if (!tHatch.outputsLiquids()) { - continue; - } - if (tHatch.isFluidLocked() && tHatch.getLockedFluidName() != null && !tHatch.getLockedFluidName().equals(copiedFluidStack.getFluid().getName())) { - continue; - } - } + if (!isValidMetaTileEntity(tHatch) || (restrictiveHatchesOnly && tHatch.mMode == 0)) { + continue; + } + if (GT_ModHandler.isSteam(copiedFluidStack)) { + if (!tHatch.outputsSteam()) { + continue; + } + } else { + if (!tHatch.outputsLiquids()) { + continue; + } + if (tHatch.isFluidLocked() + && tHatch.getLockedFluidName() != null + && !tHatch.getLockedFluidName() + .equals(copiedFluidStack.getFluid().getName())) { + continue; + } + } int tAmount = tHatch.fill(copiedFluidStack, false); if (tAmount >= copiedFluidStack.amount) { - boolean filled = tHatch.fill(copiedFluidStack, true) >= copiedFluidStack.amount; - tHatch.onEmptyingContainerWhenEmpty(); + boolean filled = tHatch.fill(copiedFluidStack, true) >= copiedFluidStack.amount; + tHatch.onEmptyingContainerWhenEmpty(); return filled; } else if (tAmount > 0) { copiedFluidStack.amount = copiedFluidStack.amount - tHatch.fill(copiedFluidStack, true); @@ -755,7 +826,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public boolean addOutput(FluidStack aLiquid) { if (aLiquid == null) return false; FluidStack copiedFluidStack = aLiquid.copy(); - if (!dumpFluid(mOutputHatches, copiedFluidStack, true)){ + if (!dumpFluid(mOutputHatches, copiedFluidStack, true)) { dumpFluid(mOutputHatches, copiedFluidStack, false); } return false; @@ -763,7 +834,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { protected void addFluidOutputs(FluidStack[] mOutputFluids2) { for (FluidStack outputFluidStack : mOutputFluids2) { - addOutput(outputFluidStack); + addOutput(outputFluidStack); } } @@ -780,8 +851,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { return tLiquid != null && tLiquid.amount >= aLiquid.amount; } } - } - else { + } else { FluidStack tLiquid = tHatch.getFluid(); if (tLiquid != null && tLiquid.isFluidEqual(aLiquid)) { tLiquid = tHatch.drain(aLiquid.amount, false); @@ -824,7 +894,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { tHatch.mRecipeMap = getRecipeMap(); if (isValidMetaTileEntity(tHatch)) { - if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) { + if (GT_Utility.areStacksEqual( + aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) { if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); return true; @@ -836,7 +907,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { tHatch.mRecipeMap = getRecipeMap(); if (isValidMetaTileEntity(tHatch)) { for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) { + if (GT_Utility.areStacksEqual( + aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) { if (tHatch.getBaseMetaTileEntity().getStackInSlot(i).stackSize >= aStack.stackSize) { tHatch.getBaseMetaTileEntity().decrStackSize(i, aStack.stackSize); return true; @@ -850,11 +922,11 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public ArrayList<ItemStack> getStoredOutputs() { ArrayList<ItemStack> rList = new ArrayList<>(); -// for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { -// if (isValidMetaTileEntity(tHatch)) { -// rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1)); -// } -// } + // for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { + // if (isValidMetaTileEntity(tHatch)) { + // rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1)); + // } + // } for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { if (isValidMetaTileEntity(tHatch)) { for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { @@ -873,15 +945,14 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (isValidMetaTileEntity(tHatch)) { for (FluidStack tFluid : ((GT_MetaTileEntity_Hatch_MultiInput) tHatch).getStoredFluid()) { if (tFluid != null) { - //GT_Log.out.print("mf: " + tFluid + "\n"); + // GT_Log.out.print("mf: " + tFluid + "\n"); rList.add(tFluid); } } } - } - else { + } else { if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { - //GT_Log.out.print("sf: " + tHatch.getFillableStack() + "\n"); + // GT_Log.out.print("sf: " + tHatch.getFillableStack() + "\n"); rList.add(tHatch.getFillableStack()); } } @@ -900,7 +971,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } } } - if(getStackInSlot(1) != null && getStackInSlot(1).getUnlocalizedName().startsWith("gt.integrated_circuit")) + if (getStackInSlot(1) != null && getStackInSlot(1).getUnlocalizedName().startsWith("gt.integrated_circuit")) rList.add(getStackInSlot(1)); return rList; } @@ -916,19 +987,18 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); } - protected void startRecipeProcessing() - { + protected void startRecipeProcessing() { for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) if (isValidMetaTileEntity(tHatch)) tHatch.startRecipeProcessing(); } - protected void endRecipeProcessing() - { + protected void endRecipeProcessing() { for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) if (isValidMetaTileEntity(tHatch)) tHatch.endRecipeProcessing(); } - protected static <T extends GT_MetaTileEntity_Hatch> T identifyHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex, Class<T> clazz) { + protected static <T extends GT_MetaTileEntity_Hatch> T identifyHatch( + IGregTechTileEntity aTileEntity, int aBaseCasingIndex, Class<T> clazz) { if (aTileEntity == null) return null; IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (!clazz.isInstance(aMetaTileEntity)) return null; @@ -995,7 +1065,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aTileEntity == null) return false; IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch && GT_ExoticEnergyInputHelper.isExoticEnergyInput(aMetaTileEntity)) { + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch + && GT_ExoticEnergyInputHelper.isExoticEnergyInput(aMetaTileEntity)) { GT_MetaTileEntity_Hatch hatch = (GT_MetaTileEntity_Hatch) aMetaTileEntity; hatch.updateTexture(aBaseCasingIndex); return mExoticEnergyHatches.add(hatch); @@ -1026,13 +1097,13 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - return addInputBusToMachineList(aTileEntity, aBaseCasingIndex) || - addInputHatchToMachineList(aTileEntity, aBaseCasingIndex); + return addInputBusToMachineList(aTileEntity, aBaseCasingIndex) + || addInputHatchToMachineList(aTileEntity, aBaseCasingIndex); } public boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - return addOutputBusToMachineList(aTileEntity, aBaseCasingIndex) || - addOutputHatchToMachineList(aTileEntity, aBaseCasingIndex); + return addOutputBusToMachineList(aTileEntity, aBaseCasingIndex) + || addOutputHatchToMachineList(aTileEntity, aBaseCasingIndex); } public boolean addInputBusToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { @@ -1083,41 +1154,45 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { @Override public String[] getInfoData() { - int mPollutionReduction=0; + int mPollutionReduction = 0; for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { if (isValidMetaTileEntity(tHatch)) { - mPollutionReduction=Math.max(tHatch.calculatePollutionReduction(100),mPollutionReduction); + mPollutionReduction = Math.max(tHatch.calculatePollutionReduction(100), mPollutionReduction); } } - long storedEnergy=0; - long maxEnergy=0; - for(GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { + long storedEnergy = 0; + long maxEnergy = 0; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { if (isValidMetaTileEntity(tHatch)) { - storedEnergy+=tHatch.getBaseMetaTileEntity().getStoredEU(); - maxEnergy+=tHatch.getBaseMetaTileEntity().getEUCapacity(); + storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); } } - return new String[]{ - /* 1*/ StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mProgresstime/20) + EnumChatFormatting.RESET + " s / " + - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mMaxProgresstime/20) + EnumChatFormatting.RESET + " s", - /* 2*/ StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + - EnumChatFormatting.GREEN + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", - /* 3*/ StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + - EnumChatFormatting.RED + GT_Utility.formatNumbers(-mEUt) + EnumChatFormatting.RESET + " EU/t", - /* 4*/ StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + - EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(getMaxInputVoltage()) + EnumChatFormatting.RESET + " EU/t(*2A) " + - StatCollector.translateToLocal("GT5U.machines.tier") + ": " + - EnumChatFormatting.YELLOW + VN[GT_Utility.getTier(getMaxInputVoltage())] + EnumChatFormatting.RESET, - /* 5*/ StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + - EnumChatFormatting.RED + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + " " + - StatCollector.translateToLocal("GT5U.multiblock.efficiency") + ": " + - EnumChatFormatting.YELLOW + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", - /* 6*/ StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + - EnumChatFormatting.GREEN + mPollutionReduction + EnumChatFormatting.RESET + " %" + return new String[] { + /* 1*/ StatCollector.translateToLocal("GT5U.multiblock.Progress") + ": " + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(mProgresstime / 20) + EnumChatFormatting.RESET + " s / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(mMaxProgresstime / 20) + EnumChatFormatting.RESET + " s", + /* 2*/ StatCollector.translateToLocal("GT5U.multiblock.energy") + ": " + EnumChatFormatting.GREEN + + GT_Utility.formatNumbers(storedEnergy) + EnumChatFormatting.RESET + " EU / " + + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(maxEnergy) + EnumChatFormatting.RESET + " EU", + /* 3*/ StatCollector.translateToLocal("GT5U.multiblock.usage") + ": " + EnumChatFormatting.RED + + GT_Utility.formatNumbers(-mEUt) + EnumChatFormatting.RESET + " EU/t", + /* 4*/ StatCollector.translateToLocal("GT5U.multiblock.mei") + ": " + EnumChatFormatting.YELLOW + + GT_Utility.formatNumbers(getMaxInputVoltage()) + EnumChatFormatting.RESET + " EU/t(*2A) " + + StatCollector.translateToLocal("GT5U.machines.tier") + + ": " + EnumChatFormatting.YELLOW + + VN[GT_Utility.getTier(getMaxInputVoltage())] + EnumChatFormatting.RESET, + /* 5*/ StatCollector.translateToLocal("GT5U.multiblock.problems") + ": " + EnumChatFormatting.RED + + (getIdealStatus() - getRepairStatus()) + EnumChatFormatting.RESET + " " + + StatCollector.translateToLocal("GT5U.multiblock.efficiency") + + ": " + EnumChatFormatting.YELLOW + + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", + /* 6*/ StatCollector.translateToLocal("GT5U.multiblock.pollution") + ": " + EnumChatFormatting.GREEN + + mPollutionReduction + EnumChatFormatting.RESET + " %" }; } @@ -1136,14 +1211,13 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { return false; } - protected ItemStack[] getCompactedInputs(){ - //TODO: repalce method with a cleaner one + protected ItemStack[] getCompactedInputs() { + // TODO: repalce method with a cleaner one ArrayList<ItemStack> tInputList = getStoredInputs(); int tInputList_sS = tInputList.size(); for (int i = 0; i < tInputList_sS - 1; i++) { for (int j = i + 1; j < tInputList_sS; j++) { - if (!GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) - continue; + if (!GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) continue; if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { tInputList.remove(j--); tInputList_sS = tInputList.size(); @@ -1157,14 +1231,13 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { return tInputList.toArray(new ItemStack[0]); } - protected FluidStack[] getCompactedFluids(){ - //TODO: repalce method with a cleaner one + protected FluidStack[] getCompactedFluids() { + // TODO: repalce method with a cleaner one ArrayList<FluidStack> tFluidList = getStoredFluids(); int tFluidList_sS = tFluidList.size(); for (int i = 0; i < tFluidList_sS - 1; i++) { for (int j = i + 1; j < tFluidList_sS; j++) { - if (!GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) - continue; + if (!GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) continue; if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { tFluidList.remove(j--); @@ -1180,31 +1253,32 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } @Override - public void getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + public void getWailaBody( + ItemStack itemStack, List<String> currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { final NBTTagCompound tag = accessor.getNBTData(); - if(tag.getBoolean("incompleteStructure")) { + if (tag.getBoolean("incompleteStructure")) { currentTip.add(RED + "** INCOMPLETE STRUCTURE **" + RESET); } currentTip.add((tag.getBoolean("hasProblems") ? (RED + "** HAS PROBLEMS **") : GREEN + "Running Fine") + RESET - + " Efficiency: " + tag.getFloat("efficiency") + "%"); - - currentTip.add(String.format("Progress: %d s / %d s", tag.getInteger("progress"), tag.getInteger("maxProgress"))); + + " Efficiency: " + tag.getFloat("efficiency") + "%"); + currentTip.add( + String.format("Progress: %d s / %d s", tag.getInteger("progress"), tag.getInteger("maxProgress"))); super.getWailaBody(itemStack, currentTip, accessor, config); } @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); tag.setBoolean("hasProblems", (getIdealStatus() - getRepairStatus()) > 0); tag.setFloat("efficiency", mEfficiency / 100.0F); - tag.setInteger("progress", mProgresstime/20); - tag.setInteger("maxProgress", mMaxProgresstime/20); + tag.setInteger("progress", mProgresstime / 20); + tag.setInteger("maxProgress", mMaxProgresstime / 20); tag.setBoolean("incompleteStructure", (getBaseMetaTileEntity().getErrorDisplayID() & 64) != 0); - } public List<GT_MetaTileEntity_Hatch> getExoticEnergyHatches() { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java index f5d43faffc..44d40e5a67 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_SpecialFilter.java @@ -14,16 +14,19 @@ public abstract class GT_MetaTileEntity_SpecialFilter extends GT_MetaTileEntity_ public boolean bNBTAllowed = false; public boolean bInvertFilter = false; - public GT_MetaTileEntity_SpecialFilter(int aID, String aName, String aNameRegional, int aTier, String[] aDescription) { + public GT_MetaTileEntity_SpecialFilter( + int aID, String aName, String aNameRegional, int aTier, String[] aDescription) { // 9 buffer slot, 1 representation slot, 1 holo slot. last seems not needed... super(aID, aName, aNameRegional, aTier, 11, aDescription); } - public GT_MetaTileEntity_SpecialFilter(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_SpecialFilter( + String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } - public GT_MetaTileEntity_SpecialFilter(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_SpecialFilter( + String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aInvSlotCount, aDescription, aTextures); } @@ -60,7 +63,9 @@ public abstract class GT_MetaTileEntity_SpecialFilter extends GT_MetaTileEntity_ @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && ((this.bNBTAllowed) || (!aStack.hasTagCompound())) && (this.isStackAllowed(aStack) != this.bInvertFilter); + return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) + && ((this.bNBTAllowed) || (!aStack.hasTagCompound())) + && (this.isStackAllowed(aStack) != this.bInvertFilter); } protected abstract boolean isStackAllowed(ItemStack aStack); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java index fa040bf5cb..a4d6fc0e6b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java @@ -1,11 +1,11 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.GT; + import gregtech.api.interfaces.ITexture; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_Cleanroom; -import static gregtech.api.enums.GT_Values.GT; - public abstract class GT_MetaTileEntity_TieredMachineBlock extends MetaTileEntity { /** * Value between [0 - 9] to describe the Tier of this Machine. @@ -26,17 +26,31 @@ public abstract class GT_MetaTileEntity_TieredMachineBlock extends MetaTileEntit */ public final ITexture[][][] mTextures; - public GT_MetaTileEntity_TieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { + public GT_MetaTileEntity_TieredMachineBlock( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String aDescription, + ITexture... aTextures) { super(aID, aName, aNameRegional, aInvSlotCount); mTier = (byte) Math.max(0, Math.min(aTier, 14)); - mDescriptionArray = aDescription == null ? new String[0] : new String[]{aDescription}; + mDescriptionArray = aDescription == null ? new String[0] : new String[] {aDescription}; mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : ""; // must always be the last call! if (GT.isClientSide()) mTextures = getTextureSet(aTextures); else mTextures = null; } - public GT_MetaTileEntity_TieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String[] aDescription, ITexture... aTextures) { + public GT_MetaTileEntity_TieredMachineBlock( + int aID, + String aName, + String aNameRegional, + int aTier, + int aInvSlotCount, + String[] aDescription, + ITexture... aTextures) { super(aID, aName, aNameRegional, aInvSlotCount); mTier = (byte) Math.max(0, Math.min(aTier, 15)); mDescriptionArray = aDescription == null ? new String[0] : aDescription; @@ -52,15 +66,17 @@ public abstract class GT_MetaTileEntity_TieredMachineBlock extends MetaTileEntit return GT_MetaTileEntity_Cleanroom.class; } - public GT_MetaTileEntity_TieredMachineBlock(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_TieredMachineBlock( + String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { super(aName, aInvSlotCount); mTier = (byte) aTier; - mDescriptionArray = aDescription == null ? new String[0] : new String[]{aDescription}; + mDescriptionArray = aDescription == null ? new String[0] : new String[] {aDescription}; mDescription = mDescriptionArray.length > 0 ? mDescriptionArray[0] : ""; mTextures = aTextures; } - public GT_MetaTileEntity_TieredMachineBlock(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_TieredMachineBlock( + String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { super(aName, aInvSlotCount); mTier = (byte) aTier; mDescriptionArray = aDescription == null ? new String[0] : aDescription; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TooltipMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TooltipMultiBlockBase.java index f77875db02..e564c65d21 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TooltipMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TooltipMultiBlockBase.java @@ -3,15 +3,16 @@ package gregtech.api.metatileentity.implementations; import gregtech.api.GregTech_API; import gregtech.api.interfaces.ISecondaryDescribable; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import org.lwjgl.input.Keyboard; - import java.util.concurrent.atomic.AtomicReferenceArray; +import org.lwjgl.input.Keyboard; /** * A multiblock with tooltip {@link GT_Multiblock_Tooltip_Builder} */ -public abstract class GT_MetaTileEntity_TooltipMultiBlockBase extends GT_MetaTileEntity_MultiBlockBase implements ISecondaryDescribable { - private static final AtomicReferenceArray<GT_Multiblock_Tooltip_Builder> tooltips = new AtomicReferenceArray<>(GregTech_API.METATILEENTITIES.length); +public abstract class GT_MetaTileEntity_TooltipMultiBlockBase extends GT_MetaTileEntity_MultiBlockBase + implements ISecondaryDescribable { + private static final AtomicReferenceArray<GT_Multiblock_Tooltip_Builder> tooltips = + new AtomicReferenceArray<>(GregTech_API.METATILEENTITIES.length); public GT_MetaTileEntity_TooltipMultiBlockBase(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java index fdef48a86e..4bd5905ac5 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java @@ -1,5 +1,12 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.V; +import static mcp.mobius.waila.api.SpecialChars.BLUE; +import static mcp.mobius.waila.api.SpecialChars.GOLD; +import static mcp.mobius.waila.api.SpecialChars.GREEN; +import static mcp.mobius.waila.api.SpecialChars.RED; +import static mcp.mobius.waila.api.SpecialChars.RESET; + import cofh.api.energy.IEnergyProvider; import cofh.api.energy.IEnergyStorage; import crazypants.enderio.machine.capbank.TileCapBank; @@ -13,6 +20,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Utility; +import java.util.List; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import net.minecraft.entity.player.EntityPlayer; @@ -23,15 +31,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import java.util.List; - -import static gregtech.api.enums.GT_Values.V; -import static mcp.mobius.waila.api.SpecialChars.RESET; -import static mcp.mobius.waila.api.SpecialChars.GOLD; -import static mcp.mobius.waila.api.SpecialChars.BLUE; -import static mcp.mobius.waila.api.SpecialChars.GREEN; -import static mcp.mobius.waila.api.SpecialChars.RED; - /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! * <p/> @@ -55,25 +54,57 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi public ITexture[][][] getTextureSet(ITexture[] aTextures) { ITexture[][][] rTextures = new ITexture[12][17][]; for (byte i = -1; i < 16; i++) { - rTextures[ 0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT [mTier]}; - rTextures[ 1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT [mTier]}; - rTextures[ 2][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT [mTier]}; - rTextures[ 3][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI [mTier]}; - rTextures[ 4][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI [mTier]}; - rTextures[ 5][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI [mTier]}; - rTextures[ 6][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN [mTier]}; - rTextures[ 7][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN [mTier]}; - rTextures[ 8][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN [mTier]}; - rTextures[ 9][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; - rTextures[10][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; - rTextures[11][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; + rTextures[0][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] + }; + rTextures[1][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] + }; + rTextures[2][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier] + }; + rTextures[3][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier] + }; + rTextures[4][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier] + }; + rTextures[5][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier] + }; + rTextures[6][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier] + }; + rTextures[7][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier] + }; + rTextures[8][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier] + }; + rTextures[9][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] + }; + rTextures[10][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] + }; + rTextures[11][i + 1] = new ITexture[] { + Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] + }; } return rTextures; } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[Math.min(2, aSide) + (aSide == aFacing ? 3 : 0) + (aBaseMetaTileEntity.isAllowedToWork() ? 0 : 6)][aColorIndex + 1]; + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { + return mTextures[ + Math.min(2, aSide) + (aSide == aFacing ? 3 : 0) + (aBaseMetaTileEntity.isAllowedToWork() ? 0 : 6)][ + aColorIndex + 1]; } @Override @@ -108,7 +139,9 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi @Override public boolean isInputFacing(byte aSide) { - return getBaseMetaTileEntity().isAllowedToWork() ? aSide == getBaseMetaTileEntity().getFrontFacing() : aSide != getBaseMetaTileEntity().getFrontFacing(); + return getBaseMetaTileEntity().isAllowedToWork() + ? aSide == getBaseMetaTileEntity().getFrontFacing() + : aSide != getBaseMetaTileEntity().getFrontFacing(); } @Override @@ -158,22 +191,42 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi for (byte i = 0; i < 6 && aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity(); i++) if (aBaseMetaTileEntity.inputEnergyFrom(i)) { TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); - if (tTileEntity instanceof IEnergyProvider && ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), 1, true) == 1) { - long tEU = (long) ((IEnergyProvider) tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false); + if (tTileEntity instanceof IEnergyProvider + && ((IEnergyProvider) tTileEntity) + .extractEnergy( + ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), + 1, + true) + == 1) { + long tEU = (long) ((IEnergyProvider) tTileEntity) + .extractEnergy( + ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)), + GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), + false); tEU = tEU * GregTech_API.mRFtoEU / 100; aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); - } else if (tTileEntity instanceof IEnergyStorage && ((IEnergyStorage) tTileEntity).extractEnergy(1, true) == 1) { - long tEU = (long) ((IEnergyStorage) tTileEntity).extractEnergy(GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false); + } else if (tTileEntity instanceof IEnergyStorage + && ((IEnergyStorage) tTileEntity).extractEnergy(1, true) == 1) { + long tEU = (long) ((IEnergyStorage) tTileEntity) + .extractEnergy(GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU), false); tEU = tEU * GregTech_API.mRFtoEU / 100; aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); - } else if (GregTech_API.meIOLoaded && tTileEntity instanceof IPowerContainer && ((IPowerContainer) tTileEntity).getEnergyStored() > 0) { + } else if (GregTech_API.meIOLoaded + && tTileEntity instanceof IPowerContainer + && ((IPowerContainer) tTileEntity).getEnergyStored() > 0) { int storedRF = ((IPowerContainer) tTileEntity).getEnergyStored(); - int extractRF = GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU); + int extractRF = GT_Utility.safeInt(maxEUInput() * 100L / GregTech_API.mRFtoEU); long tEU = 0; if (tTileEntity instanceof TileCapBank) { ICapBankNetwork network = ((TileCapBank) tTileEntity).getNetwork(); if (network != null && network.getEnergyStoredL() > 0) { - tEU = Math.min((Math.min(Math.min(network.getEnergyStoredL(), storedRF - extractRF), network.getMaxOutput())) * (long)GregTech_API.mRFtoEU / 100L, maxEUInput()); + tEU = Math.min( + (Math.min( + Math.min(network.getEnergyStoredL(), storedRF - extractRF), + network.getMaxOutput())) + * (long) GregTech_API.mRFtoEU + / 100L, + maxEUInput()); network.addEnergy(GT_Utility.safeInt(-(tEU * 100 / GregTech_API.mRFtoEU))); } } else { @@ -182,7 +235,7 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi tEU = maxEUInput(); } else { ((IPowerContainer) tTileEntity).setEnergyStored(0); - tEU = storedRF * (long)GregTech_API.mRFtoEU / 100L; + tEU = storedRF * (long) GregTech_API.mRFtoEU / 100L; } } aBaseMetaTileEntity.injectEnergyUnits((byte) 6, Math.min(tEU, maxEUInput()), 1); @@ -212,22 +265,23 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi } @Override - public boolean hasAlternativeModeText(){ - return true; + public boolean hasAlternativeModeText() { + return true; } @Override - public String getAlternativeModeText(){ - return - (getBaseMetaTileEntity().isAllowedToWork() ? GT_Utility.trans("145","Step Down, In: ") : GT_Utility.trans("146","Step Up, In: ")) + - maxEUInput() + - GT_Utility.trans("148","V ") + - maxAmperesIn() + - GT_Utility.trans("147","A, Out: ") + - maxEUOutput() + - GT_Utility.trans("148","V ") + - maxAmperesOut() + - GT_Utility.trans("149","A"); + public String getAlternativeModeText() { + return (getBaseMetaTileEntity().isAllowedToWork() + ? GT_Utility.trans("145", "Step Down, In: ") + : GT_Utility.trans("146", "Step Up, In: ")) + + maxEUInput() + + GT_Utility.trans("148", "V ") + + maxAmperesIn() + + GT_Utility.trans("147", "A, Out: ") + + maxEUOutput() + + GT_Utility.trans("148", "V ") + + maxAmperesOut() + + GT_Utility.trans("149", "A"); } @Override @@ -236,58 +290,50 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi } @Override - public void getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { + public void getWailaBody( + ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { final int facing = getBaseMetaTileEntity().getFrontFacing(); final NBTTagCompound tag = accessor.getNBTData(); - final int side = (byte)accessor.getSide().ordinal(); + final int side = (byte) accessor.getSide().ordinal(); final boolean allowedToWork = tag.getBoolean("isAllowedToWork"); final byte inputTier = GT_Utility.getTier(tag.getLong("maxEUInput")); final byte outputTier = GT_Utility.getTier(tag.getLong("maxEUOutput")); - currenttip.add( - String.format( + currenttip.add(String.format( "%s %s(%dA) -> %s(%dA)", (allowedToWork ? (GREEN + "Step Down") : (RED + "Step Up")) + RESET, GT_Mod.gregtechproxy.mWailaTransformerVoltageTier - ? GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + RESET - : tag.getLong("maxEUInput"), + ? GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + RESET + : tag.getLong("maxEUInput"), tag.getLong("maxAmperesIn"), GT_Mod.gregtechproxy.mWailaTransformerVoltageTier - ? GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + RESET - : tag.getLong("maxEUOutput"), - tag.getLong("maxAmperesOut") - ) - ); + ? GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + RESET + : tag.getLong("maxEUOutput"), + tag.getLong("maxAmperesOut"))); if ((side == facing && allowedToWork) || (side != facing && !allowedToWork)) { - currenttip.add( - String.format( + currenttip.add(String.format( GOLD + "Input:" + RESET + " %s(%dA)", GT_Mod.gregtechproxy.mWailaTransformerVoltageTier - ? GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + RESET - : tag.getLong("maxEUInput"), - tag.getLong("maxAmperesIn") - ) - ); + ? GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + RESET + : tag.getLong("maxEUInput"), + tag.getLong("maxAmperesIn"))); } else { - currenttip.add( - String.format( + currenttip.add(String.format( BLUE + "Output:" + RESET + " %s(%dA)", GT_Mod.gregtechproxy.mWailaTransformerVoltageTier - ? GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + RESET - : tag.getLong("maxEUOutput"), - tag.getLong("maxAmperesOut") - ) - ); + ? GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + RESET + : tag.getLong("maxEUOutput"), + tag.getLong("maxAmperesOut"))); } super.getWailaBody(itemStack, currenttip, accessor, config); - } @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); tag.setBoolean("isAllowedToWork", getBaseMetaTileEntity().isAllowedToWork()); tag.setLong("maxEUInput", maxEUInput()); @@ -295,6 +341,4 @@ public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachi tag.setLong("maxEUOutput", maxEUOutput()); tag.setLong("maxAmperesOut", maxAmperesOut()); } - - } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java index bfc9b2118e..3fd496e960 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Dynamo.java @@ -1,25 +1,25 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.*; + import gregtech.api.enums.Textures; import gregtech.api.interfaces.IGlobalWirelessEnergy; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IWirelessEnergyHatchInformation; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import static gregtech.GT_Mod.gregtechproxy; -import static gregtech.api.enums.GT_Values.*; - -public class GT_MetaTileEntity_Wireless_Dynamo extends GT_MetaTileEntity_Hatch_Dynamo implements IGlobalWirelessEnergy, IWirelessEnergyHatchInformation { +public class GT_MetaTileEntity_Wireless_Dynamo extends GT_MetaTileEntity_Hatch_Dynamo + implements IGlobalWirelessEnergy, IWirelessEnergyHatchInformation { private String owner_uuid; private String owner_name; - public GT_MetaTileEntity_Wireless_Dynamo(String aName, byte aTier, String[] aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Wireless_Dynamo( + String aName, byte aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); } @@ -29,12 +29,12 @@ public class GT_MetaTileEntity_Wireless_Dynamo extends GT_MetaTileEntity_Hatch_D @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI_WIRELESS_ON[mTier]}; + return new ITexture[] {aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI_WIRELESS_ON[mTier]}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI_WIRELESS_ON[mTier]}; + return new ITexture[] {aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI_WIRELESS_ON[mTier]}; } @Override @@ -125,11 +125,9 @@ public class GT_MetaTileEntity_Wireless_Dynamo extends GT_MetaTileEntity_Hatch_D owner_name = aBaseMetaTileEntity.getOwnerName(); // Attempt to load in map from file. - if (GlobalEnergy.size() == 0) - loadGlobalEnergyInfo(aBaseMetaTileEntity.getWorld()); + if (GlobalEnergy.size() == 0) loadGlobalEnergyInfo(aBaseMetaTileEntity.getWorld()); strongCheckOrAddUser(owner_uuid, owner_name); - } // Every ticks_between_energy_addition ticks change the energy content of the machine. @@ -140,4 +138,3 @@ public class GT_MetaTileEntity_Wireless_Dynamo extends GT_MetaTileEntity_Hatch_D } } } - diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java index 035147ca0b..baffde6f3f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Wireless_Hatch.java @@ -1,24 +1,23 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.*; + import gregtech.api.enums.Textures; import gregtech.api.interfaces.IGlobalWirelessEnergy; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IWirelessEnergyHatchInformation; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.util.GT_Utility; +import java.math.BigInteger; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import java.math.BigInteger; - -import static gregtech.GT_Mod.gregtechproxy; -import static gregtech.api.enums.GT_Values.*; - -public class GT_MetaTileEntity_Wireless_Hatch extends GT_MetaTileEntity_Hatch_Energy implements IGlobalWirelessEnergy, IWirelessEnergyHatchInformation { +public class GT_MetaTileEntity_Wireless_Hatch extends GT_MetaTileEntity_Hatch_Energy + implements IGlobalWirelessEnergy, IWirelessEnergyHatchInformation { - private final BigInteger eu_transferred_per_operation = BigInteger.valueOf(2 * V[mTier] * ticks_between_energy_addition); + private final BigInteger eu_transferred_per_operation = + BigInteger.valueOf(2 * V[mTier] * ticks_between_energy_addition); private final long eu_transferred_per_operation_long = eu_transferred_per_operation.longValue(); private String owner_uuid; @@ -43,12 +42,12 @@ public class GT_MetaTileEntity_Wireless_Hatch extends GT_MetaTileEntity_Hatch_En @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI_WIRELESS_ON[mTier]}; + return new ITexture[] {aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI_WIRELESS_ON[mTier]}; } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[]{aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI_WIRELESS_ON[mTier]}; + return new ITexture[] {aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI_WIRELESS_ON[mTier]}; } @Override @@ -131,8 +130,7 @@ public class GT_MetaTileEntity_Wireless_Hatch extends GT_MetaTileEntity_Hatch_En owner_name = aBaseMetaTileEntity.getOwnerName(); // Attempt to load in map from file. - if (GlobalEnergy.size() == 0) - loadGlobalEnergyInfo(aBaseMetaTileEntity.getWorld()); + if (GlobalEnergy.size() == 0) loadGlobalEnergyInfo(aBaseMetaTileEntity.getWorld()); strongCheckOrAddUser(owner_uuid, owner_name); @@ -140,7 +138,8 @@ public class GT_MetaTileEntity_Wireless_Hatch extends GT_MetaTileEntity_Hatch_En setEUVar(eu_transferred_per_operation_long); } - // This is set up in a way to be as optimised as possible. If a user has a relatively plentiful energy network + // This is set up in a way to be as optimised as possible. If a user has a relatively plentiful energy + // network // it should make no difference to them. Minimising the number of operations on BigInteger is essential. // Every ticks_between_energy_addition add eu_transferred_per_operation to internal EU storage from network. |