コード例 #1
0
  protected RedNetConnectionType getConnectionState(ForgeDirection side, boolean decorative) {
    byte _mode = cableMode[side.ordinal()];
    if (!decorative) _mode = 1;
    if (cableMode[6] == 1) _mode = 3;
    BlockPosition bp = new BlockPosition(this);
    bp.orientation = side;
    bp.moveForwards(1);

    int blockId = worldObj.getBlockId(bp.x, bp.y, bp.z);
    Block b = Block.blocksList[blockId];

    if (b == null) // block doesn't exist (air) - never connect
    {
      return RedNetConnectionType.None;
    } else if (blockId
        == MineFactoryReloadedCore.rednetCableBlock.blockID) // cables - always connect
    {
      return RedNetConnectionType.CableAll;
    } else if (_mode == 3) // cable-only, and not a cable - don't connect
    {
      return RedNetConnectionType.None;
    } else if (b instanceof IConnectableRedNet) // API node - let them figure it out
    {
      RedNetConnectionType type =
          ((IConnectableRedNet) b)
              .getConnectionType(worldObj, bp.x, bp.y, bp.z, side.getOpposite());
      return type.isConnectionForced & !(_mode == 1 | _mode == 2)
          ? RedNetConnectionType.None
          : type;
    } else if (b instanceof IRedNetNoConnection || b.isAirBlock(worldObj, bp.x, bp.y, bp.z)) {
      return RedNetConnectionType.None;
    } else if (_mode == 2 && b.isBlockSolidOnSide(worldObj, bp.x, bp.y, bp.z, side.getOpposite())) {
      return RedNetConnectionType.ForcedCableSingle;
    } else if (_mode == 1) // mode 1 forces plate mode for weak power
    {
      return RedNetConnectionType.ForcedPlateSingle;
    } else if ((blockId <= _maxVanillaBlockId && !_connectionWhitelist.contains(blockId))
        || _connectionBlackList.contains(blockId)
        || b instanceof IRedNetDecorative)
    // standard connection logic, then figure out if we shouldn't connect
    // mode 1 will skip this
    {
      return RedNetConnectionType.None;
    } else if (b.isBlockSolidOnSide(worldObj, bp.x, bp.y, bp.z, side.getOpposite())) {
      return RedNetConnectionType.CableSingle;
    } else {
      return RedNetConnectionType.PlateSingle;
    }
  }