public void func_70383_a(Entity par1Entity) {
    if (field_70391_e != null) {
      NBTTagCompound nbttagcompound = new NBTTagCompound();
      par1Entity.addEntityID(nbttagcompound);
      NBTBase nbtbase;

      for (Iterator iterator = field_70391_e.getTags().iterator();
          iterator.hasNext();
          nbttagcompound.setTag(nbtbase.getName(), nbtbase.copy())) {
        nbtbase = (NBTBase) iterator.next();
      }

      par1Entity.readFromNBT(nbttagcompound);
    }
  }
Exemplo n.º 2
0
  /* Save/Load */
  public void saveToNBT(NBTTagCompound tagCompound) {
    NBTTagList tagList = new NBTTagList();
    NBTTagCompound invSlot;

    for (int i = 0; i < this.inventory.length; ++i) {
      if (this.inventory[i] != null) {
        invSlot = new NBTTagCompound();
        invSlot.setByte("Slot", (byte) i);
        this.inventory[i].writeToNBT(invSlot);
        tagList.appendTag(invSlot);
      }
    }

    tagCompound.setTag("Inventory", tagList);
  }
Exemplo n.º 3
0
 public void writeEntityToNBT(NBTTagCompound nbttagcompound) {
   super.writeEntityToNBT(nbttagcompound);
   nbttagcompound.setTag("Inventory", inventory.writeToNBT(new NBTTagList()));
   nbttagcompound.setInteger("Dimension", dimension);
   nbttagcompound.setBoolean("Sleeping", sleeping);
   nbttagcompound.setShort("SleepTimer", (short) sleepTimer);
   nbttagcompound.setFloat("XpP", currentXP);
   nbttagcompound.setInteger("XpLevel", playerLevel);
   nbttagcompound.setInteger("XpTotal", totalXP);
   if (playerSpawnCoordinate != null) {
     nbttagcompound.setInteger("SpawnX", playerSpawnCoordinate.posX);
     nbttagcompound.setInteger("SpawnY", playerSpawnCoordinate.posY);
     nbttagcompound.setInteger("SpawnZ", playerSpawnCoordinate.posZ);
   }
   foodStats.writeStatsToNBT(nbttagcompound);
   capabilities.writeCapabilitiesToNBT(nbttagcompound);
 }
