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 --- .../gregtech/common/blocks/GT_Item_Machines.java | 10 ++- .../common/covers/GT_Cover_Fluidfilter.java | 93 ++++++++++++++++------ 2 files changed, 76 insertions(+), 27 deletions(-) (limited to 'src/main/java/gregtech/common') diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index a742994ddc..1fa33e2a1d 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -158,8 +158,16 @@ public class GT_Item_Machines tTileEntity.setOwnerName(aPlayer.getDisplayName()); } tTileEntity.getMetaTileEntity().initDefaultModes(aStack.getTagCompound()); + final byte aSide = GT_Utility.getOppositeSide(side); if (tTileEntity.getMetaTileEntity() instanceof IConnectable) { - ((IConnectable) tTileEntity.getMetaTileEntity()).connect(GT_Utility.getOppositeSide(side)); + // If we're connectable, try connecting to whatever we're up against + ((IConnectable) tTileEntity.getMetaTileEntity()).connect(aSide); + } else if (aPlayer != null && aPlayer.isSneaking()) { + // If we're being placed against something that is connectable, try telling it to connect to us + IGregTechTileEntity aTileEntity = tTileEntity.getIGregTechTileEntityAtSide(aSide); + if (aTileEntity != null && aTileEntity.getMetaTileEntity() instanceof IConnectable) { + ((IConnectable) aTileEntity.getMetaTileEntity()).connect((byte)side); + } } } } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tDamage, 3)) { diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java b/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java index 46ac0b42a3..b5ac8191f4 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java @@ -8,8 +8,18 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.*; -public class GT_Cover_Fluidfilter - extends GT_CoverBehavior { +public class GT_Cover_Fluidfilter extends GT_CoverBehavior { + + // Uses the lower 3 bits of the cover variable, so we have 8 options to work with (0-7) + private final int FILTER_INPUT_DENY_OUTPUT = 0; + private final int INVERT_INPUT_DENY_OUTPUT = 1; + private final int FILTER_INPUT_ANY_OUTPUT = 2; + private final int INVERT_INPUT_ANY_OUTPUT = 3; + private final int DENY_INPUT_FILTER_OUTPUT = 4; + private final int DENY_INPUT_INVERT_OUTPUT = 5; + private final int ANY_INPUT_FILTER_OUTPUT = 6; + private final int ANY_INPUT_INVERT_OUTPUT = 7; + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { return aCoverVariable; @@ -17,43 +27,54 @@ public class GT_Cover_Fluidfilter public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { int aFilterMode = aCoverVariable & 7; - aCoverVariable ^=aFilterMode; - aFilterMode = (aFilterMode + (aPlayer.isSneaking()? -1 : 1)) % 4; - if(aFilterMode < 0){aFilterMode = 3;} + aCoverVariable ^= aFilterMode; + aFilterMode = (aFilterMode + (aPlayer.isSneaking()? -1 : 1)) % 8; + if (aFilterMode < 0) { + aFilterMode = 7; + } switch(aFilterMode) { - case 0: GT_Utility.sendChatToPlayer(aPlayer, trans("043", "Allow input, no output")); break; - case 1: GT_Utility.sendChatToPlayer(aPlayer, trans("044", "Deny input, no output")); break; - case 2: GT_Utility.sendChatToPlayer(aPlayer, trans("045", "Allow input, permit any output")); break; - case 3: GT_Utility.sendChatToPlayer(aPlayer, trans("046", "Deny input, permit any output")); break; + case FILTER_INPUT_DENY_OUTPUT: GT_Utility.sendChatToPlayer(aPlayer, trans("043", "Filter input, Deny output")); break; + case INVERT_INPUT_DENY_OUTPUT: GT_Utility.sendChatToPlayer(aPlayer, trans("044", "Invert input, Deny output")); break; + case FILTER_INPUT_ANY_OUTPUT: GT_Utility.sendChatToPlayer(aPlayer, trans("045", "Filter input, Permit any output")); break; + case INVERT_INPUT_ANY_OUTPUT: GT_Utility.sendChatToPlayer(aPlayer, trans("046", "Invert input, Permit any output")); break; + case DENY_INPUT_FILTER_OUTPUT: GT_Utility.sendChatToPlayer(aPlayer, trans("219", "Deny input, Filter output")); break; + case DENY_INPUT_INVERT_OUTPUT: GT_Utility.sendChatToPlayer(aPlayer, trans("220", "Deny input, Invert output")); break; + case ANY_INPUT_FILTER_OUTPUT: GT_Utility.sendChatToPlayer(aPlayer, trans("221", "Permit any input, Filter output")); break; + case ANY_INPUT_INVERT_OUTPUT: GT_Utility.sendChatToPlayer(aPlayer, trans("222", "Permit any input, Invert output")); break; } aCoverVariable|=aFilterMode; return aCoverVariable; } - + public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - //System.out.println("rightclick"); - if (((aX > 0.375D) && (aX < 0.625D)) || ((aSide > 3) && (((aY > 0.375D) && (aY < 0.625D)) || ((aSide < 2) && (((aZ > 0.375D) && (aZ < 0.625D)) || (aSide == 2) || (aSide == 3)))))) { + //System.out.println("rightclick"); + if ( + ((aX > 0.375D) && (aX < 0.625D)) || + ((aSide > 3) && ((aY > 0.375D) && (aY < 0.625D))) || + ((aSide < 2) && ((aZ > 0.375D) && (aZ < 0.625D))) || + (aSide == 2) || + (aSide == 3) + ) { ItemStack tStack = aPlayer.inventory.getCurrentItem(); - if(tStack!=null){ + if (tStack == null) return true; + FluidStack tFluid = FluidContainerRegistry.getFluidForFilledItem(tStack); - if(tFluid!=null){ - //System.out.println(tFluid.getLocalizedName()+" "+tFluid.getFluidID()); + if (tFluid != null) { int aFluid = tFluid.getFluidID(); aCoverVariable = (aCoverVariable & 7) | (aFluid << 3); aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); - FluidStack sFluid = new FluidStack(FluidRegistry.getFluid(aFluid),1000); + FluidStack sFluid = new FluidStack(FluidRegistry.getFluid(aFluid), 1000); GT_Utility.sendChatToPlayer(aPlayer, trans("047", "Filter Fluid: ") + sFluid.getLocalizedName()); - }else if(tStack.getItem() instanceof IFluidContainerItem){ - IFluidContainerItem tContainer = (IFluidContainerItem)tStack.getItem(); - if(tContainer.getFluid(tStack) != null) { + } else if (tStack.getItem() instanceof IFluidContainerItem) { + IFluidContainerItem tContainer = (IFluidContainerItem) tStack.getItem(); + if (tContainer.getFluid(tStack) != null) { int aFluid = tContainer.getFluid(tStack).getFluidID(); aCoverVariable = (aCoverVariable & 7) | (aFluid << 3); aTileEntity.setCoverDataAtSide(aSide, aCoverVariable); - FluidStack sFluid = new FluidStack(FluidRegistry.getFluid(aFluid),1000); + FluidStack sFluid = new FluidStack(FluidRegistry.getFluid(aFluid), 1000); GT_Utility.sendChatToPlayer(aPlayer, trans("047", "Filter Fluid: ") + sFluid.getLocalizedName()); } } - } return true; } return false; @@ -61,18 +82,38 @@ public class GT_Cover_Fluidfilter @Override public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - if(aFluid==null){ - return true; - } + if (aFluid == null) return true; + int aFilterMode = aCoverVariable & 7; int aFilterFluid = aCoverVariable >>> 3; - return aFluid.getID() == aFilterFluid ? aFilterMode == 0 || aFilterMode == 2 : aFilterMode == 1 || aFilterMode == 3; + + if (aFilterMode == DENY_INPUT_FILTER_OUTPUT || aFilterMode == DENY_INPUT_INVERT_OUTPUT) + return false; + else if (aFilterMode == ANY_INPUT_FILTER_OUTPUT || aFilterMode == ANY_INPUT_INVERT_OUTPUT) + return true; + else if (aFluid.getID() == aFilterFluid) + return aFilterMode == FILTER_INPUT_DENY_OUTPUT || aFilterMode == FILTER_INPUT_ANY_OUTPUT; + else + return aFilterMode == INVERT_INPUT_DENY_OUTPUT || aFilterMode == INVERT_INPUT_ANY_OUTPUT; + } @Override public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + if (aFluid == null) return true; + int aFilterMode = aCoverVariable & 7; - return aFilterMode != 0 && aFilterMode != 1; + int aFilterFluid = aCoverVariable >>> 3; + + if (aFilterMode == FILTER_INPUT_DENY_OUTPUT || aFilterMode == INVERT_INPUT_DENY_OUTPUT) + return false; + else if (aFilterMode == FILTER_INPUT_ANY_OUTPUT || aFilterMode == INVERT_INPUT_ANY_OUTPUT) + return true; + else if (aFluid.getID() == aFilterFluid) + return aFilterMode == DENY_INPUT_FILTER_OUTPUT || aFilterMode == ANY_INPUT_FILTER_OUTPUT; + else + return aFilterMode == DENY_INPUT_INVERT_OUTPUT || aFilterMode == ANY_INPUT_INVERT_OUTPUT; + } public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { -- 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/common') 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