Skip to content

Commit

Permalink
Fix the memory leak in a different way
Browse files Browse the repository at this point in the history
Specifically, the way vanilla works.
  • Loading branch information
astei committed Mar 9, 2022
1 parent c22b394 commit 90d1cc4
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.steinborn.krypton.mixin.shared.bugfix;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -10,8 +11,8 @@
@Mixin(CustomPayloadS2CPacket.class)
public class CustomPayloadS2CPacketFixMemoryLeakMixin {

@Redirect(method = "getData", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;copy()Lio/netty/buffer/ByteBuf;"))
private ByteBuf getData$copyShouldBeSlice(PacketByteBuf instance) {
return instance.slice();
@Redirect(method = "<init>(Lnet/minecraft/network/PacketByteBuf;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;readBytes(I)Lio/netty/buffer/ByteBuf;"))
private ByteBuf getData$copyShouldBeSlice(PacketByteBuf instance, int length) {
return Unpooled.copiedBuffer(instance.readSlice(length));
}
}

0 comments on commit 90d1cc4

Please sign in to comment.