コード例 #1
0
ファイル: TileBuilder.java プロジェクト: Jamefrus/BuildCraft
  @Override
  public void writeToNBT(NBTTagCompound nbttagcompound) {
    super.writeToNBT(nbttagcompound);

    inv.writeToNBT(nbttagcompound);

    if (box.isInitialized()) {
      NBTTagCompound boxStore = new NBTTagCompound();
      box.writeToNBT(boxStore);
      nbttagcompound.setTag("box", boxStore);
    }

    if (path != null) {
      NBTTagList list = new NBTTagList();

      for (BlockIndex i : path) {
        NBTTagCompound c = new NBTTagCompound();
        i.writeTo(c);
        list.appendTag(c);
      }

      nbttagcompound.setTag("path", list);
    }

    nbttagcompound.setBoolean("done", done);
    fluidTank.writeToNBT(nbttagcompound);

    NBTTagCompound bptNBT = new NBTTagCompound();

    if (currentBuilder != null) {
      NBTTagCompound builderCpt = new NBTTagCompound();
      currentBuilder.saveBuildStateToNBT(builderCpt, this);
      bptNBT.setTag("builderState", builderCpt);
    }

    if (currentPathIterator != null) {
      NBTTagCompound iteratorNBT = new NBTTagCompound();
      new BlockIndex(
              (int) currentPathIterator.ix,
              (int) currentPathIterator.iy,
              (int) currentPathIterator.iz)
          .writeTo(iteratorNBT);
      bptNBT.setTag("iterator", iteratorNBT);
    }

    nbttagcompound.setTag("bptBuilder", bptNBT);
  }
コード例 #2
0
ファイル: TileBuilder.java プロジェクト: Jamefrus/BuildCraft
  @Override
  public void initialize() {
    super.initialize();

    if (worldObj.isRemote) {
      return;
    }

    if (initNBT != null) {
      iterateBpt(true);

      if (initNBT.hasKey("iterator")) {
        BlockIndex expectedTo = new BlockIndex(initNBT.getCompoundTag("iterator"));

        while (!done && currentBuilder != null && currentPathIterator != null) {
          BlockIndex bi =
              new BlockIndex(
                  (int) currentPathIterator.ix,
                  (int) currentPathIterator.iy,
                  (int) currentPathIterator.iz);

          if (bi.equals(expectedTo)) {
            break;
          }

          iterateBpt(true);
        }
      }

      if (currentBuilder != null) {
        currentBuilder.loadBuildStateToNBT(initNBT.getCompoundTag("builderState"), this);
      }

      initNBT = null;
    }

    box.kind = Kind.STRIPES;

    for (int x = xCoord - 1; x <= xCoord + 1; ++x) {
      for (int y = yCoord - 1; y <= yCoord + 1; ++y) {
        for (int z = zCoord - 1; z <= zCoord + 1; ++z) {
          TileEntity tile = worldObj.getTileEntity(x, y, z);

          if (tile instanceof TilePathMarker) {
            path = ((TilePathMarker) tile).getPath();

            for (BlockIndex b : path) {
              worldObj.setBlockToAir(b.x, b.y, b.z);

              BuildCraftBuilders.pathMarkerBlock.dropBlockAsItem(worldObj, b.x, b.y, b.z, 0, 0);
            }

            break;
          }
        }
      }
    }

    if (path != null && pathLasers.size() == 0) {
      createLasersForPath();

      sendNetworkUpdate();
    }

    iterateBpt(false);
  }