本文整理汇总了Java中cn.nukkit.utils.Zlib类的典型用法代码示例。如果您正苦于以下问题:Java Zlib类的具体用法?Java Zlib怎么用?Java Zlib使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Zlib类属于cn.nukkit.utils包,在下文中一共展示了Zlib类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: decode
import cn.nukkit.utils.Zlib; //导入依赖的package包/类
@Override
public void decode() {
this.protocol = this.getInt();
if(this.protocol >= 90){
return;
}
byte[] str;
try {
str = Zlib.inflate(this.get(this.getInt()), 1024 * 1024 * 64);
} catch (Exception e) {
return;
}
this.setBuffer(str, 0);
decodeChainData();
decodeSkinData();
}
开发者ID:PrismarineMC,项目名称:MagmaBlock,代码行数:17,代码来源:LoginPacket.java
示例2: onRun
import cn.nukkit.utils.Zlib; //导入依赖的package包/类
@Override
public void onRun() {
try {
this.finalData = Zlib.deflate(data, level);
this.data = null;
} catch (Exception e) {
//ignore
}
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:10,代码来源:CompressBatchedPacket.java
示例3: onRun
import cn.nukkit.utils.Zlib; //导入依赖的package包/类
@Override
public void onRun() {
try {
this.finalData = Zlib.deflate(this.data, this.level);
this.data = null;
} catch (Exception e) {
//ignore
}
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:10,代码来源:CompressBatchedTask.java
示例4: fromBinary
import cn.nukkit.utils.Zlib; //导入依赖的package包/类
public static Chunk fromBinary(byte[] data, LevelProvider provider) {
try {
CompoundTag chunk = NBTIO.read(new ByteArrayInputStream(Zlib.inflate(data)), ByteOrder.BIG_ENDIAN);
if (!chunk.contains("Level") || !(chunk.get("Level") instanceof CompoundTag)) {
return null;
}
return new Chunk(provider != null ? provider : McRegion.class.newInstance(), chunk.getCompound("Level"));
} catch (Exception e) {
return null;
}
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:13,代码来源:Chunk.java
示例5: testAll
import cn.nukkit.utils.Zlib; //导入依赖的package包/类
@DisplayName("Inflate and Deflate")
@Test
void testAll() throws Exception {
byte[] in = "lmlstarqaq".getBytes();
byte[] compressed = Zlib.deflate(in);
byte[] out = Zlib.inflate(compressed);
assertTrue(Arrays.equals(in, out));
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:9,代码来源:ZlibTest.java
示例6: fromBinary
import cn.nukkit.utils.Zlib; //导入依赖的package包/类
public static Chunk fromBinary(byte[] data, LevelProvider provider) {
try {
CompoundTag chunk = NBTIO.read(new ByteArrayInputStream(Zlib.inflate(data)), ByteOrder.BIG_ENDIAN);
if (!chunk.contains("Level") || !(chunk.get("Level") instanceof CompoundTag)) {
return null;
}
return new Chunk(provider, chunk.getCompound("Level"));
} catch (Exception e) {
Server.getInstance().getLogger().logException(e);
return null;
}
}
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:15,代码来源:Chunk.java
示例7: decode
import cn.nukkit.utils.Zlib; //导入依赖的package包/类
@Override
public void decode() {
this.protocol = this.getInt();
this.gameEdition = (byte) this.getByte();
byte[] str;
try {
str = Zlib.inflate(this.get((int) this.getUnsignedVarInt()));
} catch (Exception e) {
return;
}
this.setBuffer(str, 0);
decodeChainData();
decodeSkinData();
}
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:15,代码来源:LoginPacket.java
示例8: decode
import cn.nukkit.utils.Zlib; //导入依赖的package包/类
@Override
public void decode() {
this.protocol = this.getInt();
byte[] str;
try {
str = Zlib.inflate(this.get(this.getInt()), 64*1024*1024);
} catch (Exception e) {
return;
}
this.setBuffer(str, 0);
decodeChainData();
decodeSkinData();
}
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:14,代码来源:LoginPacket.java
示例9: toBinary
import cn.nukkit.utils.Zlib; //导入依赖的package包/类
@Override
public byte[] toBinary() {
CompoundTag nbt = this.getNBT().copy();
nbt.putInt("xPos", this.x);
nbt.putInt("zPos", this.z);
if (this.isGenerated()) {
nbt.putByteArray("Blocks", this.getBlockIdArray());
nbt.putByteArray("Data", this.getBlockDataArray());
nbt.putByteArray("SkyLight", this.getBlockSkyLightArray());
nbt.putByteArray("BlockLight", this.getBlockLightArray());
nbt.putIntArray("BiomeColors", this.getBiomeColorArray());
nbt.putIntArray("HeightMap", this.getHeightMapArray());
}
ArrayList<CompoundTag> entities = new ArrayList<>();
for (Entity entity : this.getEntities().values()) {
if (!(entity instanceof Player) && !entity.closed) {
entity.saveNBT();
entities.add(entity.namedTag);
}
}
ListTag<CompoundTag> entityListTag = new ListTag<>("Entities");
entityListTag.setAll(entities);
nbt.putList(entityListTag);
ArrayList<CompoundTag> tiles = new ArrayList<>();
for (BlockEntity blockEntity : this.getBlockEntities().values()) {
blockEntity.saveNBT();
tiles.add(blockEntity.namedTag);
}
ListTag<CompoundTag> tileListTag = new ListTag<>("TileEntities");
tileListTag.setAll(tiles);
nbt.putList(tileListTag);
BinaryStream extraData = new BinaryStream();
Map<Integer, Integer> extraDataArray = this.getBlockExtraDataArray();
extraData.putInt(extraDataArray.size());
for (Integer key : extraDataArray.keySet()) {
extraData.putInt(key);
extraData.putShort(extraDataArray.get(key));
}
nbt.putByteArray("ExtraData", extraData.getBuffer());
CompoundTag chunk = new CompoundTag("");
chunk.putCompound("Level", nbt);
try {
return Zlib.deflate(NBTIO.write(chunk, ByteOrder.BIG_ENDIAN), RegionLoader.COMPRESSION_LEVEL);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:57,代码来源:Chunk.java
示例10: toBinary
import cn.nukkit.utils.Zlib; //导入依赖的package包/类
@Override
public byte[] toBinary() {
CompoundTag nbt = this.getNBT().copy();
nbt.putInt("xPos", this.x);
nbt.putInt("zPos", this.z);
ListTag<CompoundTag> sectionList = new ListTag<>("Sections");
for (cn.nukkit.level.format.ChunkSection section : this.getSections()) {
if (section instanceof EmptyChunkSection) {
continue;
}
CompoundTag s = new CompoundTag(null);
s.putByte("Y", (section.getY()));
s.putByteArray("Blocks", section.getIdArray());
s.putByteArray("Data", section.getDataArray());
s.putByteArray("BlockLight", section.getLightArray());
s.putByteArray("SkyLight", section.getSkyLightArray());
sectionList.add(s);
}
nbt.putList(sectionList);
nbt.putIntArray("BiomeColors", this.getBiomeColorArray());
nbt.putIntArray("HeightMap", this.getHeightMapArray());
ArrayList<CompoundTag> entities = new ArrayList<>();
for (Entity entity : this.getEntities().values()) {
if (!(entity instanceof Player) && !entity.closed) {
entity.saveNBT();
entities.add(entity.namedTag);
}
}
ListTag<CompoundTag> entityListTag = new ListTag<>("Entities");
entityListTag.setAll(entities);
nbt.putList(entityListTag);
ArrayList<CompoundTag> tiles = new ArrayList<>();
for (BlockEntity blockEntity : this.getBlockEntities().values()) {
blockEntity.saveNBT();
tiles.add(blockEntity.namedTag);
}
ListTag<CompoundTag> tileListTag = new ListTag<>("TileEntities");
tileListTag.setAll(tiles);
nbt.putList(tileListTag);
BinaryStream extraData = new BinaryStream();
Map<Integer, Integer> extraDataArray = this.getBlockExtraDataArray();
extraData.putInt(extraDataArray.size());
for (Integer key : extraDataArray.keySet()) {
extraData.putInt(key);
extraData.putShort(extraDataArray.get(key));
}
nbt.putByteArray("ExtraData", extraData.getBuffer());
CompoundTag chunk = new CompoundTag("");
chunk.putCompound("Level", nbt);
try {
return Zlib.deflate(NBTIO.write(chunk, ByteOrder.BIG_ENDIAN), RegionLoader.COMPRESSION_LEVEL);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:65,代码来源:Chunk.java
注:本文中的cn.nukkit.utils.Zlib类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论