public static void saveModelDataToObsidianFile(ModelObj model, File obsidianFile)
{
try
{
NBTTagCompound nbt = model.createNBTTag();
File nbtFile = new File(SETUP_NAME);
CompressedStreamTools.write(nbt, nbtFile);
FileUtils.addEntryToExistingZip(obsidianFile, nbtFile);
nbtFile.delete();
}
catch(Exception e)
{
System.err.println("Could not save model data for " + model.entityName);
e.printStackTrace();
}
}
java类net.minecraft.nbt.CompressedStreamTools的实例源码
ModelFileHandler.java 文件源码
项目:ObsidianSuite
阅读 18
收藏 0
点赞 0
评论 0
ImporterQubble.java 文件源码
项目:ObsidianSuite
阅读 23
收藏 0
点赞 0
评论 0
private QubbleModel load(File file) throws IOException
{
try (ZipFile zipFile = new ZipFile(file))
{
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements())
{
ZipEntry entry = entries.nextElement();
if (entry.getName().equals("model.nbt"))
{
NBTTagCompound compound = CompressedStreamTools.read(new DataInputStream(zipFile.getInputStream(entry)));
return QubbleModel.deserialize(compound);
}
}
}
catch (ZipException zipException)
{
return this.loadLegacy(file);
}
return null;
}
ServerListNoEdit.java 文件源码
项目:CreeperHostGui
阅读 19
收藏 0
点赞 0
评论 0
@Override
public void saveServerList()
{
prepare();
super.saveServerList();
int numOfServers = countServers();
byte[] serverBytes = new byte[numOfServers];
for (int i = 0; i < numOfServers; i++)
{
boolean editStatus = i < servers.size() && servers.get(i);
serverBytes[i] = editStatus ? (byte) 1 : (byte) 0;
}
try
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByteArray("servers", serverBytes);
CompressedStreamTools.safeWrite(nbttagcompound, new File(this.mc.mcDataDir, "mtservers.dat"));
}
catch (Exception exception)
{
//logger.error("Couldn\'t save server list", exception);
}
}
ServerListNoEdit.java 文件源码
项目:CreeperHostGui
阅读 19
收藏 0
点赞 0
评论 0
@Override
public void saveServerList()
{
prepare();
super.saveServerList();
int numOfServers = countServers();
byte[] serverBytes = new byte[numOfServers];
for (int i = 0; i < numOfServers; i++)
{
boolean editStatus = i < servers.size() && servers.get(i);
serverBytes[i] = editStatus ? (byte) 1 : (byte) 0;
}
try
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByteArray("servers", serverBytes);
CompressedStreamTools.safeWrite(nbttagcompound, new File(this.mc.mcDataDir, "mtservers.dat"));
}
catch (Exception exception)
{
//logger.error("Couldn\'t save server list", exception);
}
}
AnvilChunkLoader.java 文件源码
项目:DecompiledMinecraft
阅读 26
收藏 0
点赞 0
评论 0
/**
* Loads the specified(XZ) chunk into the specified world.
*/
public Chunk loadChunk(World worldIn, int x, int z) throws IOException
{
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x, z);
NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkcoordintpair);
if (nbttagcompound == null)
{
DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z);
if (datainputstream == null)
{
return null;
}
nbttagcompound = CompressedStreamTools.read(datainputstream);
}
return this.checkedReadChunkFromNBT(worldIn, x, z, nbttagcompound);
}
SaveHandler.java 文件源码
项目:DecompiledMinecraft
阅读 21
收藏 0
点赞 0
评论 0
/**
* Writes the player data to disk from the specified PlayerEntityMP.
*/
public void writePlayerData(EntityPlayer player)
{
try
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
player.writeToNBT(nbttagcompound);
File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat.tmp");
File file2 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");
CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file1));
if (file2.exists())
{
file2.delete();
}
file1.renameTo(file2);
}
catch (Exception var5)
{
logger.warn("Failed to save player data for " + player.getName());
}
}
SaveHandler.java 文件源码
项目:DecompiledMinecraft
阅读 22
收藏 0
点赞 0
评论 0
/**
* Reads the player data from disk into the specified PlayerEntityMP.
*/
public NBTTagCompound readPlayerData(EntityPlayer player)
{
NBTTagCompound nbttagcompound = null;
try
{
File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");
if (file1.exists() && file1.isFile())
{
nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1));
}
}
catch (Exception var4)
{
logger.warn("Failed to load player data for " + player.getName());
}
if (nbttagcompound != null)
{
player.readFromNBT(nbttagcompound);
}
return nbttagcompound;
}
PacketBuffer.java 文件源码
项目:DecompiledMinecraft
阅读 24
收藏 0
点赞 0
评论 0
/**
* Writes a compressed NBTTagCompound to this buffer
*/
public void writeNBTTagCompoundToBuffer(NBTTagCompound nbt)
{
if (nbt == null)
{
this.writeByte(0);
}
else
{
try
{
CompressedStreamTools.write(nbt, new ByteBufOutputStream(this));
}
catch (IOException ioexception)
{
throw new EncoderException(ioexception);
}
}
}
PacketBuffer.java 文件源码
项目:DecompiledMinecraft
阅读 21
收藏 0
点赞 0
评论 0
/**
* Reads a compressed NBTTagCompound from this buffer
*/
public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException
{
int i = this.readerIndex();
byte b0 = this.readByte();
if (b0 == 0)
{
return null;
}
else
{
this.readerIndex(i);
return CompressedStreamTools.read(new ByteBufInputStream(this), new NBTSizeTracker(2097152L));
}
}
AnvilChunkLoader.java 文件源码
项目:DecompiledMinecraft
阅读 25
收藏 0
点赞 0
评论 0
/**
* Loads the specified(XZ) chunk into the specified world.
*/
public Chunk loadChunk(World worldIn, int x, int z) throws IOException
{
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x, z);
NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkcoordintpair);
if (nbttagcompound == null)
{
DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z);
if (datainputstream == null)
{
return null;
}
nbttagcompound = CompressedStreamTools.read(datainputstream);
}
return this.checkedReadChunkFromNBT(worldIn, x, z, nbttagcompound);
}
SaveFormatOld.java 文件源码
项目:DecompiledMinecraft
阅读 23
收藏 0
点赞 0
评论 0
/**
* Renames the world by storing the new name in level.dat. It does *not* rename the directory containing the world
* data.
*/
public void renameWorld(String dirName, String newName)
{
File file1 = new File(this.savesDirectory, dirName);
if (file1.exists())
{
File file2 = new File(file1, "level.dat");
if (file2.exists())
{
try
{
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file2));
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
nbttagcompound1.setString("LevelName", newName);
CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file2));
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}
}
SaveHandler.java 文件源码
项目:DecompiledMinecraft
阅读 24
收藏 0
点赞 0
评论 0
/**
* Writes the player data to disk from the specified PlayerEntityMP.
*/
public void writePlayerData(EntityPlayer player)
{
try
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
player.writeToNBT(nbttagcompound);
File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat.tmp");
File file2 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");
CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file1));
if (file2.exists())
{
file2.delete();
}
file1.renameTo(file2);
}
catch (Exception var5)
{
logger.warn("Failed to save player data for " + player.getName());
}
}
SaveHandler.java 文件源码
项目:DecompiledMinecraft
阅读 22
收藏 0
点赞 0
评论 0
/**
* Reads the player data from disk into the specified PlayerEntityMP.
*/
public NBTTagCompound readPlayerData(EntityPlayer player)
{
NBTTagCompound nbttagcompound = null;
try
{
File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");
if (file1.exists() && file1.isFile())
{
nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1));
}
}
catch (Exception var4)
{
logger.warn("Failed to load player data for " + player.getName());
}
if (nbttagcompound != null)
{
player.readFromNBT(nbttagcompound);
}
return nbttagcompound;
}
MapStorage.java 文件源码
项目:DecompiledMinecraft
阅读 22
收藏 0
点赞 0
评论 0
/**
* Saves the given MapDataBase to disk.
*/
private void saveData(WorldSavedData p_75747_1_)
{
if (this.saveHandler != null)
{
try
{
File file1 = this.saveHandler.getMapFileFromName(p_75747_1_.mapName);
if (file1 != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
p_75747_1_.writeToNBT(nbttagcompound);
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setTag("data", nbttagcompound);
FileOutputStream fileoutputstream = new FileOutputStream(file1);
CompressedStreamTools.writeCompressed(nbttagcompound1, fileoutputstream);
fileoutputstream.close();
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}
PacketBuffer.java 文件源码
项目:DecompiledMinecraft
阅读 24
收藏 0
点赞 0
评论 0
/**
* Writes a compressed NBTTagCompound to this buffer
*/
public void writeNBTTagCompoundToBuffer(NBTTagCompound nbt)
{
if (nbt == null)
{
this.writeByte(0);
}
else
{
try
{
CompressedStreamTools.write(nbt, new ByteBufOutputStream(this));
}
catch (IOException ioexception)
{
throw new EncoderException(ioexception);
}
}
}
PacketBuffer.java 文件源码
项目:DecompiledMinecraft
阅读 25
收藏 0
点赞 0
评论 0
/**
* Reads a compressed NBTTagCompound from this buffer
*/
public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException
{
int i = this.readerIndex();
byte b0 = this.readByte();
if (b0 == 0)
{
return null;
}
else
{
this.readerIndex(i);
return CompressedStreamTools.read(new ByteBufInputStream(this), new NBTSizeTracker(2097152L));
}
}
ServerList.java 文件源码
项目:DecompiledMinecraft
阅读 21
收藏 0
点赞 0
评论 0
/**
* Loads a list of servers from servers.dat, by running ServerData.getServerDataFromNBTCompound on each NBT compound
* found in the "servers" tag list.
*/
public void loadServerList()
{
try
{
this.servers.clear();
NBTTagCompound nbttagcompound = CompressedStreamTools.read(new File(this.mc.mcDataDir, "servers.dat"));
if (nbttagcompound == null)
{
return;
}
NBTTagList nbttaglist = nbttagcompound.getTagList("servers", 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
this.servers.add(ServerData.getServerDataFromNBTCompound(nbttaglist.getCompoundTagAt(i)));
}
}
catch (Exception exception)
{
logger.error((String)"Couldn\'t load server list", (Throwable)exception);
}
}
ServerList.java 文件源码
项目:DecompiledMinecraft
阅读 19
收藏 0
点赞 0
评论 0
/**
* Runs getNBTCompound on each ServerData instance, puts everything into a "servers" NBT list and writes it to
* servers.dat.
*/
public void saveServerList()
{
try
{
NBTTagList nbttaglist = new NBTTagList();
for (ServerData serverdata : this.servers)
{
nbttaglist.appendTag(serverdata.getNBTCompound());
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setTag("servers", nbttaglist);
CompressedStreamTools.safeWrite(nbttagcompound, new File(this.mc.mcDataDir, "servers.dat"));
}
catch (Exception exception)
{
logger.error((String)"Couldn\'t save server list", (Throwable)exception);
}
}
AnvilChunkLoader.java 文件源码
项目:BaseClient
阅读 19
收藏 0
点赞 0
评论 0
/**
* Loads the specified(XZ) chunk into the specified world.
*/
public Chunk loadChunk(World worldIn, int x, int z) throws IOException
{
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x, z);
NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkcoordintpair);
if (nbttagcompound == null)
{
DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z);
if (datainputstream == null)
{
return null;
}
nbttagcompound = CompressedStreamTools.read(datainputstream);
}
return this.checkedReadChunkFromNBT(worldIn, x, z, nbttagcompound);
}
SaveFormatOld.java 文件源码
项目:BaseClient
阅读 23
收藏 0
点赞 0
评论 0
/**
* Renames the world by storing the new name in level.dat. It does *not* rename the directory containing the world
* data.
*/
public void renameWorld(String dirName, String newName)
{
File file1 = new File(this.savesDirectory, dirName);
if (file1.exists())
{
File file2 = new File(file1, "level.dat");
if (file2.exists())
{
try
{
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file2));
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
nbttagcompound1.setString("LevelName", newName);
CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file2));
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}
}
SaveHandler.java 文件源码
项目:BaseClient
阅读 21
收藏 0
点赞 0
评论 0
/**
* Writes the player data to disk from the specified PlayerEntityMP.
*/
public void writePlayerData(EntityPlayer player)
{
try
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
player.writeToNBT(nbttagcompound);
File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat.tmp");
File file2 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");
CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file1));
if (file2.exists())
{
file2.delete();
}
file1.renameTo(file2);
}
catch (Exception var5)
{
logger.warn("Failed to save player data for " + player.getName());
}
}
SaveHandler.java 文件源码
项目:BaseClient
阅读 23
收藏 0
点赞 0
评论 0
/**
* Reads the player data from disk into the specified PlayerEntityMP.
*/
public NBTTagCompound readPlayerData(EntityPlayer player)
{
NBTTagCompound nbttagcompound = null;
try
{
File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");
if (file1.exists() && file1.isFile())
{
nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file1));
}
}
catch (Exception var4)
{
logger.warn("Failed to load player data for " + player.getName());
}
if (nbttagcompound != null)
{
player.readFromNBT(nbttagcompound);
}
return nbttagcompound;
}
MapStorage.java 文件源码
项目:BaseClient
阅读 23
收藏 0
点赞 0
评论 0
/**
* Saves the given MapDataBase to disk.
*/
private void saveData(WorldSavedData p_75747_1_)
{
if (this.saveHandler != null)
{
try
{
File file1 = this.saveHandler.getMapFileFromName(p_75747_1_.mapName);
if (file1 != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
p_75747_1_.writeToNBT(nbttagcompound);
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
nbttagcompound1.setTag("data", nbttagcompound);
FileOutputStream fileoutputstream = new FileOutputStream(file1);
CompressedStreamTools.writeCompressed(nbttagcompound1, fileoutputstream);
fileoutputstream.close();
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}
PacketBuffer.java 文件源码
项目:BaseClient
阅读 28
收藏 0
点赞 0
评论 0
/**
* Writes a compressed NBTTagCompound to this buffer
*/
public void writeNBTTagCompoundToBuffer(NBTTagCompound nbt)
{
if (nbt == null)
{
this.writeByte(0);
}
else
{
try
{
CompressedStreamTools.write(nbt, new ByteBufOutputStream(this));
}
catch (IOException ioexception)
{
throw new EncoderException(ioexception);
}
}
}
PacketBuffer.java 文件源码
项目:BaseClient
阅读 27
收藏 0
点赞 0
评论 0
/**
* Reads a compressed NBTTagCompound from this buffer
*/
public NBTTagCompound readNBTTagCompoundFromBuffer() throws IOException
{
int i = this.readerIndex();
byte b0 = this.readByte();
if (b0 == 0)
{
return null;
}
else
{
this.readerIndex(i);
return CompressedStreamTools.read(new ByteBufInputStream(this), new NBTSizeTracker(2097152L));
}
}
ServerList.java 文件源码
项目:BaseClient
阅读 19
收藏 0
点赞 0
评论 0
/**
* Loads a list of servers from servers.dat, by running ServerData.getServerDataFromNBTCompound on each NBT compound
* found in the "servers" tag list.
*/
public void loadServerList()
{
try
{
this.servers.clear();
NBTTagCompound nbttagcompound = CompressedStreamTools.read(new File(this.mc.mcDataDir, "servers.dat"));
if (nbttagcompound == null)
{
return;
}
NBTTagList nbttaglist = nbttagcompound.getTagList("servers", 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
this.servers.add(ServerData.getServerDataFromNBTCompound(nbttaglist.getCompoundTagAt(i)));
}
}
catch (Exception exception)
{
logger.error((String)"Couldn\'t load server list", (Throwable)exception);
}
}
ServerList.java 文件源码
项目:BaseClient
阅读 19
收藏 0
点赞 0
评论 0
/**
* Runs getNBTCompound on each ServerData instance, puts everything into a "servers" NBT list and writes it to
* servers.dat.
*/
public void saveServerList()
{
try
{
NBTTagList nbttaglist = new NBTTagList();
for (ServerData serverdata : this.servers)
{
nbttaglist.appendTag(serverdata.getNBTCompound());
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setTag("servers", nbttaglist);
CompressedStreamTools.safeWrite(nbttagcompound, new File(this.mc.mcDataDir, "servers.dat"));
}
catch (Exception exception)
{
logger.error((String)"Couldn\'t save server list", (Throwable)exception);
}
}
AnvilChunkLoader.java 文件源码
项目:BaseClient
阅读 22
收藏 0
点赞 0
评论 0
/**
* Loads the specified(XZ) chunk into the specified world.
*/
public Chunk loadChunk(World worldIn, int x, int z) throws IOException
{
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x, z);
NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkcoordintpair);
if (nbttagcompound == null)
{
DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z);
if (datainputstream == null)
{
return null;
}
nbttagcompound = CompressedStreamTools.read(datainputstream);
}
return this.checkedReadChunkFromNBT(worldIn, x, z, nbttagcompound);
}
SaveFormatOld.java 文件源码
项目:BaseClient
阅读 21
收藏 0
点赞 0
评论 0
/**
* Renames the world by storing the new name in level.dat. It does *not* rename the directory containing the world
* data.
*/
public void renameWorld(String dirName, String newName)
{
File file1 = new File(this.savesDirectory, dirName);
if (file1.exists())
{
File file2 = new File(file1, "level.dat");
if (file2.exists())
{
try
{
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file2));
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
nbttagcompound1.setString("LevelName", newName);
CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file2));
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}
}
SaveHandler.java 文件源码
项目:BaseClient
阅读 44
收藏 0
点赞 0
评论 0
/**
* Writes the player data to disk from the specified PlayerEntityMP.
*/
public void writePlayerData(EntityPlayer player)
{
try
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
player.writeToNBT(nbttagcompound);
File file1 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat.tmp");
File file2 = new File(this.playersDirectory, player.getUniqueID().toString() + ".dat");
CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file1));
if (file2.exists())
{
file2.delete();
}
file1.renameTo(file2);
}
catch (Exception var5)
{
logger.warn("Failed to save player data for " + player.getName());
}
}