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 --- .../implementations/GT_MetaPipeEntity_Cable.java | 9 +-------- .../implementations/GT_MetaPipeEntity_Fluid.java | 11 +---------- .../implementations/GT_MetaPipeEntity_Item.java | 13 ++----------- 3 files changed, 4 insertions(+), 29 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity/implementations') 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; } -- cgit From 9cd17d07c543a14a80672fa709c419f7c580a344 Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Tue, 4 Sep 2018 18:08:22 -0700 Subject: Fix weirdness if only one of the gt6 pipes/cables are enabled --- .../java/gregtech/api/metatileentity/MetaPipeEntity.java | 14 ++++++++------ .../implementations/GT_MetaPipeEntity_Cable.java | 7 +++++++ .../implementations/GT_MetaPipeEntity_Fluid.java | 6 ++++++ .../implementations/GT_MetaPipeEntity_Item.java | 6 ++++++ 4 files changed, 27 insertions(+), 6 deletions(-) (limited to 'src/main/java/gregtech/api/metatileentity/implementations') diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index c04dc9d523..df603de17b 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -763,7 +763,9 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { final byte tSide = GT_Utility.getOppositeSide(aSide); final IGregTechTileEntity baseMetaTile = getBaseMetaTileEntity(); - final GT_CoverBehavior coverBehavior = getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide); + if (baseMetaTile == null) return 0; + + final GT_CoverBehavior coverBehavior = baseMetaTile.getCoverBehaviorAtSide(aSide); final int coverId = baseMetaTile.getCoverIDAtSide(aSide), coverData = baseMetaTile.getCoverDataAtSide(aSide); @@ -786,8 +788,8 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { } return 1; } - 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 + 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; } @@ -800,12 +802,11 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { return 0; } - - public void checkConnections() { + protected 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) { + if ((!getGT6StyleConnection() || isConnectedAtSide(aSide)) && connect(aSide) == 0) { disconnect(aSide); } } @@ -836,4 +837,5 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { public boolean letsOut(GT_CoverBehavior coverBehavior, byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { return false; } public boolean canConnect(byte aSide, TileEntity tTileEntity) { return false; } + public boolean getGT6StyleConnection() { return false; } } 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 e59be8921f..56849e1e73 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 @@ -379,6 +379,13 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile return false; } + @Override + public boolean getGT6StyleConnection() { + // Yes if GT6 Cables are enabled + return GT_Mod.gregtechproxy.gt6Cable; + } + + @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return 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 b70697556d..e7a3dedb61 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 @@ -406,6 +406,12 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { return false; } + @Override + public boolean getGT6StyleConnection() { + // Yes if GT6 pipes are enabled + return GT_Mod.gregtechproxy.gt6Pipe; + } + @Override public void doSound(byte aIndex, double aX, double aY, double aZ) { super.doSound(aIndex, aX, aY, aZ); 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 7cf91b6c86..bba105c95f 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 @@ -237,6 +237,12 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE return connectable; } + @Override + public boolean getGT6StyleConnection() { + // Yes if GT6 pipes are enabled + return GT_Mod.gregtechproxy.gt6Pipe; + } + @Override public boolean incrementTransferCounter(int aIncrement) { -- cgit