Exemplo n.º 4
0
  public void writeToNBT(NBTTagCompound tagCompound) {
    tagCompound.setString("name", getName());
    Coordinate spawnPoint = getSpawnPoint();
    if (spawnPoint != null) {
      Coordinate.writeToNBT(tagCompound, "spawnPoint", spawnPoint);
    }
    tagCompound.setInteger("probeCounter", getProbeCounter());
    tagCompound.setInteger(
        "version",
        1); // Version number so that we can detect incompatible changes in persisted dimension
    // information objects.

    tagCompound.setInteger(
        "terrain",
        terrainType == null ? TerrainType.TERRAIN_VOID.ordinal() : terrainType.ordinal());
    tagCompound.setIntArray("features", toIntArray(featureTypes));
    tagCompound.setIntArray("structures", toIntArray(structureTypes));
    tagCompound.setIntArray("effects", toIntArray(effectTypes));

    List<Integer> c = new ArrayList<Integer>(biomes.size());
    for (BiomeGenBase t : biomes) {
      if (t != null) {
        c.add(t.biomeID);
      } else {
        c.add(BiomeGenBase.plains.biomeID);
      }
    }
    tagCompound.setIntArray("biomes", ArrayUtils.toPrimitive(c.toArray(new Integer[c.size()])));
    tagCompound.setInteger(
        "controller",
        controllerType == null
            ? ControllerType.CONTROLLER_DEFAULT.ordinal()
            : controllerType.ordinal());
    tagCompound.setString("digits", digitString);

    tagCompound.setLong("forcedSeed", forcedDimensionSeed);
    tagCompound.setLong("baseSeed", baseSeed);
    tagCompound.setInteger("worldVersion", worldVersion);

    setBlockMeta(tagCompound, baseBlockForTerrain, "baseBlock");
    setBlockMeta(tagCompound, tendrilBlock, "tendrilBlock");

    writeBlocksToNBT(tagCompound, pyramidBlocks, "pyramidBlocks");

    writeBlocksToNBT(tagCompound, sphereBlocks, "sphereBlocks");
    if (sphereBlocks.length > 0) {
      // Write out a single sphere block for compatibility with older RFTools.
      setBlockMeta(tagCompound, sphereBlocks[0], "sphereBlock");
    }

    writeBlocksToNBT(tagCompound, hugeSphereBlocks, "hugeSphereBlocks");
    writeBlocksToNBT(tagCompound, hugeLiquidSphereBlocks, "hugeLiquidSphereBlocks");
    writeFluidsToNBT(tagCompound, hugeLiquidSphereFluids, "hugeLiquidSphereFluids");

    writeBlocksToNBT(tagCompound, liquidSphereBlocks, "liquidSphereBlocks");
    if (liquidSphereBlocks.length > 0) {
      // Write out a single sphere block for compatibility with older RFTools.
      setBlockMeta(tagCompound, liquidSphereBlocks[0], "liquidSphereBlock");
    }

    writeFluidsToNBT(tagCompound, liquidSphereFluids, "liquidSphereFluids");
    if (liquidSphereFluids.length > 0) {
      tagCompound.setInteger(
          "liquidSphereFluid", Block.blockRegistry.getIDForObject(liquidSphereFluids[0]));
    }

    setBlockMeta(tagCompound, canyonBlock, "canyonBlock");
    tagCompound.setInteger("fluidBlock", Block.blockRegistry.getIDForObject(fluidForTerrain));

    writeBlocksToNBT(tagCompound, extraOregen, "extraOregen");
    writeFluidsToNBT(tagCompound, fluidsForLakes, "lakeFluids");

    tagCompound.setBoolean("peaceful", peaceful);
    tagCompound.setBoolean("noanimals", noanimals);
    tagCompound.setBoolean("shelter", shelter);
    tagCompound.setBoolean("respawnHere", respawnHere);
    if (celestialAngle != null) {
      tagCompound.setFloat("celestialAngle", celestialAngle);
    }
    if (timeSpeed != null) {
      tagCompound.setFloat("timeSpeed", timeSpeed);
    }
    tagCompound.setInteger("probes", probeCounter);
    tagCompound.setInteger("actualCost", actualRfCost);

    skyDescriptor.writeToNBT(tagCompound);
    weatherDescriptor.writeToNBT(tagCompound);

    tagCompound.setLong("patreon1", patreon1);

    NBTTagList list = new NBTTagList();
    for (MobDescriptor mob : extraMobs) {
      NBTTagCompound tc = new NBTTagCompound();

      if (mob != null) {
        if (mob.getEntityClass() != null) {
          tc.setString("class", mob.getEntityClass().getName());
          tc.setInteger("chance", mob.getSpawnChance());
          tc.setInteger("minGroup", mob.getMinGroup());
          tc.setInteger("maxGroup", mob.getMaxGroup());
          tc.setInteger("maxLoaded", mob.getMaxLoaded());
          list.appendTag(tc);
        }
      }
    }

    tagCompound.setTag("mobs", list);
    tagCompound.setString("dimensionTypes", StringUtils.join(dimensionTypes, ","));
  }
  /** copies a 32x32 chunk set from par2File to par1File, via AnvilConverterData */
  private void convertChunks(
      File par1File,
      File par2File,
      WorldChunkManager par3WorldChunkManager,
      int par4,
      int par5,
      IProgressUpdate par6IProgressUpdate) {
    try {
      String s = par2File.getName();
      RegionFile regionfile = new RegionFile(par2File);
      RegionFile regionfile1 =
          new RegionFile(
              new File(
                  par1File,
                  (new StringBuilder())
                      .append(s.substring(0, s.length() - ".mcr".length()))
                      .append(".mca")
                      .toString()));

      for (int i = 0; i < 32; i++) {
        for (int j = 0; j < 32; j++) {
          if (!regionfile.isChunkSaved(i, j) || regionfile1.isChunkSaved(i, j)) {
            continue;
          }

          DataInputStream datainputstream = regionfile.getChunkDataInputStream(i, j);

          if (datainputstream == null) {
            System.out.println("Failed to fetch input stream");
          } else {
            NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
            datainputstream.close();
            NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Level");
            AnvilConverterData anvilconverterdata = ChunkLoader.load(nbttagcompound1);
            NBTTagCompound nbttagcompound2 = new NBTTagCompound();
            NBTTagCompound nbttagcompound3 = new NBTTagCompound();
            nbttagcompound2.setTag("Level", nbttagcompound3);
            ChunkLoader.convertToAnvilFormat(
                anvilconverterdata, nbttagcompound3, par3WorldChunkManager);
            DataOutputStream dataoutputstream = regionfile1.getChunkDataOutputStream(i, j);
            CompressedStreamTools.write(nbttagcompound2, dataoutputstream);
            dataoutputstream.close();
          }
        }

        int k = (int) Math.round((100D * (double) (par4 * 1024)) / (double) (par5 * 1024));
        int l =
            (int)
                Math.round((100D * (double) ((i + 1) * 32 + par4 * 1024)) / (double) (par5 * 1024));

        if (l > k) {
          par6IProgressUpdate.setLoadingProgress(l);
        }
      }

      regionfile.close();
      regionfile1.close();
    } catch (IOException ioexception) {
      ioexception.printStackTrace();
    }
  }