Package org.jnbt

Examples of org.jnbt.NBTOutputStream


      final CompoundTag newDataTag = new CompoundTag("Data", newData);
      final Map<String, Tag> newTopLevelMap = new HashMap<String, Tag>(1);
      newTopLevelMap.put("Data", newDataTag);
      final CompoundTag newTopLevelTag = new CompoundTag("", newTopLevelMap);

      final NBTOutputStream output = new NBTOutputStream(new FileOutputStream(level));
      output.writeTag(newTopLevelTag);
      output.close();
    } catch (final ClassCastException ex) {
      throw new IOException("Invalid level format.");
    } catch (final NullPointerException ex) {
      throw new IOException("Invalid level format.");
    }
View Full Code Here


        posTag.set(0, new DoubleTag("x", x));
        posTag.set(1, new DoubleTag("y", 120));
        posTag.set(2, new DoubleTag("z", y));
        rootMap.put("Pos", new ListTag("Pos", DoubleTag.class, posTag));
        root = new CompoundTag("Data", rootMap);
        NBTOutputStream outStream = new NBTOutputStream(new FileOutputStream(out));
        outStream.writeTag(root);
        outStream.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
     
    } else {
      out = file;
      backupFile(out);
      try {
        NBTInputStream inStream = new NBTInputStream(new FileInputStream(out));
        CompoundTag root = (CompoundTag)(((CompoundTag)inStream.readTag()).getValue().get("Data"));
        inStream.close();
       
        HashMap<String, Tag> rootMap = new HashMap<String, Tag>(root.getValue());
        HashMap<String, Tag> playerMap = new HashMap<String, Tag>(((CompoundTag)rootMap.get("Player")).getValue());
        ArrayList<Tag> posTag = new ArrayList<Tag>(((ListTag)playerMap.get("Pos")).getValue());
        posTag.set(0, new DoubleTag("x", x));
        posTag.set(1, new DoubleTag("y", 120));
        posTag.set(2, new DoubleTag("z", y));
        rootMap.put("Player", new CompoundTag("Player", playerMap));
        playerMap.put("Pos", new ListTag("Pos", DoubleTag.class, posTag));
        root = new CompoundTag("Data", rootMap);
        HashMap<String, Tag> base = new HashMap<String, Tag>();
        base.put("Data", root);
        root = new CompoundTag("Base", base);
        NBTOutputStream outStream = new NBTOutputStream(new FileOutputStream(out));
        outStream.writeTag(root);
        outStream.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.jnbt.NBTOutputStream

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.