Example #1
0
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);

    inv.readFromNBT(nbttagcompound);

    if (nbttagcompound.hasKey("box")) {
      box.initialize(nbttagcompound.getCompoundTag("box"));
    }

    if (nbttagcompound.hasKey("path")) {
      path = new LinkedList<BlockIndex>();
      NBTTagList list = nbttagcompound.getTagList("path", Constants.NBT.TAG_COMPOUND);

      for (int i = 0; i < list.tagCount(); ++i) {
        path.add(new BlockIndex(list.getCompoundTagAt(i)));
      }
    }

    done = nbttagcompound.getBoolean("done");
    fluidTank.readFromNBT(nbttagcompound);

    // The rest of load has to be done upon initialize.
    initNBT = (NBTTagCompound) nbttagcompound.getCompoundTag("bptBuilder").copy();
  }
Example #2
0
 public void initialize(int centerX, int centerY, int centerZ, int size) {
   initialize(
       centerX - size,
       centerY - size,
       centerZ - size,
       centerX + size,
       centerY + size,
       centerZ + size);
 }
Example #3
0
  public void initialize(NBTTagCompound nbttagcompound) {
    kind = Kind.values()[nbttagcompound.getShort("kind")];

    initialize(
        nbttagcompound.getInteger("xMin"),
        nbttagcompound.getInteger("yMin"),
        nbttagcompound.getInteger("zMin"),
        nbttagcompound.getInteger("xMax"),
        nbttagcompound.getInteger("yMax"),
        nbttagcompound.getInteger("zMax"));
  }
Example #4
0
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);

    PowerFramework.currentFramework.loadPowerProvider(this, nbttagcompound);

    if (nbttagcompound.hasKey("box")) {
      box.initialize(nbttagcompound.getCompoundTag("box"));

      loadDefaultBoundaries = false;
    } else if (nbttagcompound.hasKey("xSize")) {
      // This is a legacy save, get old data

      int xMin = nbttagcompound.getInteger("xMin");
      int zMin = nbttagcompound.getInteger("zMin");

      int xSize = nbttagcompound.getInteger("xSize");
      int ySize = nbttagcompound.getInteger("ySize");
      int zSize = nbttagcompound.getInteger("zSize");

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

      loadDefaultBoundaries = false;
    } else {
      // This is a legacy save, compute boundaries

      loadDefaultBoundaries = true;
    }

    targetX = nbttagcompound.getInteger("targetX");
    targetY = nbttagcompound.getInteger("targetY");
    targetZ = nbttagcompound.getInteger("targetZ");
    headPosX = nbttagcompound.getDouble("headPosX");
    headPosY = nbttagcompound.getDouble("headPosY");
    headPosZ = nbttagcompound.getDouble("headPosZ");
  }
Example #5
0
  @Override
  public void readFromNBT(NBTTagCompound nbttagcompound) {
    super.readFromNBT(nbttagcompound);

    Utils.readStacksFromNBT(nbttagcompound, "Items", items);

    if (nbttagcompound.hasKey("box")) {
      box.initialize(nbttagcompound.getCompoundTag("box"));
    }

    if (nbttagcompound.hasKey("path")) {
      path = new LinkedList<BlockIndex>();
      NBTTagList list = nbttagcompound.getTagList("path");

      for (int i = 0; i < list.tagCount(); ++i) {
        path.add(new BlockIndex((NBTTagCompound) list.tagAt(i)));
      }
    }

    done = nbttagcompound.getBoolean("done");
  }
Example #6
0
  @Override
  public void doWork() {
    if (CoreProxy.proxy.isRenderWorld(worldObj)) {
      return;
    }

    if (done) {
      return;
    }

    if (builderRobot != null && !builderRobot.readyToBuild()) {
      return;
    }

    if (powerProvider.useEnergy(25, 25, true) < 25) {
      return;
    }

    iterateBpt();

    if (bluePrintBuilder != null && !bluePrintBuilder.done) {
      if (!box.isInitialized()) {
        box.initialize(bluePrintBuilder);
      }

      if (builderRobot == null) {
        builderRobot = new EntityRobot(worldObj, box);
        worldObj.spawnEntityInWorld(builderRobot);
      }

      box.createLasers(worldObj, LaserKind.Stripes);

      builderRobot.scheduleContruction(
          bluePrintBuilder.getNextBlock(
              worldObj, new SurroundingInventory(worldObj, xCoord, yCoord, zCoord)),
          bluePrintBuilder.getContext());
    }
  }
Example #7
0
 public Box(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax) {
   this();
   initialize(xMin, yMin, zMin, xMax, yMax, zMax);
 }
Example #8
0
 public Box(TileEntity e) {
   initialize(e.xCoord, e.yCoord, e.zCoord, e.xCoord + 1, e.yCoord + 1, e.zCoord + 1);
 }
Example #9
0
 public void initialize(IAreaProvider a) {
   initialize(a.xMin(), a.yMin(), a.zMin(), a.xMax(), a.yMax(), a.zMax());
 }
