Exemple #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;
  }
Exemple #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();
  }
Exemple #3
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();
    }
  }