mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-01 21:11:33 +01:00
Added all missing metadata (except Particle)
This commit is contained in:
parent
cb41b2e3d7
commit
c6cafb19a4
@ -10,6 +10,7 @@ import net.minestom.server.utils.binary.BinaryWriter;
|
|||||||
import net.minestom.server.utils.binary.Writeable;
|
import net.minestom.server.utils.binary.Writeable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jglrxavpok.hephaistos.nbt.NBT;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -43,9 +44,12 @@ public class Metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Value<JsonMessage> OptChat(@Nullable JsonMessage value) {
|
public static Value<JsonMessage> OptChat(@Nullable JsonMessage value) {
|
||||||
return new OptionalValue<>(TYPE_OPTCHAT, value, writer -> {
|
return new Value<>(TYPE_OPTCHAT, value, writer -> {
|
||||||
assert value != null;
|
final boolean present = value != null;
|
||||||
|
writer.writeBoolean(present);
|
||||||
|
if (present) {
|
||||||
writer.writeSizedString(value.toString());
|
writer.writeSizedString(value.toString());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,9 +74,12 @@ public class Metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Value<BlockPosition> OptPosition(@Nullable BlockPosition value) {
|
public static Value<BlockPosition> OptPosition(@Nullable BlockPosition value) {
|
||||||
return new OptionalValue<>(TYPE_OPTPOSITION, value, writer -> {
|
return new Value<>(TYPE_OPTPOSITION, value, writer -> {
|
||||||
assert value != null;
|
final boolean present = value != null;
|
||||||
|
writer.writeBoolean(present);
|
||||||
|
if (present) {
|
||||||
writer.writeBlockPosition(value);
|
writer.writeBlockPosition(value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,9 +88,25 @@ public class Metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Value<UUID> OptUUID(@Nullable UUID value) {
|
public static Value<UUID> OptUUID(@Nullable UUID value) {
|
||||||
return new OptionalValue<>(TYPE_OPTUUID, value, writer -> {
|
return new Value<>(TYPE_OPTUUID, value, writer -> {
|
||||||
assert value != null;
|
final boolean present = value != null;
|
||||||
|
writer.writeBoolean(present);
|
||||||
|
if (present) {
|
||||||
writer.writeUuid(value);
|
writer.writeUuid(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Value<Integer> OptBlockID(@Nullable Integer value) {
|
||||||
|
return new Value<>(TYPE_OPTBLOCKID, value, writer -> {
|
||||||
|
final boolean present = value != null;
|
||||||
|
writer.writeVarInt(present ? value : 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Value<NBT> NBT(@NotNull NBT nbt) {
|
||||||
|
return new Value<>(TYPE_NBT, nbt, writer -> {
|
||||||
|
writer.writeNBT("", nbt);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +120,13 @@ public class Metadata {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Value<Integer> OptVarInt(@Nullable Integer value) {
|
||||||
|
return new Value<>(TYPE_OPTVARINT, value, writer -> {
|
||||||
|
final boolean present = value != null;
|
||||||
|
writer.writeVarInt(present ? value + 1 : 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static Value<Entity.Pose> Pose(@NotNull Entity.Pose value) {
|
public static Value<Entity.Pose> Pose(@NotNull Entity.Pose value) {
|
||||||
return new Value<>(TYPE_POSE, value, writer -> writer.writeVarInt(value.ordinal()));
|
return new Value<>(TYPE_POSE, value, writer -> writer.writeVarInt(value.ordinal()));
|
||||||
}
|
}
|
||||||
@ -206,7 +236,7 @@ public class Metadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class OptionalValue<T> extends Value<T> {
|
/*private static class OptionalValue<T> extends Value<T> {
|
||||||
private OptionalValue(int type, T value, @NotNull Consumer<BinaryWriter> valueWriter) {
|
private OptionalValue(int type, T value, @NotNull Consumer<BinaryWriter> valueWriter) {
|
||||||
super(type, value, valueWriter);
|
super(type, value, valueWriter);
|
||||||
}
|
}
|
||||||
@ -221,6 +251,6 @@ public class Metadata {
|
|||||||
this.valueWriter.accept(writer);
|
this.valueWriter.accept(writer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user