From 0488ff552a8a0ca66f74306173c14506f6f74783 Mon Sep 17 00:00:00 2001 From: JP Sugarbroad Date: Wed, 5 Sep 2012 23:16:15 -0700 Subject: [PATCH] Properly update neighbors for redstone signal changes. --- common/buildcraft/transport/Pipe.java | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index 5d5901ba..8de03432 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -393,6 +393,18 @@ public abstract class Pipe implements IPipe, IDropControlInventory { public boolean hasGate() { return gate != null; } + + protected void updateNeighbors(boolean needSelf) { + if (needSelf) { + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, BuildCraftTransport.genericPipeBlock.blockID); + } + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord - 1, zCoord, BuildCraftTransport.genericPipeBlock.blockID); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord + 1, zCoord, BuildCraftTransport.genericPipeBlock.blockID); + worldObj.notifyBlocksOfNeighborChange(xCoord - 1, yCoord, zCoord, BuildCraftTransport.genericPipeBlock.blockID); + worldObj.notifyBlocksOfNeighborChange(xCoord + 1, yCoord, zCoord, BuildCraftTransport.genericPipeBlock.blockID); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord - 1, BuildCraftTransport.genericPipeBlock.blockID); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord + 1, BuildCraftTransport.genericPipeBlock.blockID); + } public void onBlockRemoval() { if (wireSet[IPipe.WireColor.Red.ordinal()]) @@ -415,6 +427,10 @@ public abstract class Pipe implements IPipe, IDropControlInventory { container.dropFacade(direction); } } + + if (broadcastRedstone) { + updateNeighbors(false); // self will update due to block id changing + } } public void setTrigger(int position, ITrigger trigger) { @@ -474,10 +490,12 @@ public abstract class Pipe implements IPipe, IDropControlInventory { triggerParameters = new ITriggerParameter[triggerParameters.length]; activatedActions = new Action[activatedActions.length]; broadcastSignal = new boolean[] { false, false, false, false }; + if (broadcastRedstone) { + updateNeighbors(true); + } broadcastRedstone = false; //worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); container.scheduleRenderUpdate(); - //worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, BuildCraftTransport.genericPipeBlock.blockID); } private void resolveActions() { @@ -534,8 +552,7 @@ public abstract class Pipe implements IPipe, IDropControlInventory { if (oldBroadcastRedstone != broadcastRedstone) { container.scheduleRenderUpdate(); - //worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, BuildCraftTransport.genericPipeBlock.blockID); + updateNeighbors(true); } for (int i = 0; i < oldBroadcastSignal.length; ++i)