Fix SplitPacketTransformer not saving enough space for packet id (#273)

[norelease] to avoid an unnecessary release before merging the biome context PR

(cherry picked from commit 796ee4fc14)
This commit is contained in:
shedaniel
2022-06-09 19:16:14 +08:00
committed by Max
parent d8cf9ed7a5
commit 7e69108b79

View File

@@ -35,6 +35,7 @@ import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import java.nio.charset.StandardCharsets;
import java.util.*;
@ApiStatus.Experimental
@@ -179,7 +180,7 @@ public class SplitPacketTransformer implements PacketTransformer {
@Override
public void outbound(NetworkManager.Side side, ResourceLocation id, FriendlyByteBuf buf, TransformationSink sink) {
int maxSize = (side == NetworkManager.Side.C2S ? 32767 : 1048576) - 1 - 20;
int maxSize = (side == NetworkManager.Side.C2S ? 32767 : 1048576) - 1 - 20 - id.toString().getBytes(StandardCharsets.UTF_8).length;
if (buf.readableBytes() <= maxSize) {
ByteBuf stateBuf = Unpooled.buffer(1);
stateBuf.writeByte(ONLY);