コード例 #1
0
ファイル: Pipe.java プロジェクト: binnie567/BuildCraft
  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;
          }
        }
      }
    }
  }
コード例 #2
0
ファイル: Pipe.java プロジェクト: binnie567/BuildCraft
  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);
            }
        }
      }
    }
  }
コード例 #3
0
ファイル: TileGenericPipe.java プロジェクト: Xfel/BuildCraft
  @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;
  }
コード例 #4
0
ファイル: Pipe.java プロジェクト: binnie567/BuildCraft
  @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));
  }