Package com.bergerkiller.bukkit.common.nbt

Examples of com.bergerkiller.bukkit.common.nbt.CommonTagCompound


   *
   * @param seed to use
   * @return Data compound
   */
  public CommonTagCompound createData(long seed) {
    CommonTagCompound data = new CommonTagCompound();
    data.putValue("thundering", (byte) 0);
    data.putValue("thundering", (byte) 0);
    data.putValue("LastPlayed", System.currentTimeMillis());
    data.putValue("RandomSeed", seed);
    data.putValue("version", (int) 19133);
    data.putValue("initialized", (byte) 0); // Spawn point needs to be re-initialized, etc.
    data.putValue("Time", 0L);
    data.putValue("raining", (byte) 0);
    data.putValue("SpawnX", 0);
    data.putValue("thunderTime", (int) 200000000);
    data.putValue("SpawnY", 64);
    data.putValue("SpawnZ", 0);
    data.putValue("LevelName", worldname);
    data.putValue("SizeOnDisk", getWorldSize());
    data.putValue("rainTime", (int) 50000);
    return data;
  }
View Full Code Here


    File f = getDataFile();
    if (!f.exists()) {
      return null;
    }
    try {
      CommonTagCompound root = CommonTagCompound.readFrom(f);
      if (root != null) {
        return root.get("Data", CommonTagCompound.class);
      } else {
        return null;
      }
    } catch (Exception ex) {
      return null;
View Full Code Here

   * @param data to set to
   * @return True if successful, False if not
   */
  public boolean setData(CommonTagCompound data) {
      try {
      CommonTagCompound root = new CommonTagCompound();
      root.put("Data", data);
      FileOutputStream out = StreamUtil.createOutputStream(getDataFile());
      try {
        root.writeTo(out);
      } finally {
        out.close();
      }
      return true;
    } catch (IOException e) {
View Full Code Here

   * @return WorldInfo structure
   */
  public WorldInfo getInfo() {
    WorldInfo info = null;
    try {
      CommonTagCompound t = getData();
      if (t != null) {
        info = new WorldInfo();
        info.seed = t.getValue("RandomSeed", 0L);
        info.time = t.getValue("Time", 0L);
        info.raining = t.getValue("raining", (byte) 0) != 0;
            info.thundering = t.getValue("thundering", (byte) 0) != 0;
      }
    } catch (Exception ex) {}
    World w = getWorld();
    if (w != null) {
      if (info == null) {
View Full Code Here

   * If not initialized, then the spawn position needs to be calculated, among other things.
   *
   * @return True if initialized, False if not
   */
  public boolean isInitialized() {
    CommonTagCompound data = getData();
    return data != null && data.getValue("initialized", true);
  }
View Full Code Here

    if (uid.exists()) {
      uid.delete();
    }

    // Update the name set in the level.dat for the new world
    CommonTagCompound data = newWorldConfig.getData();
    if (data != null) {
      data.putValue("LevelName", newWorldConfig.worldname);
      newWorldConfig.setData(data);
    }
    return true;
  }
View Full Code Here

   * @param compound to save to, use null to save to a new compound
   * @return the compound to which was saved
   */
  public static CommonTagCompound saveEntity(org.bukkit.entity.Entity entity, CommonTagCompound compound) {
    if (compound == null) {
      compound = new CommonTagCompound();
    }
    ((Entity) Conversion.toEntityHandle.convert(entity)).e((NBTTagCompound) compound.getHandle());
    return compound;
  }
View Full Code Here

   */
  public static Inventory createInventory(CommonTagList tags) {
    Inventory inv = new CraftInventoryCustom(null, tags.size());
   
    for(int i = 0; i < tags.size(); i++) {
      CommonTagCompound tag = (CommonTagCompound) tags.get(i);
      if(!tag.isEmpty()) {
        inv.setItem(i, CraftItemStack.asCraftMirror(ItemStack.createStack(
            (NBTTagCompound) tag.getHandle())));
      }
    }
   
    return inv;
  }
View Full Code Here

   * @param compound to save to, use null to save to a new compound
   * @return the compound to which was saved
   */
  public static CommonTagCompound saveFoodMetaData(Object foodMetaData, CommonTagCompound compound) {
    if (compound == null) {
      compound = new CommonTagCompound();
    }
    ((FoodMetaData) foodMetaData).b((NBTTagCompound) compound.getHandle());
    return compound;
  }
View Full Code Here

   * @param data to save the blockState to, null to create a new compound
   * @return compound with saved data
   */
  public static CommonTagCompound saveBlockState(BlockState blockState, CommonTagCompound data) {
    if (data == null) {
      data = new CommonTagCompound();
    }
    CommonNMS.getNative(blockState).b((NBTTagCompound) data.getHandle());
    return data;
  }
View Full Code Here

TOP

Related Classes of com.bergerkiller.bukkit.common.nbt.CommonTagCompound

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.