Add NbtElement ID constants (#2235)

* Add NbtElement ID constants

* Javadoc fixes

* Javadoc fixes II

* ID -> TYPE_ID

* TYPE_ID -> TYPE

* Apply suggestions from code review

Co-authored-by: liach <7806504+liach@users.noreply.github.com>

Co-authored-by: liach <7806504+liach@users.noreply.github.com>
This commit is contained in:
Juuxel 2021-04-03 15:30:54 +03:00 committed by GitHub
parent d92659cd00
commit 04623185ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 75 additions and 134 deletions

View File

@ -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.

View File

@ -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
@ -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

View File

@ -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
@ -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;

View File

@ -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;

View File

@ -1,114 +0,0 @@
/*
* 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 <i>testing</i> 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() {
}
}

View File

@ -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