diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index c571ad2..b2d96b1 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -2,7 +2,7 @@ name: Java with Gradle on: push: - branches: [master] + branches: [1.16.5] jobs: build: @@ -11,10 +11,10 @@ jobs: steps: - uses: actions/checkout@v3.5.2 - - name: Set up JDK 17 + - name: Set up JDK 8 uses: actions/setup-java@v1.4.4 with: - java-version: 17 + java-version: 8 - name: Give permissions to Gradle run: chmod +x ./gradlew diff --git a/.gitignore b/.gitignore index e11c116..4f5c735 100644 --- a/.gitignore +++ b/.gitignore @@ -6,11 +6,9 @@ /.idea/ /artifacts/ -/common/build/ /fabric/build/ /forge/build/ /fabric/.gradle/ /forge/.gradle/ -/common/.gradle/ /fabric/run/ /forge/run/ \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 742af4c..21e2fef 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,49 +1,26 @@ -import net.fabricmc.loom.api.LoomGradleExtensionAPI - plugins { java - id("architectury-plugin") version "3.4-SNAPSHOT" - id("dev.architectury.loom") version "1.4-SNAPSHOT" apply false } val modVersion: String by extra val minecraftVersion: String by extra -architectury { - minecraft = minecraftVersion -} - subprojects { - apply(plugin = "dev.architectury.loom") - - base.archivesName.set("PacketFixer-" + project.name) - - configure { - silentMojangMappingsLicense() - } - - dependencies { - "minecraft"("com.mojang:minecraft:$minecraftVersion") - "mappings"(project.the().officialMojangMappings()) - } -} - -allprojects { apply(plugin = "java") - apply(plugin = "architectury-plugin") - version = modVersion - group = "dev.tonimatas.packetfixer" + group = "net.tonimatasdev" + version = "$modVersion-$minecraftVersion" + base.archivesName.set("PacketFixer-" + project.name) - repositories { + java { + withSourcesJar() + toolchain.languageVersion.set(JavaLanguageVersion.of(8)) + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } - + tasks.withType { options.encoding = "UTF-8" } - - java { - withSourcesJar() - } -} +} \ No newline at end of file diff --git a/common/build.gradle.kts b/common/build.gradle.kts deleted file mode 100644 index abca978..0000000 --- a/common/build.gradle.kts +++ /dev/null @@ -1,9 +0,0 @@ -val fabricLoaderVersion: String by extra - -dependencies { - modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion") -} - -architectury { - common("fabric", "forge", "neoforge") -} diff --git a/common/src/main/java/dev/tonimatas/packetfixer/PacketFixer.java b/common/src/main/java/dev/tonimatas/packetfixer/PacketFixer.java deleted file mode 100644 index 77238a6..0000000 --- a/common/src/main/java/dev/tonimatas/packetfixer/PacketFixer.java +++ /dev/null @@ -1,13 +0,0 @@ -package dev.tonimatas.packetfixer; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class PacketFixer { - public static final Logger LOGGER = LogManager.getLogger(); - public static final String MOD_ID = "packetfixer"; - - public static void init() { - LOGGER.info("Packet Fixer has been initialized successfully"); - } -} diff --git a/common/src/main/java/dev/tonimatas/packetfixer/mixins/ClientboundCustomPayloadPacketMixin.java b/common/src/main/java/dev/tonimatas/packetfixer/mixins/ClientboundCustomPayloadPacketMixin.java deleted file mode 100644 index 73b9fcc..0000000 --- a/common/src/main/java/dev/tonimatas/packetfixer/mixins/ClientboundCustomPayloadPacketMixin.java +++ /dev/null @@ -1,14 +0,0 @@ -package dev.tonimatas.packetfixer.mixins; - -import net.minecraft.network.protocol.game.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 = 999) -public class ClientboundCustomPayloadPacketMixin { - @ModifyConstant(method = {"(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/network/FriendlyByteBuf;)V", "read"}, constant = @Constant(intValue = 1048576)) - private int newSize(int value) { - return value * 100; - } -} diff --git a/common/src/main/java/dev/tonimatas/packetfixer/mixins/Varint21FrameDecoderMixin.java b/common/src/main/java/dev/tonimatas/packetfixer/mixins/Varint21FrameDecoderMixin.java deleted file mode 100644 index aeca26b..0000000 --- a/common/src/main/java/dev/tonimatas/packetfixer/mixins/Varint21FrameDecoderMixin.java +++ /dev/null @@ -1,14 +0,0 @@ -package dev.tonimatas.packetfixer.mixins; - -import net.minecraft.network.Varint21FrameDecoder; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.Constant; -import org.spongepowered.asm.mixin.injection.ModifyConstant; - -@Mixin(Varint21FrameDecoder.class) -public class Varint21FrameDecoderMixin { - @ModifyConstant(method = "decode", constant = @Constant(intValue = 3)) - private static int newSize(int value) { - return 8; - } -} diff --git a/common/src/main/java/dev/tonimatas/packetfixer/util/Hooks.java b/common/src/main/java/dev/tonimatas/packetfixer/util/Hooks.java deleted file mode 100644 index fd9a0e2..0000000 --- a/common/src/main/java/dev/tonimatas/packetfixer/util/Hooks.java +++ /dev/null @@ -1,11 +0,0 @@ -package dev.tonimatas.packetfixer.util; - -import dev.architectury.injectables.annotations.ExpectPlatform; -import org.apache.commons.lang3.NotImplementedException; - -public class Hooks { - @ExpectPlatform - public static boolean isModLoaded(String modId) { - throw new NotImplementedException("Problems on implement isModLoaded method."); - } -} diff --git a/common/src/main/resources/packetfixer-common.mixins.json b/common/src/main/resources/packetfixer-common.mixins.json deleted file mode 100644 index 3046112..0000000 --- a/common/src/main/resources/packetfixer-common.mixins.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "dev.tonimatas.packetfixer.mixins", - "priority": 499, - "compatibilityLevel": "JAVA_8", - "plugin": "dev.tonimatas.packetfixer.mixins.MixinConfigPlugin", - "mixins": [ - "ClientboundCustomPayloadPacketMixin", - "ClientboundCustomQueryPacketMixin", - "CompressionDecoderMixin", - "NbtAccounterMixin", - "PacketBufferMixin", - "ServerboundCustomPayloadPacketMixin", - "ServerboundCustomQueryPacketMixin", - "Varint21FrameDecoderMixin", - "Varint21LengthFieldPrependerMixin" - ], - "client": [ - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 1817c39..661c0fe 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,35 +1,24 @@ -@file:Suppress("DEPRECATION", "HasPlatformType") - -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -import net.fabricmc.loom.task.RemapJarTask -import org.gradle.api.component.AdhocComponentWithVariants +@file:Suppress("UnstableApiUsage") plugins { - id("com.github.johnrengelman.shadow") version "7.1.2" -} - -architectury { - platformSetupLoomIde() - fabric() + id("fabric-loom") version "1.5-SNAPSHOT" } -val minecraftVersion: String by extra -val fabricLoaderVersion: String by extra -val fabricMinecraftVersionRange: String by extra +val loaderVersion: String by extra +val yarnMappings: String by extra val modVersion: String by extra +val minecraftVersion: String by extra -val common by configurations.creating -val shadowCommon by configurations.creating - -configurations["compileClasspath"].extendsFrom(common) -configurations["runtimeClasspath"].extendsFrom(common) -configurations["developmentFabric"].extendsFrom(common) +repositories { + maven(url = "https://maven.fabricmc.net/") + maven(url = "https://libraries.minecraft.net/") +} dependencies { - modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion") + minecraft("com.mojang:minecraft:$minecraftVersion") + mappings("net.fabricmc:yarn:$yarnMappings:v2") + modImplementation("net.fabricmc:fabric-loader:$loaderVersion") - common(project(path = ":common", configuration = "namedElements")) { isTransitive = false } - shadowCommon(project(path = ":common", configuration = "transformProductionFabric")) { isTransitive = false } } tasks.withType { @@ -42,30 +31,8 @@ tasks.withType { } } -tasks.withType { - configurations = listOf(shadowCommon) - archiveClassifier.set("dev-shadow") -} - -tasks.withType { - val shadowTask = tasks.shadowJar.get() - input.set(shadowTask.archiveFile) - dependsOn(shadowTask) - archiveClassifier.set("") -} - tasks.jar { - archiveClassifier.set("dev") -} - -tasks.sourcesJar { - val commonSources = project(":common").tasks.sourcesJar.get() - dependsOn(commonSources) - from(commonSources.archiveFile.map { zipTree(it) }) -} - -components.getByName("java").apply { - withVariantsFromConfiguration(project.configurations["shadowRuntimeElements"]) { - skip() + from("LICENSE") { + rename { "${it}_${project.base.archivesName.get()}"} } } diff --git a/fabric/src/main/java/dev/tonimatas/packetfixer/PacketFixerFabric.java b/fabric/src/main/java/dev/tonimatas/packetfixer/PacketFixerFabric.java deleted file mode 100644 index 28e1edc..0000000 --- a/fabric/src/main/java/dev/tonimatas/packetfixer/PacketFixerFabric.java +++ /dev/null @@ -1,10 +0,0 @@ -package dev.tonimatas.packetfixer; - -import net.fabricmc.api.ModInitializer; - -public class PacketFixerFabric implements ModInitializer { - @Override - public void onInitialize() { - PacketFixer.init(); - } -} diff --git a/fabric/src/main/java/dev/tonimatas/packetfixer/util/fabric/HooksImpl.java b/fabric/src/main/java/dev/tonimatas/packetfixer/util/fabric/HooksImpl.java deleted file mode 100644 index 09621e7..0000000 --- a/fabric/src/main/java/dev/tonimatas/packetfixer/util/fabric/HooksImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -package dev.tonimatas.packetfixer.util.fabric; - -import net.fabricmc.loader.api.FabricLoader; - -@SuppressWarnings("unused") -public class HooksImpl { - public static boolean isModLoaded(String modId) { - return FabricLoader.getInstance().isModLoaded(modId); - } -} diff --git a/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/PacketFixerFabric.java b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/PacketFixerFabric.java new file mode 100644 index 0000000..3b05edd --- /dev/null +++ b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/PacketFixerFabric.java @@ -0,0 +1,11 @@ +package net.tonimatasdev.packetfixerfabric; + +import net.fabricmc.api.ModInitializer; +import org.apache.logging.log4j.LogManager; + +public class PacketFixerFabric implements ModInitializer { + @Override + public void onInitialize() { + LogManager.getLogger().info("Packet Fixer (Fabric) has been initialized successfully"); + } +} diff --git a/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/CustomPayloadC2SPacketMixin.java b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/CustomPayloadC2SPacketMixin.java new file mode 100644 index 0000000..0132359 --- /dev/null +++ b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/CustomPayloadC2SPacketMixin.java @@ -0,0 +1,15 @@ +package net.tonimatasdev.packetfixerfabric.mixin; + + +import net.minecraft.network.packet.c2s.play.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 = "read", constant = @Constant(intValue = 32767)) + private int newSize(int value) { + return Integer.MAX_VALUE; + } +} diff --git a/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/CustomPayloadS2CPacketMixin.java b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/CustomPayloadS2CPacketMixin.java new file mode 100644 index 0000000..d4a1bde --- /dev/null +++ b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/CustomPayloadS2CPacketMixin.java @@ -0,0 +1,14 @@ +package net.tonimatasdev.packetfixerfabric.mixin; + +import net.minecraft.network.packet.s2c.play.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 = "*", constant = @Constant(intValue = 1048576)) + private static int newSize(int value) { + return Integer.MAX_VALUE; + } +} diff --git a/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/LoginQueryRequestS2CPacketMixin.java b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/LoginQueryRequestS2CPacketMixin.java new file mode 100644 index 0000000..f690b78 --- /dev/null +++ b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/LoginQueryRequestS2CPacketMixin.java @@ -0,0 +1,14 @@ +package net.tonimatasdev.packetfixerfabric.mixin; + +import net.minecraft.network.packet.s2c.login.LoginQueryRequestS2CPacket; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(value = LoginQueryRequestS2CPacket.class, priority = 9999) +public class LoginQueryRequestS2CPacketMixin { + @ModifyConstant(method = "read", constant = @Constant(intValue = 1048576)) + private int newSize(int value) { + return Integer.MAX_VALUE; + } +} diff --git a/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/LoginQueryResponseC2SPacketMixin.java b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/LoginQueryResponseC2SPacketMixin.java new file mode 100644 index 0000000..3af50a4 --- /dev/null +++ b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/LoginQueryResponseC2SPacketMixin.java @@ -0,0 +1,14 @@ +package net.tonimatasdev.packetfixerfabric.mixin; + +import net.minecraft.network.packet.c2s.login.LoginQueryResponseC2SPacket; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(value = LoginQueryResponseC2SPacket.class, priority = 9999) +public class LoginQueryResponseC2SPacketMixin { + @ModifyConstant(method = "read", constant = @Constant(intValue = 1048576)) + private int newSize(int value) { + return Integer.MAX_VALUE; + } +} diff --git a/common/src/main/java/dev/tonimatas/packetfixer/mixins/MixinConfigPlugin.java b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/MixinConfigPlugin.java similarity index 54% rename from common/src/main/java/dev/tonimatas/packetfixer/mixins/MixinConfigPlugin.java rename to fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/MixinConfigPlugin.java index 3640945..70c5036 100644 --- a/common/src/main/java/dev/tonimatas/packetfixer/mixins/MixinConfigPlugin.java +++ b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/MixinConfigPlugin.java @@ -1,13 +1,16 @@ -package dev.tonimatas.packetfixer.mixins; +package net.tonimatasdev.packetfixerfabric.mixin; -import dev.tonimatas.packetfixer.PacketFixer; -import dev.tonimatas.packetfixer.util.Hooks; +import net.fabricmc.loader.api.FabricLoader; +import net.fabricmc.loader.api.ModContainer; +import net.fabricmc.loader.api.metadata.ModMetadata; +import org.apache.logging.log4j.LogManager; import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; public class MixinConfigPlugin implements IMixinConfigPlugin { @@ -22,11 +25,15 @@ public String getRefMapperConfig() { @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - boolean krypton = Hooks.isModLoaded("krypton") || Hooks.isModLoaded("pluto"); - - if ((mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixer.mixin.Varint21FrameDecoderMixin") || mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixer.mixin.Varint21LengthFieldPrependerMixin")) && krypton) { - PacketFixer.LOGGER.warn("For can't fit X into 3 error fix (" + mixinClassName + "). Delete Krypton or Pluto."); - return false; + List mods = FabricLoader.getInstance().getAllMods().stream().map(ModContainer::getMetadata).map(ModMetadata::getId).collect(Collectors.toList()); + + boolean krypton = mods.contains("krypton"); + + if (mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerfabric.mixin.SplitterHandlerMixin") || mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerfabric.mixin.SizePrependerMixin")) { + if (krypton) { + LogManager.getLogger().warn("For can't fit X into 3 error fix. Delete Krypton."); + return false; + } } return true; diff --git a/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/NbtTagSizeTrackerMixin.java b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/NbtTagSizeTrackerMixin.java new file mode 100644 index 0000000..10e8eb2 --- /dev/null +++ b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/NbtTagSizeTrackerMixin.java @@ -0,0 +1,15 @@ +package net.tonimatasdev.packetfixerfabric.mixin; + +import net.minecraft.nbt.NbtTagSizeTracker; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(value = NbtTagSizeTracker.class, priority = 9999) +public abstract class NbtTagSizeTrackerMixin { + @Redirect(method = "add(J)V", at = @At(value = "FIELD", target = "Lnet/minecraft/nbt/NbtTagSizeTracker;maxBytes:J", opcode = Opcodes.GETFIELD)) + public long newSize(NbtTagSizeTracker instance) { + return Long.MAX_VALUE; + } +} diff --git a/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/PacketInflaterMixin.java b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/PacketInflaterMixin.java new file mode 100644 index 0000000..d9376ca --- /dev/null +++ b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/PacketInflaterMixin.java @@ -0,0 +1,14 @@ +package net.tonimatasdev.packetfixerfabric.mixin; + +import net.minecraft.network.PacketInflater; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(value = PacketInflater.class, priority = 9999) +public class PacketInflaterMixin { + @ModifyConstant(method = "decode", constant = @Constant(intValue = 2097152)) + private int newSize(int value) { + return Integer.MAX_VALUE; + } +} \ No newline at end of file diff --git a/common/src/main/java/dev/tonimatas/packetfixer/mixins/Varint21LengthFieldPrependerMixin.java b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SizePrependerMixin.java similarity index 66% rename from common/src/main/java/dev/tonimatas/packetfixer/mixins/Varint21LengthFieldPrependerMixin.java rename to fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SizePrependerMixin.java index 820ade6..507c108 100644 --- a/common/src/main/java/dev/tonimatas/packetfixer/mixins/Varint21LengthFieldPrependerMixin.java +++ b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SizePrependerMixin.java @@ -1,12 +1,12 @@ -package dev.tonimatas.packetfixer.mixins; +package net.tonimatasdev.packetfixerfabric.mixin; -import net.minecraft.network.Varint21LengthFieldPrepender; +import net.minecraft.network.SizePrepender; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; -@Mixin(Varint21LengthFieldPrepender.class) -public class Varint21LengthFieldPrependerMixin { +@Mixin(SizePrepender.class) +public class SizePrependerMixin { @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; diff --git a/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SplitterHandlerMixin.java b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SplitterHandlerMixin.java new file mode 100644 index 0000000..d7d03ff --- /dev/null +++ b/fabric/src/main/java/net/tonimatasdev/packetfixerfabric/mixin/SplitterHandlerMixin.java @@ -0,0 +1,14 @@ +package net.tonimatasdev.packetfixerfabric.mixin; + +import net.minecraft.network.SplitterHandler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@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) { + return 8; + } +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 3d3a18a..2046cf9 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -15,12 +15,11 @@ "environment": "*", "entrypoints": { "main": [ - "dev.tonimatas.packetfixerfabric.PacketFixerFabric" + "net.tonimatasdev.packetfixerfabric.PacketFixerFabric" ] }, "mixins": [ - "packetfixer-common.mixins.json", - "packetfixer-fabric.mixins.json" + "packetfixer.mixins.json" ], "depends": { "fabricloader": ">=0.12.12", diff --git a/fabric/src/main/resources/packetfixer-fabric.mixins.json b/fabric/src/main/resources/packetfixer-fabric.mixins.json deleted file mode 100644 index 9277552..0000000 --- a/fabric/src/main/resources/packetfixer-fabric.mixins.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "dev.tonimatas.packetfixer.mixin", - "compatibilityLevel": "JAVA_8", - "mixins": [ - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/fabric/src/main/resources/packetfixer.mixins.json b/fabric/src/main/resources/packetfixer.mixins.json new file mode 100644 index 0000000..719cdf8 --- /dev/null +++ b/fabric/src/main/resources/packetfixer.mixins.json @@ -0,0 +1,20 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "net.tonimatasdev.packetfixerfabric.mixin", + "compatibilityLevel": "JAVA_8", + "plugin": "net.tonimatasdev.packetfixerfabric.mixin.MixinConfigPlugin", + "mixins": [ + "CustomPayloadC2SPacketMixin", + "CustomPayloadS2CPacketMixin", + "LoginQueryRequestS2CPacketMixin", + "LoginQueryResponseC2SPacketMixin", + "NbtTagSizeTrackerMixin", + "PacketInflaterMixin", + "SizePrependerMixin", + "SplitterHandlerMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index e6d947a..1c762c2 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -1,11 +1,10 @@ -@file:Suppress("DEPRECATION") - -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -import net.fabricmc.loom.task.RemapJarTask -import org.gradle.api.component.AdhocComponentWithVariants +@file:Suppress("UnstableApiUsage") plugins { - id("com.github.johnrengelman.shadow") version "7.1.2" + id("net.minecraftforge.gradle") version "[6.0,6.2)" + id("org.spongepowered.mixin") version "0.7-SNAPSHOT" + id("idea") + id("eclipse") } val modVersion: String by extra @@ -13,67 +12,84 @@ val minecraftVersion: String by extra val forgeVersion: String by extra val forgeVersionRange: String by extra -architectury { - platformSetupLoomIde() - forge() +minecraft { + mappings("official", minecraftVersion) + + copyIdeResources.set(true) + + runs { + configureEach { + workingDirectory(project.file("run")) + property("forge.logging.markers", "REGISTRIES") + property("forge.logging.console.level", "debug") + + mods { + create("packetfixer") { + source(sourceSets.main.get()) + } + } + } + + create("client") { + property("forge.enabledGameTestNamespaces", "packetfixer") + } + + create("server") { + property("forge.enabledGameTestNamespaces", "packetfixer") + args("--nogui") + } + + create("gameTestServer") { + property("forge.enabledGameTestNamespaces", "packetfixer") + } + + create("data") { + workingDirectory(project.file("run-data")) + args("--mod", "packetfixer", "--all", "--output", file("src/generated/resources/"), "--existing", file("src/main/resources/")) + } + } } -loom { - forge { - mixinConfig("packetfixer-common.mixins.json") - mixinConfig("packetfixer-forge.mixins.json") - } +mixin { + add(sourceSets.main.get(), "packetfixer.refmap.json") + config("packetfixer.mixins.json") } -val common by configurations.creating -val shadowCommon by configurations.creating +sourceSets.main.get().resources { srcDir("src/generated/resources") } -configurations["compileClasspath"].extendsFrom(common) -configurations["runtimeClasspath"].extendsFrom(common) -configurations["developmentForge"].extendsFrom(common) +repositories { -dependencies { - forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion") +} - common(project(path = ":common", configuration = "namedElements")) { isTransitive = false } - shadowCommon(project(path = ":common", configuration = "transformProductionForge")) { isTransitive = false } +dependencies { + minecraft("net.minecraftforge:forge:$minecraftVersion-$forgeVersion") + annotationProcessor("org.spongepowered:mixin:0.8.5:processor") } + + tasks.withType { - val replaceProperties = mapOf("minecraftVersion" to minecraftVersion, "forgeVersionRange" to forgeVersionRange, "modVersion" to modVersion) + val replaceProperties = mapOf("forgeVersionRange" to forgeVersionRange, "version" to modVersion, "minecraftVersion" to minecraftVersion) + inputs.properties(replaceProperties) - filesMatching("META-INF/mods.toml") { + filesMatching(listOf("META-INF/mods.toml", "pack.mcmeta")) { expand(replaceProperties) } } -tasks.withType { - exclude("fabric.mod.json") - - configurations = listOf(shadowCommon) - archiveClassifier.set("dev-shadow") -} - -tasks.withType { - val shadowTask = tasks.shadowJar.get() - input.set(shadowTask.archiveFile) - dependsOn(shadowTask) - archiveClassifier.set("") -} tasks.jar { - archiveClassifier.set("dev") -} - -tasks.sourcesJar { - val commonSources = project(":common").tasks.sourcesJar.get() - dependsOn(commonSources) - from(commonSources.archiveFile.map { zipTree(it) }) -} - -components.getByName("java").apply { - withVariantsFromConfiguration(project.configurations["shadowRuntimeElements"]) { - skip() + manifest { + attributes( + "Specification-Title" to "PacketFixerForge", + "Specification-Vendor" to "TonimatasDEV", + "Specification-Version" to modVersion, + "Implementation-Title" to "PacketFixerForge", + "Implementation-Version" to modVersion, + "Implementation-Vendor" to "TonimatasDEV" + ) } + + finalizedBy("reobfJar") } diff --git a/forge/gradle.properties b/forge/gradle.properties deleted file mode 100644 index 32f842a..0000000 --- a/forge/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform=forge \ No newline at end of file diff --git a/forge/src/main/java/dev/tonimatas/packetfixer/PacketFixerForge.java b/forge/src/main/java/dev/tonimatas/packetfixer/PacketFixerForge.java deleted file mode 100644 index f5f4ad4..0000000 --- a/forge/src/main/java/dev/tonimatas/packetfixer/PacketFixerForge.java +++ /dev/null @@ -1,10 +0,0 @@ -package dev.tonimatas.packetfixer; - -import net.minecraftforge.fml.common.Mod; - -@Mod(PacketFixer.MOD_ID) -public class PacketFixerForge { - public PacketFixerForge() { - PacketFixer.init(); - } -} diff --git a/forge/src/main/java/dev/tonimatas/packetfixer/util/forge/HooksImpl.java b/forge/src/main/java/dev/tonimatas/packetfixer/util/forge/HooksImpl.java deleted file mode 100644 index 578a525..0000000 --- a/forge/src/main/java/dev/tonimatas/packetfixer/util/forge/HooksImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -package dev.tonimatas.packetfixer.util.forge; - -import net.minecraftforge.fml.loading.FMLLoader; - -@SuppressWarnings("unused") -public class HooksImpl { - public static boolean isModLoaded(String modId) { - return FMLLoader.getLoadingModList().getModFileById(modId) != null; - } -} diff --git a/forge/src/main/java/net/tonimatasdev/packetfixerforge/PacketFixerForge.java b/forge/src/main/java/net/tonimatasdev/packetfixerforge/PacketFixerForge.java new file mode 100644 index 0000000..53eb446 --- /dev/null +++ b/forge/src/main/java/net/tonimatasdev/packetfixerforge/PacketFixerForge.java @@ -0,0 +1,11 @@ +package net.tonimatasdev.packetfixerforge; + +import net.minecraftforge.fml.common.Mod; +import org.apache.logging.log4j.LogManager; + +@Mod("packetfixer") +public class PacketFixerForge { + public PacketFixerForge() { + LogManager.getLogger().info("PacketFixer (Forge) has been initialized successfully"); + } +} diff --git a/common/src/main/java/dev/tonimatas/packetfixer/mixins/ServerboundCustomQueryPacketMixin.java b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/CCustomPayloadLoginPacketMixin.java similarity index 57% rename from common/src/main/java/dev/tonimatas/packetfixer/mixins/ServerboundCustomQueryPacketMixin.java rename to forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/CCustomPayloadLoginPacketMixin.java index c532bed..a1e0bf4 100644 --- a/common/src/main/java/dev/tonimatas/packetfixer/mixins/ServerboundCustomQueryPacketMixin.java +++ b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/CCustomPayloadLoginPacketMixin.java @@ -1,12 +1,12 @@ -package dev.tonimatas.packetfixer.mixins; +package net.tonimatasdev.packetfixerforge.mixin; -import net.minecraft.network.protocol.login.ServerboundCustomQueryPacket; +import net.minecraft.network.login.client.CCustomPayloadLoginPacket; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; -@Mixin(value = ServerboundCustomQueryPacket.class, priority = 999) -public class ServerboundCustomQueryPacketMixin { +@Mixin(value = CCustomPayloadLoginPacket.class, priority = 999) +public class CCustomPayloadLoginPacketMixin { @ModifyConstant(method = "read", constant = @Constant(intValue = 1048576)) private int newSize(int value) { return value * 100; diff --git a/common/src/main/java/dev/tonimatas/packetfixer/mixins/ServerboundCustomPayloadPacketMixin.java b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/CCustomPayloadPacketMixin.java similarity index 56% rename from common/src/main/java/dev/tonimatas/packetfixer/mixins/ServerboundCustomPayloadPacketMixin.java rename to forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/CCustomPayloadPacketMixin.java index 55d212d..cab96e8 100644 --- a/common/src/main/java/dev/tonimatas/packetfixer/mixins/ServerboundCustomPayloadPacketMixin.java +++ b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/CCustomPayloadPacketMixin.java @@ -1,13 +1,13 @@ -package dev.tonimatas.packetfixer.mixins; +package net.tonimatasdev.packetfixerforge.mixin; -import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket; +import net.minecraft.network.play.client.CCustomPayloadPacket; 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 = 999) -public class ServerboundCustomPayloadPacketMixin { +@Mixin(value = CCustomPayloadPacket.class, priority = 999) +public class CCustomPayloadPacketMixin { @ModifyConstant(method = "read", constant = @Constant(intValue = 32767)) private int newSize(int value) { return value * 100; diff --git a/forge/src/main/java/dev/tonimatas/packetfixer/mixin/MixinConfigPluginForge.java b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/MixinConfigPlugin.java similarity index 58% rename from forge/src/main/java/dev/tonimatas/packetfixer/mixin/MixinConfigPluginForge.java rename to forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/MixinConfigPlugin.java index 29cad6f..76ca504 100644 --- a/forge/src/main/java/dev/tonimatas/packetfixer/mixin/MixinConfigPluginForge.java +++ b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/MixinConfigPlugin.java @@ -1,5 +1,7 @@ -package dev.tonimatas.packetfixer.mixin; +package net.tonimatasdev.packetfixerforge.mixin; +import net.minecraftforge.fml.loading.FMLLoader; +import org.apache.logging.log4j.LogManager; import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; @@ -7,7 +9,7 @@ import java.util.List; import java.util.Set; -public class MixinConfigPluginForge implements IMixinConfigPlugin { +public class MixinConfigPlugin implements IMixinConfigPlugin { @Override public void onLoad(String mixinPackage) { @@ -21,6 +23,14 @@ public String getRefMapperConfig() { @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + boolean krypton = FMLLoader.getLoadingModList().getModFileById("krypton") != null || FMLLoader.getLoadingModList().getModFileById("pluto") != null; + + if (mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerforge.mixin.NettyVarint21FrameDecoder") || mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerforge.mixin.NettyVarint21FrameEncoder")) { + if (krypton) { + LogManager.getLogger().warn("For can't fit X into 3 error fix. Delete Krypton."); + return false; + } + } return true; } @@ -43,4 +53,4 @@ public void preApply(String targetClassName, ClassNode targetClass, String mixin public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { } -} +} \ No newline at end of file diff --git a/common/src/main/java/dev/tonimatas/packetfixer/mixins/NbtAccounterMixin.java b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NbtAccounterMixin.java similarity index 53% rename from common/src/main/java/dev/tonimatas/packetfixer/mixins/NbtAccounterMixin.java rename to forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NbtAccounterMixin.java index 6bfcfeb..fea89f8 100644 --- a/common/src/main/java/dev/tonimatas/packetfixer/mixins/NbtAccounterMixin.java +++ b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NbtAccounterMixin.java @@ -1,15 +1,15 @@ -package dev.tonimatas.packetfixer.mixins; +package net.tonimatasdev.packetfixerforge.mixin; -import net.minecraft.nbt.NbtAccounter; +import net.minecraft.nbt.NBTSizeTracker; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -@Mixin(value = NbtAccounter.class, priority = 999) +@Mixin(value = NBTSizeTracker.class, priority = 999) public abstract class NbtAccounterMixin { - @Redirect(method = "accountBits", at = @At(value = "FIELD", target = "Lnet/minecraft/nbt/NbtAccounter;quota:J", opcode = Opcodes.GETFIELD)) - public long accountBits(NbtAccounter instance) { + @Redirect(method = "accountBits", at = @At(value = "FIELD", target = "Lnet/minecraft/nbt/NBTSizeTracker;quota:J", opcode = Opcodes.GETFIELD)) + public long accountBits(NBTSizeTracker instance) { return 2097152 * 100; } } diff --git a/common/src/main/java/dev/tonimatas/packetfixer/mixins/CompressionDecoderMixin.java b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NettyCompressionDecoderMixin.java similarity index 60% rename from common/src/main/java/dev/tonimatas/packetfixer/mixins/CompressionDecoderMixin.java rename to forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NettyCompressionDecoderMixin.java index c2c8d67..647eb77 100644 --- a/common/src/main/java/dev/tonimatas/packetfixer/mixins/CompressionDecoderMixin.java +++ b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NettyCompressionDecoderMixin.java @@ -1,12 +1,12 @@ -package dev.tonimatas.packetfixer.mixins; +package net.tonimatasdev.packetfixerforge.mixin; -import net.minecraft.network.CompressionDecoder; +import net.minecraft.network.NettyCompressionDecoder; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; -@Mixin(value = CompressionDecoder.class, priority = 999) -public class CompressionDecoderMixin { +@Mixin(value = NettyCompressionDecoder.class, priority = 999) +public class NettyCompressionDecoderMixin { @ModifyConstant(method = "decode", constant = @Constant(intValue = 2097152), require = 0) private int newSize(int value) { return value * 100; diff --git a/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NettyCompressionEncoderMixin.java b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NettyCompressionEncoderMixin.java new file mode 100644 index 0000000..f413c6c --- /dev/null +++ b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NettyCompressionEncoderMixin.java @@ -0,0 +1,14 @@ +package net.tonimatasdev.packetfixerforge.mixin; + +import net.minecraft.network.NettyCompressionEncoder; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(value = NettyCompressionEncoder.class, priority = 999) +public class NettyCompressionEncoderMixin { + @ModifyConstant(method = "encode(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Lio/netty/buffer/ByteBuf;)V", constant = @Constant(intValue = 2097152), require = 0) + private int newSize(int value) { + return value * 100; + } +} diff --git a/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NettyVarint21FrameDecoderMixin.java b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NettyVarint21FrameDecoderMixin.java new file mode 100644 index 0000000..d9b3cdc --- /dev/null +++ b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NettyVarint21FrameDecoderMixin.java @@ -0,0 +1,14 @@ +package net.tonimatasdev.packetfixerforge.mixin; + +import net.minecraft.network.NettyVarint21FrameDecoder; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(value = NettyVarint21FrameDecoder.class, priority = 9999) +public class NettyVarint21FrameDecoderMixin { + @ModifyConstant(method = "decode(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Ljava/util/List;)V", constant = @Constant(intValue = 3)) + private int newSize(int value) { + return 8; + } +} diff --git a/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NettyVarint21FrameEncoderMixin.java b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NettyVarint21FrameEncoderMixin.java new file mode 100644 index 0000000..edd7d22 --- /dev/null +++ b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/NettyVarint21FrameEncoderMixin.java @@ -0,0 +1,14 @@ +package net.tonimatasdev.packetfixerforge.mixin; + +import net.minecraft.network.NettyVarint21FrameEncoder; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(NettyVarint21FrameEncoder.class) +public class NettyVarint21FrameEncoderMixin { + @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; + } +} diff --git a/common/src/main/java/dev/tonimatas/packetfixer/mixins/PacketBufferMixin.java b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/PacketBufferMixin.java similarity index 56% rename from common/src/main/java/dev/tonimatas/packetfixer/mixins/PacketBufferMixin.java rename to forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/PacketBufferMixin.java index 23d4a77..c05f64a 100644 --- a/common/src/main/java/dev/tonimatas/packetfixer/mixins/PacketBufferMixin.java +++ b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/PacketBufferMixin.java @@ -1,13 +1,12 @@ -package dev.tonimatas.packetfixer.mixins; +package net.tonimatasdev.packetfixerforge.mixin; -import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.PacketBuffer; 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.*; -@Mixin(FriendlyByteBuf.class) +@Mixin(PacketBuffer.class) public class PacketBufferMixin { - @ModifyVariable(method = "writeUtf(Ljava/lang/String;I)Lnet/minecraft/network/FriendlyByteBuf;", at = @At(value = "HEAD"), ordinal = 0, argsOnly = true) + @ModifyVariable(method = "writeUtf(Ljava/lang/String;I)Lnet/minecraft/network/PacketBuffer;", at = @At(value = "HEAD"), ordinal = 0, argsOnly = true) private int writeUtfSize(int value) { return Integer.MAX_VALUE; } diff --git a/common/src/main/java/dev/tonimatas/packetfixer/mixins/ClientboundCustomQueryPacketMixin.java b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/SCustomPayloadLoginPacketMixin.java similarity index 57% rename from common/src/main/java/dev/tonimatas/packetfixer/mixins/ClientboundCustomQueryPacketMixin.java rename to forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/SCustomPayloadLoginPacketMixin.java index faca11e..8e1f35e 100644 --- a/common/src/main/java/dev/tonimatas/packetfixer/mixins/ClientboundCustomQueryPacketMixin.java +++ b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/SCustomPayloadLoginPacketMixin.java @@ -1,12 +1,12 @@ -package dev.tonimatas.packetfixer.mixins; +package net.tonimatasdev.packetfixerforge.mixin; -import net.minecraft.network.protocol.login.ClientboundCustomQueryPacket; +import net.minecraft.network.login.server.SCustomPayloadLoginPacket; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; -@Mixin(value = ClientboundCustomQueryPacket.class, priority = 999) -public class ClientboundCustomQueryPacketMixin { +@Mixin(value = SCustomPayloadLoginPacket.class, priority = 999) +public class SCustomPayloadLoginPacketMixin { @ModifyConstant(method = "read", constant = @Constant(intValue = 1048576)) private int newSize(int value) { return value * 100; diff --git a/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/SCustomPayloadPlayPacketMixin.java b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/SCustomPayloadPlayPacketMixin.java new file mode 100644 index 0000000..d8d0a8b --- /dev/null +++ b/forge/src/main/java/net/tonimatasdev/packetfixerforge/mixin/SCustomPayloadPlayPacketMixin.java @@ -0,0 +1,14 @@ +package net.tonimatasdev.packetfixerforge.mixin; + +import net.minecraft.network.play.server.SCustomPayloadPlayPacket; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(value = SCustomPayloadPlayPacket.class, priority = 999) +public class SCustomPayloadPlayPacketMixin { + @ModifyConstant(method = {"(Lnet/minecraft/util/ResourceLocation;Lnet/minecraft/network/PacketBuffer;)V", "read"}, constant = @Constant(intValue = 1048576)) + private int newSize(int value) { + return value * 100; + } +} diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 221275d..d10ed96 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -1,23 +1,23 @@ modLoader="javafml" -loaderVersion="[${forgeVersionRange},)" +loaderVersion="${forgeVersionRange}" license="MIT" -issueTrackerURL="https://github.com/TonimatasDEV/PacketFixer/issues" +issueTrackerURL="https://github.com/TonimatasDEV/PacketFixer" [[mods]] modId="packetfixer" -version="${modVersion}" -displayName="Packet Fixer" -logoFile="icon.png" -updateJSONURL="https://api.modrinth.com/updates/packet-fixer/forge_updates.json" +version="${version}" +displayName="PacketFixer" +icon="icon.png" + authors="TonimatasDEV" description=''' -A simple mod to solve various problems with packets/NBT's. +A simple mod to solve various problems with packets. ''' [[dependencies.packetfixer]] modId="forge" mandatory=true -versionRange="[${forgeVersionRange},)" +versionRange="${forgeVersionRange}" ordering="NONE" side="BOTH" diff --git a/forge/src/main/resources/icon.png b/forge/src/main/resources/icon.png index e69de29..dc341c2 100644 Binary files a/forge/src/main/resources/icon.png and b/forge/src/main/resources/icon.png differ diff --git a/forge/src/main/resources/pack.mcmeta b/forge/src/main/resources/pack.mcmeta index e69de29..4adbfad 100644 --- a/forge/src/main/resources/pack.mcmeta +++ b/forge/src/main/resources/pack.mcmeta @@ -0,0 +1,6 @@ +{ + "pack": { + "description": "PacketFixer resources", + "pack_format": 9 + } +} diff --git a/forge/src/main/resources/packetfixer-forge.mixins.json b/forge/src/main/resources/packetfixer-forge.mixins.json deleted file mode 100644 index 8d86755..0000000 --- a/forge/src/main/resources/packetfixer-forge.mixins.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "dev.tonimatas.packetfixer.mixin", - "compatibilityLevel": "JAVA_8", - "plugin": "dev.tonimatas.packetfixer.mixin.MixinConfigPluginForge", - "injectors": { - "defaultRequire": 1 - }, - "mixins": [ - ] -} diff --git a/forge/src/main/resources/packetfixer.mixins.json b/forge/src/main/resources/packetfixer.mixins.json new file mode 100644 index 0000000..97e9613 --- /dev/null +++ b/forge/src/main/resources/packetfixer.mixins.json @@ -0,0 +1,23 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "net.tonimatasdev.packetfixerforge.mixin", + "compatibilityLevel": "JAVA_8", + "plugin": "net.tonimatasdev.packetfixerforge.mixin.MixinConfigPlugin", + "refmap": "packetfixer.refmap.json", + "injectors": { + "defaultRequire": 1 + }, + "mixins": [ + "CCustomPayloadLoginPacketMixin", + "CCustomPayloadPacketMixin", + "NbtAccounterMixin", + "NettyCompressionDecoderMixin", + "NettyCompressionEncoderMixin", + "NettyVarint21FrameDecoderMixin", + "NettyVarint21FrameEncoderMixin", + "PacketBufferMixin", + "SCustomPayloadLoginPacketMixin", + "SCustomPayloadPlayPacketMixin" + ] +} diff --git a/gradle.properties b/gradle.properties index 8ce3a77..5a56157 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,15 +2,17 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false # Mod Properties -modVersion=1.2.2 +modVersion=1.2.4 -# Minecraft + +# Minecraft properties minecraftVersion=1.16.5 +minecraftVersionRange=[1.16.5] -# Forge Properties -forgeVersion=36.2.41 +# Forge properties +forgeVersion=36.2.39 forgeVersionRange=[36,) -# Fabric Properties -fabricLoaderVersion=0.15.3 -yarnMappings=10 \ No newline at end of file +# Fabric properties +loaderVersion=0.15.6 +yarnMappings=1.16.5+build.10 \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index fc1edb2..eebb4e2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,11 +1,12 @@ pluginManagement { repositories { + mavenCentral() gradlePluginPortal() maven(url = "https://maven.minecraftforge.net/") - maven(url = "https://maven.architectury.dev/") + maven(url = "https://repo.spongepowered.org/repository/maven-public/") maven(url = "https://maven.fabricmc.net/") } } -include("common", "fabric", "forge") -rootProject.name = "PacketFixer" +include("forge", "fabric") +rootProject.name = "PacketFixer" \ No newline at end of file