Document net.minecraft.util (#3297)

* Document net.minecraft.util

* Fix javadoc

* Apply suggestions from code review

Co-authored-by: Juuz <6596629+Juuxel@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: enbrain <69905075+enbrain@users.noreply.github.com>

* Fix Util#next and Util#previous docs

* revert previous change to previous

* Apply suggestions from code review

Co-authored-by: enbrain <69905075+enbrain@users.noreply.github.com>

Co-authored-by: Juuz <6596629+Juuxel@users.noreply.github.com>
Co-authored-by: enbrain <69905075+enbrain@users.noreply.github.com>
This commit is contained in:
apple502j 2022-09-22 02:30:05 +09:00 committed by GitHub
parent a7bf49e655
commit 51d6fad08d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 386 additions and 16 deletions

View File

@ -1,4 +1,8 @@
CLASS net/minecraft/class_1269 net/minecraft/util/ActionResult
COMMENT An enum indicating the hand interaction's result. Methods called on hand interaction,
COMMENT such as {@link net.minecraft.block.AbstractBlock#onUse}, return this.
COMMENT
COMMENT @see TypedActionResult
FIELD field_21466 CONSUME Lnet/minecraft/class_1269;
COMMENT Indicates an action is performed but no animation should accompany the
COMMENT performance.
@ -15,12 +19,16 @@ CLASS net/minecraft/class_1269 net/minecraft/util/ActionResult
COMMENT Indicates that an action is not performed and prevents other actions
COMMENT from performing.
METHOD method_23665 isAccepted ()Z
COMMENT Returns whether an action is performed.
COMMENT {@return whether an action is performed}
METHOD method_23666 shouldSwingHand ()Z
COMMENT Returns whether an actor should have a hand-swinging animation on
COMMENT action performance.
COMMENT {@return whether an actor should have a hand-swinging animation on
COMMENT action performance}
METHOD method_29236 success (Z)Lnet/minecraft/class_1269;
COMMENT {@return an action result indicating success}
COMMENT
COMMENT <p>This returns {@link #SUCCESS} if {@code swingHand} is {@code true}, otherwise
COMMENT {@link #CONSUME}.
ARG 0 swingHand
METHOD method_36360 shouldIncrementStat ()Z
COMMENT Returns whether action performance should increment an item's 'used'
COMMENT statistic.
COMMENT {@return whether action performance should increment an item's "used"
COMMENT statistic}

View File

@ -1,9 +1,17 @@
CLASS net/minecraft/class_7497 net/minecraft/util/ApiServices
COMMENT A record holding session services used by the server.
COMMENT
COMMENT @apiNote Individual services can be accessed using the getters in
COMMENT {@link net.minecraft.server.MinecraftServer}.
FIELD comp_838 serviceSignatureVerifier Lnet/minecraft/class_7500;
FIELD comp_840 userCache Lnet/minecraft/class_3312;
FIELD field_39392 USER_CACHE_FILE_NAME Ljava/lang/String;
METHOD comp_838 serviceSignatureVerifier ()Lnet/minecraft/class_7500;
METHOD comp_840 userCache ()Lnet/minecraft/class_3312;
METHOD method_44143 create (Lcom/mojang/authlib/yggdrasil/YggdrasilAuthenticationService;Ljava/io/File;)Lnet/minecraft/class_7497;
COMMENT {@return a new API service instance}
COMMENT
COMMENT <p>This is usually not needed; call getters on {@link
COMMENT net.minecraft.server.MinecraftServer} instead.
ARG 0 authenticationService
ARG 1 rootDirectory

View File

@ -1,7 +1,11 @@
CLASS net/minecraft/class_1306 net/minecraft/util/Arm
COMMENT An enum representing an entity's arm.
COMMENT
COMMENT @see Hand
FIELD field_38385 id I
FIELD field_6181 translationKey Ljava/lang/String;
METHOD <init> (Ljava/lang/String;IILjava/lang/String;)V
ARG 3 id
ARG 4 translationKey
METHOD method_5928 getOpposite ()Lnet/minecraft/class_1306;
COMMENT {@return the arm on the opposite side}

View File

@ -1,5 +1,6 @@
CLASS net/minecraft/class_3829 net/minecraft/util/Clearable
COMMENT Represents an object which can be cleared.
METHOD method_16825 clear (Ljava/lang/Object;)V
COMMENT Clears {@code o} if it is {@link Clearable}.
ARG 0 o
METHOD method_5448 clear ()V

View File

@ -1,4 +1,5 @@
CLASS net/minecraft/class_1767 net/minecraft/util/DyeColor
COMMENT An enum representing 16 dye colors.
FIELD field_16537 signColor I
FIELD field_7943 colorComponents [F
FIELD field_7948 name Ljava/lang/String;
@ -15,18 +16,36 @@ CLASS net/minecraft/class_1767 net/minecraft/util/DyeColor
ARG 7 fireworkColor
ARG 8 signColor
METHOD method_16357 getSignColor ()I
COMMENT {@return the color used for dyed signs as RGB integer}
COMMENT
COMMENT <p>The returned value is between {@code 0} and {@code 0xFFFFFF}.
METHOD method_7786 byFireworkColor (I)Lnet/minecraft/class_1767;
COMMENT {@return the dye color whose firework color is {@code color}, or {@code null}
COMMENT if there is no such color}
ARG 0 color
METHOD method_7787 getColorComponents ()[F
COMMENT Returns the red, blue and green components of this dye color.
COMMENT {@return the float array containing the red, green and blue components of this dye color}
COMMENT
COMMENT @return an array composed of the red, blue and green floats
COMMENT <p>Each value of the array is between {@code 0.0} and {@code 255.0} (both inclusive).
METHOD method_7789 getId ()I
COMMENT {@return the integer ID of the dye color}
METHOD method_7790 getFireworkColor ()I
COMMENT {@return the color used for colored fireworks as RGB integer}
COMMENT
COMMENT <p>The returned value is between {@code 0} and {@code 0xFFFFFF}.
METHOD method_7791 byId (I)Lnet/minecraft/class_1767;
COMMENT {@return the dye color whose ID is {@code id}}
COMMENT
COMMENT @apiNote If out-of-range IDs are passed, this returns {@link #WHITE}.
ARG 0 id
METHOD method_7792 getName ()Ljava/lang/String;
COMMENT {@return the name of the dye color}
METHOD method_7793 byName (Ljava/lang/String;Lnet/minecraft/class_1767;)Lnet/minecraft/class_1767;
COMMENT {@return the dye color whose name is {@code name}, or {@code defaultColor} if
COMMENT there is no such color}
COMMENT
COMMENT @apiNote This returns {@code null} only if {@code defaultColor} is {@code null}.
ARG 0 name
ARG 1 defaultColor
METHOD method_7794 getMapColor ()Lnet/minecraft/class_3620;
COMMENT {@return the corresponding map color}

View File

@ -1,20 +1,41 @@
CLASS net/minecraft/class_4239 net/minecraft/util/FileNameUtil
COMMENT A class holding file name-related utility methods.
FIELD field_18955 RESERVED_WINDOWS_NAMES Ljava/util/regex/Pattern;
FIELD field_18956 FILE_NAME_WITH_COUNT Ljava/util/regex/Pattern;
FIELD field_33384 MAX_NAME_LENGTH I
METHOD method_19773 getNextUniqueName (Ljava/nio/file/Path;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
COMMENT {@return a filename, prefixed with {@code name}, that does not currently
COMMENT exist inside {@code path}}
COMMENT
COMMENT @implNote This strips any illegal characters from {@code name}, then
COMMENT attempts to make a directory with the name and the extension. If this succeeds,
COMMENT the directory is deleted and the name with the extension is returned. If not, it
COMMENT appends {@code (1)} to the name and tries again until it succeeds.
COMMENT
COMMENT @throws IOException if creating the temporary directory fails, e.g. due to {@code path}
COMMENT not being a directory
ARG 0 path
ARG 1 name
ARG 2 extension
METHOD method_20200 isNormal (Ljava/nio/file/Path;)Z
COMMENT {@return whether {@code path} is already normalized}
ARG 0 path
METHOD method_20201 isAllowedName (Ljava/nio/file/Path;)Z
COMMENT {@return whether {@code path} does not contain reserved Windows file names}
COMMENT
COMMENT @apiNote This returns {@code false} for reserved names regardless of whether the platform
COMMENT the game is running is actually Windows. Note that this does not check for
COMMENT illegal characters or file permissions.
ARG 0 path
METHOD method_20202 getResourcePath (Ljava/nio/file/Path;Ljava/lang/String;Ljava/lang/String;)Ljava/nio/file/Path;
ARG 0 path
ARG 1 resourceName
ARG 2 extension
METHOD method_34675 getPosixFullPath (Ljava/lang/String;)Ljava/lang/String;
COMMENT {@return the full path of {@code path} with directory separator normalized
COMMENT to {@code /}}
ARG 0 path
METHOD method_34676 normalizeToPosix (Ljava/lang/String;)Ljava/lang/String;
COMMENT {@return the normalized path of {@code path} with directory separator normalized
COMMENT to {@code /}}
ARG 0 path

View File

@ -1,4 +1,5 @@
CLASS net/minecraft/class_6826 net/minecraft/util/FixedBufferInputStream
COMMENT A buffered input stream that uses a fixed-size buffer array.
FIELD field_36209 DEFAULT_BUFFER_SIZE I
FIELD field_36210 stream Ljava/io/InputStream;
FIELD field_36211 buf [B

View File

@ -1 +1,5 @@
CLASS net/minecraft/class_1268 net/minecraft/util/Hand
COMMENT An enum representing an entity's hand.
COMMENT
COMMENT <p>If the entity is right-handed, {@link #MAIN_HAND} is of {@link Arm#RIGHT},
COMMENT and if the entity is left-handed, {@link #MAIN_HAND} is of {@link Arm#LEFT},

View File

@ -1,5 +1,89 @@
CLASS net/minecraft/class_2960 net/minecraft/util/Identifier
COMMENT The namespace and path must contain only lowercase letters ([a-z]), digits ([0-9]), or the characters '_', '.', and '-'. The path can also contain the standard path separator '/'.
COMMENT An identifier used to identify things. This is also known as "resource location",
COMMENT "namespaced ID", "location", or just "ID". This is a non-typed immutable object,
COMMENT and identifies things using a combination of namespace and path. Identifiers should
COMMENT always be compared using {@link #equals} method, not {@code ==}.
COMMENT
COMMENT <h2 id="format">Format</h2>
COMMENT <p>Identifiers are formatted as {@code <namespace>:<path>}. If the namespace and colon
COMMENT are omitted, the namespace defaults to {@value #DEFAULT_NAMESPACE}.
COMMENT
COMMENT <p><strong>The namespace and path must contain only ASCII lowercase letters ({@code
COMMENT [a-z]}), ASCII digits ({@code [0-9]}), or the characters {@code _}, {@code .}, and
COMMENT {@code -}. </strong> The path can also contain the standard path separator {@code
COMMENT /}. Uppercase letters cannot be used. {@link #isValid} can be used to check whether a
COMMENT string is a valid identifier. When handling externally provided identifiers, it should
COMMENT either validate or use {@link #tryParse} instead of the constructor. Another common
COMMENT mistake is using a formatted string with {@code %d} or {@code %f} to construct an
COMMENT identifier without specifying the locate explicitly, as they are not guaranteed to be
COMMENT ASCII digits in certain locales. Use {@link String#format(Locale, String, Object[])}
COMMENT with {@link java.util.Locale#ROOT} instead of {@link String#formatted}.
COMMENT
COMMENT <h3 id="namespace">Namespace</h3>
COMMENT <p>The <strong>namespace</strong> of an identifier identifies the origin of the thing.
COMMENT For example, two mods to the game could both add an item with the ID "orange";
COMMENT the namespace is used to differentiate the two. (The convention is to use the ID
COMMENT assigned to the mod as the namespace.)
COMMENT
COMMENT <p>A namespace only determines the source of an identifier, and does not determine its purpose; so long as
COMMENT two identifiers are used for different purposes, they can share the namespace and path.
COMMENT For example, the identifier {@code minecraft:dirt} is shared by blocks and items.
COMMENT There is no need to change the identifier to, say, {@code minecraft_block:dirt} or
COMMENT {@code minecraft_item:dirt}.
COMMENT
COMMENT <p>Several namespaces are reserved for vanilla use. While those identifiers can be used for
COMMENT referencing and overwriting vanilla things, it is highly discouraged to use them to
COMMENT identify your own, new things. For example, a modded block or a new biome added by
COMMENT data packs should not use the reserved namespaces, but it's fine to use them when
COMMENT modifying an existing biome under that namespace. The reserved namespaces are
COMMENT {@value #DEFAULT_NAMESPACE}, {@code brigadier}, and {@value #REALMS_NAMESPACE}.
COMMENT {@value #DEFAULT_NAMESPACE} is also the default namespace used when no namespace is
COMMENT provided.
COMMENT
COMMENT <h3 id="path">Path</h3>
COMMENT <p>The path of the identifier identifies the thing within the namespace, such as
COMMENT between different items from the same mod. Additionally, this is sometimes used to
COMMENT refer to a file path, such as in textures.
COMMENT
COMMENT <h2 id="Creation">Creation</h2>
COMMENT <p>There are many ways to create a new identifier:
COMMENT
COMMENT <ul>
COMMENT <li>{@link Identifier(String)} creates an identifier from a string in
COMMENT {@code <namespace>:<path>} format. If the colon is missing, the created identifier
COMMENT has the namespace {@value #DEFAULT_NAMESPACE} and the argument is used as the path.
COMMENT When passed an invalid value, this throws {@link InvalidIdentifierException}.</li>
COMMENT <li>{@link Identifier(String, String)} creates an identifier from namespace and path.
COMMENT When passed an invalid value, this throws {@link InvalidIdentifierException}.</li>
COMMENT <li>{@link #tryParse} creates an identifier from a string in
COMMENT {@code <namespace>:<path>} format. If the colon is missing, the created identifier
COMMENT has the namespace {@value #DEFAULT_NAMESPACE} and the argument is used as the path.
COMMENT When passed an invalid value, this returns {@code null}.</li>
COMMENT <li>{@link #of} creates an identifier from namespace and path.
COMMENT When passed an invalid value, this returns {@code null}.</li>
COMMENT <li>{@link #fromCommandInput} reads an identifier from command input reader.
COMMENT When an invalid value is read, this throws {@link #COMMAND_EXCEPTION}.</li>
COMMENT <li>{@link Identifier.Serializer} is a serializer for Gson.</li>
COMMENT <li>{@link #CODEC} can be used to serialize and deserialize an identifier using
COMMENT DataFixerUpper.</li>
COMMENT </ul>
COMMENT
COMMENT <h2 id="using">Using Identifier</h2>
COMMENT <p>Identifiers identify several objects in the game. {@link
COMMENT net.minecraft.util.registry.Registry} holds objects, such as blocks and items, that are
COMMENT identified by an identifier. Textures are also identified using an identifier; such
COMMENT an identifier is represented as a file path with an extension, such as {@code
COMMENT minecraft:textures/entity/pig/pig.png}.
COMMENT
COMMENT <p>The string representation of the identifier ({@code <namespace>:<path>}) can be
COMMENT obtained by calling {@link #toString}. This always includes the namespace. An identifier
COMMENT can be converted to a translation key using {@link #toTranslationKey(String)} method.
COMMENT
COMMENT <h3 id="registrykey">RegistryKey</h3>
COMMENT <p>Identifier is not type-aware; {@code minecraft:tnt} could refer to a TNT block, a TNT
COMMENT item, or a TNT entity. To identify a registered object uniquely, {@link
COMMENT net.minecraft.util.registry.RegistryKey} can be used. A registry key is a combination
COMMENT of the registry's identifier and the object's identifier.
FIELD field_13353 namespace Ljava/lang/String;
FIELD field_13354 COMMAND_EXCEPTION Lcom/mojang/brigadier/exceptions/SimpleCommandExceptionType;
FIELD field_13355 path Ljava/lang/String;
@ -23,10 +107,9 @@ CLASS net/minecraft/class_2960 net/minecraft/util/Identifier
METHOD equals (Ljava/lang/Object;)Z
ARG 1 o
METHOD method_12829 tryParse (Ljava/lang/String;)Lnet/minecraft/class_2960;
COMMENT <p>Parses a string into an {@code Identifier}.
COMMENT Takes a string of the form {@code <namespace>:<path>}, for example {@code minecraft:iron_ingot}.
COMMENT @return resulting identifier, or {@code null} if the string couldn't be parsed as an identifier
COMMENT @see #of(String, String)
COMMENT {@return {@code id} parsed as an identifier, or {@code null} if it cannot be parsed}
COMMENT
COMMENT @see #of
ARG 0 id
METHOD method_12830 split (Ljava/lang/String;C)[Ljava/lang/String;
ARG 0 id
@ -34,32 +117,47 @@ CLASS net/minecraft/class_2960 net/minecraft/util/Identifier
METHOD method_12831 isCharValid (C)Z
ARG 0 c
METHOD method_12832 getPath ()Ljava/lang/String;
COMMENT {@return the path of the identifier}
METHOD method_12835 fromCommandInput (Lcom/mojang/brigadier/StringReader;)Lnet/minecraft/class_2960;
ARG 0 reader
METHOD method_12836 getNamespace ()Ljava/lang/String;
COMMENT {@return the namespace of the identifier}
COMMENT
COMMENT <p>This returns {@value #DEFAULT_NAMESPACE} for identifiers created without a namespace.
METHOD method_12838 splitOn (Ljava/lang/String;C)Lnet/minecraft/class_2960;
ARG 0 id
ARG 1 delimiter
METHOD method_20207 isValid (Ljava/lang/String;)Z
COMMENT {@return whether {@code id} can be parsed as an identifier}
ARG 0 id
METHOD method_20208 isPathValid (Ljava/lang/String;)Z
COMMENT {@return whether {@code path} can be used as an identifier's path}
ARG 0 path
METHOD method_20209 isNamespaceValid (Ljava/lang/String;)Z
COMMENT {@return whether {@code namespace} can be used as an identifier's namespace}
ARG 0 namespace
METHOD method_29184 isPathCharacterValid (C)Z
COMMENT {@return whether {@code character} is valid for use in identifier paths}
ARG 0 character
METHOD method_29185 isNamespaceCharacterValid (C)Z
COMMENT {@return whether {@code character} is valid for use in identifier namespaces}
ARG 0 character
METHOD method_29186 validate (Ljava/lang/String;)Lcom/mojang/serialization/DataResult;
ARG 0 id
METHOD method_36181 toUnderscoreSeparatedString ()Ljava/lang/String;
COMMENT {@return the string representation of the identifier with slashes and colons replaced
COMMENT with underscores}
METHOD method_42093 toTranslationKey (Ljava/lang/String;)Ljava/lang/String;
COMMENT {@return the {@linkplain #toTranslationKey() long translation key} prefixed with
COMMENT {@code prefix} and a dot}
ARG 1 prefix
METHOD method_42094 toTranslationKey ()Ljava/lang/String;
COMMENT {@return the long translation key, without omitting the default namespace}
METHOD method_43902 of (Ljava/lang/String;Ljava/lang/String;)Lnet/minecraft/class_2960;
COMMENT {@return the identifier from the name and path, or {@code null} if the passed values
COMMENT do not form a valid identifier}
COMMENT @see #tryParse(String)
COMMENT {@return an identifier from the provided {@code namespace} and {@code path}, or
COMMENT {@code null} if either argument is invalid}
COMMENT
COMMENT @see #tryParse
ARG 0 namespace
ARG 1 path
METHOD method_43903 toShortTranslationKey ()Ljava/lang/String;

View File

@ -1,4 +1,7 @@
CLASS net/minecraft/class_151 net/minecraft/util/InvalidIdentifierException
COMMENT An exception thrown when parsing or constructing an {@link Identifier}
COMMENT that contains an invalid character. This should not be caught, instead
COMMENT {@link Identifier#tryParse} or {@link Identifier#of} should be used.
METHOD <init> (Ljava/lang/String;)V
ARG 1 message
METHOD <init> (Ljava/lang/String;Ljava/lang/Throwable;)V

View File

@ -1,27 +1,37 @@
CLASS net/minecraft/class_1264 net/minecraft/util/ItemScatterer
COMMENT Contains utility methods for spawning item entities scattered around a certain position.
COMMENT All methods consume the item stack, so there is no need for decrementing the
COMMENT stack size yourself.
COMMENT
COMMENT @see net.minecraft.block.AbstractBlock#onStateReplaced
METHOD method_17348 (Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;Lnet/minecraft/class_1799;)V
ARG 2 stack
METHOD method_17349 spawn (Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;Lnet/minecraft/class_2371;)V
COMMENT Spawns item entities from {@code stacks} around {@code pos}.
ARG 0 world
ARG 1 pos
ARG 2 stacks
METHOD method_5449 spawn (Lnet/minecraft/class_1937;DDDLnet/minecraft/class_1799;)V
COMMENT Spawns an item entity of {@code stack} around the given position.
ARG 0 world
ARG 1 x
ARG 3 y
ARG 5 z
ARG 7 stack
METHOD method_5450 spawn (Lnet/minecraft/class_1937;DDDLnet/minecraft/class_1263;)V
COMMENT Spawns item entities from {@code inventory} around the given position.
ARG 0 world
ARG 1 x
ARG 3 y
ARG 5 z
ARG 7 inventory
METHOD method_5451 spawn (Lnet/minecraft/class_1937;Lnet/minecraft/class_2338;Lnet/minecraft/class_1263;)V
COMMENT Spawns item entities from {@code inventory} around {@code pos}.
ARG 0 world
ARG 1 pos
ARG 2 inventory
METHOD method_5452 spawn (Lnet/minecraft/class_1937;Lnet/minecraft/class_1297;Lnet/minecraft/class_1263;)V
COMMENT Spawns item entities from {@code inventory} around {@code entity}'s position.
ARG 0 world
ARG 1 entity
ARG 2 inventory

View File

@ -1,4 +1,5 @@
CLASS net/minecraft/class_3518 net/minecraft/util/JsonHelper
COMMENT Provides methods for validating and deserializing JSON elements.
FIELD field_15657 GSON Lcom/google/gson/Gson;
METHOD method_15252 asArray (Lcom/google/gson/JsonElement;Ljava/lang/String;)Lcom/google/gson/JsonArray;
ARG 0 element

View File

@ -1,4 +1,7 @@
CLASS net/minecraft/class_3528 net/minecraft/util/Lazy
COMMENT A class that lazily evaluates a value.
COMMENT
COMMENT @deprecated Use {@link com.google.common.base.Suppliers#memoize} instead.
FIELD field_15719 supplier Ljava/util/function/Supplier;
METHOD <init> (Ljava/util/function/Supplier;)V
ARG 1 delegate

View File

@ -1,5 +1,16 @@
CLASS net/minecraft/class_1275 net/minecraft/util/Nameable
COMMENT Represents something that can be named, such as block entities or entities.
METHOD method_16914 hasCustomName ()Z
COMMENT {@return whether this object has a custom name}
METHOD method_5476 getDisplayName ()Lnet/minecraft/class_2561;
COMMENT {@return the display name of this object}
COMMENT
COMMENT <p>By default, this returns the result of {@link #getName}. The return value can
COMMENT have styling applied.
METHOD method_5477 getName ()Lnet/minecraft/class_2561;
COMMENT {@return the name of this object}
COMMENT
COMMENT <p>This should return {@linkplain #getCustomName the custom name} if it exists,
COMMENT otherwise the default name. This should not have styling applied.
METHOD method_5797 getCustomName ()Lnet/minecraft/class_2561;
COMMENT {@return the custom name of this object, or {@code null} if there is none}

View File

@ -1,4 +1,5 @@
CLASS net/minecraft/class_3544 net/minecraft/util/StringHelper
COMMENT Contains string-related helper methods.
FIELD field_15771 FORMATTING_CODE Ljava/util/regex/Pattern;
FIELD field_29204 LINE_BREAK Ljava/util/regex/Pattern;
FIELD field_33559 ENDS_WITH_LINE_BREAK Ljava/util/regex/Pattern;

View File

@ -1,5 +1,12 @@
CLASS net/minecraft/class_3542 net/minecraft/util/StringIdentifiable
COMMENT An interface, implemented by enums, that allows the enum to be serialized
COMMENT by codecs. An instance is identified using a string.
COMMENT
COMMENT @apiNote To make an enum serializable with codecs, implement this on the enum class,
COMMENT implement {@link #asString} to return a unique ID, and add a {@code static final}
COMMENT field that holds {@linkplain #createCodec the codec for the enum}.
METHOD method_15434 asString ()Ljava/lang/String;
COMMENT {@return the unique string representation of the enum, used for serialization}
METHOD method_28140 createCodec (Ljava/util/function/Supplier;)Lnet/minecraft/class_3542$class_7292;
COMMENT Creates a codec that serializes an enum implementing this interface either
COMMENT using its ordinals (when compressed) or using its {@link #asString()} method

View File

@ -1,4 +1,7 @@
CLASS net/minecraft/class_6396 net/minecraft/util/SystemDetails
COMMENT Fetches the hardware and software information to populate crash reports
COMMENT and debug profiles. A custom section can be added by calling {@link
COMMENT #addSection(String, String)}.
FIELD field_33852 MEBI J
FIELD field_33853 GIGA J
FIELD field_33854 LOGGER Lorg/slf4j/Logger;
@ -7,16 +10,26 @@ CLASS net/minecraft/class_6396 net/minecraft/util/SystemDetails
FIELD field_33857 JVM_VERSION Ljava/lang/String;
FIELD field_33858 sections Ljava/util/Map;
METHOD method_37120 collect ()Ljava/lang/String;
COMMENT {@return a string representation of the system details}
COMMENT
COMMENT <p>Sections are separated by newlines, and each section consists of the name, a colon,
COMMENT a space, and the value. No indent is added by this method.
METHOD method_37121 tryAddGroup (Ljava/lang/String;Ljava/lang/Runnable;)V
ARG 1 name
ARG 2 adder
METHOD method_37122 addSection (Ljava/lang/String;Ljava/lang/String;)V
COMMENT Adds a section with the given {@code name} and {@code value}.
ARG 1 name
ARG 2 value
METHOD method_37123 addSection (Ljava/lang/String;Ljava/util/function/Supplier;)V
COMMENT Adds a section with the given {@code name} and the value supplied by
COMMENT {@code valueSupplier}. If an exception is thrown while calling the supplier,
COMMENT {@code ERR} is used as the value.
ARG 1 name
ARG 2 valueSupplier
METHOD method_37124 writeTo (Ljava/lang/StringBuilder;)V
COMMENT Writes the system details to {@code stringBuilder}.
COMMENT This writes the header and the sections (indented by one tab).
ARG 1 stringBuilder
METHOD method_37125 (Ljava/lang/StringBuilder;Ljava/lang/String;Ljava/lang/String;)V
ARG 1 name

View File

@ -1,4 +1,5 @@
CLASS net/minecraft/class_7437 net/minecraft/util/TextifiedException
COMMENT An exception that has a user-friendly {@link Text} attached.
FIELD field_39084 messageText Lnet/minecraft/class_2561;
METHOD <init> (Lnet/minecraft/class_2561;)V
ARG 1 messageText
@ -6,3 +7,4 @@ CLASS net/minecraft/class_7437 net/minecraft/util/TextifiedException
ARG 1 messageText
ARG 2 cause
METHOD method_43626 getMessageText ()Lnet/minecraft/class_2561;
COMMENT {@return the exception's message text}

View File

@ -1,6 +1,11 @@
CLASS net/minecraft/class_4802 net/minecraft/util/TimeHelper
COMMENT A class holding utility methods related to time and durations.
FIELD field_33868 SECOND_IN_NANOS J
COMMENT The equivalent of 1 second, in nanoseconds. Is {@code 1000000000}.
FIELD field_33869 MILLI_IN_NANOS J
COMMENT The equivalent of 1 millisecond, in nanoseconds. Is {@code 1000000}.
METHOD method_24505 betweenSeconds (II)Lnet/minecraft/class_6019;
COMMENT {@return an int provider that provides a time in ticks, between {@code min * 20} and
COMMENT {@code max * 20} (both inclusive)}
ARG 0 min
ARG 1 max

View File

@ -1,4 +1,5 @@
CLASS net/minecraft/class_7291 net/minecraft/util/TranslatableOption
COMMENT An option whose text can be translated.
METHOD method_42627 getText ()Lnet/minecraft/class_2561;
METHOD method_7359 getTranslationKey ()Ljava/lang/String;
METHOD method_7362 getId ()I

View File

@ -1,4 +1,5 @@
CLASS net/minecraft/class_156 net/minecraft/util/Util
COMMENT A class holding various utility methods.
FIELD field_1128 nanoTimeSupplier Lnet/minecraft/class_7576$class_7577;
FIELD field_1129 LOGGER Lorg/slf4j/Logger;
FIELD field_18034 NEXT_WORKER_ID Ljava/util/concurrent/atomic/AtomicInteger;
@ -6,13 +7,21 @@ CLASS net/minecraft/class_156 net/minecraft/util/Util
FIELD field_24477 IO_WORKER_EXECUTOR Ljava/util/concurrent/ExecutorService;
FIELD field_24622 BOOTSTRAP_EXECUTOR Ljava/util/concurrent/ExecutorService;
FIELD field_25140 NIL_UUID Ljava/util/UUID;
COMMENT The "nil UUID" that represents lack of a UUID.
FIELD field_33859 JAR_FILE_SYSTEM_PROVIDER Ljava/nio/file/spi/FileSystemProvider;
COMMENT The file system provider for handling jar and zip files.
FIELD field_34891 MAX_PARALLELISM I
FIELD field_34892 MAX_BG_THREADS_PROPERTY Ljava/lang/String;
FIELD field_34893 missingBreakpointHandler Ljava/util/function/Consumer;
FIELD field_37250 TICKER Lcom/google/common/base/Ticker;
FIELD field_39824 DATE_TIME_FORMATTER Ljava/time/format/DateTimeFormatter;
COMMENT A locale-independent datetime formatter that uses {@code yyyy-MM-dd_HH.mm.ss}
COMMENT as the format string. Example: {@code 2022-01-01_00.00.00}
METHOD method_17974 ifPresentOrElse (Ljava/util/Optional;Ljava/util/function/Consumer;Ljava/lang/Runnable;)Ljava/util/Optional;
COMMENT If {@code optional} has value, calls {@code presentAction} with the value,
COMMENT otherwise calls {@code elseAction}.
COMMENT
COMMENT @return the passed {@code optional}
ARG 0 optional
ARG 1 presentAction
ARG 2 elseAction
@ -20,27 +29,43 @@ CLASS net/minecraft/class_156 net/minecraft/util/Util
ARG 0 thread
ARG 1 t
METHOD method_18349 getMainWorkerExecutor ()Ljava/util/concurrent/ExecutorService;
COMMENT {@return the main worker executor for miscellaneous asynchronous tasks}
METHOD method_18350 shutdownExecutors ()V
METHOD method_18839 debugRunnable (Ljava/lang/Runnable;Ljava/util/function/Supplier;)Ljava/lang/Runnable;
ARG 0 runnable
ARG 1 messageSupplier
METHOD method_19483 completeExceptionally (Ljava/lang/Throwable;)Ljava/util/concurrent/CompletableFuture;
COMMENT {@return a future that is already completed exceptionally with {@code throwable}}
ARG 0 throwable
METHOD method_20793 getLast (Ljava/util/List;)Ljava/lang/Object;
COMMENT {@return the last item of {@code list}}
COMMENT
COMMENT @throws IndexOutOfBoundsException if {@code list} is empty
ARG 0 list
METHOD method_22320 throwOrPause (Ljava/lang/Throwable;)Ljava/lang/Throwable;
ARG 0 t
METHOD method_22321 getInnermostMessage (Ljava/lang/Throwable;)Ljava/lang/String;
ARG 0 t
METHOD method_24155 throwUnchecked (Ljava/lang/Throwable;)V
COMMENT Throws {@code t} if it's a {@link RuntimeException} (or any of its subclass), otherwise
COMMENT {@code t} wrapped in a RuntimeException.
COMMENT
COMMENT <p>{@link Error} is wrapped as well, despite being unchecked.
ARG 0 t
METHOD method_27172 getRandom ([ILnet/minecraft/class_5819;)I
COMMENT {@return a random integer from {@code array}}
COMMENT
COMMENT @throws IllegalArgumentException if {@code array} is empty
ARG 0 array
ARG 1 random
METHOD method_27173 getRandom ([Ljava/lang/Object;Lnet/minecraft/class_5819;)Ljava/lang/Object;
COMMENT {@return a random item from {@code array}}
COMMENT
COMMENT @throws IllegalArgumentException if {@code array} is empty
ARG 0 array
ARG 1 random
METHOD method_27760 backupAndReplace (Ljava/io/File;Ljava/io/File;Ljava/io/File;)V
COMMENT Copies {@code current} to {@code backup} and then replaces {@code current} with {@code newPath}.
ARG 0 current
ARG 1 newFile
ARG 2 backup
@ -55,16 +80,26 @@ CLASS net/minecraft/class_156 net/minecraft/util/Util
METHOD method_27957 attemptShutdown (Ljava/util/concurrent/ExecutorService;)V
ARG 0 service
METHOD method_27958 getIoWorkerExecutor ()Ljava/util/concurrent/ExecutorService;
COMMENT {@return the executor for disk or network IO tasks}
METHOD method_27959 createIoWorker ()Ljava/util/concurrent/ExecutorService;
METHOD method_28122 createWorker (Ljava/lang/String;)Ljava/util/concurrent/ExecutorService;
ARG 0 name
METHOD method_28123 (Ljava/lang/String;Ljava/util/concurrent/ForkJoinPool;)Ljava/util/concurrent/ForkJoinWorkerThread;
ARG 1 forkJoinPool
METHOD method_28124 getBootstrapExecutor ()Ljava/util/concurrent/ExecutorService;
COMMENT {@return the executor for asynchronous bootstrapping}
COMMENT
COMMENT <p>This is used by DataFixerUpper to build schemas.
METHOD method_29187 getChoiceType (Lcom/mojang/datafixers/DSL$TypeReference;Ljava/lang/String;)Lcom/mojang/datafixers/types/Type;
ARG 0 typeReference
ARG 1 id
METHOD method_29188 addPrefix (Ljava/lang/String;Ljava/util/function/Consumer;)Ljava/util/function/Consumer;
COMMENT {@return a consumer that first prepends {@code prefix} to its input
COMMENT string and passes the result to {@code consumer}}
COMMENT
COMMENT @apiNote This is useful in codec-based deserialization when passing the
COMMENT error consumer to some methods, e.g. {@code
COMMENT Util.addPrefix("Could not parse Example", LOGGER::error)}.
ARG 0 prefix
ARG 1 consumer
METHOD method_29189 (Ljava/util/function/Consumer;Ljava/lang/String;Ljava/lang/String;)V
@ -97,7 +132,7 @@ CLASS net/minecraft/class_156 net/minecraft/util/Util
ARG 0 src
ARG 1 dest
METHOD method_30626 backupAndReplace (Ljava/nio/file/Path;Ljava/nio/file/Path;Ljava/nio/file/Path;)V
COMMENT Copies {@code current} to {@code backup} and then replaces {@code current} with {@code newPath}
COMMENT Copies {@code current} to {@code backup} and then replaces {@code current} with {@code newPath}.
ARG 0 current
ARG 1 newPath
ARG 2 backup
@ -108,6 +143,11 @@ CLASS net/minecraft/class_156 net/minecraft/util/Util
METHOD method_30629 existenceCheckTask (Ljava/nio/file/Path;)Ljava/util/function/BooleanSupplier;
ARG 0 path
METHOD method_32309 getRandom (Ljava/util/List;Lnet/minecraft/class_5819;)Ljava/lang/Object;
COMMENT {@return a random item from {@code list}}
COMMENT
COMMENT @throws IllegalArgumentException if {@code list} is empty
COMMENT
COMMENT @see #getRandomOrEmpty
ARG 0 list
ARG 1 random
METHOD method_33141 toArray (Ljava/util/List;I)Lcom/mojang/serialization/DataResult;
@ -151,34 +191,47 @@ CLASS net/minecraft/class_156 net/minecraft/util/Util
METHOD method_40082 (Ljava/util/List;Ljava/lang/Void;)Ljava/util/List;
ARG 1 void_
METHOD method_40083 getRandomOrEmpty (Ljava/util/List;Lnet/minecraft/class_5819;)Ljava/util/Optional;
COMMENT {@return an {@link Optional} of a random item from {@code list}, or an empty optional
COMMENT if the list is empty}
COMMENT
COMMENT @see #getRandom(List, Random)
ARG 0 list
ARG 1 random
METHOD method_41203 backupAndReplace (Ljava/io/File;Ljava/io/File;Ljava/io/File;Z)V
COMMENT Copies {@code current} to {@code backup} and then replaces {@code current} with {@code newPath}.
ARG 0 current
ARG 1 newPath
ARG 2 backup
ARG 3 noRestoreOnFail
COMMENT if {@code true}, does not restore the current file when replacing fails
METHOD method_41204 backupAndReplace (Ljava/nio/file/Path;Ljava/nio/file/Path;Ljava/nio/file/Path;Z)V
COMMENT Copies {@code current} to {@code backup} and then replaces {@code current} with {@code newPath}.
ARG 0 current
ARG 1 newPath
ARG 2 backup
ARG 3 noRestoreOnFail
COMMENT if {@code true}, does not restore the current file when replacing fails
METHOD method_41238 debugSupplier (Ljava/util/function/Supplier;Ljava/util/function/Supplier;)Ljava/util/function/Supplier;
ARG 0 supplier
ARG 1 messageSupplier
METHOD method_43027 copyShuffled (Lit/unimi/dsi/fastutil/objects/ObjectArrayList;Lnet/minecraft/class_5819;)Ljava/util/List;
COMMENT {@return the contents of {@code stream} copied to a list and then shuffled}
ARG 0 list
ARG 1 random
METHOD method_43028 shuffle (Lit/unimi/dsi/fastutil/objects/ObjectArrayList;Lnet/minecraft/class_5819;)V
COMMENT Shuffles {@code list}, modifying the passed list in place.
ARG 0 list
ARG 1 random
METHOD method_43251 shuffle (Ljava/util/stream/IntStream;Lnet/minecraft/class_5819;)Lit/unimi/dsi/fastutil/ints/IntArrayList;
COMMENT {@return the contents of {@code stream} copied to a list and then shuffled}
ARG 0 stream
ARG 1 random
METHOD method_43252 copyShuffled (Ljava/util/stream/Stream;Lnet/minecraft/class_5819;)Ljava/util/List;
COMMENT {@return the contents of {@code stream} copied to a list and then shuffled}
ARG 0 stream
ARG 1 random
METHOD method_43253 copyShuffled ([Ljava/lang/Object;Lnet/minecraft/class_5819;)Ljava/util/List;
COMMENT {@return the contents of {@code array} copied to a list and then shuffled}
ARG 0 array
ARG 1 random
METHOD method_43368 (Ljava/util/List;Ljava/lang/Void;)Ljava/util/List;
@ -259,17 +312,37 @@ CLASS net/minecraft/class_156 net/minecraft/util/Util
COMMENT a function that, when given the size of {@code values},
COMMENT returns a map for storing the indices of the values
METHOD method_44893 getFormattedCurrentTime ()Ljava/lang/String;
COMMENT {@return the current time formatted using {@link #DATE_TIME_FORMATTER}}
METHOD method_645 previous (Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/lang/Object;
COMMENT {@return the item preceding {@code object} in {@code iterable}}
COMMENT
COMMENT <p>If {@code object} is not in {@code iterable}, this returns the last item of the iterable.
COMMENT {@code object} is compared using the {@code ==} operator.
ARG 0 iterable
ARG 1 object
METHOD method_646 createTranslationKey (Ljava/lang/String;Lnet/minecraft/class_2960;)Ljava/lang/String;
COMMENT {@return the translation key constructed from {@code type} and {@code id}}
COMMENT
COMMENT <p>If {@code id} is {@code null}, {@code unregistered_sadface} is used as the ID.
COMMENT
COMMENT @see Identifier#toTranslationKey(String)
ARG 0 type
ARG 1 id
METHOD method_648 getMeasuringTimeNano ()J
COMMENT {@return the current time in nanoseconds, to be used for measuring a duration}
COMMENT
COMMENT <p>This is not the Unix epoch time, and can only be used to determine the duration
COMMENT between two calls of this method.
COMMENT
COMMENT @see #getMeasuringTimeMs
COMMENT @see #getEpochTimeMs
METHOD method_650 getValueAsString (Lnet/minecraft/class_2769;Ljava/lang/Object;)Ljava/lang/String;
ARG 0 property
ARG 1 value
METHOD method_651 getJVMFlags ()Ljava/util/stream/Stream;
COMMENT {@return a stream of JVM flags passed when launching}
COMMENT
COMMENT <p>The streamed strings include the {@code -X} prefix.
METHOD method_652 combine (Ljava/util/List;)Ljava/util/concurrent/CompletableFuture;
COMMENT Combines a list of {@code futures} into one future that holds a list
COMMENT of their results.
@ -284,20 +357,64 @@ CLASS net/minecraft/class_156 net/minecraft/util/Util
ARG 0 futures
COMMENT the completable futures to combine
METHOD method_654 make (Ljava/lang/Object;Ljava/util/function/Consumer;)Ljava/lang/Object;
COMMENT {@return {@code object} initialized with {@code initializer}}
COMMENT
COMMENT <p>This is useful when initializing static fields:
COMMENT <pre>{@code
COMMENT private static final Map<String, String> MAP = Util.make(new HashMap<>(), (map) -> {
COMMENT map.put("example", "hello");
COMMENT });
COMMENT }</pre>
ARG 0 object
ARG 1 initializer
METHOD method_655 identityHashStrategy ()Lit/unimi/dsi/fastutil/Hash$Strategy;
COMMENT {@return the {@link Hash.Strategy} that uses identity comparison}
COMMENT
COMMENT <p>fastutil's "reference" object types should be used instead in most cases.
METHOD method_656 make (Ljava/util/function/Supplier;)Ljava/lang/Object;
COMMENT {@return the value supplied from {@code factory}}
COMMENT
COMMENT <p>This is useful when initializing static fields:
COMMENT <pre>{@code
COMMENT private static final Map<String, String> MAP = Util.make(() -> {
COMMENT Map<String, String> map = new HashMap<>();
COMMENT map.put("example", "hello");
COMMENT return map;
COMMENT });
COMMENT }</pre>
ARG 0 factory
METHOD method_658 getMeasuringTimeMs ()J
COMMENT {@return the current time in milliseconds, to be used for measuring a duration}
COMMENT
COMMENT <p>This is not the Unix epoch time, and can only be used to determine the duration
COMMENT between two calls of this method.
COMMENT
COMMENT @see #getMeasuringTimeNano
COMMENT @see #getEpochTimeMs
METHOD method_659 getEpochTimeMs ()J
COMMENT {@return the milliseconds passed since the Unix epoch}
COMMENT
COMMENT <p>This should be used to display or store the current time. {@link #getMeasuringTimeMs}
COMMENT should be used for determining the duration between two calls.
COMMENT
COMMENT @see #getMeasuringTimeMs
COMMENT @see #getMeasuringTimeNano
METHOD method_660 next (Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/lang/Object;
COMMENT {@return the item succeeding {@code object} in {@code iterable}}
COMMENT
COMMENT @implNote If {@code object} is {@code null}, this returns the first item of the iterable.
COMMENT If {@code object} is not in {@code iterable}, this enters into an infinite loop.
COMMENT {@code object} is compared using the {@code ==} operator.
ARG 0 iterable
ARG 1 object
METHOD method_664 toMap ()Ljava/util/stream/Collector;
METHOD method_666 (Ljava/lang/String;)Z
ARG 0 runtimeArg
METHOD method_668 getOperatingSystem ()Lnet/minecraft/class_156$class_158;
COMMENT {@return the operating system instance for the current platform}
COMMENT
COMMENT @implNote This uses the {@code os.name} system property to determine the operating system.
COMMENT @apiNote This is used for opening links.
CLASS 2
FIELD field_29655 cache Ljava/util/Map;
METHOD apply (Ljava/lang/Object;)Ljava/lang/Object;
@ -319,17 +436,39 @@ CLASS net/minecraft/class_156 net/minecraft/util/Util
METHOD hashCode (Ljava/lang/Object;)I
ARG 1 o
CLASS class_158 OperatingSystem
COMMENT An enum representing the operating system of the current platform.
COMMENT This defines the behavior for opening links.
COMMENT The current one can be obtained via {@link Util#getOperatingSystem}.
FIELD field_34894 name Ljava/lang/String;
METHOD <init> (Ljava/lang/String;ILjava/lang/String;)V
ARG 3 name
METHOD method_38649 getName ()Ljava/lang/String;
METHOD method_669 open (Ljava/net/URL;)V
COMMENT Opens {@code url}. If this points to an HTTP(S) URL, it is usually opened using
COMMENT the system's default browser. Otherwise, it is opened directly.
COMMENT
COMMENT <p><strong>Always validate the passed URL's schema</strong> as some values can
COMMENT execute code.
ARG 1 url
METHOD method_670 open (Ljava/lang/String;)V
COMMENT Opens {@code uri}. If this points to an HTTP(S) URI, it is usually opened using
COMMENT the system's default browser. Otherwise, it is opened directly.
COMMENT
COMMENT <p><strong>Always validate the passed URI's schema</strong> as some values can
COMMENT execute code.
ARG 1 uri
METHOD method_672 open (Ljava/io/File;)V
COMMENT Opens {@code file}.
COMMENT
COMMENT <p><strong>Do not pass untrusted file to this method</strong> as some values can
COMMENT execute code.
ARG 1 file
METHOD method_673 open (Ljava/net/URI;)V
COMMENT Opens {@code uri}. If this points to an HTTP(S) URI, it is usually opened using
COMMENT the system's default browser. Otherwise, it is opened directly.
COMMENT
COMMENT <p><strong>Always validate the passed URI's schema</strong> as some values can
COMMENT execute code.
ARG 1 uri
METHOD method_674 getURLOpenCommand (Ljava/net/URL;)[Ljava/lang/String;
ARG 1 url

View File

@ -0,0 +1,10 @@
/*
* This file is free for everyone to use under the Creative Commons Zero license.
*/
/**
* Contains utility method classes, various enums, serialization helpers, and
* miscellaneous classes. {@link net.minecraft.util.Util} contains most of
* the utility methods.
*/
package net.minecraft.util;