コード例 #1
0
  @Override
  public void updateNetwork(float oldPressure) {
    PressureNetwork endNetwork = null;

    endNetwork =
        PressureNetwork.getNetworkInDir(
            worldObj, xCoord, yCoord, zCoord, getFacing().getOpposite());

    if (endNetwork != null) {
      pNetwork = endNetwork;
      pNetwork.addMachine(this, oldPressure);
      Log.info(
          "Found an existing network ("
              + pNetwork.getRandomNumber()
              + ") @ "
              + xCoord
              + ","
              + yCoord
              + ","
              + zCoord);
    } else {
      pNetwork = new PressureNetwork(this, oldPressure);
      Log.info(
          "Created a new network ("
              + pNetwork.getRandomNumber()
              + ") @ "
              + xCoord
              + ","
              + yCoord
              + ","
              + zCoord);
    }
  }
コード例 #2
0
  @Override
  public void updateNetwork(float oldPressure) {
    if (getTarget() == null) {
      pNetwork = null;
      getHandler().updateBlock();
      return;
    }
    PressureNetwork newNetwork = null;
    PressureNetwork foundNetwork = null;
    PressureNetwork endNetwork = null;
    // This block can merge networks!
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
      foundNetwork = PressureNetwork.getNetworkInDir(worldObj, xCoord, yCoord, zCoord, dir);
      if (foundNetwork != null) {
        if (endNetwork == null) {
          endNetwork = foundNetwork;
        } else {
          newNetwork = foundNetwork;
        }
        connectedSides.add(dir);
      }

      if (newNetwork != null && endNetwork != null) {
        // Hmm.. More networks!? What's this!?
        endNetwork.mergeNetwork(newNetwork);
        newNetwork = null;
      }
    }

    if (endNetwork != null) {
      pNetwork = endNetwork;
      pNetwork.addMachine(this, oldPressure);
      if (getTarget() != null) {
        getTarget().setNetwork(ForgeDirection.UP, pNetwork);
        pNetwork.addMachine(getTarget(), oldPressure);
      }
      Log.info(
          "Found an existing network ("
              + pNetwork.getRandomNumber()
              + ") @ "
              + xCoord
              + ","
              + yCoord
              + ","
              + zCoord);
    } else {
      pNetwork = new PressureNetwork(this, oldPressure);
      if (getTarget() != null) {
        getTarget().setNetwork(ForgeDirection.UP, pNetwork);
        pNetwork.addMachine(getTarget(), oldPressure);
      }
      Log.info(
          "Created a new network ("
              + pNetwork.getRandomNumber()
              + ") @ "
              + xCoord
              + ","
              + yCoord
              + ","
              + zCoord);
    }
  }