├── .github └── workflows │ └── gradle.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts └── src │ └── main │ └── groovy │ ├── multiloader-common.gradle │ └── multiloader-loader.gradle ├── common ├── build.gradle.kts └── src │ └── main │ ├── java │ └── dev │ │ └── tonimatas │ │ └── packetfixer │ │ ├── PacketFixer.java │ │ ├── mixins │ │ ├── ClientboundCustomPayloadPacketMixin.java │ │ ├── ClientboundCustomQueryPacketMixin.java │ │ ├── ClientboundLevelChunkPacketDataMixin.java │ │ ├── CompressionDecoderMixin.java │ │ ├── CompressionEncoderMixin.java │ │ ├── ConnectionMixin.java │ │ ├── FriendlyByteBufMixin.java │ │ ├── ServerboundCustomPayloadPacketMixin.java │ │ ├── ServerboundCustomQueryPacketMixin.java │ │ ├── VarIntMixin.java │ │ ├── VarLongMixin.java │ │ ├── Varint21FrameDecoderMixin.java │ │ └── Varint21LengthFieldPrependerMixin.java │ │ └── util │ │ └── Config.java │ └── resources │ ├── icon.png │ └── packetfixer.common.mixins.json ├── fabric ├── build.gradle.kts └── src │ └── main │ ├── java │ └── dev │ │ └── tonimatas │ │ └── packetfixer │ │ ├── PacketFixerFabric.java │ │ └── mixins │ │ └── PayloadHelperMixin.java │ └── resources │ ├── fabric.mod.json │ ├── pack.mcmeta │ └── packetfixer.fabric.mixins.json ├── gradle.properties ├── gradle ├── gradle-daemon-jvm.properties └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── neoforge ├── build.gradle.kts ├── gradle.properties └── src │ └── main │ ├── java │ └── dev │ │ └── tonimatas │ │ └── packetfixer │ │ ├── PacketFixerNeoForge.java │ │ └── mixins │ │ └── MixinConfigPluginNeoForge.java │ └── resources │ ├── META-INF │ └── neoforge.mods.toml │ ├── pack.mcmeta │ └── packetfixer.neoforge.mixins.json └── settings.gradle.kts /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | name: Java with Gradle 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v4 13 | 14 | - name: Set up JDK 21 15 | uses: actions/setup-java@v4 16 | with: 17 | java-version: 21 18 | distribution: "temurin" 19 | 20 | - name: Give permissions to Gradle 21 | run: chmod +x ./gradlew 22 | 23 | - name: Build 24 | uses: gradle/gradle-build-action@v2 25 | with: 26 | arguments: build jar 27 | 28 | - name: Upload a Forge Artifacts 29 | uses: actions/upload-artifact@v4 30 | with: 31 | name: PacketFixerForge 32 | path: forge/build/libs/**.jar 33 | 34 | - name: Upload a Fabric Artifacts 35 | uses: actions/upload-artifact@v4 36 | with: 37 | name: PacketFixerFabric 38 | path: fabric/build/libs/**.jar 39 | 40 | - name: Upload a NeoForge Artifacts 41 | uses: actions/upload-artifact@v4 42 | with: 43 | name: PacketFixerNeoForge 44 | path: neoforge/build/libs/**.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | .idea/ 3 | 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 8 | # IntelliJ 9 | out/ 10 | # mpeltonen/sbt-idea plugin 11 | .idea_modules/ 12 | 13 | # JIRA plugin 14 | atlassian-ide-plugin.xml 15 | 16 | # Compiled class file 17 | *.class 18 | 19 | # Log file 20 | *.log 21 | 22 | # BlueJ files 23 | *.ctxt 24 | 25 | # Package Files # 26 | *.jar 27 | *.war 28 | *.nar 29 | *.ear 30 | *.zip 31 | *.tar.gz 32 | *.rar 33 | 34 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 35 | hs_err_pid* 36 | 37 | *~ 38 | 39 | # temporary files which can be created if a process still has a handle open of a deleted file 40 | .fuse_hidden* 41 | 42 | # KDE directory preferences 43 | .directory 44 | 45 | # Linux trash folder which might appear on any partition or disk 46 | .Trash-* 47 | 48 | # .nfs files are created when an open file is removed but is still being accessed 49 | .nfs* 50 | 51 | # General 52 | .DS_Store 53 | .AppleDouble 54 | .LSOverride 55 | 56 | # Icon must end with two \r 57 | Icon 58 | 59 | # Thumbnails 60 | ._* 61 | 62 | # Files that might appear in the root of a volume 63 | .DocumentRevisions-V100 64 | .fseventsd 65 | .Spotlight-V100 66 | .TemporaryItems 67 | .Trashes 68 | .VolumeIcon.icns 69 | .com.apple.timemachine.donotpresent 70 | 71 | # Directories potentially created on remote AFP share 72 | .AppleDB 73 | .AppleDesktop 74 | Network Trash Folder 75 | Temporary Items 76 | .apdisk 77 | 78 | # Windows thumbnail cache files 79 | Thumbs.db 80 | Thumbs.db:encryptable 81 | ehthumbs.db 82 | ehthumbs_vista.db 83 | 84 | # Dump file 85 | *.stackdump 86 | 87 | # Folder config file 88 | [Dd]esktop.ini 89 | 90 | # Recycle Bin used on file shares 91 | $RECYCLE.BIN/ 92 | 93 | # Windows Installer files 94 | *.cab 95 | *.msi 96 | *.msix 97 | *.msm 98 | *.msp 99 | 100 | # Windows shortcuts 101 | *.lnk 102 | 103 | .gradle 104 | build/ 105 | 106 | # Ignore Gradle GUI config 107 | gradle-app.setting 108 | 109 | # Cache of project 110 | .gradletasknamecache 111 | 112 | **/build/ 113 | 114 | # Common working directory 115 | run/ 116 | 117 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 118 | !gradle-wrapper.jar 119 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 TonimatasDEV 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Hits](https://hits.sh/github.com/tonimatasdev/packetfixer.svg?view=today-total&label=Views)](https://hits.sh/github.com/tonimatasdev/packetfixer/) 2 | # Packet Fixer 3 | ##### Visit my discord server: [Link](https://discord.com/invite/vWBP4P4Yd8) 4 | 5 | ## Description 6 | This mod increases the packet sizes to prevent various package erros. This mod could be used in mod packs for increasing the number of mods. 7 | 8 | ### Prevent these problems: 9 | - Tried to read NBT tag that was too big; tried to allocate: X bytes where max allowed: 2097152 10 | - Badly compressed packet - size of X is larger than protocol maximum of 2097152 11 | - Attempted to send packet over maximum protocol size: 8388608 12 | - Chunk Packet trying to allocate too much memory on read. 13 | - Packet too big (is X, should be less than 8388608) 14 | - Payload may not be larger than 1048576 bytes 15 | - Payload may not be larger than 32767 bytes 16 | - Packet too large: size X is over 8 17 | - Length wider than 21-bit 18 | - Unable to fit X into 3 19 | - Connection timeout 20 | - VarLong too big 21 | - VarInt too big 22 | 23 | ### Fix these problems: 24 | - Unable to fit X into 3 **[Delete Krypton and Pluto in both sides]** 25 | - VarInt too long **[Try deleting Krypton and Pluto in both sides]** 26 | 27 | ### Feel free to use this mod on your modpack 28 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("fabric-loom") version "1.10-SNAPSHOT" apply false 3 | id("net.neoforged.moddev") version "2.0.62-beta" apply false 4 | } 5 | 6 | val modVersion: String by extra 7 | 8 | allprojects { 9 | version = modVersion 10 | } -------------------------------------------------------------------------------- /buildSrc/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("groovy-gradle-plugin") 3 | } 4 | -------------------------------------------------------------------------------- /buildSrc/src/main/groovy/multiloader-common.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | } 4 | 5 | base { 6 | archivesName = "packetfixer-${project.name}-${minecraftVersion}" 7 | } 8 | 9 | java { 10 | toolchain.languageVersion = JavaLanguageVersion.of(21) 11 | withSourcesJar() 12 | } 13 | 14 | repositories { 15 | mavenCentral() 16 | // https://docs.gradle.org/current/userguide/declaring_repositories.html#declaring_content_exclusively_found_in_one_repository 17 | exclusiveContent { 18 | forRepository { 19 | maven { 20 | name = 'Sponge' 21 | url = 'https://repo.spongepowered.org/repository/maven-public' 22 | } 23 | } 24 | filter { includeGroupAndSubgroups('org.spongepowered') } 25 | } 26 | exclusiveContent { 27 | forRepositories( 28 | maven { 29 | name = 'ParchmentMC' 30 | url = 'https://maven.parchmentmc.org/' 31 | }, 32 | maven { 33 | name = "NeoForge" 34 | url = 'https://maven.neoforged.net/releases' 35 | } 36 | ) 37 | filter { includeGroup('org.parchmentmc.data') } 38 | } 39 | maven { 40 | name = 'BlameJared' 41 | url = 'https://maven.blamejared.com' 42 | } 43 | } 44 | 45 | // Declare capabilities on the outgoing configurations. 46 | // Read more about capabilities here: https://docs.gradle.org/current/userguide/component_capabilities.html#sec:declaring-additional-capabilities-for-a-local-component 47 | ['apiElements', 'runtimeElements', 'sourcesElements'].each { variant -> 48 | configurations."$variant".outgoing { 49 | capability("$group:${project.name}:$version") 50 | capability("$group:${base.archivesName.get()}:$version") 51 | capability("$group:packetfixer-${project.name}-${minecraftVersion}:$version") 52 | capability("$group:packetfixer:$version") 53 | } 54 | } 55 | 56 | jar { 57 | manifest { 58 | attributes([ 59 | 'Specification-Title' : "Packet Fixer", 60 | 'Specification-Vendor' : "TonimatasDEV", 61 | 'Specification-Version' : project.jar.archiveVersion, 62 | 'Implementation-Title' : project.name, 63 | 'Implementation-Version': project.jar.archiveVersion, 64 | 'Implementation-Vendor' : "TonimatasDEV", 65 | 'Built-On-Minecraft' : minecraftVersion 66 | ]) 67 | } 68 | } 69 | 70 | processResources { 71 | var expandProps = [ 72 | 'modVersion' : version, 73 | 'minecraftVersion' : minecraftVersion 74 | 75 | ] 76 | 77 | var jsonExpandProps = expandProps.collectEntries { 78 | key, value -> [(key): value instanceof String ? value.replace("\n", "\\\\n") : value] 79 | } 80 | 81 | filesMatching(['META-INF/mods.toml', 'META-INF/neoforge.mods.toml']) { 82 | expand expandProps 83 | } 84 | 85 | filesMatching(['pack.mcmeta', 'fabric.mod.json', '*.mixins.json']) { 86 | expand jsonExpandProps 87 | } 88 | 89 | inputs.properties(expandProps) 90 | } 91 | -------------------------------------------------------------------------------- /buildSrc/src/main/groovy/multiloader-loader.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'multiloader-common' 3 | } 4 | 5 | configurations { 6 | commonJava{ 7 | canBeResolved = true 8 | } 9 | commonResources{ 10 | canBeResolved = true 11 | } 12 | } 13 | 14 | dependencies { 15 | compileOnly(project(':common')) { 16 | capabilities { 17 | requireCapability "$group:packetfixer" 18 | } 19 | } 20 | commonJava project(path: ':common', configuration: 'commonJava') 21 | commonResources project(path: ':common', configuration: 'commonResources') 22 | } 23 | 24 | tasks.named('compileJava', JavaCompile) { 25 | dependsOn(configurations.commonJava) 26 | source(configurations.commonJava) 27 | } 28 | 29 | processResources { 30 | dependsOn(configurations.commonResources) 31 | from(configurations.commonResources) 32 | } 33 | 34 | tasks.named('sourcesJar', Jar) { 35 | dependsOn(configurations.commonJava) 36 | from(configurations.commonJava) 37 | dependsOn(configurations.commonResources) 38 | from(configurations.commonResources) 39 | } 40 | -------------------------------------------------------------------------------- /common/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("multiloader-common") 3 | id("net.neoforged.moddev") 4 | } 5 | 6 | val minecraftVersion: String by extra 7 | val neoFormVersionP: String by extra 8 | 9 | neoForge { 10 | neoFormVersion = "$minecraftVersion-$neoFormVersionP" 11 | } 12 | 13 | dependencies { 14 | compileOnly("org.spongepowered:mixin:0.8.5") 15 | compileOnly("io.github.llamalad7:mixinextras-common:0.3.5") 16 | annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.5") 17 | } 18 | 19 | configurations { 20 | create("commonJava") { 21 | isCanBeResolved = false 22 | isCanBeConsumed = true 23 | } 24 | 25 | create("commonResources") { 26 | isCanBeResolved = false 27 | isCanBeConsumed = true 28 | } 29 | } 30 | 31 | artifacts { 32 | add("commonJava", sourceSets.main.get().java.sourceDirectories.singleFile) 33 | add("commonResources", sourceSets.main.get().resources.sourceDirectories.singleFile) 34 | } 35 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/PacketFixer.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer; 2 | 3 | import com.mojang.logging.LogUtils; 4 | import dev.tonimatas.packetfixer.util.Config; 5 | 6 | public class PacketFixer { 7 | public static final String MOD_ID = "packetfixer"; 8 | 9 | public static void init() { 10 | LogUtils.getLogger().info("Packet Fixer has been initialized successfully"); 11 | } 12 | 13 | public static String getPayloadMessage() { 14 | return "Payload may not be larger than " + Config.getPacketSize() + " bytes. You can modify it in the Packet Fixer config."; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/ClientboundCustomPayloadPacketMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | 4 | import dev.tonimatas.packetfixer.util.Config; 5 | import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.Constant; 8 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 9 | 10 | @Mixin(ClientboundCustomPayloadPacket.class) 11 | public class ClientboundCustomPayloadPacketMixin { 12 | @ModifyConstant(method = "lambda$static$0", constant = @Constant(intValue = 1048576)) 13 | private static int newSize$1(int value) { 14 | return Config.getPacketSize(); 15 | } 16 | 17 | @ModifyConstant(method = "lambda$static$2", constant = @Constant(intValue = 1048576)) 18 | private static int newSize$2(int value) { 19 | return Config.getPacketSize(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/ClientboundCustomQueryPacketMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import dev.tonimatas.packetfixer.PacketFixer; 4 | import dev.tonimatas.packetfixer.util.Config; 5 | import net.minecraft.network.protocol.login.ClientboundCustomQueryPacket; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.Constant; 8 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 9 | 10 | @Mixin(ClientboundCustomQueryPacket.class) 11 | public class ClientboundCustomQueryPacketMixin { 12 | @ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 1048576)) 13 | private static int newSize(int value) { 14 | return Config.getPacketSize(); 15 | } 16 | 17 | @ModifyConstant(method = "readUnknownPayload", constant = @Constant(stringValue = "Payload may not be larger than 1048576 bytes")) 18 | private static String newSize(String value) { 19 | return PacketFixer.getPayloadMessage(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/ClientboundLevelChunkPacketDataMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import dev.tonimatas.packetfixer.util.Config; 4 | import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.Constant; 7 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 8 | 9 | @Mixin(ClientboundLevelChunkPacketData.class) 10 | public class ClientboundLevelChunkPacketDataMixin { 11 | @ModifyConstant(method = "(Lnet/minecraft/network/RegistryFriendlyByteBuf;II)V", constant = @Constant(intValue = 2097152)) 12 | private int init$size(int value) { 13 | return Config.getChunkPacketData(); 14 | } 15 | 16 | @ModifyConstant(method = "(Lnet/minecraft/network/RegistryFriendlyByteBuf;II)V", constant = @Constant(stringValue = "Chunk Packet trying to allocate too much memory on read.")) 17 | private String init$message(String constant) { 18 | return constant + " (" + Config.getChunkPacketData() + ") Modify it in the Packet Fixer config."; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/CompressionDecoderMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import dev.tonimatas.packetfixer.util.Config; 4 | import net.minecraft.network.CompressionDecoder; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.*; 7 | 8 | @Mixin(CompressionDecoder.class) 9 | public class CompressionDecoderMixin { 10 | @ModifyConstant(method = "decode", constant = @Constant(intValue = 8388608)) 11 | private int newSize(int value) { 12 | return Config.getDecoderSize(); 13 | } 14 | } -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/CompressionEncoderMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import dev.tonimatas.packetfixer.util.Config; 4 | import net.minecraft.network.CompressionEncoder; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Constant; 8 | import org.spongepowered.asm.mixin.injection.ModifyArg; 9 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 10 | 11 | @Mixin(CompressionEncoder.class) 12 | public class CompressionEncoderMixin { 13 | @ModifyConstant(method = "encode(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Lio/netty/buffer/ByteBuf;)V", constant = @Constant(intValue = 8388608)) 14 | private int newSize(int value) { 15 | return Config.getDecoderSize(); 16 | } 17 | 18 | @ModifyArg(method = "encode(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Lio/netty/buffer/ByteBuf;)V", at = @At(value = "INVOKE", target = "Ljava/lang/IllegalArgumentException;(Ljava/lang/String;)V")) 19 | private String newSizeString(String value) { 20 | return value.replaceAll("8388608", String.valueOf(Config.getDecoderSize())) + ". You can modify it in the Packet Fixer config."; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/ConnectionMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import dev.tonimatas.packetfixer.util.Config; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.injection.Constant; 6 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 7 | 8 | @Mixin(targets = "net.minecraft.network.Connection$1") 9 | public class ConnectionMixin { 10 | @ModifyConstant(method = "initChannel", constant = @Constant(intValue = 30)) 11 | private int timeout(int value) { 12 | return Config.getTimeout(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/FriendlyByteBufMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import dev.tonimatas.packetfixer.util.Config; 4 | import net.minecraft.network.FriendlyByteBuf; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.Constant; 7 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 8 | 9 | @Mixin(FriendlyByteBuf.class) 10 | public abstract class FriendlyByteBufMixin { 11 | @ModifyConstant(method = "readNbt(Lio/netty/buffer/ByteBuf;)Lnet/minecraft/nbt/CompoundTag;", constant = @Constant(longValue = 2097152L)) 12 | private static long newSize(long value) { 13 | return Config.getNbtMaxSize(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/ServerboundCustomPayloadPacketMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import dev.tonimatas.packetfixer.util.Config; 4 | import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.Constant; 7 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 8 | 9 | @Mixin(ServerboundCustomPayloadPacket.class) 10 | public class ServerboundCustomPayloadPacketMixin { 11 | @ModifyConstant(method = "lambda$static$0", constant = @Constant(intValue = 32767)) 12 | private static int newSize(int value) { 13 | return Config.getPacketSize(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/ServerboundCustomQueryPacketMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import dev.tonimatas.packetfixer.PacketFixer; 4 | import dev.tonimatas.packetfixer.util.Config; 5 | import net.minecraft.network.protocol.login.ServerboundCustomQueryAnswerPacket; 6 | import org.spongepowered.asm.mixin.Mixin; 7 | import org.spongepowered.asm.mixin.injection.Constant; 8 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 9 | 10 | @Mixin(ServerboundCustomQueryAnswerPacket.class) 11 | public class ServerboundCustomQueryPacketMixin { 12 | @ModifyConstant(method = "readUnknownPayload", constant = @Constant(intValue = 1048576)) 13 | private static int newSize(int value) { 14 | return Config.getPacketSize(); 15 | } 16 | 17 | @ModifyConstant(method = "readUnknownPayload", constant = @Constant(stringValue = "Payload may not be larger than 1048576 bytes")) 18 | private static String newSize(String value) { 19 | return PacketFixer.getPayloadMessage(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/VarIntMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import dev.tonimatas.packetfixer.util.Config; 4 | import net.minecraft.network.VarInt; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.Constant; 7 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 8 | 9 | @Mixin(value = VarInt.class, priority = 1001) 10 | public class VarIntMixin { 11 | @ModifyConstant(method = "getByteSize", constant = @Constant(intValue = 5)) 12 | private static int getByteSize$size(int value) { 13 | return Config.getVarIntSize(); 14 | } 15 | 16 | @ModifyConstant(method = "read", constant = @Constant(intValue = 5)) 17 | private static int read$size(int value) { 18 | return Config.getVarIntSize(); 19 | } 20 | 21 | @ModifyConstant(method = "read", constant = @Constant(stringValue = "VarInt too big")) 22 | private static String read$size(String constant) { 23 | return "VarInt too big. Packet Fixer configured to " + Config.getVarIntSize() + ". You can modify it in the Packet Fixer config."; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/VarLongMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import dev.tonimatas.packetfixer.util.Config; 4 | import net.minecraft.network.VarLong; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.Constant; 7 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 8 | 9 | @Mixin(VarLong.class) 10 | public class VarLongMixin { 11 | @ModifyConstant(method = "getByteSize", constant = @Constant(intValue = 10)) 12 | private static int getByteSize$size(int value) { 13 | return Config.getVarLong(); 14 | } 15 | 16 | @ModifyConstant(method = "read", constant = @Constant(intValue = 10)) 17 | private static int read$size(int constant) { 18 | return Config.getVarLong(); 19 | } 20 | 21 | @ModifyConstant(method = "read", constant = @Constant(stringValue = "VarLong too big")) 22 | private static String read$size(String constant) { 23 | return "VarInt too big. Packet Fixer configured to " + Config.getVarLong() + ". You can modify it in the Packet Fixer config."; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/Varint21FrameDecoderMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import io.netty.buffer.ByteBuf; 4 | import io.netty.buffer.Unpooled; 5 | import io.netty.channel.ChannelHandlerContext; 6 | import net.minecraft.network.VarInt; 7 | import net.minecraft.network.Varint21FrameDecoder; 8 | import org.spongepowered.asm.mixin.Final; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.Mutable; 11 | import org.spongepowered.asm.mixin.Shadow; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Constant; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 17 | 18 | import java.util.List; 19 | 20 | @Mixin(Varint21FrameDecoder.class) 21 | public abstract class Varint21FrameDecoderMixin { 22 | @Mutable @Shadow @Final private ByteBuf helperBuf; 23 | 24 | @Inject(method = "decode", at = @At("HEAD")) 25 | private void init$helper(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List list, CallbackInfo ci) { 26 | this.helperBuf = Unpooled.directBuffer(VarInt.getByteSize(byteBuf.readableBytes()) + 2); 27 | } 28 | 29 | @ModifyConstant(method = "copyVarint", constant = @Constant(intValue = 3)) 30 | private static int newSize(int value, ByteBuf byteBuf) { 31 | return VarInt.getByteSize(byteBuf.readableBytes()) + 2; 32 | } 33 | } -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/mixins/Varint21LengthFieldPrependerMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import dev.tonimatas.packetfixer.util.Config; 4 | import net.minecraft.network.Varint21LengthFieldPrepender; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.Constant; 7 | import org.spongepowered.asm.mixin.injection.ModifyConstant; 8 | 9 | @Mixin(Varint21LengthFieldPrepender.class) 10 | public class Varint21LengthFieldPrependerMixin { 11 | @ModifyConstant(method = "encode(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Lio/netty/buffer/ByteBuf;)V", constant = @Constant(intValue = 3)) 12 | private int newSize(int value) { 13 | return Config.getVarInt21Size(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /common/src/main/java/dev/tonimatas/packetfixer/util/Config.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.util; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.nio.file.Files; 6 | import java.util.Properties; 7 | 8 | public class Config { 9 | private static Properties properties = null; 10 | 11 | @SuppressWarnings("ResultOfMethodCallIgnored") 12 | public static void runProperties() { 13 | try { 14 | File configFolder = new File("config"); 15 | 16 | if (!configFolder.exists()) { 17 | configFolder.mkdirs(); 18 | } 19 | 20 | File propertiesFile = new File(configFolder, "packetfixer.properties"); 21 | properties = new Properties(); 22 | 23 | if (!propertiesFile.exists()) { 24 | propertiesFile.createNewFile(); 25 | 26 | properties.setProperty("allSizesUnlimited", "true"); 27 | properties.setProperty("nbtMaxSize", Long.toString(2097152)); 28 | properties.setProperty("packetSize", Integer.toString(1048576)); 29 | properties.setProperty("decoderSize", Integer.toString(8388608)); 30 | properties.setProperty("varInt21", Integer.toString(3)); 31 | properties.setProperty("varInt", Integer.toString(5)); 32 | properties.setProperty("varLong", Integer.toString(10)); 33 | checkVariable("chunkPacketData", Integer.toString(2097152)); 34 | properties.setProperty("timeout", Integer.toString(90)); 35 | 36 | save(propertiesFile); 37 | } 38 | 39 | properties.load(Files.newInputStream(propertiesFile.toPath())); 40 | 41 | checkVariable("allSizesUnlimited", "true"); 42 | checkVariable("nbtMaxSize", Long.toString(2097152)); 43 | checkVariable("packetSize", Integer.toString(1048576)); 44 | checkVariable("decoderSize", Integer.toString(8388608)); 45 | checkVariable("varInt21", Integer.toString(3)); 46 | checkVariable("varInt", Integer.toString(5)); 47 | checkVariable("varLong", Integer.toString(10)); 48 | checkVariable("chunkPacketData", Integer.toString(2097152)); 49 | checkVariable("timeout", Integer.toString(90)); 50 | save(propertiesFile); 51 | } catch (IOException e) { 52 | throw new RuntimeException(e); 53 | } 54 | } 55 | 56 | private static boolean getUnlimitedPacketSize() { 57 | if (properties == null) runProperties(); 58 | return Boolean.parseBoolean(properties.getProperty("allSizesUnlimited")); 59 | } 60 | 61 | public static long getNbtMaxSize() { 62 | if (properties == null) runProperties(); 63 | return getUnlimitedPacketSize() ? Long.MAX_VALUE : Long.parseLong(properties.getProperty("nbtMaxSize")); 64 | } 65 | 66 | public static int getPacketSize() { 67 | if (properties == null) runProperties(); 68 | return getUnlimitedPacketSize() ? Integer.MAX_VALUE : Integer.parseInt(properties.getProperty("packetSize")); 69 | } 70 | 71 | public static int getDecoderSize() { 72 | if (properties == null) runProperties(); 73 | return getUnlimitedPacketSize() ? Integer.MAX_VALUE : Integer.parseInt(properties.getProperty("decoderSize")); 74 | } 75 | 76 | public static int getVarInt21Size() { 77 | if (properties == null) runProperties(); 78 | return getUnlimitedPacketSize() ? Integer.MAX_VALUE : Integer.parseInt(properties.getProperty("varInt21")); 79 | } 80 | 81 | public static int getVarIntSize() { 82 | if (properties == null) runProperties(); 83 | return getUnlimitedPacketSize() ? Integer.MAX_VALUE : Integer.parseInt(properties.getProperty("varInt")); 84 | } 85 | 86 | public static int getVarLong() { 87 | if (properties == null) runProperties(); 88 | return getUnlimitedPacketSize() ? Integer.MAX_VALUE : Integer.parseInt(properties.getProperty("varLong")); 89 | } 90 | 91 | public static int getChunkPacketData() { 92 | if (properties == null) runProperties(); 93 | return getUnlimitedPacketSize() ? Integer.MAX_VALUE : Integer.parseInt(properties.getProperty("chunkPacketData")); 94 | } 95 | 96 | public static int getTimeout() { 97 | if (properties == null) runProperties(); 98 | return Integer.parseInt(properties.getProperty("timeout")); 99 | } 100 | 101 | private static void checkVariable(String variable, String defaultValue) { 102 | if (properties.getProperty(variable) == null) { 103 | properties.setProperty(variable, defaultValue); 104 | } 105 | } 106 | 107 | private static void save(File propertiesFile) throws IOException { 108 | properties.store(Files.newOutputStream(propertiesFile.toPath()), 109 | "Packet Fixer config file.\n" + 110 | "Default values (minecraft default): nbtMaxSize 2097152, packetSize 1048576, decoderSize 8388608 and varInt21Size 3.\n" + 111 | "Max values are " + Integer.MAX_VALUE + " for packetSize/decoderSize/varInt21 and " + Long.MAX_VALUE + " for nbtMaxSize."); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /common/src/main/resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TonimatasDEV/PacketFixer/27d4942ec5f44c7ff5cc64c378cb3f0087bc9001/common/src/main/resources/icon.png -------------------------------------------------------------------------------- /common/src/main/resources/packetfixer.common.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "dev.tonimatas.packetfixer.mixins", 5 | "compatibilityLevel": "JAVA_21", 6 | "refmap": "packetfixer.refmap.json", 7 | "mixins": [ 8 | "ClientboundCustomPayloadPacketMixin", 9 | "ClientboundCustomQueryPacketMixin", 10 | "ClientboundLevelChunkPacketDataMixin", 11 | "CompressionDecoderMixin", 12 | "CompressionEncoderMixin", 13 | "ConnectionMixin", 14 | "FriendlyByteBufMixin", 15 | "ServerboundCustomPayloadPacketMixin", 16 | "ServerboundCustomQueryPacketMixin", 17 | "Varint21FrameDecoderMixin", 18 | "Varint21LengthFieldPrependerMixin", 19 | "VarIntMixin", 20 | "VarLongMixin" 21 | ], 22 | "injectors": { 23 | "defaultRequire": 0 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /fabric/build.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnstableApiUsage") 2 | 3 | plugins { 4 | id("multiloader-loader") 5 | id("fabric-loom") 6 | } 7 | 8 | val minecraftVersion: String by extra 9 | val fabricApiVersion: String by extra 10 | val fabricLoaderVersion: String by extra 11 | val modVersion: String by extra 12 | 13 | dependencies { 14 | minecraft("com.mojang:minecraft:$minecraftVersion") 15 | mappings(loom.officialMojangMappings()) 16 | modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion") 17 | modImplementation("net.fabricmc.fabric-api:fabric-api:$fabricApiVersion+$minecraftVersion") 18 | } 19 | 20 | loom { 21 | mixin { 22 | defaultRefmapName.set("packetfixer.refmap.json") 23 | } 24 | 25 | runs { 26 | named("client") { 27 | client() 28 | configName = "Fabric Client" 29 | ideConfigGenerated(true) 30 | runDir("runs/client") 31 | } 32 | 33 | named("server") { 34 | server() 35 | configName = "Fabric Server" 36 | ideConfigGenerated(true) 37 | runDir("runs/server") 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /fabric/src/main/java/dev/tonimatas/packetfixer/PacketFixerFabric.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer; 2 | 3 | import net.fabricmc.api.ModInitializer; 4 | 5 | public class PacketFixerFabric implements ModInitializer { 6 | @Override 7 | public void onInitialize() { 8 | PacketFixer.init(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /fabric/src/main/java/dev/tonimatas/packetfixer/mixins/PayloadHelperMixin.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import net.fabricmc.fabric.impl.networking.payload.PayloadHelper; 4 | import net.minecraft.network.FriendlyByteBuf; 5 | import org.spongepowered.asm.mixin.Mixin; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Inject; 8 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 9 | 10 | @SuppressWarnings("UnstableApiUsage") 11 | @Mixin(PayloadHelper.class) 12 | public class PayloadHelperMixin { 13 | @Inject(method = "assertSize", at = @At("HEAD"), cancellable = true) 14 | private static void newSize$assertSize(FriendlyByteBuf buf, int maxSize, CallbackInfo ci) { 15 | ci.cancel(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /fabric/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "packetfixer", 4 | "version": "${modVersion}", 5 | "name": "Packet Fixer", 6 | "description": "A simple mod to solve various problems with packets/NBT's.", 7 | "authors": [ 8 | "TonimatasDEV" 9 | ], 10 | "contact": { 11 | "repo": "https://github.com/TonimatasDEV/PacketFixer" 12 | }, 13 | "license": "MIT", 14 | "icon": "icon.png", 15 | "environment": "*", 16 | "entrypoints": { 17 | "main": [ 18 | "dev.tonimatas.packetfixer.PacketFixerFabric" 19 | ] 20 | }, 21 | "mixins": [ 22 | "packetfixer.common.mixins.json", 23 | "packetfixer.fabric.mixins.json" 24 | ], 25 | "depends": { 26 | "fabricloader": "*", 27 | "minecraft": "${minecraftVersion}" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /fabric/src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": "Packet Fixer resources", 4 | "pack_format": 15 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /fabric/src/main/resources/packetfixer.fabric.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "dev.tonimatas.packetfixer.mixins", 5 | "refmap": "packetfixer.refmap.json", 6 | "compatibilityLevel": "JAVA_21", 7 | "mixins": [ 8 | "PayloadHelperMixin" 9 | ], 10 | "injectors": { 11 | "defaultRequire": 0 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx5G 2 | 3 | # Mod Properties 4 | modVersion=2.1.2 5 | 6 | # Minecraft 7 | minecraftVersion=1.21.5 8 | 9 | # Forge Properties 10 | #forgeVersion=51.0.18 11 | 12 | # Fabric Properties 13 | fabricLoaderVersion=0.16.10 14 | fabricApiVersion=0.119.6 15 | yarnMappings=1 16 | 17 | # NeoForge Properties 18 | neoforgeVersion=21.5.8-beta 19 | neoFormVersionP=20250325.162830 -------------------------------------------------------------------------------- /gradle/gradle-daemon-jvm.properties: -------------------------------------------------------------------------------- 1 | #This file is generated by updateDaemonJvm 2 | toolchainVersion=21 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TonimatasDEV/PacketFixer/27d4942ec5f44c7ff5cc64c378cb3f0087bc9001/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 19 | # 20 | 21 | ############################################################################## 22 | # 23 | # Gradle start up script for POSIX generated by Gradle. 24 | # 25 | # Important for running: 26 | # 27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 28 | # noncompliant, but you have some other compliant shell such as ksh or 29 | # bash, then to run this script, type that shell name before the whole 30 | # command line, like: 31 | # 32 | # ksh Gradle 33 | # 34 | # Busybox and similar reduced shells will NOT work, because this script 35 | # requires all of these POSIX shell features: 36 | # * functions; 37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 39 | # * compound commands having a testable exit status, especially «case»; 40 | # * various built-in commands including «command», «set», and «ulimit». 41 | # 42 | # Important for patching: 43 | # 44 | # (2) This script targets any POSIX shell, so it avoids extensions provided 45 | # by Bash, Ksh, etc; in particular arrays are avoided. 46 | # 47 | # The "traditional" practice of packing multiple parameters into a 48 | # space-separated string is a well documented source of bugs and security 49 | # problems, so this is (mostly) avoided, by progressively accumulating 50 | # options in "$@", and eventually passing that to Java. 51 | # 52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 54 | # see the in-line comments for details. 55 | # 56 | # There are tweaks for specific operating systems such as AIX, CygWin, 57 | # Darwin, MinGW, and NonStop. 58 | # 59 | # (3) This script is generated from the Groovy template 60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 61 | # within the Gradle project. 62 | # 63 | # You can find Gradle at https://github.com/gradle/gradle/. 64 | # 65 | ############################################################################## 66 | 67 | # Attempt to set APP_HOME 68 | 69 | # Resolve links: $0 may be a link 70 | app_path=$0 71 | 72 | # Need this for daisy-chained symlinks. 73 | while 74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 75 | [ -h "$app_path" ] 76 | do 77 | ls=$( ls -ld "$app_path" ) 78 | link=${ls#*' -> '} 79 | case $link in #( 80 | /*) app_path=$link ;; #( 81 | *) app_path=$APP_HOME$link ;; 82 | esac 83 | done 84 | 85 | # This is normally unused 86 | # shellcheck disable=SC2034 87 | APP_BASE_NAME=${0##*/} 88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s 90 | ' "$PWD" ) || exit 91 | 92 | # Use the maximum available, or set MAX_FD != -1 to use that value. 93 | MAX_FD=maximum 94 | 95 | warn () { 96 | echo "$*" 97 | } >&2 98 | 99 | die () { 100 | echo 101 | echo "$*" 102 | echo 103 | exit 1 104 | } >&2 105 | 106 | # OS specific support (must be 'true' or 'false'). 107 | cygwin=false 108 | msys=false 109 | darwin=false 110 | nonstop=false 111 | case "$( uname )" in #( 112 | CYGWIN* ) cygwin=true ;; #( 113 | Darwin* ) darwin=true ;; #( 114 | MSYS* | MINGW* ) msys=true ;; #( 115 | NONSTOP* ) nonstop=true ;; 116 | esac 117 | 118 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 119 | 120 | 121 | # Determine the Java command to use to start the JVM. 122 | if [ -n "$JAVA_HOME" ] ; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD=$JAVA_HOME/jre/sh/java 126 | else 127 | JAVACMD=$JAVA_HOME/bin/java 128 | fi 129 | if [ ! -x "$JAVACMD" ] ; then 130 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 131 | 132 | Please set the JAVA_HOME variable in your environment to match the 133 | location of your Java installation." 134 | fi 135 | else 136 | JAVACMD=java 137 | if ! command -v java >/dev/null 2>&1 138 | then 139 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 140 | 141 | Please set the JAVA_HOME variable in your environment to match the 142 | location of your Java installation." 143 | fi 144 | fi 145 | 146 | # Increase the maximum file descriptors if we can. 147 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 148 | case $MAX_FD in #( 149 | max*) 150 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 151 | # shellcheck disable=SC2039,SC3045 152 | MAX_FD=$( ulimit -H -n ) || 153 | warn "Could not query maximum file descriptor limit" 154 | esac 155 | case $MAX_FD in #( 156 | '' | soft) :;; #( 157 | *) 158 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 159 | # shellcheck disable=SC2039,SC3045 160 | ulimit -n "$MAX_FD" || 161 | warn "Could not set maximum file descriptor limit to $MAX_FD" 162 | esac 163 | fi 164 | 165 | # Collect all arguments for the java command, stacking in reverse order: 166 | # * args from the command line 167 | # * the main class name 168 | # * -classpath 169 | # * -D...appname settings 170 | # * --module-path (only if needed) 171 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 172 | 173 | # For Cygwin or MSYS, switch paths to Windows format before running java 174 | if "$cygwin" || "$msys" ; then 175 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 176 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 177 | 178 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 179 | 180 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 181 | for arg do 182 | if 183 | case $arg in #( 184 | -*) false ;; # don't mess with options #( 185 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 186 | [ -e "$t" ] ;; #( 187 | *) false ;; 188 | esac 189 | then 190 | arg=$( cygpath --path --ignore --mixed "$arg" ) 191 | fi 192 | # Roll the args list around exactly as many times as the number of 193 | # args, so each arg winds up back in the position where it started, but 194 | # possibly modified. 195 | # 196 | # NB: a `for` loop captures its iteration list before it begins, so 197 | # changing the positional parameters here affects neither the number of 198 | # iterations, nor the values presented in `arg`. 199 | shift # remove old arg 200 | set -- "$@" "$arg" # push replacement arg 201 | done 202 | fi 203 | 204 | 205 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 206 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 207 | 208 | # Collect all arguments for the java command: 209 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 210 | # and any embedded shellness will be escaped. 211 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 212 | # treated as '${Hostname}' itself on the command line. 213 | 214 | set -- \ 215 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 216 | -classpath "$CLASSPATH" \ 217 | org.gradle.wrapper.GradleWrapperMain \ 218 | "$@" 219 | 220 | # Stop when "xargs" is not available. 221 | if ! command -v xargs >/dev/null 2>&1 222 | then 223 | die "xargs is not available" 224 | fi 225 | 226 | # Use "xargs" to parse quoted args. 227 | # 228 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 229 | # 230 | # In Bash we could simply go: 231 | # 232 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 233 | # set -- "${ARGS[@]}" "$@" 234 | # 235 | # but POSIX shell has neither arrays nor command substitution, so instead we 236 | # post-process each arg (as a line of input to sed) to backslash-escape any 237 | # character that might be a shell metacharacter, then use eval to reverse 238 | # that process (while maintaining the separation between arguments), and wrap 239 | # the whole thing up as a single "set" statement. 240 | # 241 | # This will of course break if any of these variables contains a newline or 242 | # an unmatched quote. 243 | # 244 | 245 | eval "set -- $( 246 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 247 | xargs -n1 | 248 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 249 | tr '\n' ' ' 250 | )" '"$@"' 251 | 252 | exec "$JAVACMD" "$@" 253 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /neoforge/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("multiloader-loader") 3 | id("net.neoforged.moddev") 4 | } 5 | 6 | val minecraftVersion: String by extra 7 | val neoforgeVersion: String by extra 8 | val modVersion: String by extra 9 | 10 | neoForge { 11 | version = neoforgeVersion 12 | 13 | runs { 14 | configureEach { 15 | systemProperty("neoforge.enabledGameTestNamespaces", "packetfixer") 16 | } 17 | 18 | create("client") { 19 | client() 20 | } 21 | 22 | create("data") { 23 | clientData() 24 | } 25 | 26 | create("server") { 27 | server() 28 | } 29 | } 30 | 31 | mods { 32 | create("packetfixer") { 33 | sourceSet(sourceSets.main.get()) 34 | } 35 | } 36 | } 37 | 38 | sourceSets.main.get().resources { srcDir("src/generated/resources") } -------------------------------------------------------------------------------- /neoforge/gradle.properties: -------------------------------------------------------------------------------- 1 | loom.platform=neoforge -------------------------------------------------------------------------------- /neoforge/src/main/java/dev/tonimatas/packetfixer/PacketFixerNeoForge.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer; 2 | 3 | import net.neoforged.fml.common.Mod; 4 | 5 | @Mod(PacketFixer.MOD_ID) 6 | public class PacketFixerNeoForge { 7 | public PacketFixerNeoForge() { 8 | PacketFixer.init(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /neoforge/src/main/java/dev/tonimatas/packetfixer/mixins/MixinConfigPluginNeoForge.java: -------------------------------------------------------------------------------- 1 | package dev.tonimatas.packetfixer.mixins; 2 | 3 | import org.objectweb.asm.tree.ClassNode; 4 | import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; 5 | import org.spongepowered.asm.mixin.extensibility.IMixinInfo; 6 | 7 | import java.util.List; 8 | import java.util.Set; 9 | 10 | public class MixinConfigPluginNeoForge implements IMixinConfigPlugin { 11 | 12 | @Override 13 | public void onLoad(String mixinPackage) { 14 | System.getProperties().setProperty("neoforge.disablePacketCompressionDebug", "true"); 15 | } 16 | 17 | @Override 18 | public String getRefMapperConfig() { 19 | return null; 20 | } 21 | 22 | @Override 23 | public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { 24 | return true; 25 | } 26 | 27 | @Override 28 | public void acceptTargets(Set myTargets, Set otherTargets) { 29 | 30 | } 31 | 32 | @Override 33 | public List getMixins() { 34 | return null; 35 | } 36 | 37 | @Override 38 | public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 39 | 40 | } 41 | 42 | @Override 43 | public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /neoforge/src/main/resources/META-INF/neoforge.mods.toml: -------------------------------------------------------------------------------- 1 | modLoader="javafml" 2 | loaderVersion="[0,)" 3 | license="MIT" 4 | issueTrackerURL="https://github.com/TonimatasDEV/PacketFixer/issues" 5 | 6 | [[mixins]] 7 | config="packetfixer.neoforge.mixins.json" 8 | 9 | [[mixins]] 10 | config="packetfixer.common.mixins.json" 11 | 12 | [[mods]] 13 | modId="packetfixer" 14 | version="${modVersion}" 15 | displayName="Packet Fixer" 16 | logoFile="icon.png" 17 | #updateJSONURL="https://api.modrinth.com/updates/packet-fixer/forge_updates.json" 18 | authors="TonimatasDEV" 19 | description=''' 20 | A simple mod to solve various problems with packets/NBT's. 21 | ''' 22 | 23 | [[dependencies.packetfixer]] 24 | modId="neoforge" 25 | type="required" 26 | versionRange="[0,)" 27 | ordering="NONE" 28 | side="BOTH" 29 | 30 | [[dependencies.packetfixer]] 31 | modId="minecraft" 32 | type="required" 33 | versionRange="[${minecraftVersion}]" 34 | ordering="NONE" 35 | side="BOTH" -------------------------------------------------------------------------------- /neoforge/src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": "Packet Fixer resources", 4 | "pack_format": 15 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /neoforge/src/main/resources/packetfixer.neoforge.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "dev.tonimatas.packetfixer.mixins", 5 | "compatibilityLevel": "JAVA_21", 6 | "plugin": "dev.tonimatas.packetfixer.mixins.MixinConfigPluginNeoForge", 7 | "injectors": { 8 | "defaultRequire": 1 9 | }, 10 | "mixins": [ 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | @file:Suppress("UnstableApiUsage") 2 | 3 | pluginManagement { 4 | repositories { 5 | gradlePluginPortal() 6 | mavenCentral() 7 | exclusiveContent { 8 | forRepository { 9 | maven("https://maven.fabricmc.net") 10 | } 11 | filter { 12 | includeGroup("net.fabricmc") 13 | includeGroup("fabric-loom") 14 | } 15 | } 16 | exclusiveContent { 17 | forRepository { 18 | maven("https://repo.spongepowered.org/repository/maven-public") 19 | } 20 | filter { 21 | includeGroupAndSubgroups("org.spongepowered") 22 | } 23 | } 24 | } 25 | } 26 | 27 | plugins { 28 | id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" 29 | } 30 | 31 | rootProject.name = "PacketFixer" 32 | include("common") 33 | include("fabric") 34 | include("neoforge") --------------------------------------------------------------------------------