CompoundTag root = (CompoundTag)inStream.readTag();
inStream.close();
HashMap<String, Tag> rootMap = new HashMap<String, Tag>(root.getValue());
ArrayList<Tag> posTag = new ArrayList<Tag>(((ListTag)rootMap.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("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);