mirror of https://github.com/Minestom/Minestom.git
fix: write metadata optvarint as varint + 1 || 0
This commit is contained in:
parent
e28adbca3e
commit
f76d421744
|
@ -101,7 +101,17 @@ public final class Metadata {
|
|||
}
|
||||
|
||||
public static Entry<Integer> OptVarInt(@Nullable Integer value) {
|
||||
return new MetadataImpl.EntryImpl<>(TYPE_OPTVARINT, value, NetworkBuffer.OPT_VAR_INT);
|
||||
return new MetadataImpl.EntryImpl<>(TYPE_OPTVARINT, value, new NetworkBuffer.Type<>() {
|
||||
@Override
|
||||
public void write(@NotNull NetworkBuffer buffer, Integer value) {
|
||||
buffer.write(NetworkBuffer.VAR_INT, value == null ? 0 : value + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer read(@NotNull NetworkBuffer buffer) {
|
||||
return buffer.read(NetworkBuffer.VAR_INT) - 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Entry<Entity.Pose> Pose(@NotNull Entity.Pose value) {
|
||||
|
|
|
@ -65,7 +65,6 @@ public final class NetworkBuffer {
|
|||
public static final Type<Point> OPT_BLOCK_POSITION = NetworkBufferTypeImpl.fromOptional(BLOCK_POSITION);
|
||||
public static final Type<UUID> OPT_UUID = NetworkBufferTypeImpl.fromOptional(UUID);
|
||||
public static final Type<Integer> OPT_BLOCK_STATE = NetworkBufferTypeImpl.fromOptional(BLOCK_STATE);
|
||||
public static final Type<Integer> OPT_VAR_INT = NetworkBufferTypeImpl.fromOptional(VAR_INT);
|
||||
|
||||
public static final Type<Direction> DIRECTION = NetworkBufferTypeImpl.fromEnum(Direction.class);
|
||||
public static final Type<Entity.Pose> POSE = NetworkBufferTypeImpl.fromEnum(Entity.Pose.class);
|
||||
|
|
Loading…
Reference in New Issue