Skip to content

Commit

Permalink
Port 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TonimatasDEV committed Nov 6, 2023
1 parent a9c1c6f commit 6342f14
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package net.tonimatasdev.packetfixerfabric.mixin;


import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = CustomPayloadC2SPacket.class, priority = 9999)
public class CustomPayloadC2SPacketMixin {
@ModifyConstant(method = "<init>(Lnet/minecraft/network/PacketByteBuf;)V", constant = @Constant(intValue = 32767))
@ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 32767))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package net.tonimatasdev.packetfixerfabric.mixin;

import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = CustomPayloadS2CPacket.class, priority = 9999)
public class CustomPayloadS2CPacketMixin {
@ModifyConstant(method = "<init>*", constant = @Constant(intValue = 1048576))
@ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 1048576))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Mixin(value = LoginQueryRequestS2CPacket.class, priority = 9999)
public class LoginQueryRequestS2CPacketMixin {
@ModifyConstant(method = "<init>(Lnet/minecraft/network/PacketByteBuf;)V", constant = @Constant(intValue = 1048576))
@ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 1048576))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package net.tonimatasdev.packetfixerfabric.mixin;

import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.c2s.login.LoginQueryResponseC2SPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = LoginQueryResponseC2SPacket.class, priority = 9999)
public class LoginQueryResponseC2SPacketMixin {
@ModifyVariable(method = "<init>(Lnet/minecraft/network/PacketByteBuf;)V", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/network/PacketByteBuf;readNullable(Lnet/minecraft/network/PacketByteBuf$PacketReader;)Ljava/lang/Object;"), index = 1, argsOnly = true)
private PacketByteBuf redirectReadNullable(PacketByteBuf value) {
return new PacketByteBuf(value.readBytes(value.readableBytes()));
@ModifyConstant(method = "getVanillaPayload", constant = @Constant(intValue = 1048576))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.tonimatasdev.packetfixerfabric.mixin;

import net.minecraft.network.PacketEncoder;
import net.minecraft.network.handler.PacketEncoder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.tonimatasdev.packetfixerfabric.mixin;

import net.minecraft.network.PacketInflater;
import net.minecraft.network.handler.PacketInflater;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.tonimatasdev.packetfixerfabric.mixin;

import net.minecraft.network.SizePrepender;
import net.minecraft.network.handler.SizePrepender;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
package net.tonimatasdev.packetfixerfabric.mixin;

import net.minecraft.network.SplitterHandler;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.network.handler.SplitterHandler;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = SplitterHandler.class, priority = 9999)
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) {
@ModifyConstant(method = "shouldSplit", constant = @Constant(intValue = 3))
private static int newSize(int value) {
return 8;
}

@Inject(method = "handlerRemoved0", at = @At(value = "HEAD"), cancellable = true)
private void redirectReadNullable(ChannelHandlerContext p_299287_, CallbackInfo ci) {
Unpooled.directBuffer(8).release();
ci.cancel();
}

@Redirect(method = "decode", at = @At(value = "FIELD", target = "Lnet/minecraft/network/handler/SplitterHandler;reusableBuf:Lio/netty/buffer/ByteBuf;", opcode = Opcodes.GETFIELD))
public ByteBuf accountBits(SplitterHandler instance) {
return Unpooled.directBuffer(8);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.tonimatasdev.packetfixerfabric.mixin.compat.connectivity;

import net.minecraft.network.PacketInflater;
import net.minecraft.network.handler.PacketInflater;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package net.tonimatasdev.packetfixerforge.mixin;


import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket;
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = ClientboundCustomPayloadPacket.class, priority = 9999)
public class ClientboundCustomPayloadPacketMixin {
@ModifyConstant(method = "<init>*", constant = @Constant(intValue = 1048576))
@ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 1048576))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Mixin(value = ClientboundCustomQueryPacket.class, priority = 9999)
public class ClientboundCustomQueryPacketMixin {
@ModifyConstant(method = "<init>(Lnet/minecraft/network/FriendlyByteBuf;)V", constant = @Constant(intValue = 1048576))
@ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 1048576))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package net.tonimatasdev.packetfixerforge.mixin;

import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = ServerboundCustomPayloadPacket.class, priority = 9999)
public class ServerboundCustomPayloadPacketMixin {
@ModifyConstant(method = "<init>(Lnet/minecraft/network/FriendlyByteBuf;)V", constant = @Constant(intValue = 32767))
@ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 32767))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package net.tonimatasdev.packetfixerforge.mixin;

import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.login.ServerboundCustomQueryPacket;
import net.minecraft.network.protocol.login.ServerboundCustomQueryAnswerPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = ServerboundCustomQueryPacket.class, priority = 9999)
@Mixin(value = ServerboundCustomQueryAnswerPacket.class, priority = 9999)
public class ServerboundCustomQueryPacketMixin {
@ModifyVariable(method = "<init>(Lnet/minecraft/network/FriendlyByteBuf;)V", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/network/FriendlyByteBuf;readNullable(Lnet/minecraft/network/FriendlyByteBuf$Reader;)Ljava/lang/Object;"), index = 1, argsOnly = true)
private FriendlyByteBuf redirectReadNullable(FriendlyByteBuf value) {
return new FriendlyByteBuf(value.readBytes(value.readableBytes()));
@ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 1048576))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.tonimatasdev.packetfixerforge.mixin;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.network.Varint21FrameDecoder;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Varint21FrameDecoder.class)
public class Varint21FrameDecoderMixin {
@ModifyConstant(method = "copyVarint", constant = @Constant(intValue = 3))
private static int newSize(int value) {
return 8;
}

@Inject(method = "handlerRemoved0", at = @At(value = "HEAD"), cancellable = true)
private void redirectReadNullable(ChannelHandlerContext p_299287_, CallbackInfo ci) {
Unpooled.directBuffer(8).release();
ci.cancel();
}

@Redirect(method = "decode", at = @At(value = "FIELD", target = "Lnet/minecraft/network/Varint21FrameDecoder;helperBuf:Lio/netty/buffer/ByteBuf;", opcode = Opcodes.GETFIELD))
public ByteBuf accountBits(Varint21FrameDecoder instance) {
return Unpooled.directBuffer(8);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(Varint21LengthFieldPrepender.class)
public class SizePrependerMixin {
public class Varint21LengthFieldPrependerMixin {
@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;
Expand Down
4 changes: 2 additions & 2 deletions forge/src/main/resources/packetfixer.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"PacketEncoderMixin",
"ServerboundCustomPayloadPacketMixin",
"ServerboundCustomQueryPacketMixin",
"SizePrependerMixin",
"SplitterHandlerMixin",
"Varint21LengthFieldPrependerMixin",
"Varint21FrameDecoderMixin",
"compat.connectivity.CompressionDecoderMixin"
]
}
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.daemon=false
# Mod Properties
modVersion=1.1.9

minecraftVersion=1.19.4
forgeVersion=45.1.17
forgeVersionRange=45
loaderVersion=0.14.22
yarnMappings=1.19.4+build.2
minecraftVersion=1.20.2
forgeVersion=48.0.34
forgeVersionRange=48
loaderVersion=0.14.24
yarnMappings=1.20.2+build.4

0 comments on commit 6342f14

Please sign in to comment.