diff --git a/mappings/net/minecraft/nbt/AbstractNbtNumber.mapping b/mappings/net/minecraft/nbt/AbstractNbtNumber.mapping index 87a475c0ec..9c9b3131bb 100644 --- a/mappings/net/minecraft/nbt/AbstractNbtNumber.mapping +++ b/mappings/net/minecraft/nbt/AbstractNbtNumber.mapping @@ -1,7 +1,7 @@ CLASS net/minecraft/class_2514 net/minecraft/nbt/AbstractNbtNumber COMMENT Represents an NBT number. COMMENT
- COMMENT The type value {@code 99} can be used to + COMMENT The type {@linkplain net.fabricmc.yarn.constants.NbtTypeIds#NUMBER NbtTypeIds.NUMBER} can be used to COMMENT {@linkplain NbtCompound#contains check for the existence of any numeric element in a NBT compound object}. METHOD method_10696 shortValue ()S COMMENT Gets the value as a 16-bit integer. diff --git a/mappings/net/minecraft/nbt/NbtByte.mapping b/mappings/net/minecraft/nbt/NbtByte.mapping index ddd1031fda..5fcbe07db7 100644 --- a/mappings/net/minecraft/nbt/NbtByte.mapping +++ b/mappings/net/minecraft/nbt/NbtByte.mapping @@ -1,7 +1,5 @@ CLASS net/minecraft/class_2481 net/minecraft/nbt/NbtByte COMMENT Represents an NBT byte. - COMMENT
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 1}. FIELD field_11498 value B FIELD field_21025 TYPE Lnet/minecraft/class_4614; FIELD field_21026 ZERO Lnet/minecraft/class_2481; diff --git a/mappings/net/minecraft/nbt/NbtByteArray.mapping b/mappings/net/minecraft/nbt/NbtByteArray.mapping index 20b38f12f0..b0f0f05050 100644 --- a/mappings/net/minecraft/nbt/NbtByteArray.mapping +++ b/mappings/net/minecraft/nbt/NbtByteArray.mapping @@ -1,7 +1,5 @@ CLASS net/minecraft/class_2479 net/minecraft/nbt/NbtByteArray COMMENT Represents an NBT byte array. - COMMENT
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 7}.
FIELD field_11493 value [B
FIELD field_21024 TYPE Lnet/minecraft/class_4614;
METHOD
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 10}.
FIELD field_11515 entries Ljava/util/Map;
FIELD field_21029 TYPE Lnet/minecraft/class_4614;
FIELD field_25128 CODEC Lcom/mojang/serialization/Codec;
@@ -20,7 +18,7 @@ CLASS net/minecraft/class_2487 net/minecraft/nbt/NbtCompound
METHOD method_10540 getType (Ljava/lang/String;)B
COMMENT Gets the {@linkplain NbtElement#getType NBT type} of the element stored at the specified key.
COMMENT
- COMMENT @return the element NBT type, or {@linkplain NbtNull 0} if it does not exist
+ COMMENT @return the element NBT type, or {@linkplain net.fabricmc.yarn.constants.NbtTypeIds#NULL NbtTypeIds.NULL} if it does not exist
ARG 1 key
METHOD method_10541 getKeys ()Ljava/util/Set;
METHOD method_10542 readByte (Ljava/io/DataInput;Lnet/minecraft/class_2505;)B
@@ -98,7 +96,7 @@ CLASS net/minecraft/class_2487 net/minecraft/nbt/NbtCompound
METHOD method_10573 contains (Ljava/lang/String;I)Z
COMMENT Returns whether the NBT compound object contains an element of the specified type at the specified key.
COMMENT
- COMMENT The type restriction can also be {@code 99}, which only allows any type of number.
+ COMMENT The type restriction can also be {@linkplain net.fabricmc.yarn.constants.NbtTypeIds#NUMBER NbtTypeIds.NUMBER}, which only allows any type of number.
COMMENT
COMMENT @return {@code true} if the key exists and the element type is equivalent to the given {@code type}, else {@code false}
ARG 1 key
diff --git a/mappings/net/minecraft/nbt/NbtDouble.mapping b/mappings/net/minecraft/nbt/NbtDouble.mapping
index 4cb4890e14..2bd78af501 100644
--- a/mappings/net/minecraft/nbt/NbtDouble.mapping
+++ b/mappings/net/minecraft/nbt/NbtDouble.mapping
@@ -1,7 +1,5 @@
CLASS net/minecraft/class_2489 net/minecraft/nbt/NbtDouble
COMMENT Represents an NBT 64-bit floating-point number.
- COMMENT
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 6}.
FIELD field_11520 value D
FIELD field_21030 ZERO Lnet/minecraft/class_2489;
FIELD field_21031 TYPE Lnet/minecraft/class_4614;
diff --git a/mappings/net/minecraft/nbt/NbtElement.mapping b/mappings/net/minecraft/nbt/NbtElement.mapping
index f427805c7c..453e57c2a8 100644
--- a/mappings/net/minecraft/nbt/NbtElement.mapping
+++ b/mappings/net/minecraft/nbt/NbtElement.mapping
@@ -1,22 +1,5 @@
CLASS net/minecraft/class_2520 net/minecraft/nbt/NbtElement
COMMENT Represents an NBT element.
- COMMENT
- COMMENT Each type of NBT element has an associated integer {@linkplain NbtElement#getType NBT type}. The following is a list of possible types:
- COMMENT
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 5}.
FIELD field_11523 value F
FIELD field_21034 ZERO Lnet/minecraft/class_2494;
FIELD field_21035 TYPE Lnet/minecraft/class_4614;
diff --git a/mappings/net/minecraft/nbt/NbtInt.mapping b/mappings/net/minecraft/nbt/NbtInt.mapping
index ae72bc6947..07a2949eb3 100644
--- a/mappings/net/minecraft/nbt/NbtInt.mapping
+++ b/mappings/net/minecraft/nbt/NbtInt.mapping
@@ -1,7 +1,5 @@
CLASS net/minecraft/class_2497 net/minecraft/nbt/NbtInt
COMMENT Represents an NBT 32-bit integer.
- COMMENT
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 3}.
FIELD field_11525 value I
FIELD field_21037 TYPE Lnet/minecraft/class_4614;
METHOD
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 11}.
FIELD field_11524 value [I
FIELD field_21036 TYPE Lnet/minecraft/class_4614;
METHOD
COMMENT An NBT list holds values of the same {@linkplain NbtElement#getType NBT type}.
COMMENT The {@linkplain AbstractNbtList#getHeldType NBT type} of an NBT list is determined
- COMMENT once its first element is inserted; empty NBT lists return {@code 0} as their held {@linkplain AbstractNbtList#getHeldType NBT type}.
- COMMENT
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 9}.
+ COMMENT once its first element is inserted; empty NBT lists return {@linkplain net.fabricmc.yarn.constants.NbtTypeIds#NULL NbtTypeIds.NULL} as their held {@linkplain AbstractNbtList#getHeldType NBT type}.
FIELD field_11550 value Ljava/util/List;
FIELD field_11551 type B
FIELD field_21039 TYPE Lnet/minecraft/class_4614;
diff --git a/mappings/net/minecraft/nbt/NbtLong.mapping b/mappings/net/minecraft/nbt/NbtLong.mapping
index c1ad64c76d..4ed4ce4205 100644
--- a/mappings/net/minecraft/nbt/NbtLong.mapping
+++ b/mappings/net/minecraft/nbt/NbtLong.mapping
@@ -1,7 +1,5 @@
CLASS net/minecraft/class_2503 net/minecraft/nbt/NbtLong
COMMENT Represents an NBT 64-bit integer.
- COMMENT
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 4}.
FIELD field_11553 value J
FIELD field_21041 TYPE Lnet/minecraft/class_4614;
METHOD
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 12}.
FIELD field_11552 value [J
FIELD field_21040 TYPE Lnet/minecraft/class_4614;
METHOD
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 0}.
FIELD field_21032 TYPE Lnet/minecraft/class_4614;
FIELD field_21033 INSTANCE Lnet/minecraft/class_2491;
diff --git a/mappings/net/minecraft/nbt/NbtShort.mapping b/mappings/net/minecraft/nbt/NbtShort.mapping
index 9552a31170..61a2979ef2 100644
--- a/mappings/net/minecraft/nbt/NbtShort.mapping
+++ b/mappings/net/minecraft/nbt/NbtShort.mapping
@@ -1,7 +1,5 @@
CLASS net/minecraft/class_2516 net/minecraft/nbt/NbtShort
COMMENT Represents an NBT 16-bit integer.
- COMMENT
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 2}.
FIELD field_11588 value S
FIELD field_21043 TYPE Lnet/minecraft/class_4614;
METHOD
- COMMENT This class uses the {@linkplain NbtElement#getType NBT type} {@code 8}.
FIELD field_11590 value Ljava/lang/String;
FIELD field_21045 TYPE Lnet/minecraft/class_4614;
FIELD field_21046 EMPTY Lnet/minecraft/class_2519;
diff --git a/src/constants/java/net/fabricmc/yarn/constants/NbtTypeIds.java b/src/constants/java/net/fabricmc/yarn/constants/NbtTypeIds.java
new file mode 100644
index 0000000000..cbd10f34d2
--- /dev/null
+++ b/src/constants/java/net/fabricmc/yarn/constants/NbtTypeIds.java
@@ -0,0 +1,114 @@
+/*
+ * This file is free for everyone to use under the Creative Commons Zero license.
+ */
+
+package net.fabricmc.yarn.constants;
+
+/**
+ * Constants representing the type of an {@linkplain net.minecraft.nbt.NbtElement NbtElement}.
+ *
+ * @see net.minecraft.nbt.NbtElement#getType()
+ */
+public final class NbtTypeIds {
+ /**
+ * An NBT null value.
+ *
+ * @see net.minecraft.nbt.NbtNull
+ */
+ public static final int NULL = 0;
+
+ /**
+ * An NBT byte value.
+ *
+ * @see net.minecraft.nbt.NbtByte
+ */
+ public static final int BYTE = 1;
+
+ /**
+ * An NBT short value.
+ *
+ * @see net.minecraft.nbt.NbtShort
+ */
+ public static final int SHORT = 2;
+
+ /**
+ * An NBT integer value.
+ *
+ * @see net.minecraft.nbt.NbtInt
+ */
+ public static final int INT = 3;
+
+ /**
+ * An NBT long value.
+ *
+ * @see net.minecraft.nbt.NbtLong
+ */
+ public static final int LONG = 4;
+
+ /**
+ * An NBT float value.
+ *
+ * @see net.minecraft.nbt.NbtFloat
+ */
+ public static final int FLOAT = 5;
+
+ /**
+ * An NBT double value.
+ *
+ * @see net.minecraft.nbt.NbtDouble
+ */
+ public static final int DOUBLE = 6;
+
+ /**
+ * An NBT byte array value.
+ *
+ * @see net.minecraft.nbt.NbtByteArray
+ */
+ public static final int BYTE_ARRAY = 7;
+
+ /**
+ * An NBT string value.
+ *
+ * @see net.minecraft.nbt.NbtString
+ */
+ public static final int STRING = 8;
+
+ /**
+ * An NBT list value.
+ *
+ * @see net.minecraft.nbt.NbtList
+ */
+ public static final int LIST = 9;
+
+ /**
+ * An NBT compound value.
+ *
+ * @see net.minecraft.nbt.NbtCompound
+ */
+ public static final int COMPOUND = 10;
+
+ /**
+ * An NBT integer array value.
+ *
+ * @see net.minecraft.nbt.NbtIntArray
+ */
+ public static final int INT_ARRAY = 11;
+
+ /**
+ * An NBT long array value.
+ *
+ * @see net.minecraft.nbt.NbtLongArray
+ */
+ public static final int LONG_ARRAY = 12;
+
+ /**
+ * A wildcard value that can be used for testing whether an {@linkplain net.minecraft.nbt.NbtElement NbtElement} is an {@linkplain net.minecraft.nbt.AbstractNbtNumber AbstractNbtNumber}.
+ *
+ * @see net.minecraft.nbt.NbtCompound#getType(String)
+ * @see net.minecraft.nbt.NbtCompound#contains(String, int)
+ */
+ public static final int NUMBER = 99;
+
+ private NbtTypeIds() {
+ }
+}
diff --git a/unpick-definitions/nbt_type_ids.unpick b/unpick-definitions/nbt_type_ids.unpick
new file mode 100644
index 0000000000..a9e2bde8bd
--- /dev/null
+++ b/unpick-definitions/nbt_type_ids.unpick
@@ -0,0 +1,38 @@
+v2
+
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds NULL
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds BYTE
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds SHORT
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds INT
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds LONG
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds FLOAT
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds DOUBLE
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds BYTE_ARRAY
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds STRING
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds LIST
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds COMPOUND
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds INT_ARRAY
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds LONG_ARRAY
+constant nbt_type_ids net/fabricmc/yarn/constants/NbtTypeIds NUMBER
+
+target_method net/minecraft/nbt/NbtElement getType ()B
+ return nbt_type_ids
+target_method net/minecraft/nbt/NbtOps method_29144 (BB)Lnet/minecraft/nbt/AbstractNbtList;
+ param 0 nbt_type_ids
+ param 1 nbt_type_ids
+target_method net/minecraft/nbt/NbtOps method_29145 (BBB)Z
+ param 0 nbt_type_ids
+ param 1 nbt_type_ids
+ param 2 nbt_type_ids
+target_method net/minecraft/nbt/NbtCompound getType (Ljava/lang/String;)B
+ return nbt_type_ids
+target_method net/minecraft/nbt/NbtCompound contains (Ljava/lang/String;I)Z
+ param 1 nbt_type_ids
+target_method net/minecraft/nbt/NbtCompound getList (Ljava/lang/String;I)Lnet/minecraft/nbt/NbtList;
+ param 1 nbt_type_ids
+target_method net/minecraft/nbt/AbstractNbtList getHeldType ()B
+ return nbt_type_ids
+target_method net/minecraft/nbt/NbtList
- COMMENT
METHOD method_10707 copy ()Lnet/minecraft/class_2520;
COMMENT Copies this NBT element.
COMMENT
@@ -25,6 +8,8 @@ CLASS net/minecraft/class_2520 net/minecraft/nbt/NbtElement
COMMENT Gets the type of this NBT element.
COMMENT
COMMENT @return the type
+ COMMENT
+ COMMENT @see net.fabricmc.yarn.constants.NbtTypeIds a list of valid types
METHOD method_10713 write (Ljava/io/DataOutput;)V
ARG 1 output
METHOD method_10714 asString ()Ljava/lang/String;
diff --git a/mappings/net/minecraft/nbt/NbtFloat.mapping b/mappings/net/minecraft/nbt/NbtFloat.mapping
index 4f37192aba..a67f3d4048 100644
--- a/mappings/net/minecraft/nbt/NbtFloat.mapping
+++ b/mappings/net/minecraft/nbt/NbtFloat.mapping
@@ -1,7 +1,5 @@
CLASS net/minecraft/class_2494 net/minecraft/nbt/NbtFloat
COMMENT Represents an NBT 32-bit floating-point number.
- COMMENT