Example #10
0
 public void initialize(Box box) {
   initialize(box.xMin, box.yMin, box.zMin, box.xMax, box.yMax, box.zMax);
 }
Example #11
0
  public void iterateBpt() {
    if (items[0] == null || !(items[0].getItem() instanceof ItemBptBase)) {

      if (bluePrintBuilder != null) {
        bluePrintBuilder = null;
      }

      if (builderRobot != null) {
        builderRobot.setDead();
        builderRobot = null;
      }

      if (box.isInitialized()) {
        box.deleteLasers();
        box.reset();
      }

      if (currentPathIterator != null) {
        currentPathIterator = null;
      }

      return;
    }

    if (bluePrintBuilder == null || bluePrintBuilder.done) {
      if (path != null && path.size() > 1) {
        if (currentPathIterator == null) {
          Iterator<BlockIndex> it = path.iterator();
          BlockIndex start = it.next();
          currentPathIterator = new PathIterator(start, it);
        }

        if (bluePrintBuilder != null && builderRobot != null) {
          builderRobot.markEndOfBlueprint(bluePrintBuilder);
        }

        bluePrintBuilder = currentPathIterator.next();

        if (bluePrintBuilder != null) {
          box.deleteLasers();
          box.reset();
          box.initialize(bluePrintBuilder);
          box.createLasers(worldObj, LaserKind.Stripes);
        }

        if (builderRobot != null) {
          builderRobot.setBox(box);
        }

        if (bluePrintBuilder == null) {
          currentPathIterator = currentPathIterator.iterate();
        }

        if (currentPathIterator == null) {
          done = true;
        }
      } else {
        if (bluePrintBuilder != null && bluePrintBuilder.done) {
          if (builderRobot != null) {
            builderRobot.markEndOfBlueprint(bluePrintBuilder);
          }

          done = true;
          bluePrintBuilder = null;
        } else {
          bluePrintBuilder =
              instanciateBluePrint(
                  xCoord,
                  yCoord,
                  zCoord,
                  Orientations.values()[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)]
                      .reverse());

          if (bluePrintBuilder != null) {
            box.initialize(bluePrintBuilder);
            box.createLasers(worldObj, LaserKind.Stripes);
          }
        }
      }
    }
  }
Example #12
0
  public void iterateBpt(boolean forceIterate) {
    if (getStackInSlot(0) == null || !(getStackInSlot(0).getItem() instanceof ItemBlueprint)) {
      if (box.isInitialized()) {
        if (currentBuilder != null) {
          currentBuilder = null;
        }

        if (box.isInitialized()) {
          box.reset();
        }

        if (currentPathIterator != null) {
          currentPathIterator = null;
        }

        updateRequirements();

        sendNetworkUpdate();

        return;
      }
    }

    if (currentBuilder == null || (currentBuilder.isDone(this) || forceIterate)) {
      if (path != null && path.size() > 1) {
        if (currentPathIterator == null) {
          Iterator<BlockIndex> it = path.iterator();
          BlockIndex start = it.next();
          currentPathIterator =
              new PathIterator(
                  start,
                  it,
                  ForgeDirection.values()[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)]
                      .getOpposite());
        }

        if (currentBuilder != null && currentBuilder.isDone(this)) {
          currentBuilder.postProcessing(worldObj);
        }

        currentBuilder = currentPathIterator.next();

        if (currentBuilder != null) {
          box.reset();
          box.initialize(currentBuilder);
          sendNetworkUpdate();
        }

        if (currentBuilder == null) {
          currentPathIterator = currentPathIterator.iterate();
        }

        if (currentPathIterator == null) {
          done = true;
        } else {
          done = false;
        }

        updateRequirements();
      } else {
        if (currentBuilder != null && currentBuilder.isDone(this)) {
          currentBuilder.postProcessing(worldObj);
          currentBuilder = recursiveBuilder.nextBuilder();

          updateRequirements();
        } else {
          BlueprintBase bpt = instanciateBlueprint();

          if (bpt != null) {
            recursiveBuilder =
                new RecursiveBlueprintBuilder(
                    bpt,
                    worldObj,
                    xCoord,
                    yCoord,
                    zCoord,
                    ForgeDirection.values()[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)]
                        .getOpposite());

            currentBuilder = recursiveBuilder.nextBuilder();

            updateRequirements();
          }
        }

        if (currentBuilder == null) {
          done = true;
        } else {
          box.initialize(currentBuilder);
          sendNetworkUpdate();
          done = false;
        }
      }
    }

    if (done && getStackInSlot(0) != null) {
      boolean dropBlueprint = true;
      for (int i = 1; i < getSizeInventory(); ++i) {
        if (getStackInSlot(i) == null) {
          setInventorySlotContents(i, getStackInSlot(0));
          dropBlueprint = false;
          break;
        }
      }
      if (dropBlueprint) {
        InvUtils.dropItems(getWorldObj(), getStackInSlot(0), xCoord, yCoord, zCoord);
      }

      setInventorySlotContents(0, null);
      box.reset();
    }
  }
Example #13
0
  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();
  }