Exemple #1
0
 public void initialize(IAreaProvider a) {
   initialize(a.xMin(), a.yMin(), a.zMin(), a.xMax(), a.yMax(), a.zMax());
 }
  private void setBoundaries(boolean useDefault) {

    IAreaProvider a = null;

    if (!useDefault) {
      a = Utils.getNearbyAreaProvider(worldObj, xCoord, yCoord, zCoord);
    }

    if (a == null) {
      a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10);

      useDefault = true;
    }

    int xSize = a.xMax() - a.xMin() + 1;
    int ySize = a.yMax() - a.yMin() + 1;
    int zSize = a.zMax() - a.zMin() + 1;

    if (xSize < 3 || zSize < 3) {
      a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10);

      useDefault = true;
    }

    xSize = a.xMax() - a.xMin() + 1;
    ySize = a.yMax() - a.yMin() + 1;
    zSize = a.zMax() - a.zMin() + 1;

    box.initialize(a);

    if (ySize < 5) {
      ySize = 5;
      box.yMax = box.yMin + ySize - 1;
    }

    if (useDefault) {
      int xMin = 0, zMin = 0;

      Orientations o =
          Orientations.values()[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)].reverse();

      switch (o) {
        case XPos:
          xMin = xCoord + 1;
          zMin = zCoord - 4 - 1;
          break;
        case XNeg:
          xMin = xCoord - 9 - 2;
          zMin = zCoord - 4 - 1;
          break;
        case ZPos:
          xMin = xCoord - 4 - 1;
          zMin = zCoord + 1;
          break;
        case ZNeg:
        default:
          xMin = xCoord - 4 - 1;
          zMin = zCoord - 9 - 2;
          break;
      }

      box.initialize(xMin, yCoord, zMin, xMin + xSize - 1, yCoord + ySize - 1, zMin + zSize - 1);
    }

    a.removeFromWorld();
  }