Пример #1
0
  private boolean linkTo(TileMarker marker, int n) {
    if (marker == null) {
      return false;
    }

    if (origin.isSet() && marker.origin.isSet()) {
      return false;
    }

    if (!origin.isSet() && !marker.origin.isSet()) {
      origin = new Origin();
      marker.origin = origin;
      origin.vectO = new TileWrapper(xCoord, yCoord, zCoord);
      origin.vect[n] = new TileWrapper(marker.xCoord, marker.yCoord, marker.zCoord);
    } else if (!origin.isSet()) {
      origin = marker.origin;
      origin.vect[n] = new TileWrapper(xCoord, yCoord, zCoord);
    } else {
      marker.origin = origin;
      origin.vect[n] = new TileWrapper(marker.xCoord, marker.yCoord, marker.zCoord);
    }

    origin.vectO.getMarker(worldObj).createLasers();
    updateSignals();
    marker.updateSignals();

    return true;
  }
Пример #2
0
  @Override
  public void postPacketHandling(PacketUpdate packet) {
    super.postPacketHandling(packet);

    switchSignals();

    if (origin.vectO.isSet()) {
      origin.vectO.getMarker(worldObj).updateSignals();

      for (TileWrapper w : origin.vect) {
        TileMarker m = w.getMarker(worldObj);

        if (m != null) {
          m.updateSignals();
        }
      }
    }

    createLasers();
  }
Пример #3
0
  @Override
  public void initialize() {
    super.initialize();

    updateSignals();

    if (initVectO != null) {
      origin = new Origin();

      origin.vectO = new TileWrapper((int) initVectO.x, (int) initVectO.y, (int) initVectO.z);

      for (int i = 0; i < 3; ++i) {
        if (initVect[i] != null) {
          linkTo(
              (TileMarker)
                  worldObj.getTileEntity(
                      (int) initVect[i].x, (int) initVect[i].y, (int) initVect[i].z),
              i);
        }
      }
    }
  }
Пример #4
0
  @Override
  public void destroy() {
    TileMarker markerOrigin = null;

    if (origin.isSet()) {
      markerOrigin = origin.vectO.getMarker(worldObj);

      Origin o = origin;

      if (markerOrigin != null && markerOrigin.lasers != null) {
        for (EntityBlock entity : markerOrigin.lasers) {
          if (entity != null) {
            entity.setDead();
          }
        }
        markerOrigin.lasers = null;
      }

      for (TileWrapper m : o.vect) {
        TileMarker mark = m.getMarker(worldObj);

        if (mark != null) {
          if (mark.lasers != null) {
            for (EntityBlock entity : mark.lasers) {
              if (entity != null) {
                entity.setDead();
              }
            }
            mark.lasers = null;
          }

          if (mark != this) {
            mark.origin = new Origin();
          }
        }
      }

      if (markerOrigin != this && markerOrigin != null) {
        markerOrigin.origin = new Origin();
      }

      for (TileWrapper wrapper : o.vect) {
        TileMarker mark = wrapper.getMarker(worldObj);

        if (mark != null) {
          mark.updateSignals();
        }
      }
      if (markerOrigin != null) {
        markerOrigin.updateSignals();
      }
    }

    if (signals != null) {
      for (EntityBlock block : signals) {
        if (block != null) {
          block.setDead();
        }
      }
    }

    signals = null;

    if (!worldObj.isRemote && markerOrigin != null && markerOrigin != this) {
      markerOrigin.sendNetworkUpdate();
    }
  }