Skip to content

Commit

Permalink
Forge port 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TonimatasDEV committed Sep 21, 2023
1 parent 3350fc0 commit cb8eaaf
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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))
private int newSize(int value) {
@ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 1048576))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

@Mixin(value = ClientboundCustomQueryPacket.class, priority = 9999)
public class ClientboundCustomQueryPacketMixin {
@ModifyConstant(method = "<init>(Lnet/minecraft/network/FriendlyByteBuf;)V", constant = @Constant(intValue = 1048576))
private int newSize(int value) {
@ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 1048576))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ public abstract class NbtAccounterMixin {
//}

// >= 1.19
@Redirect(method = "accountBytes", at = @At(value = "FIELD", target = "Lnet/minecraft/nbt/NbtAccounter;quota:J", opcode = Opcodes.GETFIELD))
//@Redirect(method = "accountBytes", at = @At(value = "FIELD", target = "Lnet/minecraft/nbt/NbtAccounter;quota:J", opcode = Opcodes.GETFIELD))
//public long accountBits(NbtAccounter instance) {
// return Long.MAX_VALUE;
//}

@Redirect(method = "accountBytes(J)V", at = @At(value = "FIELD", target = "Lnet/minecraft/nbt/NbtAccounter;quota:J", opcode = Opcodes.GETFIELD))
public long accountBits(NbtAccounter instance) {
return Long.MAX_VALUE;
}
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.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))
private int newSize(int value) {
@ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 32767))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
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 {
// <= 1.18
//@ModifyConstant(method = "<init>(Lnet/minecraft/network/FriendlyByteBuf;)V", constant = @Constant(intValue = 1048576))
//private int newSize(int value) {
// return Integer.MAX_VALUE;
//}

// >= 1.19
@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()));
// 1.19 to 1.20.1
//@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()));
//}

// >= 1.20.2
@ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 1048576))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ modVersion=1.1.7
# --------------------------------- 1.20.1

minecraftVersion=1.20.2
forgeVersion=47.1.44
forgeVersionRange=47
forgeVersion=48.0.0
forgeVersionRange=48
loaderVersion=0.14.22
yarnMappings=1.20.2+build.1

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ pluginManagement {
}
}

include("fabric", /*"forge"*/)
include("fabric", "forge")
rootProject.name = "PacketFixer"

0 comments on commit cb8eaaf

Please sign in to comment.