Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legacy NBT read fix #43

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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