Java Code Examples for cn.nukkit.nbt.NBTIO#read()
The following examples show how to use
cn.nukkit.nbt.NBTIO#read() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Item.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public static CompoundTag parseCompoundTag(byte[] tag) { try { return NBTIO.read(tag, ByteOrder.LITTLE_ENDIAN); } catch (IOException e) { throw new RuntimeException(e); } }
Example 2
Source File: Chunk.java From Jupiter with GNU General Public License v3.0 | 5 votes |
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; } }
Example 3
Source File: Chunk.java From Jupiter with GNU General Public License v3.0 | 5 votes |
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; } }
Example 4
Source File: Chunk.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public static Chunk fromFastBinary(byte[] data, LevelProvider provider) { try { CompoundTag chunk = NBTIO.read(new DataInputStream(new ByteArrayInputStream(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) { return null; } }
Example 5
Source File: Item.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public static CompoundTag parseCompoundTag(byte[] tag) { try { return NBTIO.read(tag, ByteOrder.LITTLE_ENDIAN); } catch (IOException e) { throw new RuntimeException(e); } }
Example 6
Source File: Chunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
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; } }
Example 7
Source File: Chunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
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; } }
Example 8
Source File: Chunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public static Chunk fromFastBinary(byte[] data, LevelProvider provider) { try { CompoundTag chunk = NBTIO.read(new DataInputStream(new ByteArrayInputStream(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) { return null; } }
Example 9
Source File: Item.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public static CompoundTag parseCompoundTag(byte[] tag) { try { return NBTIO.read(tag, ByteOrder.LITTLE_ENDIAN); } catch (IOException e) { throw new RuntimeException(e); } }
Example 10
Source File: Chunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
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; } }
Example 11
Source File: Chunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
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; } }
Example 12
Source File: Chunk.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public static Chunk fromFastBinary(byte[] data, LevelProvider provider) { try { CompoundTag chunk = NBTIO.read(new DataInputStream(new ByteArrayInputStream(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) { return null; } }
Example 13
Source File: Binary.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public static EntityMetadata readMetadata(byte[] payload) { BinaryStream stream = new BinaryStream(); stream.setBuffer(payload); long count = stream.getUnsignedVarInt(); EntityMetadata m = new EntityMetadata(); for (int i = 0; i < count; i++) { int key = (int) stream.getUnsignedVarInt(); int type = (int) stream.getUnsignedVarInt(); EntityData value = null; switch (type) { case Entity.DATA_TYPE_BYTE: value = new ByteEntityData(key, stream.getByte()); break; case Entity.DATA_TYPE_SHORT: value = new ShortEntityData(key, stream.getLShort()); break; case Entity.DATA_TYPE_INT: value = new IntEntityData(key, stream.getVarInt()); break; case Entity.DATA_TYPE_FLOAT: value = new FloatEntityData(key, stream.getLFloat()); break; case Entity.DATA_TYPE_STRING: value = new StringEntityData(key, stream.getString()); break; case Entity.DATA_TYPE_NBT: int offset = stream.getOffset(); FastByteArrayInputStream fbais = new FastByteArrayInputStream(stream.get()); try { CompoundTag tag = NBTIO.read(fbais, ByteOrder.LITTLE_ENDIAN, true); value = new NBTEntityData(key, tag); } catch (IOException e) { throw new RuntimeException(e); } stream.setOffset(offset + (int) fbais.position()); break; case Entity.DATA_TYPE_POS: BlockVector3 v3 = stream.getSignedBlockPosition(); value = new IntPositionEntityData(key, v3.x, v3.y, v3.z); break; case Entity.DATA_TYPE_LONG: value = new LongEntityData(key, stream.getVarLong()); break; case Entity.DATA_TYPE_VECTOR3F: value = new Vector3fEntityData(key, stream.getVector3f()); break; } if (value != null) m.put(value); } return m; }