Some network stuff, and minor atomic stack/affine transformation revisit (#2246)

* Some network stuff, and minor atomic stack/affine transformation revisit

Signed-off-by: liach <liach@users.noreply.github.com>

* typos

Signed-off-by: liach <liach@users.noreply.github.com>

* Let unpick glitch. I'm hopeless

* End of experiment

the uncommented ones work while the commented ones don't

Turns out unpick is unpicking what's exposed to the public api than
what's in the method body. So yeah, not much valuable stuff to unpick
in network package as a result.

Signed-off-by: liach <liach@users.noreply.github.com>

Co-authored-by: liach <liach@users.noreply.github.com>
This commit is contained in:
liach 2021-04-03 21:02:25 +07:00 committed by GitHub
parent 9d9739c2ad
commit 0bc94eeaeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 144 additions and 25 deletions

View File

@ -25,6 +25,13 @@ CLASS net/minecraft/class_2535 net/minecraft/network/ClientConnection
FIELD field_11657 EPOLL_CLIENT_IO_GROUP Lnet/minecraft/class_3528;
FIELD field_11658 packetsReceivedCounter I
FIELD field_11660 disconnectReason Lnet/minecraft/class_2561;
FIELD field_33280 CURRENT_PACKET_COUNTER_WEIGHT F
COMMENT Represents when the average packet counter is updated, what percent of the
COMMENT value of the average counter is set from the current counter.
COMMENT
COMMENT <p>The formula is {@link #averagePacketsSent averagePacketsSent} = {@value}
COMMENT &times; {@link #packetsSentCounter packetsSentCounter} + (1 - {@value}) &times;
COMMENT {@code averagePacketsSent}.
METHOD <init> (Lnet/minecraft/class_2598;)V
ARG 1 side
METHOD channelActive (Lio/netty/channel/ChannelHandlerContext;)V
@ -84,6 +91,12 @@ CLASS net/minecraft/class_2535 net/minecraft/network/ClientConnection
METHOD method_30615 updateStats ()V
METHOD method_32306 getState ()Lnet/minecraft/class_2539;
COMMENT Returns the current network state of this connection.
METHOD method_36121 getSide ()Lnet/minecraft/class_2598;
COMMENT Returns the side of this connection, or the direction of the packets received
COMMENT by this connection.
METHOD method_36122 getOppositeSide ()Lnet/minecraft/class_2598;
COMMENT Returns the opposite side of this connection, or the direction of the packets
COMMENT sent by this connection.
CLASS class_2536 QueuedPacket
FIELD field_11661 packet Lnet/minecraft/class_2596;
FIELD field_11662 callback Lio/netty/util/concurrent/GenericFutureListener;

View File

@ -1 +1,2 @@
CLASS net/minecraft/class_2598 net/minecraft/network/NetworkSide
METHOD method_36146 getOpposite ()Lnet/minecraft/class_2598;

View File

@ -3,6 +3,8 @@ CLASS net/minecraft/class_2539 net/minecraft/network/NetworkState
FIELD field_11693 STATES [Lnet/minecraft/class_2539;
FIELD field_20594 stateId I
FIELD field_20595 packetHandlers Ljava/util/Map;
FIELD field_33281 NULL_PACKET_ID_OR_MIN_STATE_ID I
FIELD field_33282 MAX_STATE_ID I
METHOD <init> (Ljava/lang/String;IILnet/minecraft/class_2539$class_4533;)V
ARG 3 id
METHOD method_10781 getPacketId (Lnet/minecraft/class_2598;Lnet/minecraft/class_2596;)Ljava/lang/Integer;
@ -33,3 +35,4 @@ CLASS net/minecraft/class_2539 net/minecraft/network/NetworkState
FIELD field_20598 packetHandlers Ljava/util/Map;
METHOD method_22315 setup (Lnet/minecraft/class_2598;Lnet/minecraft/class_2539$class_4532;)Lnet/minecraft/class_2539$class_4533;
ARG 1 side
ARG 2 handler

View File

@ -33,7 +33,10 @@ CLASS net/minecraft/class_2540 net/minecraft/network/PacketByteBuf
COMMENT <td>{@link BlockPos}</td><td>{@link #readBlockPos()}</td><td>{@link #writeBlockPos(BlockPos)}</td>
COMMENT </tr>
COMMENT <tr>
COMMENT <td>{@link ChunkSectionPos}</td><td>{@link #readChunkSectionPos()}</td><td>(removed by proguard)</td>
COMMENT <td>{@link ChunkPos}</td><td>{@link #readChunkPos()}</td><td>{@link #writeChunkPos(ChunkPos)}</td>
COMMENT </tr>
COMMENT <tr>
COMMENT <td>{@link ChunkSectionPos}</td><td>{@link #readChunkSectionPos()}</td><td>{@link #writeChunkSectionPos(ChunkSectionPos)}</td>
COMMENT </tr>
COMMENT <tr>
COMMENT <td>{@link Text}</td><td>{@link #readText()}</td><td>{@link #writeText(Text)}</td>
@ -77,6 +80,29 @@ CLASS net/minecraft/class_2540 net/minecraft/network/PacketByteBuf
COMMENT IndexOutOfBoundsException} if there is not enough bytes to be read or
COMMENT not enough space to write.
FIELD field_11695 parent Lio/netty/buffer/ByteBuf;
FIELD field_33283 DEFAULT_MAX_STRING_LENGTH S
COMMENT The default max length of strings {@linkplain #readString() read} or {@linkplain
COMMENT #writeString(String) written}. This is also the max length of identifiers
COMMENT {@linkplain #readIdentifier() read} or {@linkplain #writeIdentifier(Identifier)
COMMENT written} in their string form.
FIELD field_33284 MAX_TEXT_LENGTH I
COMMENT The maximum size, in terms of JSON string length, allowed of the text read by
COMMENT {@link #readText()} or written by {@link #writeText(Text)}.
FIELD field_33285 MAX_VAR_INT_LENGTH I
COMMENT The max number of bytes an encoded var int value may use.
COMMENT
COMMENT <p>Its value is {@value}. A regular int value always use 4 bytes in contrast.
COMMENT
COMMENT @see #getVarIntLength(int)
FIELD field_33286 MAX_VAR_LONG_LENGTH I
COMMENT The max number of bytes an encoded var long value may use.
COMMENT
COMMENT <p>Its value is {@value}. A regular long value always use 8 bytes in contrast.
COMMENT
COMMENT @see #getVarLongLength(long)
FIELD field_33287 MAX_READ_NBT_SIZE I
COMMENT The maximum size, in number of bytes, allowed of the NBT compound read by
COMMENT {@link #readNbt()}.
METHOD <init> (Lio/netty/buffer/ByteBuf;)V
COMMENT Creates a packet byte buf that delegates its operations to the {@code
COMMENT parent} buf.
@ -131,6 +157,7 @@ CLASS net/minecraft/class_2540 net/minecraft/network/PacketByteBuf
COMMENT
COMMENT @return this buf, for chaining
COMMENT @see #readVarLong()
COMMENT @see #getVarLongLength(long)
ARG 1 value
COMMENT the value to write
METHOD method_10792 readVarLong ()J
@ -187,9 +214,9 @@ CLASS net/minecraft/class_2540 net/minecraft/network/PacketByteBuf
COMMENT the UUID to write
METHOD method_10798 readNbt ()Lnet/minecraft/class_2487;
COMMENT Reads an NBT compound from this buf. The binary representation of NBT is
COMMENT handled by {@link net.minecraft.nbt.NbtIo}. If an Nbt null is encountered,
COMMENT handled by {@link net.minecraft.nbt.NbtIo}. If an NBT null is encountered,
COMMENT this method returns {@code null}. The compound can have a maximum size of
COMMENT {@code 2097152} bytes.
COMMENT {@value #MAX_READ_NBT_SIZE} bytes.
COMMENT
COMMENT @return the read compound, may be {@code null}
COMMENT @throws io.netty.handler.codec.EncoderException if the NBT cannot be read
@ -197,6 +224,7 @@ CLASS net/minecraft/class_2540 net/minecraft/network/PacketByteBuf
COMMENT @see #writeNbt(NbtCompound)
COMMENT @see #readUnlimitedNbt()
COMMENT @see #readNbt(NbtTagSizeTracker)
COMMENT @see #MAX_READ_NBT_SIZE
METHOD method_10799 readIntArray (I)[I
COMMENT Reads an array of primitive ints from this buf. The array first has a
COMMENT var int indicating its length, followed by the var int entries. The array
@ -266,16 +294,18 @@ CLASS net/minecraft/class_2540 net/minecraft/network/PacketByteBuf
COMMENT
COMMENT @return this buf, for chaining
COMMENT @see #readVarInt()
COMMENT @see #getVarIntLength(int)
ARG 1 value
COMMENT the value to write
METHOD method_10805 writeText (Lnet/minecraft/class_2561;)Lnet/minecraft/class_2540;
COMMENT Writes a text to this buf. A text is represented by a JSON string with
COMMENT max length {@code 262144}.
COMMENT max length {@value #MAX_TEXT_LENGTH}.
COMMENT
COMMENT @return this buf, for chaining
COMMENT @throws io.netty.handler.codec.EncoderException if the JSON string
COMMENT written exceeds {@code 262144} in length
COMMENT written exceeds {@value #MAX_TEXT_LENGTH} in length
COMMENT @see #readText()
COMMENT @see #MAX_TEXT_LENGTH
ARG 1 text
COMMENT the text to write
METHOD method_10806 writeIntArray ([I)Lnet/minecraft/class_2540;
@ -300,12 +330,13 @@ CLASS net/minecraft/class_2540 net/minecraft/network/PacketByteBuf
COMMENT the pos to write
METHOD method_10808 readText ()Lnet/minecraft/class_2561;
COMMENT Reads a text from this buf. A text is represented by a JSON string with
COMMENT max length {@code 262144}.
COMMENT max length {@value #MAX_TEXT_LENGTH}.
COMMENT
COMMENT @return the read text
COMMENT @throws io.netty.handler.codec.DecoderException if the JSON string read
COMMENT exceeds {@code 262144} in length
COMMENT exceeds {@value #MAX_TEXT_LENGTH} in length
COMMENT @see #writeText(Text)
COMMENT @see #MAX_TEXT_LENGTH
METHOD method_10809 readLongArray ([JI)[J
COMMENT Reads an array of primitive longs from this buf. The array first has a
COMMENT var int indicating its length, followed by the regular long (not var
@ -329,11 +360,11 @@ CLASS net/minecraft/class_2540 net/minecraft/network/PacketByteBuf
METHOD method_10810 readIdentifier ()Lnet/minecraft/class_2960;
COMMENT Reads an identifier from this buf. An identifier is represented by its
COMMENT string form. The read identifier's string form can have a max length of
COMMENT {@code 32767}.
COMMENT {@value #DEFAULT_MAX_STRING_LENGTH}.
COMMENT
COMMENT @return the read identifier
COMMENT @throws io.netty.handler.codec.DecoderException if the identifier's
COMMENT string form is longer than {@code 32767}
COMMENT string form is longer than {@value #DEFAULT_MAX_STRING_LENGTH}
COMMENT @see #writeIdentifier(Identifier)
METHOD method_10811 readBlockPos ()Lnet/minecraft/class_2338;
COMMENT Reads a block position from this buf. A block position is represented by
@ -344,11 +375,11 @@ CLASS net/minecraft/class_2540 net/minecraft/network/PacketByteBuf
METHOD method_10812 writeIdentifier (Lnet/minecraft/class_2960;)Lnet/minecraft/class_2540;
COMMENT Writes an identifier to this buf. An identifier is represented by its
COMMENT string form. The written identifier's byte array can have a max length of
COMMENT {@code 32767}.
COMMENT {@value #DEFAULT_MAX_STRING_LENGTH}.
COMMENT
COMMENT @return the read identifier
COMMENT @throws io.netty.handler.codec.EncoderException if the {@code id}'s
COMMENT byte array is longer than {@code 32767}
COMMENT byte array is longer than {@value #DEFAULT_MAX_STRING_LENGTH}
COMMENT @see #readIdentifier()
ARG 1 id
COMMENT the identifier to write
@ -363,20 +394,20 @@ CLASS net/minecraft/class_2540 net/minecraft/network/PacketByteBuf
METHOD method_10814 writeString (Ljava/lang/String;)Lnet/minecraft/class_2540;
COMMENT Writes a string to this buf. A string is represented by a byte array of
COMMENT its UTF-8 data. That byte array can have a maximum length of
COMMENT {@code 32767}.
COMMENT {@value #DEFAULT_MAX_STRING_LENGTH}.
COMMENT
COMMENT @return this buf, for chaining
COMMENT @throws io.netty.handler.codec.EncoderException if the byte array of the
COMMENT string to write is longer than {@code 32767}
COMMENT string to write is longer than {@value #DEFAULT_MAX_STRING_LENGTH}
COMMENT @see #readString()
COMMENT @see #readString(int)
COMMENT @see #writeString(String, int)
ARG 1 string
COMMENT the string to write
METHOD method_10815 getVarIntSizeBytes (I)I
METHOD method_10815 getVarIntLength (I)I
COMMENT Returns the number of bytes needed to encode {@code value} as a
COMMENT {@linkplain #writeVarInt(int) var int}. Guaranteed to be between {@code
COMMENT 1} and {@code 5}.
COMMENT 1} and {@value #MAX_VAR_INT_LENGTH}.
COMMENT
COMMENT @return the number of bytes a var int {@code value} uses
ARG 0 value
@ -429,14 +460,12 @@ CLASS net/minecraft/class_2540 net/minecraft/network/PacketByteBuf
COMMENT Reads a chunk section position from this buf. A chunk section position is
COMMENT represented by a regular long.
COMMENT
COMMENT @apiNote The writing equivalent has been removed by proguard as chunk
COMMENT section writing is only used by debug rendering. The writing equivalent
COMMENT would be {@code buf.writeLong(chunkSectionPos.toLong())}.
COMMENT
COMMENT @return the read chunk section pos
COMMENT @see #writeChunkSectionPos(ChunkSectionPos)
METHOD method_19772 readString ()Ljava/lang/String;
COMMENT Reads a string from this buf. A string is represented by a byte array of
COMMENT its UTF-8 data. The string can have a maximum length of {@code 32767}.
COMMENT its UTF-8 data. The string can have a maximum length of {@value
COMMENT #DEFAULT_MAX_STRING_LENGTH}.
COMMENT
COMMENT @return the string read
COMMENT @throws io.netty.handler.codec.DecoderException if the string read
@ -619,3 +648,36 @@ CLASS net/minecraft/class_2540 net/minecraft/network/PacketByteBuf
COMMENT a parser that parses each key for the map given this buf
ARG 3 valueParser
COMMENT a parser that parses each value for the map given this buf
METHOD method_36129 getVarLongLength (J)I
COMMENT Returns the number of bytes needed to encode {@code value} as a
COMMENT {@linkplain #writeVarLong(int) var long}. Guaranteed to be between {@code
COMMENT 1} and {@value #MAX_VAR_LONG_LENGTH}.
COMMENT
COMMENT @return the number of bytes a var long {@code value} uses
ARG 0 value
COMMENT the value to encode
METHOD method_36130 writeChunkPos (Lnet/minecraft/class_1923;)Lnet/minecraft/class_2540;
COMMENT Writes a chunk position to this buf. A chunk position is represented by
COMMENT a regular long.
COMMENT
COMMENT @return this buf, for chaining
COMMENT @see #readChunkPos()
ARG 1 pos
COMMENT the chunk position to write
METHOD method_36131 writeChunkSectionPos (Lnet/minecraft/class_4076;)Lnet/minecraft/class_2540;
COMMENT Reads a chunk section position from this buf. A chunk section position is
COMMENT represented by a regular long.
COMMENT
COMMENT @return this buf, for chaining
COMMENT @see #readChunkSectionPos()
ARG 1 pos
COMMENT the section position to write
METHOD method_36132 getWrittenBytes ()[B
COMMENT Returns an array of bytes of contents in this buf between index {@code 0} and
COMMENT the {@link #writerIndex()}.
METHOD method_36133 readChunkPos ()Lnet/minecraft/class_1923;
COMMENT Reads a chunk position from this buf. A chunk position is represented by
COMMENT a regular long.
COMMENT
COMMENT @return the read chunk position
COMMENT @see #writeChunkPos(ChunkPos)

View File

@ -2,5 +2,8 @@ CLASS net/minecraft/class_2534 net/minecraft/network/PacketDeflater
FIELD field_11636 compressionThreshold I
FIELD field_11637 deflateBuffer [B
FIELD field_11638 deflater Ljava/util/zip/Deflater;
METHOD <init> (I)V
ARG 1 compressionThreshold
METHOD method_10742 setCompressionThreshold (I)V
ARG 1 compressionThreshold
METHOD method_36120 getCompressionThreshold ()I

View File

@ -1,7 +1,10 @@
CLASS net/minecraft/class_2532 net/minecraft/network/PacketInflater
FIELD field_11622 inflater Ljava/util/zip/Inflater;
FIELD field_11623 compressionThreshold I
FIELD field_33279 MAXIMUM_PACKET_SIZE I
COMMENT The maximum size allowed for a compressed packet. Has value {@value}.
METHOD <init> (I)V
ARG 1 compressionThreshold
METHOD method_10739 setCompressionThreshold (I)V
ARG 1 compressionThreshold
METHOD method_36119 getCompressionThreshold ()I

View File

@ -1 +1,4 @@
CLASS net/minecraft/class_2552 net/minecraft/network/SizePrepender
FIELD field_33288 MAX_PREPEND_LENGTH I
COMMENT The max length, in number of bytes, of the prepending size var int permitted.
COMMENT Has value {@value}.

View File

@ -1,6 +1,11 @@
CLASS net/minecraft/class_4590 net/minecraft/util/math/AffineTransformation
COMMENT @implNote Even though this is used only on the client, it accesses protected
COMMENT fields from {@link Matrix4f}, which requires them to be in the same package.
COMMENT An affine transformation is a decomposition of a 4&times;4 real matrix into
COMMENT a {@linkplain #rotation1 rotation} quaternion, a {@linkplain #scale scale}
COMMENT 3-vector, a second {@linkplain #rotation2 rotation} quaternion, and a
COMMENT {@linkplain #translation translation} 3-vector. It is also known as "TRSR"
COMMENT transformation, meaning "translation rotation scale rotation".
COMMENT
COMMENT <p>This class is immutable; its matrix is lazily decomposed upon demand.
FIELD field_20900 matrix Lnet/minecraft/class_1159;
FIELD field_20901 initialized Z
FIELD field_20902 translation Lnet/minecraft/class_1160;
@ -29,3 +34,6 @@ CLASS net/minecraft/class_4590 net/minecraft/util/math/AffineTransformation
METHOD method_22936 getMatrix ()Lnet/minecraft/class_1159;
METHOD method_22937 getRotation2 ()Lnet/minecraft/class_1158;
METHOD method_22938 init ()V
METHOD method_35865 getTranslation ()Lnet/minecraft/class_1160;
METHOD method_35866 getScale ()Lnet/minecraft/class_1160;
METHOD method_35867 getRotation1 ()Lnet/minecraft/class_1158;

View File

@ -3,11 +3,12 @@ CLASS net/minecraft/class_5831 net/minecraft/util/thread/AtomicStack
COMMENT an object. When the stack is full on addition, it overrides the earliest
COMMENT content in the stack.
COMMENT
COMMENT @apiNote This class has final fields but its constructor has been removed
COMMENT by proguard, so it's not easily usable. Vanilla uses this for debugging
COMMENT purpose on paletted container and chunk holder's asynchronous access checks.
COMMENT @apiNote Vanilla uses this for debugging purpose on paletted container and
COMMENT chunk holder's asynchronous access checks.
FIELD field_28810 contents Ljava/util/concurrent/atomic/AtomicReferenceArray;
FIELD field_28811 size Ljava/util/concurrent/atomic/AtomicInteger;
METHOD <init> (I)V
ARG 1 maxSize
METHOD method_33720 toList ()Ljava/util/List;
COMMENT Builds a list of the contents of the stack.
COMMENT

View File

@ -0,0 +1,22 @@
v2
# value and desc specified because unpick is too dumb to handle auto conversions (short -> int, int -> long)
constant max_string_length net/minecraft/network/PacketByteBuf DEFAULT_MAX_STRING_LENGTH 32767 I
constant max_string_length net/minecraft/network/PacketByteBuf MAX_TEXT_LENGTH
#constant max_nbt_size net/minecraft/network/PacketByteBuf MAX_READ_NBT_SIZE 2097152 J
constant max_var_int_length net/minecraft/network/PacketByteBuf MAX_VAR_INT_LENGTH
constant max_var_long_length net/minecraft/network/PacketByteBuf MAX_VAR_LONG_LENGTH
target_method net/minecraft/network/PacketByteBuf readString (I)Ljava/lang/String;
param 0 max_string_length
target_method net/minecraft/network/PacketByteBuf writeString (Ljava/lang/String;I)Lnet/minecraft/network/PacketByteBuf;
param 1 max_string_length
# somehow does not work
#target_method net/minecraft/nbt/NbtTagSizeTracker <init> (J)V
# param 0 max_nbt_size
target_method net/minecraft/network/PacketByteBuf getVarIntLength (I)I
return max_var_int_length
target_method net/minecraft/network/PacketByteBuf getVarLongLength (J)I
return max_var_long_length
# var int/long length also used in readVarXx method body, but unpick cannot replace them