private void readNearbyPipesSignal(WireColor color) { boolean foundBiggerSignal = false; for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = container.getTile(o); if (tile instanceof TileGenericPipe) { TileGenericPipe tilePipe = (TileGenericPipe) tile; if (BlockGenericPipe.isFullyDefined(tilePipe.pipe)) if (isWireConnectedTo(tile, color)) { foundBiggerSignal |= receiveSignal(tilePipe.pipe.signalStrength[color.ordinal()] - 1, color); } } } if (!foundBiggerSignal && signalStrength[color.ordinal()] != 0) { signalStrength[color.ordinal()] = 0; // worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); container.scheduleRenderUpdate(); for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = container.getTile(o); if (tile instanceof TileGenericPipe) { TileGenericPipe tilePipe = (TileGenericPipe) tile; if (BlockGenericPipe.isFullyDefined(tilePipe.pipe)) { tilePipe.pipe.internalUpdateScheduled = true; } } } } }
private void updateSignalStateForColor(IPipe.WireColor color) { if (!wireSet[color.ordinal()]) return; // STEP 1: compute internal signal strength if (broadcastSignal[color.ordinal()]) { receiveSignal(255, color); } else { readNearbyPipesSignal(color); } // STEP 2: transmit signal in nearby blocks if (signalStrength[color.ordinal()] > 1) { for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = container.getTile(o); if (tile instanceof TileGenericPipe) { TileGenericPipe tilePipe = (TileGenericPipe) tile; if (BlockGenericPipe.isFullyDefined(tilePipe.pipe) && tilePipe.pipe.wireSet[color.ordinal()]) if (isWireConnectedTo(tile, color)) { tilePipe.pipe.receiveSignal(signalStrength[color.ordinal()] - 1, color); } } } } }
@Override public LinkedList<ITrigger> getTriggers() { LinkedList<ITrigger> result = new LinkedList<ITrigger>(); if (BlockGenericPipe.isFullyDefined(pipe) && pipe.hasGate()) { result.add(BuildCraftCore.triggerRedstoneActive); result.add(BuildCraftCore.triggerRedstoneInactive); } return result; }
@Override public boolean isWireConnectedTo(TileEntity tile, WireColor color) { if (!(tile instanceof TileGenericPipe)) return false; TileGenericPipe tilePipe = (TileGenericPipe) tile; if (!BlockGenericPipe.isFullyDefined(tilePipe.pipe)) return false; if (!tilePipe.pipe.wireSet[color.ordinal()]) return false; return (tilePipe.pipe.transport instanceof PipeTransportStructure || transport instanceof PipeTransportStructure || Utils.checkPipesConnections(container, tile)); }