From 562653ebd4aa24ceb3f7fb198fd4a0bdb0e8c7b6 Mon Sep 17 00:00:00 2001 From: apple502j <33279053+apple502j@users.noreply.github.com> Date: Wed, 19 Oct 2022 05:15:20 +0900 Subject: [PATCH] Document some math stuff (#3305) * Document some math stuff * Apply suggestions from code review Co-authored-by: enbrain <69905075+enbrain@users.noreply.github.com> Co-authored-by: liach <7806504+liach@users.noreply.github.com> Co-authored-by: enbrain <69905075+enbrain@users.noreply.github.com> Co-authored-by: liach <7806504+liach@users.noreply.github.com> --- .../net/minecraft/util/math/BlockBox.mapping | 33 +++++++++++++++---- mappings/net/minecraft/util/math/Box.mapping | 26 ++++++++------- .../net/minecraft/util/math/ChunkPos.mapping | 17 ++++++++++ .../minecraft/util/math/ColorHelper.mapping | 16 +++++++++ .../net/minecraft/util/math/Direction.mapping | 8 +++++ .../minecraft/util/math/MathHelper.mapping | 5 +++ 6 files changed, 87 insertions(+), 18 deletions(-) diff --git a/mappings/net/minecraft/util/math/BlockBox.mapping b/mappings/net/minecraft/util/math/BlockBox.mapping index a3aba61e37..5778bd828e 100644 --- a/mappings/net/minecraft/util/math/BlockBox.mapping +++ b/mappings/net/minecraft/util/math/BlockBox.mapping @@ -31,18 +31,27 @@ CLASS net/minecraft/class_3341 net/minecraft/util/math/BlockBox METHOD equals (Ljava/lang/Object;)Z ARG 1 o METHOD method_14657 intersects (Lnet/minecraft/class_3341;)Z + COMMENT {@return whether {@code other} intersects with this box} ARG 1 other METHOD method_14659 getDimensions ()Lnet/minecraft/class_2382; + COMMENT {@return the dimensions (the size) of this box} METHOD method_14660 getBlockCountY ()I + COMMENT {@return the number of blocks on the Y axis} + COMMENT + COMMENT

This is equal to {@code maxY - minY + 1}. METHOD method_14661 move (III)Lnet/minecraft/class_3341; ARG 1 dx ARG 2 dy ARG 3 dz METHOD method_14662 contains (Lnet/minecraft/class_2382;)Z - ARG 1 vec + COMMENT {@return whether this box contains {@code pos}} + ARG 1 pos METHOD method_14663 getBlockCountZ ()I + COMMENT {@return the number of blocks on the Z axis} + COMMENT + COMMENT

This is equal to {@code maxZ - minZ + 1}. METHOD method_14665 infinite ()Lnet/minecraft/class_3341; - COMMENT Creates an all-encompassing, infinite box. + COMMENT {@return a new all-encompassing, infinite box} METHOD method_14667 rotated (IIIIIIIIILnet/minecraft/class_2350;)Lnet/minecraft/class_3341; ARG 0 x ARG 1 y @@ -55,21 +64,23 @@ CLASS net/minecraft/class_3341 net/minecraft/util/math/BlockBox ARG 8 sizeZ ARG 9 facing METHOD method_14669 intersectsXZ (IIII)Z + COMMENT {@return whether the rectangle from the given coordinates intersects with this box's XZ plane} ARG 1 minX ARG 2 minZ ARG 3 maxX ARG 4 maxZ METHOD method_19311 offset (III)Lnet/minecraft/class_3341; - COMMENT Creates a new box that is translated by {@code x}, {@code y}, {@code z} - COMMENT on each axis from this box. + COMMENT {@return a new box that is translated by {@code x}, {@code y}, {@code z} + COMMENT on each axis from this box} COMMENT - COMMENT @return the new box created COMMENT @see #move(int, int, int) ARG 1 x ARG 2 y ARG 3 z METHOD method_22874 getCenter ()Lnet/minecraft/class_2338; - COMMENT @implNote Biased toward the minimum bound corner of the box. + COMMENT {@return the center of this box} + COMMENT + COMMENT @apiNote This is biased toward the minimum bound corner of the box. METHOD method_29299 move (Lnet/minecraft/class_2382;)Lnet/minecraft/class_3341; ARG 1 vec METHOD method_34389 encompass (Lnet/minecraft/class_2338;)Lnet/minecraft/class_3341; @@ -79,9 +90,11 @@ CLASS net/minecraft/class_3341 net/minecraft/util/math/BlockBox ARG 1 pos COMMENT the pos to encompass METHOD method_34390 create (Lnet/minecraft/class_2382;Lnet/minecraft/class_2382;)Lnet/minecraft/class_3341; + COMMENT {@return a new box from two corners, {@code first} and {@code second}} ARG 0 first ARG 1 second METHOD method_34391 forEachVertex (Ljava/util/function/Consumer;)V + COMMENT Calls {@code consumer} for each vertex (corner) of this box. ARG 1 consumer METHOD method_34392 (Ljava/util/stream/IntStream;)Lcom/mojang/serialization/DataResult; ARG 0 values @@ -90,14 +103,22 @@ CLASS net/minecraft/class_3341 net/minecraft/util/math/BlockBox METHOD method_34394 (Lnet/minecraft/class_3341;)Ljava/util/stream/IntStream; ARG 0 box METHOD method_35410 expand (I)Lnet/minecraft/class_3341; + COMMENT {@return a new box that is expanded on each direction by {@code offset}} ARG 1 offset METHOD method_35411 encompassPositions (Ljava/lang/Iterable;)Ljava/util/Optional; + COMMENT {@return the minimum box encompassing all of the given {@code positions}, + COMMENT or an empty optional if {@code positions} is empty} ARG 0 positions METHOD method_35412 encompass (Lnet/minecraft/class_3341;)Lnet/minecraft/class_3341; ARG 1 box METHOD method_35413 encompass (Ljava/lang/Iterable;)Ljava/util/Optional; + COMMENT {@return the minimum box encompassing all of the given {@code boxes}, + COMMENT or an empty optional if {@code boxes} is empty} ARG 0 boxes METHOD method_35414 getBlockCountX ()I + COMMENT {@return the number of blocks on the X axis} + COMMENT + COMMENT

This is equal to {@code maxX - minX + 1}. METHOD method_35415 getMinX ()I METHOD method_35416 getMinY ()I METHOD method_35417 getMinZ ()I diff --git a/mappings/net/minecraft/util/math/Box.mapping b/mappings/net/minecraft/util/math/Box.mapping index 20b6dce1c9..849dfc2044 100644 --- a/mappings/net/minecraft/util/math/Box.mapping +++ b/mappings/net/minecraft/util/math/Box.mapping @@ -35,6 +35,7 @@ CLASS net/minecraft/class_238 net/minecraft/util/math/Box METHOD equals (Ljava/lang/Object;)Z ARG 1 o METHOD method_1001 getMin (Lnet/minecraft/class_2350$class_2351;)D + COMMENT {@return the minimum coordinate for the given {@code axis} of this box} ARG 1 axis METHOD method_1002 shrink (DDD)Lnet/minecraft/class_238; ARG 1 x @@ -104,28 +105,28 @@ CLASS net/minecraft/class_238 net/minecraft/util/math/Box ARG 3 dy ARG 5 dz METHOD method_35574 withMinX (D)Lnet/minecraft/class_238; - COMMENT Creates a box with the minimum X provided and all other coordinates - COMMENT of this box. + COMMENT {@return a new box with the minimum X provided and all other coordinates + COMMENT of this box} ARG 1 minX METHOD method_35575 withMinY (D)Lnet/minecraft/class_238; - COMMENT Creates a box with the minimum Y provided and all other coordinates - COMMENT of this box. + COMMENT {@return a new box with the minimum Y provided and all other coordinates + COMMENT of this box} ARG 1 minY METHOD method_35576 withMinZ (D)Lnet/minecraft/class_238; - COMMENT Creates a box with the minimum Z provided and all other coordinates - COMMENT of this box. + COMMENT {@return a new box with the minimum Z provided and all other coordinates + COMMENT of this box} ARG 1 minZ METHOD method_35577 withMaxX (D)Lnet/minecraft/class_238; - COMMENT Creates a box with the maximum X provided and all other coordinates - COMMENT of this box. + COMMENT {@return a new box with the maximum X provided and all other coordinates + COMMENT of this box} ARG 1 maxX METHOD method_35578 withMaxY (D)Lnet/minecraft/class_238; - COMMENT Creates a box with the maximum Y provided and all other coordinates - COMMENT of this box. + COMMENT {@return a new box with the maximum Y provided and all other coordinates + COMMENT of this box} ARG 1 maxY METHOD method_35579 withMaxZ (D)Lnet/minecraft/class_238; - COMMENT Creates a box with the maximum Z provided and all other coordinates - COMMENT of this box. + COMMENT {@return a new box with the maximum Z provided and all other coordinates + COMMENT of this box} ARG 1 maxZ METHOD method_35580 contract (DDD)Lnet/minecraft/class_238; COMMENT @see #expand(double, double, double) @@ -139,6 +140,7 @@ CLASS net/minecraft/class_238 net/minecraft/util/math/Box ARG 3 y ARG 5 z METHOD method_990 getMax (Lnet/minecraft/class_2350$class_2351;)D + COMMENT {@return the maximum coordinate for the given {@code axis} of this box} ARG 1 axis METHOD method_991 union (Lnet/minecraft/class_238;)Lnet/minecraft/class_238; COMMENT Creates the minimum box that contains this box and the given box. diff --git a/mappings/net/minecraft/util/math/ChunkPos.mapping b/mappings/net/minecraft/util/math/ChunkPos.mapping index 3cfdc3145d..ba157d290b 100644 --- a/mappings/net/minecraft/util/math/ChunkPos.mapping +++ b/mappings/net/minecraft/util/math/ChunkPos.mapping @@ -1,6 +1,12 @@ CLASS net/minecraft/class_1923 net/minecraft/util/math/ChunkPos + COMMENT An immutable pair of two integers representing the X and Z coordinates of a chunk. + COMMENT + COMMENT

Chunk positions are usually serialized as a {@code long}. FIELD field_17348 MARKER J + COMMENT A {@code long}-serialized chunk position {@code 1875066, 1875066}. This is a + COMMENT special value used as a marker. FIELD field_35107 ORIGIN Lnet/minecraft/class_1923; + COMMENT The origin of the chunk position, {@code 0, 0}. FIELD field_9180 z I FIELD field_9181 x I METHOD (II)V @@ -37,6 +43,9 @@ CLASS net/minecraft/class_1923 net/minecraft/util/math/ChunkPos ARG 2 y ARG 3 offsetZ METHOD method_37232 toLong (Lnet/minecraft/class_2338;)J + COMMENT {@return the chunk position of the given {@code pos} serialized as {@code long}} + COMMENT + COMMENT @see #toLong(int, int) ARG 0 pos METHOD method_42305 fromRegion (II)Lnet/minecraft/class_1923; ARG 0 x @@ -49,6 +58,9 @@ CLASS net/minecraft/class_1923 net/minecraft/util/math/ChunkPos ARG 1 z METHOD method_8323 getStartPos ()Lnet/minecraft/class_2338; METHOD method_8324 toLong ()J + COMMENT {@return the chunk position serialized as {@code long}} + COMMENT + COMMENT @see #toLong(int, int) METHOD method_8325 getPackedX (J)I ARG 0 pos METHOD method_8326 getStartX ()I @@ -56,6 +68,11 @@ CLASS net/minecraft/class_1923 net/minecraft/util/math/ChunkPos METHOD method_8328 getStartZ ()I METHOD method_8329 getEndZ ()I METHOD method_8331 toLong (II)J + COMMENT {@return the chunk position serialized as {@code long}} + COMMENT + COMMENT

This returns {@code chunkX | (chunkZ << 32)}. + COMMENT + COMMENT @see #toLong() ARG 0 chunkX ARG 1 chunkZ METHOD method_8332 getPackedZ (J)I diff --git a/mappings/net/minecraft/util/math/ColorHelper.mapping b/mappings/net/minecraft/util/math/ColorHelper.mapping index dd0af6fbcd..f6dfefe2ee 100644 --- a/mappings/net/minecraft/util/math/ColorHelper.mapping +++ b/mappings/net/minecraft/util/math/ColorHelper.mapping @@ -1,18 +1,34 @@ CLASS net/minecraft/class_5253 net/minecraft/util/math/ColorHelper + COMMENT Contains color-related helper methods. CLASS class_5254 Argb + COMMENT Contains color-related helper methods that use ARGB colors represented + COMMENT as {@code 0xAARRGGBB}. METHOD method_27762 getAlpha (I)I + COMMENT {@return the alpha value of {@code argb}} + COMMENT + COMMENT

The returned value is between {@code 0} and {@code 255} (both inclusive). ARG 0 argb METHOD method_27763 mixColor (II)I ARG 0 first ARG 1 second METHOD method_27764 getArgb (IIII)I + COMMENT {@return the ARGB color value from its components} ARG 0 alpha ARG 1 red ARG 2 green ARG 3 blue METHOD method_27765 getRed (I)I + COMMENT {@return the red value of {@code argb}} + COMMENT + COMMENT

The returned value is between {@code 0} and {@code 255} (both inclusive). ARG 0 argb METHOD method_27766 getGreen (I)I + COMMENT {@return the green value of {@code argb}} + COMMENT + COMMENT

The returned value is between {@code 0} and {@code 255} (both inclusive). ARG 0 argb METHOD method_27767 getBlue (I)I + COMMENT {@return the blue value of {@code argb}} + COMMENT + COMMENT

The returned value is between {@code 0} and {@code 255} (both inclusive). ARG 0 argb diff --git a/mappings/net/minecraft/util/math/Direction.mapping b/mappings/net/minecraft/util/math/Direction.mapping index 25b47b958c..ef3a621e28 100644 --- a/mappings/net/minecraft/util/math/Direction.mapping +++ b/mappings/net/minecraft/util/math/Direction.mapping @@ -1,4 +1,9 @@ CLASS net/minecraft/class_2350 net/minecraft/util/math/Direction + COMMENT An enum representing 6 cardinal directions in Minecraft. + COMMENT + COMMENT

In Minecraft, the X axis determines the east-west direction, the Y axis determines + COMMENT the up-down direction, and the Z axis determines the south-north direction (note + COMMENT that positive-Z direction is south, not north). FIELD field_11030 idHorizontal I FIELD field_11031 idOpposite I FIELD field_11032 id I @@ -64,6 +69,8 @@ CLASS net/minecraft/class_2350 net/minecraft/util/math/Direction METHOD method_10165 getOffsetZ ()I METHOD method_10166 getAxis ()Lnet/minecraft/class_2350$class_2351; METHOD method_10168 byName (Ljava/lang/String;)Lnet/minecraft/class_2350; + COMMENT {@return a direction with the given {@code name}, or {@code null} if there is + COMMENT no such direction} ARG 0 name METHOD method_10169 from (Lnet/minecraft/class_2350$class_2351;Lnet/minecraft/class_2350$class_2352;)Lnet/minecraft/class_2350; ARG 0 axis @@ -108,6 +115,7 @@ CLASS net/minecraft/class_2350 net/minecraft/util/math/Direction ARG 0 direction METHOD method_42013 stream ()Ljava/util/stream/Stream; METHOD method_42014 shuffle (Lnet/minecraft/class_5819;)Ljava/util/Collection; + COMMENT {@return a shuffled collection of all directions} ARG 0 random CLASS class_2351 Axis FIELD field_11053 name Ljava/lang/String; diff --git a/mappings/net/minecraft/util/math/MathHelper.mapping b/mappings/net/minecraft/util/math/MathHelper.mapping index ff2d8fffce..8d8a1835d3 100644 --- a/mappings/net/minecraft/util/math/MathHelper.mapping +++ b/mappings/net/minecraft/util/math/MathHelper.mapping @@ -1,4 +1,9 @@ CLASS net/minecraft/class_3532 net/minecraft/util/math/MathHelper + COMMENT Contains math-related helper methods. This includes {@code float}-specific extensions + COMMENT to {@link Math}, linear interpolation (lerp), and color-related methods. + COMMENT + COMMENT

Trigonometric functions defined in this class use the "sine table", a pre-calculated + COMMENT table of {@code sin(N)} ({@code 0 <= N < pi * 2}). FIELD field_15722 COSINE_TABLE [D FIELD field_15723 MULTIPLY_DE_BRUIJN_BIT_POSITION [I FIELD field_15724 SQUARE_ROOT_OF_TWO F