From 1698e57f729efb52e2b98e865a9671f0b50a5b2e Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Mon, 3 Sep 2018 00:57:51 -0700 Subject: Pipe/Cable overhaul & Add filter output on fluid filters * Unified connect() method for pipes/wires - each subclass has it's own canConnect(), letsIn(), and letsOut() methods that map to the specifics for that implementation * Shift Clicking while placing a GT machine will now try connecting to the cable/pipe it is placed on * You can open a connection to the air for pipes & wires, allowing the next thing you place down to auto connect (ie: a JABBA barrel) * Distribute Fluids - Modeled after several of the upstream PRs * Fluid regulators on pipes should stop spazzing out now * Fluid filter covers - Now work with filtering output BUG/TODO: * Spray paint doesn't seem to keep wires/pipes from connecting properly * Spray paint on wires/pipes should force a disconnection check --- .../api/metatileentity/BaseMetaTileEntity.java | 88 +++++++++++++++++----- 1 file changed, 71 insertions(+), 17 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 9e38ba60cd..991fcd6d2a 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -56,7 +56,6 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; protected boolean mReleaseEnergy = false; protected int[] mAverageEUInput = new int[]{0, 0, 0, 0, 0}, mAverageEUOutput = new int[]{0, 0, 0, 0, 0}; - private boolean mEnergyStateReady = false; private boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false}, mActiveEUOutputs = new boolean[]{false, false, false, false, false, false}; private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; @@ -459,8 +458,6 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } } } - // We're ready to tell about our energy state - Only used server side - mEnergyStateReady = true; } if (!hasValidMetaTileEntity()) { @@ -985,23 +982,26 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE return false; } - @Override - public boolean energyStateReady() { - if (!isServerSide()) return true; - else return mEnergyStateReady; - } - @Override public boolean inputEnergyFrom(byte aSide) { + return inputEnergyFrom(aSide, true); + } + + public boolean inputEnergyFrom(byte aSide, boolean waitForActive) { if (aSide == 6) return true; - if (isServerSide()) return (aSide >= 0 && aSide < 6 ? mActiveEUInputs[aSide] : false) && !mReleaseEnergy; + if (isServerSide() && waitForActive) return ((aSide >= 0 && aSide < 6) && mActiveEUInputs[aSide]) && !mReleaseEnergy; return isEnergyInputSide(aSide); } @Override public boolean outputsEnergyTo(byte aSide) { + return outputsEnergyTo(aSide, true); + } + + @Override + public boolean outputsEnergyTo(byte aSide, boolean waitForActive) { if (aSide == 6) return true; - if (isServerSide()) return (aSide >= 0 && aSide < 6 ? mActiveEUOutputs[aSide] : false) || mReleaseEnergy; + if (isServerSide() && waitForActive) return ((aSide >= 0 && aSide < 6) && mActiveEUOutputs[aSide]) || mReleaseEnergy; return isEnergyOutputSide(aSide); } @@ -1767,42 +1767,96 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE @Override public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)))) + if (mTickTimer > 5 && canAccessData() && + (mRunningThroughTick || !mInputDisabled) && + ( + aSide == ForgeDirection.UNKNOWN || + ( + mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && + getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((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()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid().getFluid(), this)))) + if (mTickTimer > 5 && canAccessData() && + (mRunningThroughTick || !mOutputDisabled) && + ( + aSide == ForgeDirection.UNKNOWN || + ( + mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && + getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((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()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)))) + if (mTickTimer > 5 && canAccessData() && + (mRunningThroughTick || !mOutputDisabled) && + ( + aSide == ForgeDirection.UNKNOWN || + ( + mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && + getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((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()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)))) + if (mTickTimer > 5 && canAccessData() && + (mRunningThroughTick || !mInputDisabled) && + ( + aSide == ForgeDirection.UNKNOWN || + ( + mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && + getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((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()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)))) + if (mTickTimer > 5 && canAccessData() && + (mRunningThroughTick || !mOutputDisabled) && + ( + aSide == ForgeDirection.UNKNOWN || + ( + mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && + getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), aFluid, this) + ) + ) + ) return mMetaTileEntity.canDrain(aSide, aFluid); return false; } @Override public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (canAccessData() && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)) || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)))) + if (canAccessData() && + ( + aSide == ForgeDirection.UNKNOWN || + ( + mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) && + getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this)) || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) && + getCoverBehaviorAtSide((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getCoverDataAtSide((byte) aSide.ordinal()), null, this) + ) + ) + ) return mMetaTileEntity.getTankInfo(aSide); return new FluidTankInfo[]{}; } -- cgit From fad72d1c68001be4cac656309a18436dadb862bb Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Mon, 3 Sep 2018 18:21:40 -0700 Subject: * Fix: Colored cables/pipes properly connect (or don't) to each other based on color * Trigger connection evaluation on painting of cables/pipes or machines * Trigger connection evaluation on placement of blocks -- IE: A wire/pipe open to air, and then a dirt block is placed on it - this will close the pipe/wire connection --- .../api/metatileentity/BaseMetaPipeEntity.java | 16 ++++++++- .../api/metatileentity/BaseMetaTileEntity.java | 3 +- .../api/metatileentity/MetaPipeEntity.java | 38 ++++++++++++++++++---- .../api/metatileentity/MetaTileEntity.java | 12 +++++-- .../implementations/GT_MetaPipeEntity_Cable.java | 9 +---- .../implementations/GT_MetaPipeEntity_Fluid.java | 11 +------ .../implementations/GT_MetaPipeEntity_Item.java | 13 ++------ .../gregtech/common/blocks/GT_Block_Machines.java | 7 ++++ 8 files changed, 69 insertions(+), 40 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index c58db1c81a..2a86b2bbf0 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -50,6 +50,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE private byte[] mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0}; private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; private boolean mInventoryChanged = false, mWorkUpdate = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false; + private boolean mCheckConnections = false; private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0; private int oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0; private short mID = 0; @@ -1294,8 +1295,9 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE @Override public byte setColorization(byte aColor) { if (aColor > 15 || aColor < -1) aColor = -1; + mColor = (byte) (aColor + 1); if (canAccessData()) mMetaTileEntity.onColorChangeServer(aColor); - return mColor = (byte) (aColor + 1); + return mColor; } @Override @@ -1353,6 +1355,18 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE mInventoryChanged = true; } + public void onNeighborBlockChange(int aX, int aY, int aZ) { + 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. + // 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(); + } + } + } + @Override public int getLightOpacity() { return mMetaTileEntity == null ? 0 : mMetaTileEntity.getLightOpacity(); diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 991fcd6d2a..43c479be70 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -1993,8 +1993,9 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE @Override public byte setColorization(byte aColor) { if (aColor > 15 || aColor < -1) aColor = -1; + mColor = (byte) (aColor + 1); if (canAccessData()) mMetaTileEntity.onColorChangeServer(aColor); - return mColor = (byte) (aColor + 1); + return mColor; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index 70ae71a719..c04dc9d523 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -6,6 +6,7 @@ import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.interfaces.metatileentity.IConnectable; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IColoredTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; @@ -59,6 +60,7 @@ 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. */ @@ -639,12 +641,16 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { @Override public void onColorChangeServer(byte aColor) { - // + setCheckConnections(); } @Override public void onColorChangeClient(byte aColor) { - // + // Do nothing apparently + } + + public void setCheckConnections() { + mCheckConnections = true; } public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { @@ -737,7 +743,19 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { return GT_LanguageManager.addStringLocalization("Interaction_DESCRIPTION_Index_"+aKey, aEnglish, false); } + private boolean connectableColor(TileEntity tTileEntity) { + // Determine if two entities are connectable based on their colorization: + // Uncolored can connect to anything + // If both are colored they must be the same color to connect. + if (tTileEntity instanceof IColoredTileEntity) { + if (getBaseMetaTileEntity().getColorization() >= 0) { + byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); + if (tColor >= 0 && tColor != getBaseMetaTileEntity().getColorization()) return false; + } + } + return true; + } @Override public int connect(byte aSide) { @@ -755,6 +773,7 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { // Careful - tTileEntity might be null, and that's ok -- so handle it TileEntity tTileEntity = baseMetaTile.getTileEntityAtSide(aSide); + if (!connectableColor(tTileEntity)) return 0; if ((alwaysLookConnected || letsIn || letsOut)) { // Are we trying to connect to a pipe? let's do it! @@ -769,8 +788,6 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { } else if(((GT_Mod.gregtechproxy.gt6Cable || GT_Mod.gregtechproxy.gt6Pipe) && baseMetaTile.getAirAtSide(aSide)) || canConnect(aSide, tTileEntity)) { // Allow open connections to Air, so that it'll connect to the next block placed down next to it - // NOTE: Will need to check valid connection on a block update because of this, otherwise - // we might end up connected to silly things connectAtSide(aSide); return 1; } @@ -783,9 +800,16 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { return 0; } - public void checkConnections() { - // Try connecting to connecting to everything around us: Only used when GT6 style cables/pipes are disabled - for (byte aSide = 0; aSide < 6; aSide++) if (connect(aSide) == 0) disconnect(aSide); + + public void checkConnections() { + // Verify connections around us. If GT6 style cables are not enabled then revert to old behavior and try + // connecting to everything around us + for (byte aSide = 0; aSide < 6; aSide++) { + if ((!GT_Mod.gregtechproxy.gt6Cable || isConnectedAtSide(aSide)) && connect(aSide) == 0) { + disconnect(aSide); + } + } + mCheckConnections = false; } private void connectAtSide(byte aSide) { diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 7c3df98955..4f627458a4 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -835,12 +835,20 @@ public abstract class MetaTileEntity implements IMetaTileEntity { @Override 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++ ) { + // Flag surrounding pipes/cables to revaluate their connection with us if we got painted + final TileEntity tTileEntity = meta.getTileEntityAtSide(aSide); + if ((tTileEntity instanceof BaseMetaPipeEntity)) { + ((BaseMetaPipeEntity) tTileEntity).onNeighborBlockChange(aX, aY, aZ); + } + } } @Override public void onColorChangeClient(byte aColor) { - // + // Do nothing apparently } @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 a393206257..e59be8921f 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 @@ -295,7 +295,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile mTransferredVoltageLast20 = 0; mTransferredAmperageLast20OK=mTransferredAmperageLast20; mTransferredAmperageLast20 = 0; - if (!GT_Mod.gregtechproxy.gt6Cable) checkConnections(); + if (!GT_Mod.gregtechproxy.gt6Cable || mCheckConnections) checkConnections(); } } else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate(); } @@ -347,13 +347,6 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile final byte tSide = GT_Utility.getOppositeSide(aSide); final ForgeDirection tDir = ForgeDirection.getOrientation(tSide); - if (tTileEntity instanceof IColoredTileEntity) { - if (getBaseMetaTileEntity().getColorization() >= 0) { - byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); - if (tColor >= 0 && tColor != getBaseMetaTileEntity().getColorization()) return false; - } - } - // GT Machine handling if ((tTileEntity instanceof IEnergyConnected) && (((IEnergyConnected) tTileEntity).inputEnergyFrom(tSide, false) || ((IEnergyConnected) tTileEntity).outputsEnergyTo(tSide, false))) 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 0644a07de1..b70697556d 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 @@ -227,7 +227,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { mLastReceivedFrom = 0; } - if (!GT_Mod.gregtechproxy.gt6Pipe) checkConnections(); + if (!GT_Mod.gregtechproxy.gt6Pipe || mCheckConnections) checkConnections(); boolean shouldDistribute = (oLastReceivedFrom == mLastReceivedFrom); for (int i = 0, j = aBaseMetaTileEntity.getRandomNumber(mPipeAmount); i < mPipeAmount; i++) { @@ -387,15 +387,6 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { if (coverBehavior instanceof GT_Cover_Drain) return true; - if (gTileEntity != null && getBaseMetaTileEntity().getColorization() >= 0) { - // If we're painted... - byte tColor = gTileEntity.getColorization(); - if (tColor >= 0 && (tColor & 15) != (getBaseMetaTileEntity().getColorization() & 15)) { - // and the other tile entity is painted.. then we must both be painted the same color - return false; - } - } - // Tinker Construct Faucets return a null tank info, so check the class if (GregTech_API.mTConstruct && tTileEntity instanceof tconstruct.smeltery.logic.FaucetLogic) return true; 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 a57e78885b..7cf91b6c86 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 @@ -158,7 +158,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE if (aBaseMetaTileEntity.isServerSide() && aTick % 10 == 0) { if (aTick % mTickTime == 0) mTransferredItems = 0; - if (!GT_Mod.gregtechproxy.gt6Pipe) checkConnections(); + if (!GT_Mod.gregtechproxy.gt6Pipe || mCheckConnections) checkConnections(); if (oLastReceivedFrom == mLastReceivedFrom) { doTickProfilingInThisTick = false; @@ -220,16 +220,8 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE final IGregTechTileEntity gTileEntity = (tTileEntity instanceof IGregTechTileEntity) ? (IGregTechTileEntity) tTileEntity : null; if (gTileEntity != null) { if (gTileEntity.getMetaTileEntity() == null) return false; - connectable = true; - if ( getBaseMetaTileEntity().getColorization() >= 0) { - // If we're painted... - byte tColor = gTileEntity.getColorization(); - if (tColor >= 0 && (tColor & 15) != (getBaseMetaTileEntity().getColorization() & 15)) { - // and the other tile entity is painted.. then we must both be painted the same color - return false; - } - } if (gTileEntity.getMetaTileEntity().connectsToItemPipe(tSide)) return true; + connectable = true; } if (tTileEntity instanceof IInventory) { @@ -239,7 +231,6 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE if (tTileEntity instanceof ISidedInventory) { int[] tSlots = ((ISidedInventory) tTileEntity).getAccessibleSlotsFromSide(tSide); if (tSlots == null || tSlots.length <= 0) return false; - connectable = true; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java index 8688fce78f..157a38962a 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -87,6 +87,13 @@ public class GT_Block_Machines } } + public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof BaseMetaPipeEntity)) { + ((BaseMetaPipeEntity) tTileEntity).onNeighborBlockChange(aX, aY, aZ); + } + } + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { super.onBlockAdded(aWorld, aX, aY, aZ); if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { -- cgit