-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f595a9
commit e504ae2
Showing
4 changed files
with
12 additions
and
80 deletions.
There are no files selected for viewing
24 changes: 3 additions & 21 deletions
24
...ain/java/net/tonimatasdev/packetfixerforge/mixin/ClientboundCustomPayloadPacketMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
22 changes: 3 additions & 19 deletions
22
.../main/java/net/tonimatasdev/packetfixerforge/mixin/ClientboundCustomQueryPacketMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
22 changes: 3 additions & 19 deletions
22
...ain/java/net/tonimatasdev/packetfixerforge/mixin/ServerboundCustomPayloadPacketMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
24 changes: 3 additions & 21 deletions
24
.../main/java/net/tonimatasdev/packetfixerforge/mixin/ServerboundCustomQueryPacketMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |