public Tag<?> readTag() throws IOException { return readTag(0); }
public static AnvilLevelDataProvider load(@NonNull Path levelDatPath) throws IOException { // level.dat is Notchian, so it's big-endian and GZIP compressed CompoundTag tag; try (NBTReader reader = NBTReaders.createBigEndianReader(new GZIPInputStream(Files.newInputStream(levelDatPath)))) { tag = (CompoundTag) reader.readTag(); } CompoundTag dataTag = (CompoundTag) tag.getValue().get("Data"); Map<String, Tag<?>> map = dataTag.getValue(); Vector3i out = new Vector3i(((IntTag) map.get("SpawnX")).getPrimitiveValue(), ((IntTag) map.get("SpawnY")).getPrimitiveValue(), ((IntTag) map.get("SpawnZ")).getPrimitiveValue()); long dayTime = ((LongTag) map.get("DayTime")).getPrimitiveValue(); long seed = ((LongTag) map.get("RandomSeed")).getPrimitiveValue(); return new AnvilLevelDataProvider(out.toFloat(), (int) dayTime, seed); }
Map<String, Tag<?>> map = new HashMap<>(); Tag<?> inTag1; while ((inTag1 = readTag(depth + 1)) != EndTag.INSTANCE) { map.put(inTag1.getName(), inTag1);
Tag<?> tag; try (NBTReader stream = NBTReaders.createBigEndianReader(regionReader.readChunk(irXZ.x, irXZ.z))) { tag = stream.readTag();
public static ItemStack readItemStack(ByteBuf buf) { int id = Varints.decodeSigned(buf); if (id == 0) { return new VoxelwindItemStack(BlockTypes.AIR, 1, null); } int aux = Varints.decodeSigned(buf); int damage = aux >> 8; int count = aux & 0xff; short nbtSize = buf.readShortLE(); ItemType type = ItemTypes.forId(id); ItemStackBuilder builder = new VoxelwindItemStackBuilder() .itemType(type) .itemData(MetadataSerializer.deserializeMetadata(type, (short) damage)) .amount(count); if (nbtSize > 0) { try (NBTReader reader = new NBTReader(new LittleEndianByteBufInputStream(buf.readSlice(nbtSize)))) { Tag<?> tag = reader.readTag(); if (tag instanceof CompoundTag) { VoxelwindNBTUtils.applyItemData(builder, ((CompoundTag) tag).getValue()); } } catch (IOException e) { throw new IllegalStateException("Unable to load NBT data", e); } } return builder.build(); }