From 14f261a835106f208d1e77d9c107a44b050f592a Mon Sep 17 00:00:00 2001 From: Luke100000 Date: Wed, 18 Oct 2023 13:52:50 +0200 Subject: [PATCH] Fixed crash on very large packages --- .../mixin/SizePrependerMixin.java | 14 ++++++++++++++ .../mixin/SplitterHandlerMixin.java | 14 ++++++++++++++ fabric/src/main/resources/packetfixer.mixins.json | 2 ++ 3 files changed, 30 insertions(+) create mode 100644 fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SizePrependerMixin.java create mode 100644 fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SplitterHandlerMixin.java diff --git a/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SizePrependerMixin.java b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SizePrependerMixin.java new file mode 100644 index 0000000..507c108 --- /dev/null +++ b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SizePrependerMixin.java @@ -0,0 +1,14 @@ +package net.tonimatasdev.packetfixerfabric.mixin; + +import net.minecraft.network.SizePrepender; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(SizePrepender.class) +public class SizePrependerMixin { + @ModifyConstant(method = "encode(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Lio/netty/buffer/ByteBuf;)V", constant = @Constant(intValue = 3)) + private int newSize(int value) { + return 8; + } +} diff --git a/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SplitterHandlerMixin.java b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SplitterHandlerMixin.java new file mode 100644 index 0000000..c4e4ac3 --- /dev/null +++ b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SplitterHandlerMixin.java @@ -0,0 +1,14 @@ +package net.tonimatasdev.packetfixerfabric.mixin; + +import net.minecraft.network.SplitterHandler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(SplitterHandler.class) +public class SplitterHandlerMixin { + @ModifyConstant(method = "decode(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Ljava/util/List;)V", constant = @Constant(intValue = 3)) + private int newSize(int value) { + return 8; + } +} diff --git a/fabric/src/main/resources/packetfixer.mixins.json b/fabric/src/main/resources/packetfixer.mixins.json index 37de13a..6b91606 100644 --- a/fabric/src/main/resources/packetfixer.mixins.json +++ b/fabric/src/main/resources/packetfixer.mixins.json @@ -12,6 +12,8 @@ "NbtTagSizeTrackerMixin", "PacketEncoderMixin", "PacketInflaterMixin", + "SizePrependerMixin", + "SplitterHandlerMixin", "compat.connectivity.PacketInflaterMixin", "compat.immersiveportals.CustomPayloadS2CPacketMixin" ],