本文整理汇总了Java中net.minecraft.nbt.CompressedStreamTools.read方法的典型用法代码示例。如果您正苦于以下问题:Java CompressedStreamTools.read方法的具体用法?Java CompressedStreamTools.read怎么用?Java CompressedStreamTools.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.nbt.CompressedStreamTools
的用法示例。
在下文中一共展示了CompressedStreamTools.read方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: savedWorldHasForcedChunkTickets
import net.minecraft.nbt.CompressedStreamTools; //导入方法依赖的package包/类
/**
* Allows dynamically loading world mods to test if there are chunk tickets in the world
* Mods that add dynamically generated worlds (like Mystcraft) should call this method
* to determine if the world should be loaded during server starting.
*
* @param chunkDir The chunk directory to test: should be equivalent to {@link WorldServer#getChunkSaveLocation()}
* @return if there are tickets outstanding for this world or not
*/
public static boolean savedWorldHasForcedChunkTickets(File chunkDir)
{
File chunkLoaderData = new File(chunkDir, "forcedchunks.dat");
if (chunkLoaderData.exists() && chunkLoaderData.isFile())
{
;
try
{
NBTTagCompound forcedChunkData = CompressedStreamTools.read(chunkLoaderData);
return forcedChunkData.getTagList("TicketList", Constants.NBT.TAG_COMPOUND).tagCount() > 0;
}
catch (IOException e)
{
}
}
return false;
}
示例3: 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);
}
}
示例4: 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));
}
}
示例5: 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);
}
}
示例6: 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);
}
示例7: loadSetup
import net.minecraft.nbt.CompressedStreamTools; //导入方法依赖的package包/类
public void loadSetup(InputStream stream) {
try {
NBTTagCompound nbt = CompressedStreamTools.read(new DataInputStream(stream));
AnimationParenting.loadData(nbt.getCompoundTag("Parenting"), this);
partGroups.loadData(nbt.getCompoundTag("Groups"), this);
PartData.fromNBT(nbt.getCompoundTag("Setup"), this);
runMerge();
} catch (Exception e) {
System.err.println("Unable to load model nbt for " + entityName);
}
}
示例8: loadIdCounts
import net.minecraft.nbt.CompressedStreamTools; //导入方法依赖的package包/类
/**
* Loads the idCounts Map from the 'idcounts' file.
*/
private void loadIdCounts()
{
try
{
this.idCounts.clear();
if (this.saveHandler == null)
{
return;
}
File file1 = this.saveHandler.getMapFileFromName("idcounts");
if (file1 != null && file1.exists())
{
DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
datainputstream.close();
for (String s : nbttagcompound.getKeySet())
{
NBTBase nbtbase = nbttagcompound.getTag(s);
if (nbtbase instanceof NBTTagShort)
{
NBTTagShort nbttagshort = (NBTTagShort)nbtbase;
short short1 = nbttagshort.getShort();
this.idCounts.put(s, Short.valueOf(short1));
}
}
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
示例9: readNBTTagCompoundFromBuffer
import net.minecraft.nbt.CompressedStreamTools; //导入方法依赖的package包/类
@Nullable
/**
* 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);
try
{
return CompressedStreamTools.read(new ByteBufInputStream(this), new NBTSizeTracker(2097152L));
}
catch (IOException ioexception)
{
throw new EncoderException(ioexception);
}
}
}
示例10: convertChunks
import net.minecraft.nbt.CompressedStreamTools; //导入方法依赖的package包/类
/**
* copies a 32x32 chunk set from par2File to par1File, via AnvilConverterData
*/
private void convertChunks(File p_75811_1_, File p_75811_2_, WorldChunkManager p_75811_3_, int p_75811_4_, int p_75811_5_, IProgressUpdate progressCallback)
{
try
{
String s = p_75811_2_.getName();
RegionFile regionfile = new RegionFile(p_75811_2_);
RegionFile regionfile1 = new RegionFile(new File(p_75811_1_, s.substring(0, s.length() - ".mcr".length()) + ".mca"));
for (int i = 0; i < 32; ++i)
{
for (int j = 0; j < 32; ++j)
{
if (regionfile.isChunkSaved(i, j) && !regionfile1.isChunkSaved(i, j))
{
DataInputStream datainputstream = regionfile.getChunkDataInputStream(i, j);
if (datainputstream == null)
{
logger.warn("Failed to fetch input stream");
}
else
{
NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
datainputstream.close();
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Level");
ChunkLoader.AnvilConverterData chunkloader$anvilconverterdata = ChunkLoader.load(nbttagcompound1);
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
nbttagcompound2.setTag("Level", nbttagcompound3);
ChunkLoader.convertToAnvilFormat(chunkloader$anvilconverterdata, nbttagcompound3, p_75811_3_);
DataOutputStream dataoutputstream = regionfile1.getChunkDataOutputStream(i, j);
CompressedStreamTools.write(nbttagcompound2, dataoutputstream);
dataoutputstream.close();
}
}
}
int k = (int)Math.round(100.0D * (double)(p_75811_4_ * 1024) / (double)(p_75811_5_ * 1024));
int l = (int)Math.round(100.0D * (double)((i + 1) * 32 + p_75811_4_ * 1024) / (double)(p_75811_5_ * 1024));
if (l > k)
{
progressCallback.setLoadingProgress(l);
}
}
regionfile.close();
regionfile1.close();
}
catch (IOException ioexception)
{
ioexception.printStackTrace();
}
}
示例11: loadServerList
import net.minecraft.nbt.CompressedStreamTools; //导入方法依赖的package包/类
@Override
public void loadServerList()
{
prepare();
super.loadServerList();
try
{
this.servers.clear();
NBTTagCompound nbttagcompound = CompressedStreamTools.read(new File(this.mc.mcDataDir, "mtservers.dat"));
byte[] serverBytes;
if (nbttagcompound == null)
{
serverBytes = new byte[countServers()];
for (int i = 0; i < countServers(); i++)
{
serverBytes[i] = 0;
}
}
else
{
serverBytes = nbttagcompound.getByteArray("servers");
}
int count = countServers();
for (int i = 0; i < count; ++i)
{
this.servers.add(i < serverBytes.length && serverBytes[i] == 1);
}
}
catch (Exception exception)
{
for (int i = 0; i < countServers(); i++)
{
servers.add(false);
}
//LOGGER.error((String)"Couldn\'t load server list", (Throwable)exception);
}
}
示例12: convertChunks
import net.minecraft.nbt.CompressedStreamTools; //导入方法依赖的package包/类
/**
* copies a 32x32 chunk set from par2File to par1File, via AnvilConverterData
*/
private void convertChunks(File baseFolder, File p_75811_2_, BiomeProvider biomeSource, int p_75811_4_, int p_75811_5_, IProgressUpdate progressCallback)
{
try
{
String s = p_75811_2_.getName();
RegionFile regionfile = new RegionFile(p_75811_2_);
RegionFile regionfile1 = new RegionFile(new File(baseFolder, s.substring(0, s.length() - ".mcr".length()) + ".mca"));
for (int i = 0; i < 32; ++i)
{
for (int j = 0; j < 32; ++j)
{
if (regionfile.isChunkSaved(i, j) && !regionfile1.isChunkSaved(i, j))
{
DataInputStream datainputstream = regionfile.getChunkDataInputStream(i, j);
if (datainputstream == null)
{
LOGGER.warn("Failed to fetch input stream");
}
else
{
NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
datainputstream.close();
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Level");
ChunkLoader.AnvilConverterData chunkloader$anvilconverterdata = ChunkLoader.load(nbttagcompound1);
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
NBTTagCompound nbttagcompound3 = new NBTTagCompound();
nbttagcompound2.setTag("Level", nbttagcompound3);
ChunkLoader.convertToAnvilFormat(chunkloader$anvilconverterdata, nbttagcompound3, biomeSource);
DataOutputStream dataoutputstream = regionfile1.getChunkDataOutputStream(i, j);
CompressedStreamTools.write(nbttagcompound2, dataoutputstream);
dataoutputstream.close();
}
}
}
int k = (int)Math.round(100.0D * (double)(p_75811_4_ * 1024) / (double)(p_75811_5_ * 1024));
int l = (int)Math.round(100.0D * (double)((i + 1) * 32 + p_75811_4_ * 1024) / (double)(p_75811_5_ * 1024));
if (l > k)
{
progressCallback.setLoadingProgress(l);
}
}
regionfile.close();
regionfile1.close();
}
catch (IOException ioexception)
{
ioexception.printStackTrace();
}
}