Skip to content

Commit

Permalink
Rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
TonimatasDEV committed Dec 8, 2023
1 parent 4f595a9 commit e504ae2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,15 @@
package net.tonimatasdev.packetfixerforge.mixin;


import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(value = ClientboundCustomPayloadPacket.class, priority = 9999)
public class ClientboundCustomPayloadPacketMixin {
@Shadow @Final private static int MAX_PAYLOAD_SIZE;

/**
* @author TonimatasDEV
* @reason Temporally fix payload problems.
*/
@Overwrite
private static net.neoforged.neoforge.network.custom.payload.SimplePayload readUnknownPayload(ResourceLocation p_295991_, FriendlyByteBuf p_295803_) {
int i = p_295803_.readableBytes();
if (i >= 0 && (i <= MAX_PAYLOAD_SIZE || true)) {
return net.neoforged.neoforge.network.custom.payload.SimplePayload.inbound(p_295803_, p_295991_);
} else {
throw new IllegalArgumentException("Payload may not be larger than 1048576 bytes");
}
@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
@@ -1,30 +1,14 @@
package net.tonimatasdev.packetfixerforge.mixin;

import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.login.ClientboundCustomQueryPacket;
import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = ClientboundCustomQueryPacket.class, priority = 9999)
public class ClientboundCustomQueryPacketMixin {
@Shadow @Final private static int MAX_PAYLOAD_SIZE;

/**
* @author TonimatasDEV
* @reason Temporally fix payload problems.
*/
@Overwrite
private static net.neoforged.neoforge.network.custom.payload.SimpleQueryPayload readUnknownPayload(ResourceLocation p_294837_, FriendlyByteBuf p_296380_) {
int i = p_296380_.readableBytes();
if (i >= 0 && (i <= MAX_PAYLOAD_SIZE || true)) {
return net.neoforged.neoforge.network.custom.payload.SimpleQueryPayload.inbound(p_296380_, p_294837_);
} else {
throw new IllegalArgumentException("Payload may not be larger than 1048576 bytes");
}
@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
@@ -1,30 +1,14 @@
package net.tonimatasdev.packetfixerforge.mixin;

import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = ServerboundCustomPayloadPacket.class, priority = 9999)
public class ServerboundCustomPayloadPacketMixin {
@Shadow @Final private static int MAX_PAYLOAD_SIZE;

/**
* @author TonimatasDEV
* @reason Temporally fix payload problems.
*/
@Overwrite
private static net.neoforged.neoforge.network.custom.payload.SimplePayload readUnknownPayload(ResourceLocation p_294973_, FriendlyByteBuf p_296037_) {
int i = p_296037_.readableBytes();
if (i >= 0 && (i <= MAX_PAYLOAD_SIZE || true)) {
return net.neoforged.neoforge.network.custom.payload.SimplePayload.inbound(p_296037_, p_294973_);
} else {
throw new IllegalArgumentException("Payload may not be larger than 32767 bytes");
}
@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,32 +1,14 @@
package net.tonimatasdev.packetfixerforge.mixin;

import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.login.ServerboundCustomQueryAnswerPacket;
import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = ServerboundCustomQueryAnswerPacket.class, priority = 9999)
public class ServerboundCustomQueryPacketMixin {
@Shadow
@Final
private static int MAX_PAYLOAD_SIZE;

/**
* @author TonimatasDEV
* @reason Temporally fix payload problems.
*/
@Overwrite
private static net.neoforged.neoforge.network.custom.payload.SimpleQueryPayload readUnknownPayload(FriendlyByteBuf p_294928_) {
int i = p_294928_.readableBytes();
if (i >= 0 && (i <= MAX_PAYLOAD_SIZE || true)) {
return p_294928_.readNullable(net.neoforged.neoforge.network.custom.payload.SimpleQueryPayload::inbound);
} else {
throw new IllegalArgumentException("Payload may not be larger than 1048576 bytes");
}
@ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 1048576))
private static int newSize(int value) {
return Integer.MAX_VALUE;
}
}

0 comments on commit e504ae2

Please sign in to comment.