diff options
author | Jason Mitchell <mitchej@gmail.com> | 2023-01-20 00:30:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-20 09:30:50 +0100 |
commit | 7ed516e30ba224b4b8e3fad9c836c22ca00bfcdb (patch) | |
tree | bea33f6637b929427e9abbe733e19606f8bf9032 /src/main/java/gregtech/api/metatileentity/implementations | |
parent | 750a4070af4756e3708e2b2555b9874864bf3cfb (diff) | |
download | GT5-Unofficial-7ed516e30ba224b4b8e3fad9c836c22ca00bfcdb.tar.gz GT5-Unofficial-7ed516e30ba224b4b8e3fad9c836c22ca00bfcdb.tar.bz2 GT5-Unofficial-7ed516e30ba224b4b8e3fad9c836c22ca00bfcdb.zip |
MTE Inventory updates (#1496)
* MTE Inventory updates
* Separate Input/Output inventory
* Use a LinkedHashMap to ensure inventory orders are deterministic
* Input/Output work on either Input/Output inventories
* MTE Inventory
* Add GT_Packet_MultiTileEntity
* More dyanmic packet with packetFeatures
* Add IMTE_HasModes for MultiBlockPart
* Help with MTE Inventory (#1613)
* convert inventory to use ItemStackHandler
* Update MUI
* inventories
* move Iteminventory to its own method
Co-authored-by: miozune <miozune@gmail.com>
* Update MUI
* Update MUI
* Add IMultiBlockPart
* Mte fluid inventory (#1639)
* first work on fluid inventory
* make gui work with numbers not dividable by 4
* use math.min
* add outputfluids saving
* actually working
* Update MUI
Co-authored-by: miozune <miozune@gmail.com>
* Ticking Covers!
* Parts now register covers with the controller
* Controllers now tick covers on parts
* Break cover ticking out into `tickCoverAtSide`
Fix some inventory methods on MultiBlockController
* Filter on tickable covers
* Improve GUIs for MTEs (#1650)
* working controller GUI
* locked inventory selection work
* input and output locking of inventories
Co-authored-by: miozune <miozune@gmail.com>
* spotless
* CoverInfo refactor (#1654)
* Add `CoverInfo` and deprecate the old fields to hold cover information
* Disable MTE registration
* Fix NPE - Return EMPTY_INFO for SIDE_UNKNOWN
Temporarily add back old NBT saving in case of a revert so covers aren't lost.
* Actually save the old NBT data, instead of empty
Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com>
Co-authored-by: miozune <miozune@gmail.com>
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity/implementations')
6 files changed, 110 insertions, 134 deletions
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 965e920e82..47915e64cb 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.ALL_VALID_SIDES; + import cofh.api.energy.IEnergyReceiver; import cpw.mods.fml.common.Loader; import gregtech.GT_Mod; @@ -26,6 +28,7 @@ import gregtech.api.objects.GT_Cover_None; import gregtech.api.render.TextureFactory; import gregtech.api.util.*; import gregtech.common.GT_Client; +import gregtech.common.covers.CoverInfo; import gregtech.common.covers.GT_Cover_SolarPanel; import ic2.api.energy.EnergyNet; import ic2.api.energy.tile.IEnergyEmitter; @@ -231,14 +234,8 @@ 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; - HashSet<TileEntity> nul = null; + if (!getBaseMetaTileEntity().getCoverInfoAtSide(aSide).letsEnergyIn()) return 0; + final HashSet<TileEntity> nul = null; return transferElectricity(aSide, aVoltage, aAmperage, nul); } @@ -252,12 +249,12 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @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(); + final BaseMetaPipeEntity tBase = (BaseMetaPipeEntity) getBaseMetaTileEntity(); if (!(tBase.getNode() instanceof PowerNode)) return 0; - PowerNode tNode = (PowerNode) tBase.getNode(); + final PowerNode tNode = (PowerNode) tBase.getNode(); if (tNode != null) { int tPlace = 0; - Node[] tToPower = new Node[tNode.mConsumers.size()]; + final Node[] tToPower = new Node[tNode.mConsumers.size()]; if (tNode.mHadVoltage) { for (ConsumerNode consumer : tNode.mConsumers) { if (consumer.needsEnergy()) tToPower[tPlace++] = consumer; @@ -359,6 +356,16 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile } @Override + public boolean letsIn(CoverInfo coverInfo) { + return coverInfo.letsEnergyIn(); + } + + @Override + public boolean letsOut(CoverInfo coverInfo) { + return coverInfo.letsEnergyOut(); + } + + @Override public boolean canConnect(byte aSide, TileEntity tTileEntity) { final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity(); final GT_CoverBehaviorBase<?> coverBehavior = baseMetaTile.getCoverBehaviorAtSideNew(aSide); @@ -472,8 +479,8 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @Override public String[] getInfoData() { - BaseMetaPipeEntity base = (BaseMetaPipeEntity) getBaseMetaTileEntity(); - PowerNodePath path = (PowerNodePath) base.getNodePath(); + final BaseMetaPipeEntity base = (BaseMetaPipeEntity) getBaseMetaTileEntity(); + final PowerNodePath path = (PowerNodePath) base.getNodePath(); long amps = 0; long volts = 0; if (path != null) { @@ -562,7 +569,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile 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); + final AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb); } } @@ -593,32 +600,27 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @Override public void reloadLocks() { - BaseMetaPipeEntity pipe = (BaseMetaPipeEntity) getBaseMetaTileEntity(); + final BaseMetaPipeEntity pipe = (BaseMetaPipeEntity) getBaseMetaTileEntity(); if (pipe.getNode() != null) { - for (byte i = 0; i < 6; i++) { - if (isConnectedAtSide(i)) { - final GT_CoverBehaviorBase<?> coverBehavior = pipe.getCoverBehaviorAtSideNew(i); - 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)) { - pipe.addToLock(pipe, i); + for (byte tSide : ALL_VALID_SIDES) { + if (isConnectedAtSide(tSide)) { + final CoverInfo coverInfo = pipe.getCoverInfoAtSide(tSide); + if (coverInfo.getCoverBehavior() instanceof GT_Cover_None) continue; + if (!letsIn(coverInfo) || !letsOut(coverInfo)) { + pipe.addToLock(pipe, tSide); } else { - pipe.removeFromLock(pipe, i); + pipe.removeFromLock(pipe, tSide); } } } } else { boolean dontAllow = false; - for (byte i = 0; i < 6; i++) { - if (isConnectedAtSide(i)) { - final GT_CoverBehaviorBase<?> coverBehavior = pipe.getCoverBehaviorAtSideNew(i); - 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)) { + for (byte tSide : ALL_VALID_SIDES) { + if (isConnectedAtSide(tSide)) { + final CoverInfo coverInfo = pipe.getCoverInfoAtSide(tSide); + if (coverInfo.getCoverBehavior() instanceof GT_Cover_None) continue; + + if (!letsIn(coverInfo) || !letsOut(coverInfo)) { 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 d25f92b58b..61d55bfd9b 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 @@ -18,6 +18,7 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.*; import gregtech.api.util.WorldSpawnedEventBuilder.ParticleEventBuilder; import gregtech.common.GT_Client; +import gregtech.common.covers.CoverInfo; import gregtech.common.covers.GT_Cover_Drain; import gregtech.common.covers.GT_Cover_FluidRegulator; import java.util.ArrayList; @@ -130,7 +131,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { byte aColorIndex, boolean aConnected, boolean aRedstone) { - float tThickNess = getThickNess(); + final float tThickNess = getThickNess(); if (mDisableInput == 0) return new ITexture[] { aConnected @@ -140,7 +141,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { Dyes.getModulation(aColorIndex, mMaterial.mRGBa)) }; byte tMask = 0; - byte[][] sRestrictionArray = { + final byte[][] sRestrictionArray = { {2, 3, 5, 4}, {2, 3, 4, 5}, {1, 0, 4, 5}, @@ -303,7 +304,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { && aEntity instanceof EntityLivingBase) { for (FluidStack tFluid : mFluids) { if (tFluid != null) { - int tTemperature = tFluid.getFluid().getTemperature(tFluid); + final int tTemperature = tFluid.getFluid().getTemperature(tFluid); if (tTemperature > 320 && !isCoverOnSide( (BaseMetaPipeEntity) getBaseMetaTileEntity(), (EntityLivingBase) aEntity)) { @@ -331,9 +332,9 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { if (!GT_Mod.gregtechproxy.gt6Pipe || mCheckConnections) checkConnections(); - boolean shouldDistribute = (oLastReceivedFrom == mLastReceivedFrom); + final boolean shouldDistribute = (oLastReceivedFrom == mLastReceivedFrom); for (int i = 0, j = aBaseMetaTileEntity.getRandomNumber(mPipeAmount); i < mPipeAmount; i++) { - int index = (i + j) % mPipeAmount; + final int index = (i + j) % mPipeAmount; if (mFluids[index] != null && mFluids[index].amount <= 0) mFluids[index] = null; if (mFluids[index] == null) continue; @@ -354,7 +355,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { final FluidStack tFluid = mFluids[index]; if (tFluid != null && tFluid.amount > 0) { - int tTemperature = tFluid.getFluid().getTemperature(tFluid); + final int tTemperature = tFluid.getFluid().getTemperature(tFluid); if (tTemperature > mHeatResistance) { if (aBaseMetaTileEntity.getRandomNumber(100) == 0) { // Poof @@ -423,8 +424,8 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { if (tFluid == null) return; // Tank, From, Amount to receive - List<MutableTriple<IFluidHandler, ForgeDirection, Integer>> tTanks = new ArrayList<>(); - int amount = tFluid.amount; + final List<MutableTriple<IFluidHandler, ForgeDirection, Integer>> tTanks = new ArrayList<>(); + final int amount = tFluid.amount; for (byte aSide, i = 0, j = (byte) aBaseMetaTileEntity.getRandomNumber(6); i < 6; i++) { // Get a list of tanks accepting fluids, and what side they're on @@ -436,22 +437,8 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { 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))) { + && getBaseMetaTileEntity().getCoverInfoAtSide(aSide).letsFluidOut(tFluid.getFluid()) + && (gTank == null || gTank.getCoverInfoAtSide(tSide).letsFluidIn(tFluid.getFluid()))) { if (tTank.fill(ForgeDirection.getOrientation(tSide), tFluid, false) > 0) { tTanks.add(new MutableTriple<>(tTank, ForgeDirection.getOrientation(tSide), 0)); } @@ -460,8 +447,9 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { } // How much of this fluid is available for distribution? - double tAmount = Math.max(1, Math.min(mCapacity * 10, tFluid.amount)), tNumTanks = tTanks.size(); - FluidStack maxFluid = tFluid.copy(); + final double tAmount = Math.max(1, Math.min(mCapacity * 10, tFluid.amount)); + final double tNumTanks = tTanks.size(); + final FluidStack maxFluid = tFluid.copy(); maxFluid.amount = Integer.MAX_VALUE; double availableCapacity = 0; @@ -473,16 +461,17 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { // Now distribute for (MutableTriple<IFluidHandler, ForgeDirection, Integer> tEntry : tTanks) { + // Distribue fluids based on percentage available space at destination if (availableCapacity > tAmount) - 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.floor(tEntry.right * tAmount / availableCapacity); + + // If the percent is not enough to give at least 1L, try to give 1L + if (tEntry.right == 0) tEntry.right = (int) Math.min(1, tAmount); + if (tEntry.right <= 0) continue; - int tFilledAmount = tEntry.left.fill(tEntry.middle, drainFromIndex(tEntry.right, false, index), false); + final int tFilledAmount = + tEntry.left.fill(tEntry.middle, drainFromIndex(tEntry.right, false, index), false); if (tFilledAmount > 0) tEntry.left.fill(tEntry.middle, drainFromIndex(tFilledAmount, true, index), true); @@ -494,8 +483,8 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { 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); + final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); + final byte tMask = (byte) (1 << tSide); if (aPlayer.isSneaking()) { if (isInputDisabledAtSide(tSide)) { mDisableInput &= ~tMask; @@ -551,6 +540,16 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { } @Override + public boolean letsIn(CoverInfo coverInfo) { + return coverInfo.letsFluidIn(null); + } + + @Override + public boolean letsOut(CoverInfo coverInfo) { + return coverInfo.letsFluidOut(null); + } + + @Override public boolean canConnect(byte aSide, TileEntity tTileEntity) { if (tTileEntity == null) return false; @@ -706,7 +705,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { if (!mFluids[index].isFluidEqual(aFluid)) return 0; - int space = getCapacity() / mPipeAmount - mFluids[index].amount; + final int space = getCapacity() / mPipeAmount - mFluids[index].amount; if (aFluid.amount <= space) { if (doFill) { mFluids[index].amount += aFluid.amount; @@ -745,7 +744,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { mFluids[index].amount -= used; } - FluidStack drained = mFluids[index].copy(); + final FluidStack drained = mFluids[index].copy(); drained.amount = used; if (mFluids[index].amount <= 0) { @@ -808,7 +807,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { } private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - float tSpace = (1f - mThickNess) / 2; + final float tSpace = (1f - mThickNess) / 2; float tSide0 = tSpace; float tSide1 = 1f - tSpace; float tSide2 = tSpace; @@ -841,7 +840,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { tSide1 = tSide3 = tSide5 = 1; } - byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections; + final 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; @@ -864,7 +863,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { 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); + final AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb); } } 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 c919187927..5ae9150a58 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,6 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; import static gregtech.api.enums.Textures.BlockIcons.PIPE_RESTRICTOR; import gregtech.GT_Mod; @@ -20,6 +21,7 @@ import gregtech.api.util.GT_CoverBehaviorBase; import gregtech.api.util.GT_Utility; import gregtech.api.util.ISerializableObject; import gregtech.common.GT_Client; +import gregtech.common.covers.CoverInfo; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -264,7 +266,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE if (oLastReceivedFrom == mLastReceivedFrom) { doTickProfilingInThisTick = false; - ArrayList<IMetaTileEntityItemPipe> tPipeList = new ArrayList<IMetaTileEntityItemPipe>(); + final ArrayList<IMetaTileEntityItemPipe> tPipeList = new ArrayList<>(); for (boolean temp = true; temp && !isInventoryEmpty() && pipeCapacityCheck(); ) { temp = false; @@ -290,7 +292,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE 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); + final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); if (isConnectedAtSide(tSide)) { disconnect(tSide); GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("215", "Disconnected")); @@ -335,6 +337,16 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE } @Override + public boolean letsIn(CoverInfo coverInfo) { + return coverInfo.letsItemsOut(-1); + } + + @Override + public boolean letsOut(CoverInfo coverInfo) { + return coverInfo.letsItemsOut(-1); + } + + @Override public boolean canConnect(byte aSide, TileEntity tTileEntity) { if (tTileEntity == null) return false; @@ -354,7 +366,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE connectable = true; } if (tTileEntity instanceof ISidedInventory) { - int[] tSlots = ((ISidedInventory) tTileEntity).getAccessibleSlotsFromSide(tSide); + final int[] tSlots = ((ISidedInventory) tTileEntity).getAccessibleSlotsFromSide(tSide); if (tSlots == null || tSlots.length <= 0) return false; connectable = true; } @@ -377,8 +389,9 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE @Override public boolean sendItemStack(Object aSender) { if (pipeCapacityCheck()) { - byte tOffset = (byte) getBaseMetaTileEntity().getRandomNumber(6), tSide = 0; - for (byte i = 0; i < 6; i++) { + final byte tOffset = (byte) getBaseMetaTileEntity().getRandomNumber(6); + byte tSide = 0; + for (byte i : ALL_VALID_SIDES) { tSide = (byte) ((i + tOffset) % 6); if (isConnectedAtSide(tSide) && (isInventoryEmpty() || (tSide != mLastReceivedFrom || aSender != getBaseMetaTileEntity()))) { @@ -391,15 +404,8 @@ 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())) { - TileEntity tInventory = getBaseMetaTileEntity().getTileEntityAtSide(aSide); + if (getBaseMetaTileEntity().getCoverInfoAtSide(aSide).letsItemsOut(-1)) { + final 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)) { @@ -459,23 +465,9 @@ 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); + final IGregTechTileEntity tTileEntity = getBaseMetaTileEntity(); + final CoverInfo coverInfo = tTileEntity.getCoverInfoAtSide((byte) aSide); + final boolean tAllow = coverInfo.letsItemsIn(-2) || coverInfo.letsItemsOut(-2); if (tAllow) { if (cacheSides == null) cacheSides = super.getAccessibleSlotsFromSide(aSide); return cacheSides; @@ -534,7 +526,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE } private AxisAlignedBB getActualCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - float tSpace = (1f - mThickNess) / 2; + final float tSpace = (1f - mThickNess) / 2; float tSide0 = tSpace; float tSide1 = 1f - tSpace; float tSide2 = tSpace; @@ -567,7 +559,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE tSide1 = tSide3 = tSide5 = 1; } - byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections; + final 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; @@ -590,7 +582,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE 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); + final AxisAlignedBB aabb = getActualCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); if (inputAABB.intersectsWith(aabb)) outputAABB.add(aabb); } } 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 5de80c5cb6..632b8cca8b 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,6 @@ package gregtech.api.metatileentity.implementations; +import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; 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; @@ -527,8 +528,8 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B } return true; } - for (byte i = 0; i < 6; i++) { - if (aBaseMetaTileEntity.getAirAtSide(i)) { + for (byte tSide : ALL_VALID_SIDES) { + if (aBaseMetaTileEntity.getAirAtSide(tSide)) { if (useModularUI()) { GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); } else { 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 b6ace5a630..fdedbad86a 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 @@ -197,13 +197,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch @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().getCoverInfoAtSide(aSide).isGUIClickable()) return; if (aPlayer.isSneaking()) { if (disableSort) { disableSort = false; 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 11ffa6e802..2809ab3815 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 @@ -230,19 +230,13 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch impl @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().getCoverInfoAtSide(aSide).isGUIClickable()) return; if (aPlayer.isSneaking()) { mMode = (byte) ((mMode + 9) % 10); } else { mMode = (byte) ((mMode + 1) % 10); } - String inBrackets; + final String inBrackets; switch (mMode) { case 0: GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("108", "Outputs misc. Fluids, Steam and Items")); @@ -312,15 +306,9 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch impl } private boolean tryToLockHatch(EntityPlayer aPlayer, byte aSide) { - if (!getBaseMetaTileEntity() - .getCoverBehaviorAtSideNew(aSide) - .isGUIClickable( - aSide, - getBaseMetaTileEntity().getCoverIDAtSide(aSide), - getBaseMetaTileEntity().getComplexCoverDataAtSide(aSide), - getBaseMetaTileEntity())) return false; + if (!getBaseMetaTileEntity().getCoverInfoAtSide(aSide).isGUIClickable()) return false; if (!isFluidLocked()) return false; - ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + final ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); if (tCurrentItem == null) return false; FluidStack tFluid = FluidContainerRegistry.getFluidForFilledItem(tCurrentItem); if (tFluid == null && tCurrentItem.getItem() instanceof IFluidContainerItem) @@ -432,7 +420,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch impl protected void onEmptyingContainerWhenEmpty() { if (this.lockedFluidName == null && this.mFluid != null && isFluidLocked()) { this.setLockedFluidName(this.mFluid.getFluid().getName()); - EntityPlayer player; + final EntityPlayer player; if (playerThatLockedfluid == null || (player = playerThatLockedfluid.get()) == null) return; GT_Utility.sendChatToPlayer( player, @@ -496,7 +484,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch impl .setDefaultColor(COLOR_TEXT_WHITE.get()) .setPos(101, 20)) .widget(TextWidget.dynamicString(() -> { - ItemStack lockedDisplayStack = mInventory[getLockedDisplaySlot()]; + final ItemStack lockedDisplayStack = mInventory[getLockedDisplaySlot()]; return lockedDisplayStack == null ? "None" : lockedDisplayStack.getDisplayName(); }) .setSynced(false) |