コード例 #1
0
ファイル: DimensionInformation.java プロジェクト: ntf/RFTools
 private static void writeBlocksToNBT(
     NBTTagCompound tagCompound, BlockMeta[] blocks, String name) {
   List<Integer> ids = new ArrayList<Integer>(blocks.length);
   List<Integer> meta = new ArrayList<Integer>(blocks.length);
   for (BlockMeta t : blocks) {
     ids.add(Block.blockRegistry.getIDForObject(t.getBlock()));
     meta.add((int) t.getMeta());
   }
   tagCompound.setIntArray(name, ArrayUtils.toPrimitive(ids.toArray(new Integer[ids.size()])));
   tagCompound.setIntArray(
       name + "_meta", ArrayUtils.toPrimitive(meta.toArray(new Integer[meta.size()])));
 }
コード例 #2
0
ファイル: DimensionInformation.java プロジェクト: ntf/RFTools
 private static <T extends Enum> int[] toIntArray(Collection<T> collection) {
   List<Integer> c = new ArrayList<Integer>(collection.size());
   for (T t : collection) {
     c.add(t.ordinal());
   }
   return ArrayUtils.toPrimitive(c.toArray(new Integer[c.size()]));
 }
コード例 #3
0
ファイル: DimensionInformation.java プロジェクト: ntf/RFTools
 private Block[] readFluidsFromNBT(NBTTagCompound tagCompound, String name) {
   List<Block> fluids = new ArrayList<Block>();
   for (int a : getIntArraySafe(tagCompound, name)) {
     fluids.add((Block) Block.blockRegistry.getObjectById(a));
   }
   return fluids.toArray(new Block[fluids.size()]);
 }
コード例 #4
0
ファイル: DimensionInformation.java プロジェクト: ntf/RFTools
 private static Block[] readFluidArrayFromBuf(ByteBuf buf) {
   List<Block> blocks = new ArrayList<Block>();
   int size = buf.readInt();
   for (int i = 0; i < size; i++) {
     blocks.add((Block) Block.blockRegistry.getObjectById(buf.readInt()));
   }
   return blocks.toArray(new Block[blocks.size()]);
 }
コード例 #5
0
ファイル: DimensionInformation.java プロジェクト: ntf/RFTools
 private static void writeFluidsToNBT(NBTTagCompound tagCompound, Block[] fluids, String name) {
   List<Integer> c;
   c = new ArrayList<Integer>(fluids.length);
   for (Block t : fluids) {
     c.add(Block.blockRegistry.getIDForObject(t));
   }
   tagCompound.setIntArray(name, ArrayUtils.toPrimitive(c.toArray(new Integer[c.size()])));
 }
コード例 #6
0
ファイル: DimensionInformation.java プロジェクト: ntf/RFTools
 private static BlockMeta[] readBlockArrayFromBuf(ByteBuf buf) {
   int size = buf.readInt();
   List<BlockMeta> blocksMeta = new ArrayList<BlockMeta>();
   for (int i = 0; i < size; i++) {
     Block b = (Block) Block.blockRegistry.getObjectById(buf.readInt());
     int m = buf.readInt();
     blocksMeta.add(new BlockMeta(b, m));
   }
   return blocksMeta.toArray(new BlockMeta[blocksMeta.size()]);
 }
コード例 #7
0
ファイル: DimensionInformation.java プロジェクト: ntf/RFTools
 private static BlockMeta[] readBlockArrayFromNBT(NBTTagCompound tagCompound, String name) {
   List<BlockMeta> blocks = new ArrayList<BlockMeta>();
   int[] blockIds = getIntArraySafe(tagCompound, name);
   int[] metas = getIntArraySafe(tagCompound, name + "_meta");
   for (int i = 0; i < blockIds.length; i++) {
     int id = blockIds[i];
     Block block = (Block) Block.blockRegistry.getObjectById(id);
     int meta = 0;
     if (i < metas.length) {
       meta = metas[i];
     }
     blocks.add(new BlockMeta(block, meta));
   }
   return blocks.toArray(new BlockMeta[blocks.size()]);
 }
コード例 #8
0
ファイル: DimensionInformation.java プロジェクト: ntf/RFTools
  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, ","));
  }