Skip to content

Commit

Permalink
Add NbtElement ID constants (FabricMC#2235)
Browse files Browse the repository at this point in the history
* Add NbtElement ID constants

* Javadoc fixes

* Javadoc fixes II

* ID -> TYPE_ID

* TYPE_ID -> TYPE

* Apply suggestions from code review

Co-authored-by: liach <[email protected]>

Co-authored-by: liach <[email protected]>
  • Loading branch information
Juuxel and liach authored Apr 3, 2021
1 parent d92659c commit 0462318
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 134 deletions.
2 changes: 1 addition & 1 deletion mappings/net/minecraft/nbt/AbstractNbtNumber.mapping
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CLASS net/minecraft/class_2514 net/minecraft/nbt/AbstractNbtNumber
COMMENT Represents an NBT number.
COMMENT <p>
COMMENT The type {@linkplain net.fabricmc.yarn.constants.NbtTypeIds#NUMBER NbtTypeIds.NUMBER} can be used to
COMMENT The type {@link NbtElement#NUMBER_TYPE NUMBER_TYPE} 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.
Expand Down
4 changes: 2 additions & 2 deletions mappings/net/minecraft/nbt/NbtCompound.mapping
Original file line number Diff line number Diff line change
Expand Up @@ -18,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 net.fabricmc.yarn.constants.NbtTypeIds#NULL NbtTypeIds.NULL} if it does not exist
COMMENT @return the element NBT type, or {@link NbtElement#NULL_TYPE NULL_TYPE} 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
Expand Down Expand Up @@ -96,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 <p>
COMMENT The type restriction can also be {@linkplain net.fabricmc.yarn.constants.NbtTypeIds#NUMBER NbtTypeIds.NUMBER}, which only allows any type of number.
COMMENT The type restriction can also be {@link NbtElement#NUMBER_TYPE NUMBER_TYPE}, 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
Expand Down
59 changes: 57 additions & 2 deletions mappings/net/minecraft/nbt/NbtElement.mapping
Original file line number Diff line number Diff line change
@@ -1,5 +1,62 @@
CLASS net/minecraft/class_2520 net/minecraft/nbt/NbtElement
COMMENT Represents an NBT element.
FIELD field_33250 NULL_TYPE B
COMMENT The numeric ID of an NBT null value. Is {@value}.
COMMENT
COMMENT @see NbtNull
FIELD field_33251 BYTE_TYPE B
COMMENT The numeric ID of an NBT byte value. Is {@value}.
COMMENT
COMMENT @see NbtByte
FIELD field_33252 SHORT_TYPE B
COMMENT The numeric ID of an NBT short value. Is {@value}.
COMMENT
COMMENT @see NbtShort
FIELD field_33253 INT_TYPE B
COMMENT The numeric ID of an NBT integer value. Is {@value}.
COMMENT
COMMENT @see NbtInt
FIELD field_33254 LONG_TYPE B
COMMENT The numeric ID of an NBT long value. Is {@value}.
COMMENT
COMMENT @see NbtLong
FIELD field_33255 FLOAT_TYPE B
COMMENT The numeric ID of an NBT float value. Is {@value}.
COMMENT
COMMENT @see NbtFloat
FIELD field_33256 DOUBLE_TYPE B
COMMENT The numeric ID of an NBT double value. Is {@value}.
COMMENT
COMMENT @see NbtDouble
FIELD field_33257 BYTE_ARRAY_TYPE B
COMMENT The numeric ID of an NBT byte array value. Is {@value}.
COMMENT
COMMENT @see NbtByteArray
FIELD field_33258 STRING_TYPE B
COMMENT The numeric ID of an NBT string value. Is {@value}.
COMMENT
COMMENT @see NbtString
FIELD field_33259 LIST_TYPE B
COMMENT The numeric ID of an NBT list value. Is {@value}.
COMMENT
COMMENT @see NbtList
FIELD field_33260 COMPOUND_TYPE B
COMMENT The numeric ID of an NBT compound value. Is {@value}.
COMMENT
COMMENT @see NbtCompound
FIELD field_33261 INT_ARRAY_TYPE B
COMMENT The numeric ID of an NBT integer array value. Is {@value}.
COMMENT
COMMENT @see NbtIntArray
FIELD field_33262 LONG_ARRAY_TYPE B
COMMENT The numeric ID of an NBT long array value. Is {@value}.
COMMENT
COMMENT @see NbtLongArray
FIELD field_33263 NUMBER_TYPE B
COMMENT A wildcard NBT numeric ID that can be used for <i>checking</i> whether an NBT element is an {@link AbstractNbtNumber}. Is {@value}.
COMMENT
COMMENT @see NbtCompound#getType(String)
COMMENT @see NbtCompound#contains(String, int)
METHOD method_10707 copy ()Lnet/minecraft/class_2520;
COMMENT Copies this NBT element.
COMMENT
Expand All @@ -8,8 +65,6 @@ 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;
Expand Down
2 changes: 1 addition & 1 deletion mappings/net/minecraft/nbt/NbtList.mapping
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CLASS net/minecraft/class_2499 net/minecraft/nbt/NbtList
COMMENT <p>
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 {@linkplain net.fabricmc.yarn.constants.NbtTypeIds#NULL NbtTypeIds.NULL} as their held {@linkplain AbstractNbtList#getHeldType NBT type}.
COMMENT once its first element is inserted; empty NBT lists return {@link NbtElement#NULL_TYPE NULL_TYPE} 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;
Expand Down
114 changes: 0 additions & 114 deletions src/constants/java/net/fabricmc/yarn/constants/NbtTypeIds.java

This file was deleted.

28 changes: 14 additions & 14 deletions unpick-definitions/nbt_type_ids.unpick
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
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
constant nbt_type_ids net/minecraft/nbt/NbtElement NULL_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement BYTE_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement SHORT_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement INT_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement LONG_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement FLOAT_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement DOUBLE_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement BYTE_ARRAY_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement STRING_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement LIST_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement COMPOUND_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement INT_ARRAY_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement LONG_ARRAY_TYPE
constant nbt_type_ids net/minecraft/nbt/NbtElement NUMBER_TYPE

target_method net/minecraft/nbt/NbtElement getType ()B
return nbt_type_ids
Expand Down

0 comments on commit 0462318

Please sign in to comment.