Skip to content

Commit

Permalink
fix: support legacy nbt read via adventure
Browse files Browse the repository at this point in the history
  • Loading branch information
mworzala committed Apr 29, 2024
1 parent 8cddebb commit f13e6fc
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/main/java/net/hollowcube/polar/PolarReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
import net.minestom.server.network.NetworkBuffer;
import net.minestom.server.utils.NamespaceID;
import net.minestom.server.utils.chunk.ChunkUtils;
import net.minestom.server.utils.nbt.BinaryTagReader;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import java.io.DataInputStream;
import java.io.InputStream;
import java.nio.ByteBuffer;

import static net.minestom.server.network.NetworkBuffer.*;
Expand Down Expand Up @@ -206,23 +209,20 @@ private static void validateVersion(int version) {
* @see NetworkBuffer#NBT
*/
private static BinaryTag legacyReadNBT(@NotNull NetworkBuffer buffer) {
// try {
// var nbtReader = new NBTReader(new InputStream() {
// @Override
// public int read() {
// return buffer.read(BYTE) & 0xFF;
// }
// @Override
// public int available() {
// return buffer.readableBytes();
// }
// }, CompressedProcesser.NONE);
//
// return nbtReader.read();
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
throw new UnsupportedOperationException("todo");
try {
var nbtReader = new BinaryTagReader(new DataInputStream(new InputStream() {
public int read() {
return buffer.read(NetworkBuffer.BYTE) & 255;
}

public int available() {
return buffer.readableBytes();
}
}));
return nbtReader.readNamed().getValue();
} catch (Exception e) {
throw new RuntimeException(e);
}
}

@Contract("false, _ -> fail")
Expand Down

0 comments on commit f13e6fc

Please sign in to comment.