本文整理汇总了Java中net.minecraft.nbt.CompressedStreamTools类的典型用法代码示例。如果您正苦于以下问题:Java CompressedStreamTools类的具体用法?Java CompressedStreamTools怎么用?Java CompressedStreamTools使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CompressedStreamTools类属于net.minecraft.nbt包,在下文中一共展示了CompressedStreamTools类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveModelDataToObsidianFile
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
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();
}
}
示例2: load
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
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;
}
示例3: saveServerList
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
@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);
}
}
示例4: loadChunk
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
/**
* 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);
}
示例5: writePlayerData
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
/**
* 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());
}
}
示例6: readPlayerData
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
/**
* 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;
}
示例7: writeNBTTagCompoundToBuffer
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
/**
* 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);
}
}
}
示例8: readNBTTagCompoundFromBuffer
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
/**
* 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));
}
}
示例9: renameWorld
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
/**
* 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();
}
}
}
}
示例10: saveData
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
/**
* 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();
}
}
}
示例11: loadServerList
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
/**
* 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);
}
}
示例12: saveServerList
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
/**
* 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);
}
}
示例13: loadChunk
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
@Nullable
/**
* Loads the specified(XZ) chunk into the specified world.
*/
public Chunk loadChunk(World worldIn, int x, int z) throws IOException
{
ChunkPos chunkpos = new ChunkPos(x, z);
NBTTagCompound nbttagcompound = (NBTTagCompound)this.chunksToRemove.get(chunkpos);
if (nbttagcompound == null)
{
DataInputStream datainputstream = RegionFileCache.getChunkInputStream(this.chunkSaveLocation, x, z);
if (datainputstream == null)
{
return null;
}
nbttagcompound = this.dataFixer.process(FixTypes.CHUNK, CompressedStreamTools.read(datainputstream));
}
return this.checkedReadChunkFromNBT(worldIn, x, z, nbttagcompound);
}
示例14: writePlayerData
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
/**
* Writes the player data to disk from the specified PlayerEntityMP.
*/
public void writePlayerData(EntityPlayer player)
{
try
{
NBTTagCompound nbttagcompound = player.writeToNBT(new NBTTagCompound());
File file1 = new File(this.playersDirectory, player.getCachedUniqueIdString() + ".dat.tmp");
File file2 = new File(this.playersDirectory, player.getCachedUniqueIdString() + ".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 {}", new Object[] {player.getName()});
}
}
示例15: saveData
import net.minecraft.nbt.CompressedStreamTools; //导入依赖的package包/类
/**
* Saves the given MapDataBase to disk.
*/
private void saveData(WorldSavedData data)
{
if (this.saveHandler != null)
{
try
{
File file1 = this.saveHandler.getMapFileFromName(data.mapName);
if (file1 != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setTag("data", data.writeToNBT(new NBTTagCompound()));
FileOutputStream fileoutputstream = new FileOutputStream(file1);
CompressedStreamTools.writeCompressed(nbttagcompound, fileoutputstream);
fileoutputstream.close();
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}