fix: add missing default metadata values

This commit is contained in:
mworzala 2024-01-28 18:12:09 -05:00
parent cf4a2d134e
commit 6b3f670cfb
No known key found for this signature in database
GPG Key ID: B148F922E64797C7
2 changed files with 15 additions and 4 deletions

View File

@ -155,6 +155,8 @@ public final class Metadata {
public static final byte TYPE_VECTOR3 = 26; public static final byte TYPE_VECTOR3 = 26;
public static final byte TYPE_QUATERNION = 27; public static final byte TYPE_QUATERNION = 27;
// Impl Note: Adding an entry here requires that a default value entry is added in MetadataImpl.EMPTY_VALUES
private static final VarHandle NOTIFIED_CHANGES; private static final VarHandle NOTIFIED_CHANGES;
static { static {

View File

@ -2,6 +2,10 @@ package net.minestom.server.entity;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.minestom.server.coordinate.Vec; import net.minestom.server.coordinate.Vec;
import net.minestom.server.entity.metadata.animal.FrogMeta;
import net.minestom.server.entity.metadata.animal.SnifferMeta;
import net.minestom.server.entity.metadata.animal.tameable.CatMeta;
import net.minestom.server.instance.block.Block;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.network.NetworkBuffer; import net.minestom.server.network.NetworkBuffer;
import net.minestom.server.utils.Direction; import net.minestom.server.utils.Direction;
@ -10,10 +14,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.UnknownNullability; import org.jetbrains.annotations.UnknownNullability;
import org.jglrxavpok.hephaistos.nbt.NBTEnd; import org.jglrxavpok.hephaistos.nbt.NBTEnd;
import static net.minestom.server.entity.Metadata.Boolean;
import static net.minestom.server.entity.Metadata.Byte;
import static net.minestom.server.entity.Metadata.Float;
import static net.minestom.server.entity.Metadata.String;
import static net.minestom.server.entity.Metadata.*; import static net.minestom.server.entity.Metadata.*;
import static net.minestom.server.network.NetworkBuffer.VAR_INT; import static net.minestom.server.network.NetworkBuffer.VAR_INT;
@ -23,6 +23,7 @@ final class MetadataImpl {
static { static {
EMPTY_VALUES.set(TYPE_BYTE, Byte((byte) 0)); EMPTY_VALUES.set(TYPE_BYTE, Byte((byte) 0));
EMPTY_VALUES.set(TYPE_VARINT, VarInt(0)); EMPTY_VALUES.set(TYPE_VARINT, VarInt(0));
EMPTY_VALUES.set(TYPE_LONG, Long(0L));
EMPTY_VALUES.set(TYPE_FLOAT, Float(0f)); EMPTY_VALUES.set(TYPE_FLOAT, Float(0f));
EMPTY_VALUES.set(TYPE_STRING, String("")); EMPTY_VALUES.set(TYPE_STRING, String(""));
EMPTY_VALUES.set(TYPE_CHAT, Chat(Component.empty())); EMPTY_VALUES.set(TYPE_CHAT, Chat(Component.empty()));
@ -34,12 +35,20 @@ final class MetadataImpl {
EMPTY_VALUES.set(TYPE_OPTPOSITION, OptPosition(null)); EMPTY_VALUES.set(TYPE_OPTPOSITION, OptPosition(null));
EMPTY_VALUES.set(TYPE_DIRECTION, Direction(Direction.DOWN)); EMPTY_VALUES.set(TYPE_DIRECTION, Direction(Direction.DOWN));
EMPTY_VALUES.set(TYPE_OPTUUID, OptUUID(null)); EMPTY_VALUES.set(TYPE_OPTUUID, OptUUID(null));
EMPTY_VALUES.set(TYPE_BLOCKSTATE, BlockState(Block.AIR.id()));
EMPTY_VALUES.set(TYPE_OPTBLOCKSTATE, OptBlockState(null)); EMPTY_VALUES.set(TYPE_OPTBLOCKSTATE, OptBlockState(null));
EMPTY_VALUES.set(TYPE_NBT, NBT(NBTEnd.INSTANCE)); EMPTY_VALUES.set(TYPE_NBT, NBT(NBTEnd.INSTANCE));
//EMPTY_VALUES.set(TYPE_PARTICLE -> throw new UnsupportedOperationException(); //EMPTY_VALUES.set(TYPE_PARTICLE -> throw new UnsupportedOperationException();
EMPTY_VALUES.set(TYPE_VILLAGERDATA, VillagerData(0, 0, 0)); EMPTY_VALUES.set(TYPE_VILLAGERDATA, VillagerData(0, 0, 0));
EMPTY_VALUES.set(TYPE_OPTVARINT, OptVarInt(null)); EMPTY_VALUES.set(TYPE_OPTVARINT, OptVarInt(null));
EMPTY_VALUES.set(TYPE_POSE, Pose(Entity.Pose.STANDING)); EMPTY_VALUES.set(TYPE_POSE, Pose(Entity.Pose.STANDING));
EMPTY_VALUES.set(TYPE_CAT_VARIANT, CatVariant(CatMeta.Variant.TABBY));
EMPTY_VALUES.set(TYPE_FROG_VARIANT, FrogVariant(FrogMeta.Variant.TEMPERATE));
// OptGlobalPos
// PaintingVariant
EMPTY_VALUES.set(TYPE_SNIFFER_STATE, SnifferState(SnifferMeta.State.IDLING));
EMPTY_VALUES.set(TYPE_VECTOR3, Vector3(Vec.ZERO));
EMPTY_VALUES.set(TYPE_QUATERNION, Quaternion(new float[]{0, 0, 0, 0}));
EMPTY_VALUES.trim(); EMPTY_VALUES.trim();
} }