From 46a5032b6063a0c7f6d3811c6459e78f518e30f1 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sat, 23 May 2026 06:22:05 -0400 Subject: [PATCH 01/23] fabric: split into common / intermediary / official + 26.X aggregator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restructures the Fabric module into four siblings to support Minecraft 26.X alongside the existing 1.16.1→1.21.11 chain-loading range: fabric-common/ pure-Java library (chain-loader-adjacent utilities, loggers, registry manager, Adventure-only types). Has no MC dependency so it survives the intermediary vs official mapping boundary at runtime. fabric-intermediary/ existing chain-loading aggregator (1.14 yarn, intermediary remap). Holds the bootstrap + all MC-typed code + the per-version mcXXXX subprojects (mc1140, mc1194, mc1202, mc1211, mc1216) that the chain loader walks at preLaunch. fabric-official/ structural sibling for MC 26.X (Java 25 floor, Mojang's new version scheme). Uses fabric intermediary 0.0.0 mapping because Mojang stopped publishing official mappings starting with 26.X and Yarn has no 26.X build either; meaningful MC-typed code awaits usable mappings. mc261 is the first chain slot under it. fabric/ top-level aggregator. Loom JiJ-nests the three siblings plus their per-version subprojects into the single published packetevents-fabric-.jar. All existing fabric/{src,mcXXXX} content was moved via `git mv` so blame follows; no source rewrites. The accesswidener resolution in fabric-intermediary now uses the literal filename instead of ${rootProject.name}, which previously silently failed under the workspace composite (rootProject.name = "packetevents-public"). --- fabric-common/build.gradle.kts | 24 +++ .../manager/FabricLoggerManager.java | 0 .../manager/logger/AbstractFabricLogger.java | 0 .../manager/logger/JdkFabricLogger.java | 0 .../manager/logger/Log4jFabricLogger.java | 0 .../manager/logger/Slf4jFabricLogger.java | 0 .../manager/logger/jul/JULoggerFactory.java | 0 .../logger/jul/Log4jBackedJULogger.java | 0 .../logger/jul/Slf4jBackedJULogger.java | 0 .../registry/FabricRegistryManager.java | 0 .../packetevents/util/LazyHolder.java | 0 .../util/viaversion/ViaVersionAccessor.java | 0 fabric-intermediary/build.gradle.kts | 172 ++++++++++++++++++ fabric-intermediary/gradle.properties | 15 ++ .../mc1140/build.gradle.kts | 0 .../mc1140/gradle.properties | 0 .../mc1140/Fabric1140ChainLoadEntrypoint.java | 0 .../Fabric1140ClientChainLoadEntrypoint.java | 0 .../fabric/Fabric1140ClientPlayerManager.java | 0 .../fabric/Fabric1140ServerPlayerManager.java | 0 .../registry/Fabric1140ItemRegistry.java | 0 .../ClientPlayerNetworkHandlerMixin.java | 0 .../mixin/MixinClientConnectionChInit.java | 0 .../MixinClientConnectionCompression.java | 0 .../mixin/MixinServerNetworkIoChInit.java | 0 .../mc1140/mixin/PlayerManagerMixin.java | 0 .../mixin/PlayerManagerRespawnMixin.java | 0 .../mc1140/src/main/resources/fabric.mod.json | 0 .../resources/packetevents-mc1140.mixins.json | 0 .../main/resources/packetevents.accesswidener | 0 .../mc1194/build.gradle.kts | 2 +- .../mc1194/gradle.properties | 0 .../mc1914/Fabric1913ChainLoadEntrypoint.java | 0 .../fabric/Fabric1190ServerPlayerManager.java | 0 .../registry/Fabric1193ItemRegistry.java | 0 .../mc1914/mixin/ClientConnectionMixin.java | 0 .../mc1194/src/main/resources/fabric.mod.json | 0 .../resources/packetevents-mc1914.mixins.json | 0 .../main/resources/packetevents.accesswidener | 0 .../mc1202/build.gradle.kts | 2 +- .../mc1202/gradle.properties | 0 .../ClientPlayerNetworkHandlerMixin.java | 0 .../mc1202/Fabric1202ChainLoadEntrypoint.java | 0 .../fabric/Fabric1202ServerPlayerManager.java | 0 .../mixin/PlayerManagerRespawnMixin.java | 0 .../mc1202/src/main/resources/fabric.mod.json | 0 .../resources/packetevents-mc1202.mixins.json | 0 .../main/resources/packetevents.accesswidener | 0 .../mc1211/build.gradle.kts | 4 +- .../mc1211/gradle.properties | 0 .../Fabric1205ClientChainLoadEntrypoint.java | 0 .../fabric/Fabric1205ClientPlayerManager.java | 0 .../mc1211/src/main/resources/fabric.mod.json | 0 .../main/resources/packetevents.accesswidener | 0 .../mc1215}/build.gradle.kts | 2 +- .../mc1215/gradle.properties | 0 .../mc1215/Fabric1212ChainLoadEntrypoint.java | 0 .../registry/Fabric1212ItemRegistry.java | 0 .../mc1215/src/main/resources/fabric.mod.json | 0 .../main/resources/packetevents.accesswidener | 0 .../mc1216}/build.gradle.kts | 2 +- .../mc1216/gradle.properties | 0 .../mc1216/Fabric1212ChainLoadEntrypoint.java | 0 .../registry/Fabric1212ItemRegistry.java | 0 .../mc1216/src/main/resources/fabric.mod.json | 0 .../main/resources/packetevents.accesswidener | 0 .../mixin/ClientPacketListenerMixin.java | 0 .../packetevents/FabricItemType.java | 0 .../packetevents/PacketEventsClientMod.java | 0 .../packetevents/PacketEventsMod.java | 0 .../packetevents/PacketEventsServerMod.java | 0 .../factory/fabric/FabricChannelInjector.java | 0 .../factory/fabric/FabricPacketEventsAPI.java | 0 .../FabricPacketEventsAPIManagerFactory.java | 0 .../fabric/FabricPacketEventsBuilder.java | 0 .../packetevents/handler/PacketDecoder.java | 0 .../packetevents/handler/PacketEncoder.java | 0 .../packetevents/loader/ChainLoadData.java | 0 .../loader/ChainLoadEntryPoint.java | 0 .../manager/AbstractFabricPlayerManager.java | 0 .../manager/FabricProtocolManager.java | 0 .../manager/FabricServerManager.java | 0 .../manager/InternalFabricPacketListener.java | 0 .../manager/PacketEventsMixinManager.java | 0 .../packetevents/mixin/ConnectionMixin.java | 0 .../packetevents/mixin/PlayerListMixin.java | 0 .../util/FabricCustomPipelineUtil.java | 0 .../util/FabricInjectionUtil.java | 0 .../viaversion/ViaVersionAccessorImpl.java | 0 .../util/viaversion/ViaVersionUtil.java | 0 .../resources/assets/packetevents/icon.png | Bin .../src/main/resources/fabric.mod.json | 29 +++ .../main/resources/packetevents.accesswidener | 0 .../main/resources/packetevents.mixins.json | 0 .../src/main/resources/packetevents/icon.png | Bin fabric-official/build.gradle.kts | 169 +++++++++++++++++ fabric-official/gradle.properties | 12 ++ fabric-official/mc261/build.gradle.kts | 23 +++ fabric-official/mc261/gradle.properties | 1 + .../mc261/src/main/resources/fabric.mod.json | 14 ++ .../src/main/resources/fabric.mod.json | 18 ++ fabric/build.gradle.kts | 166 ++++------------- fabric/gradle.properties | 12 +- fabric/src/main/resources/fabric.mod.json | 27 +-- 104 files changed, 531 insertions(+), 163 deletions(-) create mode 100644 fabric-common/build.gradle.kts rename {fabric => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/FabricLoggerManager.java (100%) rename {fabric => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/logger/AbstractFabricLogger.java (100%) rename {fabric => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/logger/JdkFabricLogger.java (100%) rename {fabric => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/logger/Log4jFabricLogger.java (100%) rename {fabric => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/logger/Slf4jFabricLogger.java (100%) rename {fabric => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/JULoggerFactory.java (100%) rename {fabric => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/Log4jBackedJULogger.java (100%) rename {fabric => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/Slf4jBackedJULogger.java (100%) rename {fabric => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/registry/FabricRegistryManager.java (100%) rename {fabric => fabric-common}/src/main/java/io/github/retrooper/packetevents/util/LazyHolder.java (100%) rename {fabric => fabric-common}/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessor.java (100%) create mode 100644 fabric-intermediary/build.gradle.kts create mode 100644 fabric-intermediary/gradle.properties rename {fabric => fabric-intermediary}/mc1140/build.gradle.kts (100%) rename {fabric => fabric-intermediary}/mc1140/gradle.properties (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/Fabric1140ChainLoadEntrypoint.java (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/Fabric1140ClientChainLoadEntrypoint.java (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ClientPlayerManager.java (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ServerPlayerManager.java (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/manager/registry/Fabric1140ItemRegistry.java (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/ClientPlayerNetworkHandlerMixin.java (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionChInit.java (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionCompression.java (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinServerNetworkIoChInit.java (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/PlayerManagerMixin.java (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/PlayerManagerRespawnMixin.java (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/resources/fabric.mod.json (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/resources/packetevents-mc1140.mixins.json (100%) rename {fabric => fabric-intermediary}/mc1140/src/main/resources/packetevents.accesswidener (100%) rename {fabric => fabric-intermediary}/mc1194/build.gradle.kts (85%) rename {fabric => fabric-intermediary}/mc1194/gradle.properties (100%) rename {fabric => fabric-intermediary}/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/Fabric1913ChainLoadEntrypoint.java (100%) rename {fabric => fabric-intermediary}/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/factory/fabric/Fabric1190ServerPlayerManager.java (100%) rename {fabric => fabric-intermediary}/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/manager/registry/Fabric1193ItemRegistry.java (100%) rename {fabric => fabric-intermediary}/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/mixin/ClientConnectionMixin.java (100%) rename {fabric => fabric-intermediary}/mc1194/src/main/resources/fabric.mod.json (100%) rename {fabric => fabric-intermediary}/mc1194/src/main/resources/packetevents-mc1914.mixins.json (100%) rename {fabric => fabric-intermediary}/mc1194/src/main/resources/packetevents.accesswidener (100%) rename {fabric => fabric-intermediary}/mc1202/build.gradle.kts (84%) rename {fabric => fabric-intermediary}/mc1202/gradle.properties (100%) rename {fabric => fabric-intermediary}/mc1202/src/client/java/io/github/retrooper/packetevents/mc1202/factory/fabric/ClientPlayerNetworkHandlerMixin.java (100%) rename {fabric => fabric-intermediary}/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/Fabric1202ChainLoadEntrypoint.java (100%) rename {fabric => fabric-intermediary}/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/factory/fabric/Fabric1202ServerPlayerManager.java (100%) rename {fabric => fabric-intermediary}/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/mixin/PlayerManagerRespawnMixin.java (100%) rename {fabric => fabric-intermediary}/mc1202/src/main/resources/fabric.mod.json (100%) rename {fabric => fabric-intermediary}/mc1202/src/main/resources/packetevents-mc1202.mixins.json (100%) rename {fabric => fabric-intermediary}/mc1202/src/main/resources/packetevents.accesswidener (100%) rename {fabric => fabric-intermediary}/mc1211/build.gradle.kts (73%) rename {fabric => fabric-intermediary}/mc1211/gradle.properties (100%) rename {fabric => fabric-intermediary}/mc1211/src/client/java/io/github/retrooper/packetevents/mc1211/Fabric1205ClientChainLoadEntrypoint.java (100%) rename {fabric => fabric-intermediary}/mc1211/src/client/java/io/github/retrooper/packetevents/mc1211/factory/fabric/Fabric1205ClientPlayerManager.java (100%) rename {fabric => fabric-intermediary}/mc1211/src/main/resources/fabric.mod.json (100%) rename {fabric => fabric-intermediary}/mc1211/src/main/resources/packetevents.accesswidener (100%) rename {fabric/mc1216 => fabric-intermediary/mc1215}/build.gradle.kts (84%) rename {fabric => fabric-intermediary}/mc1215/gradle.properties (100%) rename {fabric => fabric-intermediary}/mc1215/src/main/java/io/github/retrooper/packetevents/mc1215/Fabric1212ChainLoadEntrypoint.java (100%) rename {fabric => fabric-intermediary}/mc1215/src/main/java/io/github/retrooper/packetevents/mc1215/manager/registry/Fabric1212ItemRegistry.java (100%) rename {fabric => fabric-intermediary}/mc1215/src/main/resources/fabric.mod.json (100%) rename {fabric => fabric-intermediary}/mc1215/src/main/resources/packetevents.accesswidener (100%) rename {fabric/mc1215 => fabric-intermediary/mc1216}/build.gradle.kts (84%) rename {fabric => fabric-intermediary}/mc1216/gradle.properties (100%) rename {fabric => fabric-intermediary}/mc1216/src/main/java/io/github/retrooper/packetevents/mc1216/Fabric1212ChainLoadEntrypoint.java (100%) rename {fabric => fabric-intermediary}/mc1216/src/main/java/io/github/retrooper/packetevents/mc1216/manager/registry/Fabric1212ItemRegistry.java (100%) rename {fabric => fabric-intermediary}/mc1216/src/main/resources/fabric.mod.json (100%) rename {fabric => fabric-intermediary}/mc1216/src/main/resources/packetevents.accesswidener (100%) rename {fabric => fabric-intermediary}/src/client/java/io/github/retrooper/packetevents/mixin/ClientPacketListenerMixin.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/FabricItemType.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/PacketEventsClientMod.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/PacketEventsMod.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/PacketEventsServerMod.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricChannelInjector.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPI.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPIManagerFactory.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsBuilder.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/handler/PacketDecoder.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/handler/PacketEncoder.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadData.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadEntryPoint.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/manager/AbstractFabricPlayerManager.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/manager/FabricProtocolManager.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/manager/FabricServerManager.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/manager/InternalFabricPacketListener.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/manager/PacketEventsMixinManager.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/mixin/PlayerListMixin.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/util/FabricCustomPipelineUtil.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessorImpl.java (100%) rename {fabric => fabric-intermediary}/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionUtil.java (100%) rename {fabric => fabric-intermediary}/src/main/resources/assets/packetevents/icon.png (100%) create mode 100644 fabric-intermediary/src/main/resources/fabric.mod.json rename {fabric => fabric-intermediary}/src/main/resources/packetevents.accesswidener (100%) rename {fabric => fabric-intermediary}/src/main/resources/packetevents.mixins.json (100%) rename {fabric => fabric-intermediary}/src/main/resources/packetevents/icon.png (100%) create mode 100644 fabric-official/build.gradle.kts create mode 100644 fabric-official/gradle.properties create mode 100644 fabric-official/mc261/build.gradle.kts create mode 100644 fabric-official/mc261/gradle.properties create mode 100644 fabric-official/mc261/src/main/resources/fabric.mod.json create mode 100644 fabric-official/src/main/resources/fabric.mod.json diff --git a/fabric-common/build.gradle.kts b/fabric-common/build.gradle.kts new file mode 100644 index 0000000000..d0603021d3 --- /dev/null +++ b/fabric-common/build.gradle.kts @@ -0,0 +1,24 @@ +plugins { + packetevents.`library-conventions` +} + +repositories { + maven("https://maven.fabricmc.net/") + maven("https://repo.viaversion.com/") +} + +dependencies { + compileOnly(libs.bundles.adventure) + compileOnly(project(":api", "shadow")) + compileOnly(project(":netty-common")) + + compileOnly("net.fabricmc:fabric-loader:${rootProject.findProperty("loader_version") ?: "0.16.14"}") + compileOnly(libs.via.version) + compileOnly("org.slf4j:slf4j-api:2.0.16") + compileOnly("org.apache.logging.log4j:log4j-api:2.24.3") +} + +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/FabricLoggerManager.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/FabricLoggerManager.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/FabricLoggerManager.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/FabricLoggerManager.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/AbstractFabricLogger.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/AbstractFabricLogger.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/AbstractFabricLogger.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/AbstractFabricLogger.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/JdkFabricLogger.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/JdkFabricLogger.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/JdkFabricLogger.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/JdkFabricLogger.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/Log4jFabricLogger.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/Log4jFabricLogger.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/Log4jFabricLogger.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/Log4jFabricLogger.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/Slf4jFabricLogger.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/Slf4jFabricLogger.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/Slf4jFabricLogger.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/Slf4jFabricLogger.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/JULoggerFactory.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/JULoggerFactory.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/JULoggerFactory.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/JULoggerFactory.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/Log4jBackedJULogger.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/Log4jBackedJULogger.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/Log4jBackedJULogger.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/Log4jBackedJULogger.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/Slf4jBackedJULogger.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/Slf4jBackedJULogger.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/Slf4jBackedJULogger.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/logger/jul/Slf4jBackedJULogger.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/registry/FabricRegistryManager.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/registry/FabricRegistryManager.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/registry/FabricRegistryManager.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/registry/FabricRegistryManager.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/util/LazyHolder.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/util/LazyHolder.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/util/LazyHolder.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/util/LazyHolder.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessor.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessor.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessor.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessor.java diff --git a/fabric-intermediary/build.gradle.kts b/fabric-intermediary/build.gradle.kts new file mode 100644 index 0000000000..bfb2ba5ab2 --- /dev/null +++ b/fabric-intermediary/build.gradle.kts @@ -0,0 +1,172 @@ +import me.modmuss50.mpp.ModPublishExtension +import me.modmuss50.mpp.PublishModTask +import net.fabricmc.loom.task.RemapJarTask +import net.fabricmc.loom.task.RemapSourcesJarTask +import net.fabricmc.loom.task.prod.ServerProductionRunTask + +plugins { + packetevents.`library-conventions` + net.fabricmc.`fabric-loom-remap` +} + +repositories { + mavenCentral() + maven("https://repo.viaversion.com/") + maven("https://jitpack.io") // Conditional Mixin +} + +val minecraft_version: String by project +val yarn_mappings: String by project +val loader_version: String by project + +dependencies { + api(libs.bundles.adventure) + api(project(":api", "shadow")) + api(project(":netty-common")) + api(project(":fabric-common")) + modApi("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") + + include(libs.bundles.adventure) + include(project(":api", "shadow")) + include(project(":netty-common")) + include(project(":fabric-common")) + include("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") + + // To change the versions, see the gradle.properties file + minecraft("com.mojang:minecraft:$minecraft_version") + mappings("net.fabricmc:yarn:$yarn_mappings") + + compileOnly(libs.via.version) + compileOnly("org.slf4j:slf4j-simple:2.0.16") +} + +loom { + mods { + register("packetevents-${project.name}") { + sourceSet(sourceSets.main.get()) + } + } +} + +allprojects { + apply(plugin = "fabric-loom") + apply(plugin = "packetevents.publish-conventions") + + repositories { + maven("https://repo.codemc.io/repository/maven-snapshots/") + } + + dependencies { + modImplementation("net.fabricmc:fabric-loader:$loader_version") + } + + tasks { + withType { + val targetJavaVersion = 17 + if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible) { + options.release = targetJavaVersion + } + } + + remapJar { + destinationDirectory = rootProject.layout.buildDirectory.dir("libs") + archiveBaseName = "${rootProject.name}-fabric${if (project.name != "fabric") "-${project.name}" else ""}" + archiveVersion = rootProject.ext["artifactVersion"] as String + } + + remapSourcesJar { + archiveBaseName = "${rootProject.name}-fabric${if (project.name != "fabric") "-${project.name}" else ""}" + archiveVersion = rootProject.ext["artifactVersion"] as String + } + } + + loom { + mixin { + // Replaces strings in annotations instead of using refmap + // This allows us to write mixins that target methodName* and have them work across versions + // Even as the signature changes without having to use @Dynamic and intermediary names + // This preserves some compile-time safety, reduces jar size but be careful to not inject into wrong methods + useLegacyMixinAp.set(false) + } + + // accesswidener file is literally named "packetevents.accesswidener" (matches + // fabric.mod.json's accessWidener key), not "${rootProject.name}.accesswidener". + // rootProject.name resolves to "packetevents-public" in the workspace composite. + val accessWidenerFile = sourceSets["main"].resources.srcDirs.first() + .resolve("packetevents.accesswidener") + + if (accessWidenerFile.exists()) { + accessWidenerPath.set(accessWidenerFile) + } + } +} + +subprojects { + version = rootProject.version + val minecraft_version: String by project + + repositories { + maven { + name = "ParchmentMC" + url = uri("https://maven.parchmentmc.org") + } + } + + dependencies { + compileOnly(project(":api", "shadow")) + compileOnly(project(":netty-common")) + compileOnly(project(":fabric-common")) + compileOnly(project(":fabric-intermediary", configuration = "namedElements")) + } + + // version replacement already processed for :fabric in packetevents.`library-conventions` + tasks { + processResources { + // Declare the inputs to allow Gradle to track changes + inputs.property("version", project.version) + inputs.property("modName", "packetevents-${project.name}") + inputs.property("minecraft_version", minecraft_version) // Add if you use this + + // Match and expand variables in fabric.mod.json + filesMatching("fabric.mod.json") { + expand( + mapOf( + "version" to project.version, + "modName" to "packetevents-${project.name}", + "minecraft_version" to minecraft_version // Or pull from a variable + ) + ) + } + } + } + + tasks.register("prodServer") { + javaLauncher = javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(21) + } + } +} + +subprojects.forEach { + tasks.named("remapJar").configure { + dependsOn("${it.path}:remapJar") + } +} + +tasks.remapJar.configure { + subprojects.forEach { subproject -> + subproject.tasks.matching { it.name == "remapJar" }.configureEach { + nestedJars.from(this) + } + } +} + +tasks.withType { + dependsOn(tasks.named("remapJar")) + dependsOn(tasks.named("remapSourcesJar")) +} + +configure { + file = tasks.named("remapJar").flatMap { it.archiveFile } + additionalFiles.from(tasks.named("remapSourcesJar").flatMap { it.archiveFile }) +} diff --git a/fabric-intermediary/gradle.properties b/fabric-intermediary/gradle.properties new file mode 100644 index 0000000000..2a2d2fcea0 --- /dev/null +++ b/fabric-intermediary/gradle.properties @@ -0,0 +1,15 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true + +# Fabric Properties +# check these on https://fabricmc.net/develop +minecraft_version=1.14 +yarn_mappings=1.14+build.21 +loader_version=0.16.14 + +publishing.skip_files=true +publishing.platform=fabric +publishing.modrinth.loaders=fabric +publishing.modrinth.version.start=1.14 +publishing.modrinth.version.end=latest diff --git a/fabric/mc1140/build.gradle.kts b/fabric-intermediary/mc1140/build.gradle.kts similarity index 100% rename from fabric/mc1140/build.gradle.kts rename to fabric-intermediary/mc1140/build.gradle.kts diff --git a/fabric/mc1140/gradle.properties b/fabric-intermediary/mc1140/gradle.properties similarity index 100% rename from fabric/mc1140/gradle.properties rename to fabric-intermediary/mc1140/gradle.properties diff --git a/fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/Fabric1140ChainLoadEntrypoint.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/Fabric1140ChainLoadEntrypoint.java similarity index 100% rename from fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/Fabric1140ChainLoadEntrypoint.java rename to fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/Fabric1140ChainLoadEntrypoint.java diff --git a/fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/Fabric1140ClientChainLoadEntrypoint.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/Fabric1140ClientChainLoadEntrypoint.java similarity index 100% rename from fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/Fabric1140ClientChainLoadEntrypoint.java rename to fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/Fabric1140ClientChainLoadEntrypoint.java diff --git a/fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ClientPlayerManager.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ClientPlayerManager.java similarity index 100% rename from fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ClientPlayerManager.java rename to fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ClientPlayerManager.java diff --git a/fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ServerPlayerManager.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ServerPlayerManager.java similarity index 100% rename from fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ServerPlayerManager.java rename to fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ServerPlayerManager.java diff --git a/fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/manager/registry/Fabric1140ItemRegistry.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/manager/registry/Fabric1140ItemRegistry.java similarity index 100% rename from fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/manager/registry/Fabric1140ItemRegistry.java rename to fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/manager/registry/Fabric1140ItemRegistry.java diff --git a/fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/ClientPlayerNetworkHandlerMixin.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/ClientPlayerNetworkHandlerMixin.java similarity index 100% rename from fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/ClientPlayerNetworkHandlerMixin.java rename to fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/ClientPlayerNetworkHandlerMixin.java diff --git a/fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionChInit.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionChInit.java similarity index 100% rename from fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionChInit.java rename to fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionChInit.java diff --git a/fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionCompression.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionCompression.java similarity index 100% rename from fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionCompression.java rename to fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionCompression.java diff --git a/fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinServerNetworkIoChInit.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinServerNetworkIoChInit.java similarity index 100% rename from fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinServerNetworkIoChInit.java rename to fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinServerNetworkIoChInit.java diff --git a/fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/PlayerManagerMixin.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/PlayerManagerMixin.java similarity index 100% rename from fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/PlayerManagerMixin.java rename to fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/PlayerManagerMixin.java diff --git a/fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/PlayerManagerRespawnMixin.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/PlayerManagerRespawnMixin.java similarity index 100% rename from fabric/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/PlayerManagerRespawnMixin.java rename to fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/PlayerManagerRespawnMixin.java diff --git a/fabric/mc1140/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json similarity index 100% rename from fabric/mc1140/src/main/resources/fabric.mod.json rename to fabric-intermediary/mc1140/src/main/resources/fabric.mod.json diff --git a/fabric/mc1140/src/main/resources/packetevents-mc1140.mixins.json b/fabric-intermediary/mc1140/src/main/resources/packetevents-mc1140.mixins.json similarity index 100% rename from fabric/mc1140/src/main/resources/packetevents-mc1140.mixins.json rename to fabric-intermediary/mc1140/src/main/resources/packetevents-mc1140.mixins.json diff --git a/fabric/mc1140/src/main/resources/packetevents.accesswidener b/fabric-intermediary/mc1140/src/main/resources/packetevents.accesswidener similarity index 100% rename from fabric/mc1140/src/main/resources/packetevents.accesswidener rename to fabric-intermediary/mc1140/src/main/resources/packetevents.accesswidener diff --git a/fabric/mc1194/build.gradle.kts b/fabric-intermediary/mc1194/build.gradle.kts similarity index 85% rename from fabric/mc1194/build.gradle.kts rename to fabric-intermediary/mc1194/build.gradle.kts index d34cc42f67..06e7eae906 100644 --- a/fabric/mc1194/build.gradle.kts +++ b/fabric-intermediary/mc1194/build.gradle.kts @@ -6,7 +6,7 @@ repositories { } dependencies { - compileOnly(project(":fabric:mc1140", configuration = "namedElements")) + compileOnly(project(":fabric-intermediary:mc1140", configuration = "namedElements")) // To change the versions, see the gradle.properties file minecraft("com.mojang:minecraft:$minecraft_version") mappings("net.fabricmc:yarn:$yarn_mappings") diff --git a/fabric/mc1194/gradle.properties b/fabric-intermediary/mc1194/gradle.properties similarity index 100% rename from fabric/mc1194/gradle.properties rename to fabric-intermediary/mc1194/gradle.properties diff --git a/fabric/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/Fabric1913ChainLoadEntrypoint.java b/fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/Fabric1913ChainLoadEntrypoint.java similarity index 100% rename from fabric/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/Fabric1913ChainLoadEntrypoint.java rename to fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/Fabric1913ChainLoadEntrypoint.java diff --git a/fabric/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/factory/fabric/Fabric1190ServerPlayerManager.java b/fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/factory/fabric/Fabric1190ServerPlayerManager.java similarity index 100% rename from fabric/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/factory/fabric/Fabric1190ServerPlayerManager.java rename to fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/factory/fabric/Fabric1190ServerPlayerManager.java diff --git a/fabric/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/manager/registry/Fabric1193ItemRegistry.java b/fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/manager/registry/Fabric1193ItemRegistry.java similarity index 100% rename from fabric/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/manager/registry/Fabric1193ItemRegistry.java rename to fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/manager/registry/Fabric1193ItemRegistry.java diff --git a/fabric/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/mixin/ClientConnectionMixin.java b/fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/mixin/ClientConnectionMixin.java similarity index 100% rename from fabric/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/mixin/ClientConnectionMixin.java rename to fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/mixin/ClientConnectionMixin.java diff --git a/fabric/mc1194/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1194/src/main/resources/fabric.mod.json similarity index 100% rename from fabric/mc1194/src/main/resources/fabric.mod.json rename to fabric-intermediary/mc1194/src/main/resources/fabric.mod.json diff --git a/fabric/mc1194/src/main/resources/packetevents-mc1914.mixins.json b/fabric-intermediary/mc1194/src/main/resources/packetevents-mc1914.mixins.json similarity index 100% rename from fabric/mc1194/src/main/resources/packetevents-mc1914.mixins.json rename to fabric-intermediary/mc1194/src/main/resources/packetevents-mc1914.mixins.json diff --git a/fabric/mc1194/src/main/resources/packetevents.accesswidener b/fabric-intermediary/mc1194/src/main/resources/packetevents.accesswidener similarity index 100% rename from fabric/mc1194/src/main/resources/packetevents.accesswidener rename to fabric-intermediary/mc1194/src/main/resources/packetevents.accesswidener diff --git a/fabric/mc1202/build.gradle.kts b/fabric-intermediary/mc1202/build.gradle.kts similarity index 84% rename from fabric/mc1202/build.gradle.kts rename to fabric-intermediary/mc1202/build.gradle.kts index 765bc2f7fa..6d81c0c2c9 100644 --- a/fabric/mc1202/build.gradle.kts +++ b/fabric-intermediary/mc1202/build.gradle.kts @@ -2,7 +2,7 @@ val minecraft_version: String by project val yarn_mappings: String by project dependencies { - compileOnly(project(":fabric:mc1140", configuration = "namedElements")) + compileOnly(project(":fabric-intermediary:mc1140", configuration = "namedElements")) // To change the versions, see the gradle.properties file minecraft("com.mojang:minecraft:$minecraft_version") diff --git a/fabric/mc1202/gradle.properties b/fabric-intermediary/mc1202/gradle.properties similarity index 100% rename from fabric/mc1202/gradle.properties rename to fabric-intermediary/mc1202/gradle.properties diff --git a/fabric/mc1202/src/client/java/io/github/retrooper/packetevents/mc1202/factory/fabric/ClientPlayerNetworkHandlerMixin.java b/fabric-intermediary/mc1202/src/client/java/io/github/retrooper/packetevents/mc1202/factory/fabric/ClientPlayerNetworkHandlerMixin.java similarity index 100% rename from fabric/mc1202/src/client/java/io/github/retrooper/packetevents/mc1202/factory/fabric/ClientPlayerNetworkHandlerMixin.java rename to fabric-intermediary/mc1202/src/client/java/io/github/retrooper/packetevents/mc1202/factory/fabric/ClientPlayerNetworkHandlerMixin.java diff --git a/fabric/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/Fabric1202ChainLoadEntrypoint.java b/fabric-intermediary/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/Fabric1202ChainLoadEntrypoint.java similarity index 100% rename from fabric/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/Fabric1202ChainLoadEntrypoint.java rename to fabric-intermediary/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/Fabric1202ChainLoadEntrypoint.java diff --git a/fabric/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/factory/fabric/Fabric1202ServerPlayerManager.java b/fabric-intermediary/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/factory/fabric/Fabric1202ServerPlayerManager.java similarity index 100% rename from fabric/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/factory/fabric/Fabric1202ServerPlayerManager.java rename to fabric-intermediary/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/factory/fabric/Fabric1202ServerPlayerManager.java diff --git a/fabric/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/mixin/PlayerManagerRespawnMixin.java b/fabric-intermediary/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/mixin/PlayerManagerRespawnMixin.java similarity index 100% rename from fabric/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/mixin/PlayerManagerRespawnMixin.java rename to fabric-intermediary/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/mixin/PlayerManagerRespawnMixin.java diff --git a/fabric/mc1202/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1202/src/main/resources/fabric.mod.json similarity index 100% rename from fabric/mc1202/src/main/resources/fabric.mod.json rename to fabric-intermediary/mc1202/src/main/resources/fabric.mod.json diff --git a/fabric/mc1202/src/main/resources/packetevents-mc1202.mixins.json b/fabric-intermediary/mc1202/src/main/resources/packetevents-mc1202.mixins.json similarity index 100% rename from fabric/mc1202/src/main/resources/packetevents-mc1202.mixins.json rename to fabric-intermediary/mc1202/src/main/resources/packetevents-mc1202.mixins.json diff --git a/fabric/mc1202/src/main/resources/packetevents.accesswidener b/fabric-intermediary/mc1202/src/main/resources/packetevents.accesswidener similarity index 100% rename from fabric/mc1202/src/main/resources/packetevents.accesswidener rename to fabric-intermediary/mc1202/src/main/resources/packetevents.accesswidener diff --git a/fabric/mc1211/build.gradle.kts b/fabric-intermediary/mc1211/build.gradle.kts similarity index 73% rename from fabric/mc1211/build.gradle.kts rename to fabric-intermediary/mc1211/build.gradle.kts index 35a7903df9..e87e9d5b82 100644 --- a/fabric/mc1211/build.gradle.kts +++ b/fabric-intermediary/mc1211/build.gradle.kts @@ -2,8 +2,8 @@ val minecraft_version: String by project val yarn_mappings: String by project dependencies { - compileOnly(project(":fabric:mc1202", configuration = "namedElements")) - compileOnly(project(":fabric:mc1140", configuration = "namedElements")) + compileOnly(project(":fabric-intermediary:mc1202", configuration = "namedElements")) + compileOnly(project(":fabric-intermediary:mc1140", configuration = "namedElements")) // To change the versions, see the gradle.properties file minecraft("com.mojang:minecraft:$minecraft_version") diff --git a/fabric/mc1211/gradle.properties b/fabric-intermediary/mc1211/gradle.properties similarity index 100% rename from fabric/mc1211/gradle.properties rename to fabric-intermediary/mc1211/gradle.properties diff --git a/fabric/mc1211/src/client/java/io/github/retrooper/packetevents/mc1211/Fabric1205ClientChainLoadEntrypoint.java b/fabric-intermediary/mc1211/src/client/java/io/github/retrooper/packetevents/mc1211/Fabric1205ClientChainLoadEntrypoint.java similarity index 100% rename from fabric/mc1211/src/client/java/io/github/retrooper/packetevents/mc1211/Fabric1205ClientChainLoadEntrypoint.java rename to fabric-intermediary/mc1211/src/client/java/io/github/retrooper/packetevents/mc1211/Fabric1205ClientChainLoadEntrypoint.java diff --git a/fabric/mc1211/src/client/java/io/github/retrooper/packetevents/mc1211/factory/fabric/Fabric1205ClientPlayerManager.java b/fabric-intermediary/mc1211/src/client/java/io/github/retrooper/packetevents/mc1211/factory/fabric/Fabric1205ClientPlayerManager.java similarity index 100% rename from fabric/mc1211/src/client/java/io/github/retrooper/packetevents/mc1211/factory/fabric/Fabric1205ClientPlayerManager.java rename to fabric-intermediary/mc1211/src/client/java/io/github/retrooper/packetevents/mc1211/factory/fabric/Fabric1205ClientPlayerManager.java diff --git a/fabric/mc1211/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1211/src/main/resources/fabric.mod.json similarity index 100% rename from fabric/mc1211/src/main/resources/fabric.mod.json rename to fabric-intermediary/mc1211/src/main/resources/fabric.mod.json diff --git a/fabric/mc1211/src/main/resources/packetevents.accesswidener b/fabric-intermediary/mc1211/src/main/resources/packetevents.accesswidener similarity index 100% rename from fabric/mc1211/src/main/resources/packetevents.accesswidener rename to fabric-intermediary/mc1211/src/main/resources/packetevents.accesswidener diff --git a/fabric/mc1216/build.gradle.kts b/fabric-intermediary/mc1215/build.gradle.kts similarity index 84% rename from fabric/mc1216/build.gradle.kts rename to fabric-intermediary/mc1215/build.gradle.kts index 96da42c684..2655c2059b 100644 --- a/fabric/mc1216/build.gradle.kts +++ b/fabric-intermediary/mc1215/build.gradle.kts @@ -2,7 +2,7 @@ val minecraft_version: String by project val yarn_mappings: String by project dependencies { - compileOnly(project(":fabric:mc1211", configuration = "namedElements")) + compileOnly(project(":fabric-intermediary:mc1211", configuration = "namedElements")) // To change the versions, see the gradle.properties file minecraft("com.mojang:minecraft:$minecraft_version") diff --git a/fabric/mc1215/gradle.properties b/fabric-intermediary/mc1215/gradle.properties similarity index 100% rename from fabric/mc1215/gradle.properties rename to fabric-intermediary/mc1215/gradle.properties diff --git a/fabric/mc1215/src/main/java/io/github/retrooper/packetevents/mc1215/Fabric1212ChainLoadEntrypoint.java b/fabric-intermediary/mc1215/src/main/java/io/github/retrooper/packetevents/mc1215/Fabric1212ChainLoadEntrypoint.java similarity index 100% rename from fabric/mc1215/src/main/java/io/github/retrooper/packetevents/mc1215/Fabric1212ChainLoadEntrypoint.java rename to fabric-intermediary/mc1215/src/main/java/io/github/retrooper/packetevents/mc1215/Fabric1212ChainLoadEntrypoint.java diff --git a/fabric/mc1215/src/main/java/io/github/retrooper/packetevents/mc1215/manager/registry/Fabric1212ItemRegistry.java b/fabric-intermediary/mc1215/src/main/java/io/github/retrooper/packetevents/mc1215/manager/registry/Fabric1212ItemRegistry.java similarity index 100% rename from fabric/mc1215/src/main/java/io/github/retrooper/packetevents/mc1215/manager/registry/Fabric1212ItemRegistry.java rename to fabric-intermediary/mc1215/src/main/java/io/github/retrooper/packetevents/mc1215/manager/registry/Fabric1212ItemRegistry.java diff --git a/fabric/mc1215/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1215/src/main/resources/fabric.mod.json similarity index 100% rename from fabric/mc1215/src/main/resources/fabric.mod.json rename to fabric-intermediary/mc1215/src/main/resources/fabric.mod.json diff --git a/fabric/mc1215/src/main/resources/packetevents.accesswidener b/fabric-intermediary/mc1215/src/main/resources/packetevents.accesswidener similarity index 100% rename from fabric/mc1215/src/main/resources/packetevents.accesswidener rename to fabric-intermediary/mc1215/src/main/resources/packetevents.accesswidener diff --git a/fabric/mc1215/build.gradle.kts b/fabric-intermediary/mc1216/build.gradle.kts similarity index 84% rename from fabric/mc1215/build.gradle.kts rename to fabric-intermediary/mc1216/build.gradle.kts index 96da42c684..2655c2059b 100644 --- a/fabric/mc1215/build.gradle.kts +++ b/fabric-intermediary/mc1216/build.gradle.kts @@ -2,7 +2,7 @@ val minecraft_version: String by project val yarn_mappings: String by project dependencies { - compileOnly(project(":fabric:mc1211", configuration = "namedElements")) + compileOnly(project(":fabric-intermediary:mc1211", configuration = "namedElements")) // To change the versions, see the gradle.properties file minecraft("com.mojang:minecraft:$minecraft_version") diff --git a/fabric/mc1216/gradle.properties b/fabric-intermediary/mc1216/gradle.properties similarity index 100% rename from fabric/mc1216/gradle.properties rename to fabric-intermediary/mc1216/gradle.properties diff --git a/fabric/mc1216/src/main/java/io/github/retrooper/packetevents/mc1216/Fabric1212ChainLoadEntrypoint.java b/fabric-intermediary/mc1216/src/main/java/io/github/retrooper/packetevents/mc1216/Fabric1212ChainLoadEntrypoint.java similarity index 100% rename from fabric/mc1216/src/main/java/io/github/retrooper/packetevents/mc1216/Fabric1212ChainLoadEntrypoint.java rename to fabric-intermediary/mc1216/src/main/java/io/github/retrooper/packetevents/mc1216/Fabric1212ChainLoadEntrypoint.java diff --git a/fabric/mc1216/src/main/java/io/github/retrooper/packetevents/mc1216/manager/registry/Fabric1212ItemRegistry.java b/fabric-intermediary/mc1216/src/main/java/io/github/retrooper/packetevents/mc1216/manager/registry/Fabric1212ItemRegistry.java similarity index 100% rename from fabric/mc1216/src/main/java/io/github/retrooper/packetevents/mc1216/manager/registry/Fabric1212ItemRegistry.java rename to fabric-intermediary/mc1216/src/main/java/io/github/retrooper/packetevents/mc1216/manager/registry/Fabric1212ItemRegistry.java diff --git a/fabric/mc1216/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1216/src/main/resources/fabric.mod.json similarity index 100% rename from fabric/mc1216/src/main/resources/fabric.mod.json rename to fabric-intermediary/mc1216/src/main/resources/fabric.mod.json diff --git a/fabric/mc1216/src/main/resources/packetevents.accesswidener b/fabric-intermediary/mc1216/src/main/resources/packetevents.accesswidener similarity index 100% rename from fabric/mc1216/src/main/resources/packetevents.accesswidener rename to fabric-intermediary/mc1216/src/main/resources/packetevents.accesswidener diff --git a/fabric/src/client/java/io/github/retrooper/packetevents/mixin/ClientPacketListenerMixin.java b/fabric-intermediary/src/client/java/io/github/retrooper/packetevents/mixin/ClientPacketListenerMixin.java similarity index 100% rename from fabric/src/client/java/io/github/retrooper/packetevents/mixin/ClientPacketListenerMixin.java rename to fabric-intermediary/src/client/java/io/github/retrooper/packetevents/mixin/ClientPacketListenerMixin.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/FabricItemType.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/FabricItemType.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/FabricItemType.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/FabricItemType.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/PacketEventsClientMod.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsClientMod.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/PacketEventsClientMod.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsClientMod.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/PacketEventsMod.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsMod.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/PacketEventsMod.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsMod.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/PacketEventsServerMod.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsServerMod.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/PacketEventsServerMod.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsServerMod.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricChannelInjector.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricChannelInjector.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricChannelInjector.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricChannelInjector.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPI.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPI.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPI.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPI.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPIManagerFactory.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPIManagerFactory.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPIManagerFactory.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPIManagerFactory.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsBuilder.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsBuilder.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsBuilder.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsBuilder.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/handler/PacketDecoder.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/handler/PacketDecoder.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/handler/PacketDecoder.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/handler/PacketDecoder.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/handler/PacketEncoder.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/handler/PacketEncoder.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/handler/PacketEncoder.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/handler/PacketEncoder.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadData.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadData.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadData.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadData.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadEntryPoint.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadEntryPoint.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadEntryPoint.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadEntryPoint.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/AbstractFabricPlayerManager.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/AbstractFabricPlayerManager.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/AbstractFabricPlayerManager.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/AbstractFabricPlayerManager.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/FabricProtocolManager.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/FabricProtocolManager.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/FabricProtocolManager.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/FabricProtocolManager.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/FabricServerManager.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/FabricServerManager.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/FabricServerManager.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/FabricServerManager.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/InternalFabricPacketListener.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/InternalFabricPacketListener.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/InternalFabricPacketListener.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/InternalFabricPacketListener.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/manager/PacketEventsMixinManager.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/PacketEventsMixinManager.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/manager/PacketEventsMixinManager.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/PacketEventsMixinManager.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/mixin/PlayerListMixin.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/mixin/PlayerListMixin.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/mixin/PlayerListMixin.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/mixin/PlayerListMixin.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/util/FabricCustomPipelineUtil.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/FabricCustomPipelineUtil.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/util/FabricCustomPipelineUtil.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/FabricCustomPipelineUtil.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessorImpl.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessorImpl.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessorImpl.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessorImpl.java diff --git a/fabric/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionUtil.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionUtil.java similarity index 100% rename from fabric/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionUtil.java rename to fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionUtil.java diff --git a/fabric/src/main/resources/assets/packetevents/icon.png b/fabric-intermediary/src/main/resources/assets/packetevents/icon.png similarity index 100% rename from fabric/src/main/resources/assets/packetevents/icon.png rename to fabric-intermediary/src/main/resources/assets/packetevents/icon.png diff --git a/fabric-intermediary/src/main/resources/fabric.mod.json b/fabric-intermediary/src/main/resources/fabric.mod.json new file mode 100644 index 0000000000..5582fe056f --- /dev/null +++ b/fabric-intermediary/src/main/resources/fabric.mod.json @@ -0,0 +1,29 @@ +{ + "schemaVersion": 1, + "id": "packetevents", + "version": "${version}", + "name": "PacketEvents", + "description": "", + "authors": [ + "retrooper" + ], + "contact": {}, + "license": "GPL-3.0", + "icon": "assets/packetevents/icon.png", + "environment": "*", + "entrypoints": { + "preLaunch": [ + "io.github.retrooper.packetevents.PacketEventsMod" + ], + "main": [ + "io.github.retrooper.packetevents.PacketEventsMod" + ] + }, + "mixins": [ + "packetevents.mixins.json" + ], + "accessWidener": "packetevents.accesswidener", + "depends": { + "fabricloader": "*" + } +} diff --git a/fabric/src/main/resources/packetevents.accesswidener b/fabric-intermediary/src/main/resources/packetevents.accesswidener similarity index 100% rename from fabric/src/main/resources/packetevents.accesswidener rename to fabric-intermediary/src/main/resources/packetevents.accesswidener diff --git a/fabric/src/main/resources/packetevents.mixins.json b/fabric-intermediary/src/main/resources/packetevents.mixins.json similarity index 100% rename from fabric/src/main/resources/packetevents.mixins.json rename to fabric-intermediary/src/main/resources/packetevents.mixins.json diff --git a/fabric/src/main/resources/packetevents/icon.png b/fabric-intermediary/src/main/resources/packetevents/icon.png similarity index 100% rename from fabric/src/main/resources/packetevents/icon.png rename to fabric-intermediary/src/main/resources/packetevents/icon.png diff --git a/fabric-official/build.gradle.kts b/fabric-official/build.gradle.kts new file mode 100644 index 0000000000..f1c046b038 --- /dev/null +++ b/fabric-official/build.gradle.kts @@ -0,0 +1,169 @@ +import me.modmuss50.mpp.ModPublishExtension +import me.modmuss50.mpp.PublishModTask +import net.fabricmc.loom.task.RemapJarTask +import net.fabricmc.loom.task.RemapSourcesJarTask +import net.fabricmc.loom.task.prod.ServerProductionRunTask + +plugins { + packetevents.`library-conventions` + net.fabricmc.`fabric-loom-remap` +} + +repositories { + mavenCentral() + maven("https://repo.viaversion.com/") + maven("https://jitpack.io") +} + +val minecraft_version: String by project +val loader_version: String by project + +dependencies { + api(project(":api", "shadow")) + api(project(":netty-common")) + api(project(":fabric-common")) + + include(project(":api", "shadow")) + include(project(":netty-common")) + include(project(":fabric-common")) + + minecraft("com.mojang:minecraft:$minecraft_version") + // Mojang stopped publishing official mappings starting with MC 26.X — manifest has + // neither client_mappings nor server_mappings, and Yarn hasn't published for 26.X. + // Fabric intermediary publishes a `0.0.0` empty mapping for 26.X. Until usable + // mappings land, fabric-official is a structural stub that loads on 26.X but + // cannot reference meaningful MC symbols. Re-enable officialMojangMappings() and + // pull in conditional-mixin/Adventure mod-deps the day Mojang or Yarn resume + // publishing — both fail Loom source-remap against the 0.0.0 mapping. + mappings("net.fabricmc:intermediary:0.0.0:v2") +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(25)) + } +} + +loom { + mods { + register("packetevents-${project.name}") { + sourceSet(sourceSets.main.get()) + } + } +} + +allprojects { + apply(plugin = "fabric-loom") + apply(plugin = "packetevents.publish-conventions") + + repositories { + maven("https://repo.codemc.io/repository/maven-snapshots/") + } + + dependencies { + modImplementation("net.fabricmc:fabric-loader:$loader_version") + } + + java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(25)) + } + } + + tasks { + // Intermediary 0.0.0 has no "named" namespace, so source remap fails. Disable + // it where these tasks exist (root fabric-official has them; mc261 subproject + // may not). + matching { it.name == "remapSourcesJar" || it.name == "sourcesJar" } + .configureEach { enabled = false } + + withType { + val targetJavaVersion = 25 + options.release = targetJavaVersion + } + + remapJar { + destinationDirectory = rootProject.layout.buildDirectory.dir("libs") + archiveBaseName = "${rootProject.name}-fabric${if (project.name != "fabric-official") "-${project.name}" else "-official"}" + archiveVersion = rootProject.ext["artifactVersion"] as String + } + + remapSourcesJar { + archiveBaseName = "${rootProject.name}-fabric${if (project.name != "fabric-official") "-${project.name}" else "-official"}" + archiveVersion = rootProject.ext["artifactVersion"] as String + } + } + + loom { + mixin { + useLegacyMixinAp.set(false) + } + + val accessWidenerFile = sourceSets["main"].resources.srcDirs.first() + .resolve("${rootProject.name}.accesswidener") + + if (accessWidenerFile.exists()) { + accessWidenerPath.set(accessWidenerFile) + } + } +} + +subprojects { + version = rootProject.version + val minecraft_version: String by project + + dependencies { + compileOnly(project(":api", "shadow")) + compileOnly(project(":netty-common")) + compileOnly(project(":fabric-common")) + compileOnly(project(":fabric-official", configuration = "namedElements")) + } + + tasks { + processResources { + inputs.property("version", project.version) + inputs.property("modName", "packetevents-${project.name}") + inputs.property("minecraft_version", minecraft_version) + + filesMatching("fabric.mod.json") { + expand( + mapOf( + "version" to project.version, + "modName" to "packetevents-${project.name}", + "minecraft_version" to minecraft_version, + ) + ) + } + } + } + + tasks.register("prodServer") { + javaLauncher = javaToolchains.launcherFor { + languageVersion = JavaLanguageVersion.of(25) + } + } +} + +subprojects.forEach { + tasks.named("remapJar").configure { + dependsOn("${it.path}:remapJar") + } +} + +tasks.remapJar.configure { + subprojects.forEach { subproject -> + subproject.tasks.matching { it.name == "remapJar" }.configureEach { + nestedJars.from(this) + } + } +} + +tasks.withType { + dependsOn(tasks.named("remapJar")) + dependsOn(tasks.named("remapSourcesJar")) +} + +configure { + file = tasks.named("remapJar").flatMap { it.archiveFile } + additionalFiles.from(tasks.named("remapSourcesJar").flatMap { it.archiveFile }) +} diff --git a/fabric-official/gradle.properties b/fabric-official/gradle.properties new file mode 100644 index 0000000000..891ea70173 --- /dev/null +++ b/fabric-official/gradle.properties @@ -0,0 +1,12 @@ +org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true + +# Fabric Properties (MC 26.1+, official Mojang mappings, Java 25) +minecraft_version=26.1.2 +loader_version=0.19.1 + +publishing.skip_files=true +publishing.platform=fabric +publishing.modrinth.loaders=fabric +publishing.modrinth.version.start=26.1 +publishing.modrinth.version.end=latest diff --git a/fabric-official/mc261/build.gradle.kts b/fabric-official/mc261/build.gradle.kts new file mode 100644 index 0000000000..ebd54d3b8f --- /dev/null +++ b/fabric-official/mc261/build.gradle.kts @@ -0,0 +1,23 @@ +val minecraft_version: String by project + +plugins { + net.fabricmc.`fabric-loom-remap` +} + +repositories { + mavenCentral() +} + +dependencies { + minecraft("com.mojang:minecraft:$minecraft_version") + // See fabric-official/build.gradle.kts for why this isn't officialMojangMappings(). + mappings("net.fabricmc:intermediary:0.0.0:v2") +} + +loom { + mods { + register("packetevents-${project.name}") { + sourceSet(sourceSets.main.get()) + } + } +} diff --git a/fabric-official/mc261/gradle.properties b/fabric-official/mc261/gradle.properties new file mode 100644 index 0000000000..610ac2d374 --- /dev/null +++ b/fabric-official/mc261/gradle.properties @@ -0,0 +1 @@ +minecraft_version=26.1.2 diff --git a/fabric-official/mc261/src/main/resources/fabric.mod.json b/fabric-official/mc261/src/main/resources/fabric.mod.json new file mode 100644 index 0000000000..5ba5cbe9bc --- /dev/null +++ b/fabric-official/mc261/src/main/resources/fabric.mod.json @@ -0,0 +1,14 @@ +{ + "schemaVersion": 1, + "id": "packetevents-fabric-mc261", + "version": "${version}", + "name": "${modName}", + "description": "Per-version source root for Minecraft 26.1+. Currently a structural stub; meaningful entrypoints await usable mappings.", + "license": "GPL-3.0", + "environment": "*", + "depends": { + "minecraft": ">=26.1", + "java": ">=25", + "fabricloader": ">=0.19" + } +} diff --git a/fabric-official/src/main/resources/fabric.mod.json b/fabric-official/src/main/resources/fabric.mod.json new file mode 100644 index 0000000000..f95f8932a7 --- /dev/null +++ b/fabric-official/src/main/resources/fabric.mod.json @@ -0,0 +1,18 @@ +{ + "schemaVersion": 1, + "id": "packetevents-fabric-official", + "version": "${version}", + "name": "PacketEvents (Fabric, official mappings)", + "description": "PacketEvents variant for Minecraft 26.X (Mojang's new version scheme, Java 25+). Currently a structural stub — Mojang has stopped publishing official mappings, and Yarn has no 26.X build, so meaningful MC-typed code awaits mapping availability.", + "authors": ["retrooper", "GrimAnticheat"], + "contact": { + "homepage": "https://github.com/GrimAnticheat/packetevents" + }, + "license": "GPL-3.0", + "environment": "*", + "depends": { + "minecraft": ">=26.1", + "java": ">=25", + "fabricloader": ">=0.19" + } +} diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 7979506608..62e3139ba4 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,18 +1,20 @@ -import me.modmuss50.mpp.ModPublishExtension -import me.modmuss50.mpp.PublishModTask import net.fabricmc.loom.task.RemapJarTask -import net.fabricmc.loom.task.RemapSourcesJarTask -import net.fabricmc.loom.task.prod.ServerProductionRunTask + +// Top-level fabric aggregator — produces the published `packetevents-fabric-.jar` +// by JiJ-nesting the intermediary and official variant outputs along with the shared +// fabric-common library. This jar is a "meta" Fabric mod: its own fabric.mod.json carries +// the version + depends declarations, and Fabric Loader extracts the nested per-variant +// mods at runtime and gates them by their declared minecraft version ranges. plugins { packetevents.`library-conventions` + packetevents.`publish-conventions` net.fabricmc.`fabric-loom-remap` } repositories { mavenCentral() maven("https://repo.viaversion.com/") - maven("https://jitpack.io") // Conditional Mixin } val minecraft_version: String by project @@ -20,147 +22,47 @@ val yarn_mappings: String by project val loader_version: String by project dependencies { - api(libs.bundles.adventure) - api(project(":api", "shadow")) - api(project(":netty-common")) - modApi("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") - - include(libs.bundles.adventure) - include(project(":api", "shadow")) - include(project(":netty-common")) - include("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") - - // To change the versions, see the gradle.properties file + // Bind to the oldest MC version we support so Loom remap is happy with a 1.16.1 floor. minecraft("com.mojang:minecraft:$minecraft_version") mappings("net.fabricmc:yarn:$yarn_mappings") + modImplementation("net.fabricmc:fabric-loader:$loader_version") - compileOnly(libs.via.version) - compileOnly("org.slf4j:slf4j-simple:2.0.16") + // The aggregator does not contribute MC-typed code itself, but pulls the variants + // and fabric-common in as nested JiJ dependencies. + include(project(":fabric-common")) + include(project(":fabric-intermediary", configuration = "namedElements")) + include(project(":fabric-official", configuration = "namedElements")) } loom { mods { - register("packetevents-${project.name}") { + register("packetevents") { sourceSet(sourceSets.main.get()) } } } -allprojects { - apply(plugin = "fabric-loom") - apply(plugin = "packetevents.publish-conventions") +evaluationDependsOn(":fabric-intermediary") +evaluationDependsOn(":fabric-official") - repositories { - maven("https://repo.codemc.io/repository/maven-snapshots/") +tasks { + withType { + options.release = 17 } - dependencies { - modImplementation("net.fabricmc:fabric-loader:$loader_version") - } - - tasks { - withType { - val targetJavaVersion = 17 - if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible) { - options.release = targetJavaVersion - } - } - - remapJar { - destinationDirectory = rootProject.layout.buildDirectory.dir("libs") - archiveBaseName = "${rootProject.name}-fabric${if (project.name != "fabric") "-${project.name}" else ""}" - archiveVersion = rootProject.ext["artifactVersion"] as String - } - - remapSourcesJar { - archiveBaseName = "${rootProject.name}-fabric${if (project.name != "fabric") "-${project.name}" else ""}" - archiveVersion = rootProject.ext["artifactVersion"] as String - } - } - - loom { - mixin { - // Replaces strings in annotations instead of using refmap - // This allows us to write mixins that target methodName* and have them work across versions - // Even as the signature changes without having to use @Dynamic and intermediary names - // This preserves some compile-time safety, reduces jar size but be careful to not inject into wrong methods - useLegacyMixinAp.set(false) - } - - val accessWidenerFile = sourceSets["main"].resources.srcDirs.first() - .resolve("${rootProject.name}.accesswidener") - - if (accessWidenerFile.exists()) { - accessWidenerPath.set(accessWidenerFile) - } - } -} - -subprojects { - version = rootProject.version - val minecraft_version: String by project - - repositories { - maven { - name = "ParchmentMC" - url = uri("https://maven.parchmentmc.org") - } + remapJar { + destinationDirectory = rootProject.layout.buildDirectory.dir("libs") + archiveBaseName = "${rootProject.name}-fabric" + archiveVersion = rootProject.ext["artifactVersion"] as String + + // Pull the variant remapJars as nested mods. evaluationDependsOn above + // guarantees the Loom tasks in the variant projects are registered before + // this configuration block runs. + val intermediaryRemap = project(":fabric-intermediary").tasks.named("remapJar") + val officialRemap = project(":fabric-official").tasks.named("remapJar") + dependsOn(intermediaryRemap) + dependsOn(officialRemap) + nestedJars.from(intermediaryRemap) + nestedJars.from(officialRemap) } - - dependencies { - compileOnly(project(":api", "shadow")) - compileOnly(project(":netty-common")) - compileOnly(project(":fabric", configuration = "namedElements")) - } - - // version replacement already processed for :fabric in packetevents.`library-conventions` - tasks { - processResources { - // Declare the inputs to allow Gradle to track changes - inputs.property("version", project.version) - inputs.property("modName", "packetevents-${project.name}") - inputs.property("minecraft_version", minecraft_version) // Add if you use this - - // Match and expand variables in fabric.mod.json - filesMatching("fabric.mod.json") { - expand( - mapOf( - "version" to project.version, - "modName" to "packetevents-${project.name}", - "minecraft_version" to minecraft_version // Or pull from a variable - ) - ) - } - } - } - - tasks.register("prodServer") { - javaLauncher = javaToolchains.launcherFor { - languageVersion = JavaLanguageVersion.of(21) - } - } -} - -subprojects.forEach { - tasks.named("remapJar").configure { - dependsOn("${it.path}:remapJar") - } -} - -tasks.remapJar.configure { - subprojects.forEach { subproject -> - subproject.tasks.matching { it.name == "remapJar" }.configureEach { - nestedJars.from(this) - } - } -} - -tasks.withType { - dependsOn(tasks.named("remapJar")) - dependsOn(tasks.named("remapSourcesJar")) -} - -configure { - file = tasks.named("remapJar").flatMap { it.archiveFile } - additionalFiles.from(tasks.named("remapSourcesJar").flatMap { it.archiveFile }) } diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 2a2d2fcea0..2dd2c35751 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -1,15 +1,15 @@ -# Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true -# Fabric Properties -# check these on https://fabricmc.net/develop -minecraft_version=1.14 -yarn_mappings=1.14+build.21 +# Aggregator builds against the lowest-supported MC version (1.16.1) so Loom is happy. +# Per-variant MC versions live in fabric-intermediary/gradle.properties and +# fabric-official/gradle.properties. +minecraft_version=1.16.1 +yarn_mappings=1.16.1+build.21 loader_version=0.16.14 publishing.skip_files=true publishing.platform=fabric publishing.modrinth.loaders=fabric -publishing.modrinth.version.start=1.14 +publishing.modrinth.version.start=1.16.1 publishing.modrinth.version.end=latest diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 5582fe056f..05d3d40d44 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -3,27 +3,16 @@ "id": "packetevents", "version": "${version}", "name": "PacketEvents", - "description": "", - "authors": [ - "retrooper" - ], - "contact": {}, + "description": "PacketEvents — Fabric meta-mod aggregator (loads intermediary or official variant by MC range).", + "authors": ["retrooper", "GrimAnticheat"], + "contact": { + "homepage": "https://github.com/GrimAnticheat/packetevents" + }, "license": "GPL-3.0", - "icon": "assets/packetevents/icon.png", "environment": "*", - "entrypoints": { - "preLaunch": [ - "io.github.retrooper.packetevents.PacketEventsMod" - ], - "main": [ - "io.github.retrooper.packetevents.PacketEventsMod" - ] - }, - "mixins": [ - "packetevents.mixins.json" - ], - "accessWidener": "packetevents.accesswidener", "depends": { - "fabricloader": "*" + "minecraft": ">=1.16.1", + "java": ">=17", + "fabricloader": ">=0.16" } } From ff8662f3e91e70bc4495a48223266e206e85166a Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sat, 23 May 2026 06:38:14 -0400 Subject: [PATCH 02/23] =?UTF-8?q?fabric:=20codex=20review=20#1=20fixes=20?= =?UTF-8?q?=E2=80=94=20modid,=20MC=20range,=20JiJ,=20skip-worktree?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Clear skip-worktree on settings.gradle.kts so the include() additions for fabric-common / fabric-intermediary / fabric-official actually ship in the branch (the worktree-only edit didn't reach the index in the prior commit). - Rename fabric-intermediary modid from "packetevents" to "packetevents-fabric-intermediary". Sharing the id with the outer aggregator made Fabric Loader see duplicate "packetevents" mods. - Add `minecraft: ">=1.16.1 <26"` upper bound to fabric-intermediary so intermediary-mapped code can't load on a 26.X server where intermediary symbol names don't resolve. - Stop double-JiJ in fabric/build.gradle.kts: aggregator now nests the variant remapJars by file path only (no `include(project(...))` for variants), which removed the dev/namedElements jars that Loom was silently adding alongside the real remapped output. - Fix archiveBaseName for variants. fabric-intermediary's nested jar used to be `packetevents-public-fabric-fabric-intermediary` (double "fabric" because the convention prepends `-fabric` then `-${project.name}`). Variants now compute archiveBaseName explicitly. Findings #5 and #6 from the review remain open: 1.14/1.15 support drop is intentional per project floor (1.16.1); the variant-scaffolding duplication is the next clean-up but not a functional blocker. --- fabric-intermediary/build.gradle.kts | 14 +++++++-- .../src/main/resources/fabric.mod.json | 6 ++-- fabric-official/build.gradle.kts | 12 ++++++-- fabric/build.gradle.kts | 29 +++++++++---------- settings.gradle.kts | 18 +++++++----- 5 files changed, 49 insertions(+), 30 deletions(-) diff --git a/fabric-intermediary/build.gradle.kts b/fabric-intermediary/build.gradle.kts index bfb2ba5ab2..f44336e517 100644 --- a/fabric-intermediary/build.gradle.kts +++ b/fabric-intermediary/build.gradle.kts @@ -70,12 +70,22 @@ allprojects { remapJar { destinationDirectory = rootProject.layout.buildDirectory.dir("libs") - archiveBaseName = "${rootProject.name}-fabric${if (project.name != "fabric") "-${project.name}" else ""}" + archiveBaseName = if (project == project(":fabric-intermediary")) { + "${rootProject.name}-fabric-intermediary" + } else { + // mcXXXX subprojects keep their own short name (e.g. mc1140) so the + // nested jars stay `packetevents-fabric-mc1140-.jar`. + "${rootProject.name}-fabric-${project.name}" + } archiveVersion = rootProject.ext["artifactVersion"] as String } remapSourcesJar { - archiveBaseName = "${rootProject.name}-fabric${if (project.name != "fabric") "-${project.name}" else ""}" + archiveBaseName = if (project == project(":fabric-intermediary")) { + "${rootProject.name}-fabric-intermediary" + } else { + "${rootProject.name}-fabric-${project.name}" + } archiveVersion = rootProject.ext["artifactVersion"] as String } } diff --git a/fabric-intermediary/src/main/resources/fabric.mod.json b/fabric-intermediary/src/main/resources/fabric.mod.json index 5582fe056f..11bb903164 100644 --- a/fabric-intermediary/src/main/resources/fabric.mod.json +++ b/fabric-intermediary/src/main/resources/fabric.mod.json @@ -1,6 +1,6 @@ { "schemaVersion": 1, - "id": "packetevents", + "id": "packetevents-fabric-intermediary", "version": "${version}", "name": "PacketEvents", "description": "", @@ -24,6 +24,8 @@ ], "accessWidener": "packetevents.accesswidener", "depends": { - "fabricloader": "*" + "minecraft": ">=1.16.1 <26", + "java": ">=17", + "fabricloader": ">=0.16" } } diff --git a/fabric-official/build.gradle.kts b/fabric-official/build.gradle.kts index f1c046b038..a5efa62ac9 100644 --- a/fabric-official/build.gradle.kts +++ b/fabric-official/build.gradle.kts @@ -84,12 +84,20 @@ allprojects { remapJar { destinationDirectory = rootProject.layout.buildDirectory.dir("libs") - archiveBaseName = "${rootProject.name}-fabric${if (project.name != "fabric-official") "-${project.name}" else "-official"}" + archiveBaseName = if (project == project(":fabric-official")) { + "${rootProject.name}-fabric-official" + } else { + "${rootProject.name}-fabric-${project.name}" + } archiveVersion = rootProject.ext["artifactVersion"] as String } remapSourcesJar { - archiveBaseName = "${rootProject.name}-fabric${if (project.name != "fabric-official") "-${project.name}" else "-official"}" + archiveBaseName = if (project == project(":fabric-official")) { + "${rootProject.name}-fabric-official" + } else { + "${rootProject.name}-fabric-${project.name}" + } archiveVersion = rootProject.ext["artifactVersion"] as String } } diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 62e3139ba4..295a6dc39d 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -27,11 +27,11 @@ dependencies { mappings("net.fabricmc:yarn:$yarn_mappings") modImplementation("net.fabricmc:fabric-loader:$loader_version") - // The aggregator does not contribute MC-typed code itself, but pulls the variants - // and fabric-common in as nested JiJ dependencies. + // The aggregator does not contribute MC-typed code itself. fabric-common is a + // regular Java library so it's pulled via Loom's `include(...)` JiJ mechanism. + // The variant mods (fabric-intermediary, fabric-official) are nested below via + // `nestedJars.from(remapJar)` to avoid the double-JiJ of dev + remapped artifacts. include(project(":fabric-common")) - include(project(":fabric-intermediary", configuration = "namedElements")) - include(project(":fabric-official", configuration = "namedElements")) } loom { @@ -42,9 +42,6 @@ loom { } } -evaluationDependsOn(":fabric-intermediary") -evaluationDependsOn(":fabric-official") - tasks { withType { options.release = 17 @@ -55,14 +52,14 @@ tasks { archiveBaseName = "${rootProject.name}-fabric" archiveVersion = rootProject.ext["artifactVersion"] as String - // Pull the variant remapJars as nested mods. evaluationDependsOn above - // guarantees the Loom tasks in the variant projects are registered before - // this configuration block runs. - val intermediaryRemap = project(":fabric-intermediary").tasks.named("remapJar") - val officialRemap = project(":fabric-official").tasks.named("remapJar") - dependsOn(intermediaryRemap) - dependsOn(officialRemap) - nestedJars.from(intermediaryRemap) - nestedJars.from(officialRemap) + // Nest the variant remapJars without triggering full project configuration + // (which would inject dev/namedElements jars into the include config). + dependsOn(":fabric-intermediary:remapJar", ":fabric-official:remapJar") + nestedJars.from( + rootProject.layout.buildDirectory.file("libs/${rootProject.name}-fabric-intermediary-${rootProject.ext["artifactVersion"]}.jar") + ) + nestedJars.from( + rootProject.layout.buildDirectory.file("libs/${rootProject.name}-fabric-official-${rootProject.ext["artifactVersion"]}.jar") + ) } } diff --git a/settings.gradle.kts b/settings.gradle.kts index da87313fae..12b50d30c8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -25,7 +25,7 @@ plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" } -rootProject.name = "packetevents" +rootProject.name = "packetevents-public" include("api") include("netty-common") // Platform modules @@ -34,13 +34,15 @@ include("bungeecord") include("velocity") include("sponge") include("fabric") -include(":fabric:mc1140") -include(":fabric:mc1194") -include(":fabric:mc1202") -include(":fabric:mc1211") -include(":fabric:mc1216") +include("fabric-common") +include("fabric-intermediary") +include(":fabric-intermediary:mc1140") +include(":fabric-intermediary:mc1194") +include(":fabric-intermediary:mc1202") +include(":fabric-intermediary:mc1211") +include(":fabric-intermediary:mc1216") +include("fabric-official") +include(":fabric-official:mc261") // Patch modules include(":patch:adventure-text-serializer-gson") include(":patch:adventure-text-serializer-legacy") - -if (file("workspace.gradle.kts").exists()) apply(from = "workspace.gradle.kts") From 2ef32fd364e38ecca000b802d6601c676219a582 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sat, 23 May 2026 06:43:12 -0400 Subject: [PATCH 03/23] ci: bump CI JDK to 25 for fabric-official 26.X support MC 26.1+ requires Java 25 for Loom to fetch/configure the server jar. The previous Java 21 toolchain causes a fail-fast in fabric-official's configure phase: "Minecraft 26.1.2 requires Java 25 but Gradle is using 21". Bumps the CI Gradle JDK to 25 so the Loom setup of fabric-official can proceed. Java 17/21 modules continue to compile via Gradle's release flag. --- .github/workflows/gradle-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index fe73893098..82ea6d822d 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -15,10 +15,10 @@ jobs: - name: Validate gradle wrapper uses: gradle/actions/wrapper-validation@v5 - - name: Set up JDK 21 + - name: Set up JDK 25 uses: actions/setup-java@v5 with: - java-version: '21' + java-version: '25' distribution: 'temurin' cache: 'gradle' server-id: github # Value of the distributionManagement/repository/id field of the pom.xml From cbd2272d5049f61a7c317a2cfad4d4d68bb0dded Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sat, 23 May 2026 17:13:27 -0400 Subject: [PATCH 04/23] fabric-intermediary mcXXXX: add minecraft <26 upper bounds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same root cause as the Grim PR — Fabric Loader reads each mod's accessWidener in loadClassTweakers BEFORE filtering by depends, so an intermediary-namespaced AW from packetevents-mc1140/mc1194/mc1202/mc1211/ mc1215/mc1216 would crash on a 26.X server (`Namespace (intermediary) does not match current runtime namespace (official)`). Each mcXXXX now declares an explicit `<26` upper bound on minecraft. mc1140 also gets an explicit `>=1.14` lower bound (it was previously unbound). Verified end-to-end: fabric-26.1.2 boots clean with only fabric-official loaded; fabric-1.21.11 loads packetevents-mc1140/mc1194/mc1202/mc1211/ mc1216 chain without regression. --- fabric-intermediary/mc1140/src/main/resources/fabric.mod.json | 3 ++- fabric-intermediary/mc1194/src/main/resources/fabric.mod.json | 2 +- fabric-intermediary/mc1202/src/main/resources/fabric.mod.json | 2 +- fabric-intermediary/mc1211/src/main/resources/fabric.mod.json | 2 +- fabric-intermediary/mc1215/src/main/resources/fabric.mod.json | 2 +- fabric-intermediary/mc1216/src/main/resources/fabric.mod.json | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json index 77ee14b251..c5bdee26c4 100644 --- a/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json +++ b/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json @@ -23,6 +23,7 @@ ], "accessWidener": "packetevents.accesswidener", "depends": { - "fabricloader": "*" + "fabricloader": "*", + "minecraft": ">=1.14 <26" } } diff --git a/fabric-intermediary/mc1194/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1194/src/main/resources/fabric.mod.json index 3333e4a001..23cd5d5e9f 100644 --- a/fabric-intermediary/mc1194/src/main/resources/fabric.mod.json +++ b/fabric-intermediary/mc1194/src/main/resources/fabric.mod.json @@ -21,6 +21,6 @@ "accessWidener": "packetevents.accesswidener", "depends": { "fabricloader": "*", - "minecraft": ">=1.19" + "minecraft": ">=1.19 \u003c26" } } diff --git a/fabric-intermediary/mc1202/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1202/src/main/resources/fabric.mod.json index 6cae6dfacc..cbe562acbb 100644 --- a/fabric-intermediary/mc1202/src/main/resources/fabric.mod.json +++ b/fabric-intermediary/mc1202/src/main/resources/fabric.mod.json @@ -21,6 +21,6 @@ "accessWidener": "packetevents.accesswidener", "depends": { "fabricloader": "*", - "minecraft": ">=1.20.2" + "minecraft": ">=1.20.2 \u003c26" } } diff --git a/fabric-intermediary/mc1211/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1211/src/main/resources/fabric.mod.json index 53ae9aa1a1..8d04897cfd 100644 --- a/fabric-intermediary/mc1211/src/main/resources/fabric.mod.json +++ b/fabric-intermediary/mc1211/src/main/resources/fabric.mod.json @@ -18,6 +18,6 @@ "accessWidener": "packetevents.accesswidener", "depends": { "fabricloader": "*", - "minecraft": ">=1.20.5" + "minecraft": ">=1.20.5 \u003c26" } } diff --git a/fabric-intermediary/mc1215/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1215/src/main/resources/fabric.mod.json index da12739935..f90ad896f1 100644 --- a/fabric-intermediary/mc1215/src/main/resources/fabric.mod.json +++ b/fabric-intermediary/mc1215/src/main/resources/fabric.mod.json @@ -18,6 +18,6 @@ "accessWidener": "packetevents.accesswidener", "depends": { "fabricloader": "*", - "minecraft": ">=1.21.2" + "minecraft": ">=1.21.2 \u003c26" } } diff --git a/fabric-intermediary/mc1216/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1216/src/main/resources/fabric.mod.json index 9e93ed05a3..51737cbb76 100644 --- a/fabric-intermediary/mc1216/src/main/resources/fabric.mod.json +++ b/fabric-intermediary/mc1216/src/main/resources/fabric.mod.json @@ -18,6 +18,6 @@ "accessWidener": "packetevents.accesswidener", "depends": { "fabricloader": "*", - "minecraft": ">=1.21.2" + "minecraft": ">=1.21.2 \u003c26" } } From fe7b6f3b28b2b3548a6033a4689a200967e9c9ea Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sun, 24 May 2026 00:45:59 -0400 Subject: [PATCH 05/23] fabric: erase MC types into fabric-common as Object-bridged surface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hoist the 13 MC-free + 6 MC-typed bridge classes from fabric-intermediary into fabric-common. The MC-typed signatures widen to platform-agnostic types so a Mojang-named branch (fabric-official) can reuse the same common code without seeing yarn names: * PacketEventsMod: drop both isOurConnection(ClientConnection / NetworkSide) overloads. They were documented as upstream ABI-compat only and unused internally — removing them is cheaper than another bridge. * FabricInjectionUtil.injectAtPipelineBuilder takes PacketSide instead of NetworkSide; the per-version mixin entrypoints convert at the callsite. fireUserLoginEvent takes Object instead of ServerPlayerEntity. * AbstractFabricPlayerManager.disconnectPlayer is now (Object, String); add an abstract kickOnException(Object, String) so PacketEncoder's netty-thread exception path no longer has to instanceof a yarn type. * PacketEncoder / PacketDecoder .player widen from PlayerEntity to Object. PacketEncoder.exceptionCaught delegates to playerManager.kickOnException instead of the inline ServerPlayerEntity cast + server-thread hop. * FabricChannelInjector.setPlayer drops the (PlayerEntity) casts (the fields are Object now). Per-version concrete managers (mc1140/mc1194/mc1202) updated to override disconnectPlayer(Object, String) with an internal cast back to ServerPlayerEntity. mc1140 also picks up the kickOnException override since that's where the server-thread hop logic lives. FabricItemType stays in fabric-intermediary — its 7 MC touches don't erase cleanly; a parallel Mojang-named FabricItemType will live in fabric-official. Dead code dropped: FabricCustomPipelineUtil (unused everywhere) and the two empty ConnectionMixin/PlayerListMixin placeholders. Build: :fabric-common:compileJava + all five :fabric-intermediary:mcXXXX remapJar tasks pass. fabric-common grows from 17KB to 54KB carrying the moved bridge classes; fabric-intermediary jar stays the same size since the moved bytes JiJ back in via include(project(":fabric-common")). --- fabric-common/build.gradle.kts | 12 +++ .../packetevents/PacketEventsClientMod.java | 0 .../packetevents/PacketEventsMod.java | 18 ---- .../packetevents/PacketEventsServerMod.java | 0 .../factory/fabric/FabricChannelInjector.java | 5 +- .../factory/fabric/FabricPacketEventsAPI.java | 0 .../FabricPacketEventsAPIManagerFactory.java | 0 .../fabric/FabricPacketEventsBuilder.java | 0 .../packetevents/handler/PacketDecoder.java | 4 +- .../packetevents/handler/PacketEncoder.java | 15 ++- .../packetevents/loader/ChainLoadData.java | 0 .../loader/ChainLoadEntryPoint.java | 0 .../manager/AbstractFabricPlayerManager.java | 19 +++- .../manager/FabricProtocolManager.java | 0 .../manager/FabricServerManager.java | 0 .../manager/InternalFabricPacketListener.java | 0 .../manager/PacketEventsMixinManager.java | 0 .../util/FabricInjectionUtil.java | 15 +-- .../viaversion/ViaVersionAccessorImpl.java | 0 .../util/viaversion/ViaVersionUtil.java | 0 .../fabric/Fabric1140ServerPlayerManager.java | 10 +- .../mixin/MixinClientConnectionChInit.java | 4 +- .../mixin/MixinServerNetworkIoChInit.java | 4 +- .../fabric/Fabric1190ServerPlayerManager.java | 4 +- .../mc1914/mixin/ClientConnectionMixin.java | 7 +- .../fabric/Fabric1202ServerPlayerManager.java | 4 +- .../packetevents/mixin/ConnectionMixin.java | 0 .../packetevents/mixin/PlayerListMixin.java | 0 .../util/FabricCustomPipelineUtil.java | 98 ------------------- 29 files changed, 66 insertions(+), 153 deletions(-) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/PacketEventsClientMod.java (100%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/PacketEventsMod.java (87%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/PacketEventsServerMod.java (100%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricChannelInjector.java (97%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPI.java (100%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPIManagerFactory.java (100%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsBuilder.java (100%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/handler/PacketDecoder.java (96%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/handler/PacketEncoder.java (90%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadData.java (100%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadEntryPoint.java (100%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/AbstractFabricPlayerManager.java (77%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/FabricProtocolManager.java (100%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/FabricServerManager.java (100%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/InternalFabricPacketListener.java (100%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/manager/PacketEventsMixinManager.java (100%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java (97%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessorImpl.java (100%) rename {fabric-intermediary => fabric-common}/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionUtil.java (100%) delete mode 100644 fabric-intermediary/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java delete mode 100644 fabric-intermediary/src/main/java/io/github/retrooper/packetevents/mixin/PlayerListMixin.java delete mode 100644 fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/FabricCustomPipelineUtil.java diff --git a/fabric-common/build.gradle.kts b/fabric-common/build.gradle.kts index d0603021d3..20fa587bae 100644 --- a/fabric-common/build.gradle.kts +++ b/fabric-common/build.gradle.kts @@ -5,6 +5,8 @@ plugins { repositories { maven("https://maven.fabricmc.net/") maven("https://repo.viaversion.com/") + maven("https://repo.spongepowered.org/repository/maven-public/") + maven("https://jitpack.io") } dependencies { @@ -16,6 +18,16 @@ dependencies { compileOnly(libs.via.version) compileOnly("org.slf4j:slf4j-api:2.0.16") compileOnly("org.apache.logging.log4j:log4j-api:2.24.3") + // PacketEventsMixinManager extends a conditional-mixin base class, which itself + // extends Sponge Mixin's IMixinConfigPlugin. + compileOnly("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") + compileOnly("org.spongepowered:mixin:0.8.7") +} + +// library-conventions defaults to release=8; the moved bridge code uses switch +// expressions and pattern-matching instanceof that require Java 17+. +tasks.withType { + options.release = 17 } java { diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsClientMod.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/PacketEventsClientMod.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsClientMod.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/PacketEventsClientMod.java diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsMod.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/PacketEventsMod.java similarity index 87% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsMod.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/PacketEventsMod.java index 40400e3c2f..70fc17afe9 100644 --- a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsMod.java +++ b/fabric-common/src/main/java/io/github/retrooper/packetevents/PacketEventsMod.java @@ -25,12 +25,9 @@ import io.github.retrooper.packetevents.loader.ChainLoadData; import io.github.retrooper.packetevents.loader.ChainLoadEntryPoint; import net.fabricmc.api.EnvType; -import com.github.retrooper.packetevents.protocol.PacketSide; import net.fabricmc.api.ModInitializer; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; -import net.minecraft.network.ClientConnection; -import net.minecraft.network.NetworkSide; import java.util.List; @@ -39,21 +36,6 @@ public class PacketEventsMod implements PreLaunchEntrypoint, ModInitializer { public static PacketEventsMod INSTANCE; public static final String MOD_ID = "packetevents"; - - // isOurConnection() overloads are unused by our fork internally - // Methods kept for true ABI compatability with upstream PacketEvents - public static boolean isOurConnection(ClientConnection connection) { - return isOurConnection(connection.side); - } - public static boolean isOurConnection(NetworkSide flow) { - PacketSide connectionSide = switch (flow) { - case CLIENTBOUND -> PacketSide.CLIENT; - case SERVERBOUND -> PacketSide.SERVER; - }; - PacketEventsAPI api = PacketEvents.getAPI(); - return api != null && api.getInjector().getPacketSide() == connectionSide; - } - @Override public void onPreLaunch() { INSTANCE = this; diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsServerMod.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/PacketEventsServerMod.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/PacketEventsServerMod.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/PacketEventsServerMod.java diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricChannelInjector.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricChannelInjector.java similarity index 97% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricChannelInjector.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricChannelInjector.java index a9b8962a7e..4166b80448 100644 --- a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricChannelInjector.java +++ b/fabric-common/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricChannelInjector.java @@ -26,7 +26,6 @@ import io.github.retrooper.packetevents.handler.PacketEncoder; import io.netty.channel.Channel; import net.fabricmc.api.EnvType; -import net.minecraft.entity.player.PlayerEntity; import static com.github.retrooper.packetevents.PacketEvents.DECODER_NAME; import static com.github.retrooper.packetevents.PacketEvents.ENCODER_NAME; @@ -81,8 +80,8 @@ public void setPlayer(Object channel, Object player) { return; // this channel isn't injected by packetevents } Channel ch = (Channel) channel; - ((PacketDecoder) ch.pipeline().get(DECODER_NAME)).player = (PlayerEntity) player; - ((PacketEncoder) ch.pipeline().get(ENCODER_NAME)).player = (PlayerEntity) player; + ((PacketDecoder) ch.pipeline().get(DECODER_NAME)).player = player; + ((PacketEncoder) ch.pipeline().get(ENCODER_NAME)).player = player; } @Override diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPI.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPI.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPI.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPI.java diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPIManagerFactory.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPIManagerFactory.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPIManagerFactory.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsAPIManagerFactory.java diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsBuilder.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsBuilder.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsBuilder.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricPacketEventsBuilder.java diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/handler/PacketDecoder.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/handler/PacketDecoder.java similarity index 96% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/handler/PacketDecoder.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/handler/PacketDecoder.java index 0f880edaee..24e37bc293 100644 --- a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/handler/PacketDecoder.java +++ b/fabric-common/src/main/java/io/github/retrooper/packetevents/handler/PacketDecoder.java @@ -28,7 +28,6 @@ import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToMessageDecoder; -import net.minecraft.entity.player.PlayerEntity; import org.jetbrains.annotations.ApiStatus; import java.util.List; @@ -38,7 +37,8 @@ public class PacketDecoder extends MessageToMessageDecoder { private final PacketSide side; public User user; - public PlayerEntity player; + // Platform-typed player: see PacketEncoder.player for the rationale. + public Object player; private final boolean preViaVersion; public PacketDecoder(PacketSide side, User user, boolean preViaVersion) { diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/handler/PacketEncoder.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/handler/PacketEncoder.java similarity index 90% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/handler/PacketEncoder.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/handler/PacketEncoder.java index db19f54880..59f50532b5 100644 --- a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/handler/PacketEncoder.java +++ b/fabric-common/src/main/java/io/github/retrooper/packetevents/handler/PacketEncoder.java @@ -24,8 +24,6 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPromise; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.server.network.ServerPlayerEntity; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; @@ -46,7 +44,9 @@ public class PacketEncoder extends ChannelOutboundHandlerAdapter { private final PacketSide side; public User user; - public PlayerEntity player; + // Platform-typed player: yarn ServerPlayerEntity on intermediary, Mojang ServerPlayer + // on official. Concrete-only handling is delegated to AbstractFabricPlayerManager. + public Object player; private ChannelPromise promise; private final boolean preViaVersion; @@ -107,7 +107,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E if (didWeCauseThis && (user == null || user.getEncoderState() != ConnectionState.HANDSHAKING)) { if (PacketEvents.getAPI().getSettings().isKickOnPacketExceptionEnabled()) { try { - if (user != null && player instanceof ServerPlayerEntity) { + if (user != null && player != null) { WrapperPlayServerDisconnect disconnectPacket = new WrapperPlayServerDisconnect( net.kyori.adventure.text.Component.text("Invalid packet") ); @@ -115,10 +115,9 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E } } catch (Exception ignored) {} ctx.channel().close(); - if (player instanceof ServerPlayerEntity serverPlayer) { - serverPlayer.getServer().execute(() -> { - FabricPacketEventsAPI.getServerAPI().getPlayerManager().disconnectPlayer(serverPlayer, "Invalid packet"); - }); + if (player != null) { + FabricPacketEventsAPI.getServerAPI().getPlayerManager() + .kickOnException(player, "Invalid packet"); } } } diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadData.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadData.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadData.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadData.java diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadEntryPoint.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadEntryPoint.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadEntryPoint.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/loader/ChainLoadEntryPoint.java diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/AbstractFabricPlayerManager.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/AbstractFabricPlayerManager.java similarity index 77% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/AbstractFabricPlayerManager.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/AbstractFabricPlayerManager.java index 539c32c4e8..6671487a73 100644 --- a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/AbstractFabricPlayerManager.java +++ b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/AbstractFabricPlayerManager.java @@ -4,8 +4,6 @@ import com.github.retrooper.packetevents.protocol.ConnectionState; import com.github.retrooper.packetevents.wrapper.PacketWrapper; import io.github.retrooper.packetevents.impl.netty.manager.player.PlayerManagerAbstract; -import net.minecraft.network.chat.Component; -import net.minecraft.server.network.ServerPlayerEntity; import org.jetbrains.annotations.NotNull; public abstract class AbstractFabricPlayerManager extends PlayerManagerAbstract { @@ -80,5 +78,20 @@ public void receivePacketSilently(Object player, PacketWrapper wrapper) { packetEventsAPI.getProtocolManager().receivePacketSilently(getChannel(player), wrapper); } - public abstract void disconnectPlayer(ServerPlayerEntity serverPlayerEntity, String message); + /** + * Disconnect a player with the given message. The runtime object is the platform's + * server-player type (yarn {@code ServerPlayerEntity} on fabric-intermediary, Mojang + * {@code ServerPlayer} on fabric-official) — common code should never inspect it. + */ + public abstract void disconnectPlayer(@NotNull Object serverPlayer, @NotNull String message); + + /** + * Called from the netty pipeline when a packet processing exception should kick the + * player. Concrete impls own the server-thread hop and the platform-typed cast; the + * default forwards directly to {@link #disconnectPlayer(Object, String)}, which is + * safe for hand-rolled tests but real impls should schedule onto the server thread. + */ + public void kickOnException(@NotNull Object serverPlayer, @NotNull String message) { + disconnectPlayer(serverPlayer, message); + } } diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/FabricProtocolManager.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/FabricProtocolManager.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/FabricProtocolManager.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/FabricProtocolManager.java diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/FabricServerManager.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/FabricServerManager.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/FabricServerManager.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/FabricServerManager.java diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/InternalFabricPacketListener.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/InternalFabricPacketListener.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/InternalFabricPacketListener.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/InternalFabricPacketListener.java diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/PacketEventsMixinManager.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/manager/PacketEventsMixinManager.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/manager/PacketEventsMixinManager.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/manager/PacketEventsMixinManager.java diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java similarity index 97% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java index 160aa723a7..78d436468e 100644 --- a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java +++ b/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java @@ -22,9 +22,6 @@ import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPipeline; -import net.minecraft.network.NetworkSide; -import net.minecraft.network.chat.TextComponent; -import net.minecraft.server.network.ServerPlayerEntity; import java.util.List; @@ -32,12 +29,10 @@ public class FabricInjectionUtil { private static final String VIA_DECODER_NAME = "via-decoder"; private static final String VIA_ENCODER_NAME = "via-encoder"; - public static void injectAtPipelineBuilder(ChannelPipeline pipeline, NetworkSide flow) { - PacketSide pipelineSide = switch (flow) { - case CLIENTBOUND -> PacketSide.CLIENT; - case SERVERBOUND -> PacketSide.SERVER; - }; - + // pipelineSide is already PacketSide because each branch's mixin entrypoint converts + // from its native NetworkSide/PacketFlow enum before calling in. Keeping the enum + // out of fabric-common is what frees this class from yarn vs. Mojang chat.network.*. + public static void injectAtPipelineBuilder(ChannelPipeline pipeline, PacketSide pipelineSide) { FabricPacketEventsAPI fabricPacketEventsAPI = FabricPacketEventsAPI.getAPI(pipelineSide); fabricPacketEventsAPI.getLogManager().debug("Game connected!"); @@ -352,7 +347,7 @@ private static String findLatestHandler(List names, String... handlers) return latest; } - public static void fireUserLoginEvent(ServerPlayerEntity player) { + public static void fireUserLoginEvent(Object player) { FabricPacketEventsAPI api = FabricPacketEventsAPI.getServerAPI(); User user = api.getPlayerManager().getUser(player); diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessorImpl.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessorImpl.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessorImpl.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionAccessorImpl.java diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionUtil.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionUtil.java similarity index 100% rename from fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionUtil.java rename to fabric-common/src/main/java/io/github/retrooper/packetevents/util/viaversion/ViaVersionUtil.java diff --git a/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ServerPlayerManager.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ServerPlayerManager.java index fa55c6232d..e88d7042a5 100644 --- a/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ServerPlayerManager.java +++ b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/factory/fabric/Fabric1140ServerPlayerManager.java @@ -47,7 +47,13 @@ public Object getChannel(@NotNull Object player) { } @Override - public void disconnectPlayer(ServerPlayerEntity serverPlayerEntity, String message) { - serverPlayerEntity.networkHandler.disconnect(new TextComponent(message)); + public void disconnectPlayer(@NotNull Object player, @NotNull String message) { + ((ServerPlayerEntity) player).networkHandler.disconnect(new TextComponent(message)); + } + + @Override + public void kickOnException(@NotNull Object player, @NotNull String message) { + ServerPlayerEntity sp = (ServerPlayerEntity) player; + sp.getServer().execute(() -> disconnectPlayer(sp, message)); } } diff --git a/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionChInit.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionChInit.java index a74f918ceb..b21e3a6dbb 100644 --- a/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionChInit.java +++ b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinClientConnectionChInit.java @@ -1,11 +1,11 @@ package io.github.retrooper.packetevents.mc1140.mixin; +import com.github.retrooper.packetevents.protocol.PacketSide; import io.github.retrooper.packetevents.util.FabricInjectionUtil; import io.netty.channel.Channel; import io.netty.channel.socket.SocketChannel; import me.fallenbreath.conditionalmixin.api.annotation.Condition; import me.fallenbreath.conditionalmixin.api.annotation.Restriction; -import net.minecraft.network.NetworkSide; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -21,7 +21,7 @@ public class MixinClientConnectionChInit { @Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false) private void onInitChannel(Channel channel, CallbackInfo ci) { if (channel instanceof SocketChannel) { - FabricInjectionUtil.injectAtPipelineBuilder(channel.pipeline(), NetworkSide.CLIENTBOUND); + FabricInjectionUtil.injectAtPipelineBuilder(channel.pipeline(), PacketSide.CLIENT); } } } diff --git a/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinServerNetworkIoChInit.java b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinServerNetworkIoChInit.java index f25bc0e6f3..fcff26254a 100644 --- a/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinServerNetworkIoChInit.java +++ b/fabric-intermediary/mc1140/src/main/java/io/github/retrooper/packetevents/mc1140/mixin/MixinServerNetworkIoChInit.java @@ -1,11 +1,11 @@ package io.github.retrooper.packetevents.mc1140.mixin; +import com.github.retrooper.packetevents.protocol.PacketSide; import io.github.retrooper.packetevents.util.FabricInjectionUtil; import io.netty.channel.Channel; import io.netty.channel.socket.SocketChannel; import me.fallenbreath.conditionalmixin.api.annotation.Condition; import me.fallenbreath.conditionalmixin.api.annotation.Restriction; -import net.minecraft.network.NetworkSide; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -21,7 +21,7 @@ public class MixinServerNetworkIoChInit { @Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false) private void onInitChannel(Channel channel, CallbackInfo ci) { if (channel instanceof SocketChannel) { - FabricInjectionUtil.injectAtPipelineBuilder(channel.pipeline(), NetworkSide.SERVERBOUND); + FabricInjectionUtil.injectAtPipelineBuilder(channel.pipeline(), PacketSide.SERVER); } } } diff --git a/fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/factory/fabric/Fabric1190ServerPlayerManager.java b/fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/factory/fabric/Fabric1190ServerPlayerManager.java index 21f5bf773d..bf09d1735f 100644 --- a/fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/factory/fabric/Fabric1190ServerPlayerManager.java +++ b/fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/factory/fabric/Fabric1190ServerPlayerManager.java @@ -31,7 +31,7 @@ public Fabric1190ServerPlayerManager(PacketEventsAPI packetEventsAPI) { // new TextComponent -> Text.literal in 1.19 @Override - public void disconnectPlayer(ServerPlayerEntity serverPlayerEntity, String message) { - serverPlayerEntity.networkHandler.disconnect(Text.literal(message)); + public void disconnectPlayer(@org.jetbrains.annotations.NotNull Object player, @org.jetbrains.annotations.NotNull String message) { + ((ServerPlayerEntity) player).networkHandler.disconnect(Text.literal(message)); } } diff --git a/fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/mixin/ClientConnectionMixin.java b/fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/mixin/ClientConnectionMixin.java index 5b55b0ec6f..04dc12d1a4 100644 --- a/fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/mixin/ClientConnectionMixin.java +++ b/fabric-intermediary/mc1194/src/main/java/io/github/retrooper/packetevents/mc1914/mixin/ClientConnectionMixin.java @@ -1,5 +1,6 @@ package io.github.retrooper.packetevents.mc1914.mixin; +import com.github.retrooper.packetevents.protocol.PacketSide; import com.llamalad7.mixinextras.sugar.Local; import io.github.retrooper.packetevents.util.FabricInjectionUtil; import io.netty.channel.ChannelPipeline; @@ -29,6 +30,10 @@ private static void addHandlers( @Local(ordinal = 0, argsOnly = true) ChannelPipeline pipeline, @Local(ordinal = 0, argsOnly = true) NetworkSide flow ) { - FabricInjectionUtil.injectAtPipelineBuilder(pipeline, flow); + PacketSide side = switch (flow) { + case CLIENTBOUND -> PacketSide.CLIENT; + case SERVERBOUND -> PacketSide.SERVER; + }; + FabricInjectionUtil.injectAtPipelineBuilder(pipeline, side); } } \ No newline at end of file diff --git a/fabric-intermediary/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/factory/fabric/Fabric1202ServerPlayerManager.java b/fabric-intermediary/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/factory/fabric/Fabric1202ServerPlayerManager.java index bdd717797b..8f9103ebb0 100644 --- a/fabric-intermediary/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/factory/fabric/Fabric1202ServerPlayerManager.java +++ b/fabric-intermediary/mc1202/src/main/java/io/github/retrooper/packetevents/mc1202/factory/fabric/Fabric1202ServerPlayerManager.java @@ -48,7 +48,7 @@ public Object getChannel(@NotNull Object player) { // disconnect method moved from ServerPlayNetworkHandler -> ServerCommonNetworkHandler in 1.20.2 @Override - public void disconnectPlayer(ServerPlayerEntity serverPlayerEntity, String message) { - serverPlayerEntity.networkHandler.disconnect(Text.literal(message)); + public void disconnectPlayer(@NotNull Object player, @NotNull String message) { + ((ServerPlayerEntity) player).networkHandler.disconnect(Text.literal(message)); } } diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/mixin/PlayerListMixin.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/mixin/PlayerListMixin.java deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/FabricCustomPipelineUtil.java b/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/FabricCustomPipelineUtil.java deleted file mode 100644 index 5996a9fc92..0000000000 --- a/fabric-intermediary/src/main/java/io/github/retrooper/packetevents/util/FabricCustomPipelineUtil.java +++ /dev/null @@ -1,98 +0,0 @@ -package io.github.retrooper.packetevents.util; - -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2022 ViaVersion and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; -import net.fabricmc.loader.api.FabricLoader; -import net.fabricmc.loader.api.MappingResolver; -import net.minecraft.network.PacketDeflater; -import net.minecraft.network.PacketInflater; - -public class FabricCustomPipelineUtil { - private static final MethodHandle FABRIC_PACKET_DECODE_BYTEBUF; - - static { - try { - // Get the mapping resolver to handle obfuscated names - MappingResolver resolver = FabricLoader.getInstance().getMappingResolver(); - - // Get the runtime (potentially obfuscated) class for CompressionDecoder - Class compressionDecoderClass = PacketInflater.class; - - // Map the method name from intermediary to runtime (obfuscated) names - String intermediaryMethodName = "decode"; // Intermediary method name - String intermediaryClassName = compressionDecoderClass.getName(); // Intermediary class name - - // Define the method descriptor in intermediary mappings - // Parameters: ChannelHandlerContext, ByteBuf, List - // Return type: void - String methodDescriptor = "(Lio/netty/channel/ChannelHandlerContext;Lio/netty/buffer/ByteBuf;Ljava/util/List;)V"; - - // Map the method name to the runtime (obfuscated) name - String mappedMethodName = resolver.mapMethodName( - "intermediary", - intermediaryClassName, - intermediaryMethodName, - methodDescriptor - ); - - // Create a MethodHandles.Lookup with private access - MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(compressionDecoderClass, MethodHandles.lookup()); - - // Define the method type for the decode method - MethodType methodType = MethodType.methodType( - void.class, // Return type - ChannelHandlerContext.class, // Parameter 1 - ByteBuf.class, // Parameter 2 - List.class // Parameter 3 - ); - - // Find the MethodHandle for the decode method - FABRIC_PACKET_DECODE_BYTEBUF = lookup.findVirtual( - compressionDecoderClass, - mappedMethodName, - methodType - ); - } catch (IllegalAccessException | NoSuchMethodException e) { - throw new RuntimeException(e); - } - } - - public static List callPacketDecodeByteBuf(PacketInflater decoder, ChannelHandlerContext ctx, ByteBuf msg) throws InvocationTargetException { - List output = new ArrayList<>(1); - - try { - FABRIC_PACKET_DECODE_BYTEBUF.invokeExact(decoder, ctx, msg, output); - } catch (Throwable e) { - e.printStackTrace(); - } - return output; - } -} - - From 2d8b75d2136120d67d1a3af47d40c8f34d93e7d5 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sun, 24 May 2026 00:52:40 -0400 Subject: [PATCH 06/23] fabric-official: wire PacketEventsMod entrypoint via fabric-common JiJ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that fabric-common carries an MC-free PacketEventsMod, fabric-official no longer needs its own duplicate chain-loader scaffold. Point the mod's preLaunch + main entrypoints directly at fabric-common's class (JiJ'd into the official jar) and have mc261 contribute a peMainChainLoad entry for ServerVersion.V_26_1. * fabric-official/build.gradle.kts: tighten the mappings comment — source in this module still can't reference net.minecraft.* because we're on intermediary:0.0.0:v2; per-version Mojang-named code goes in mc261 once Loom can resolve Mojang names against a real mapping. * fabric.mod.json: declare entrypoints io.github.retrooper.packetevents .PacketEventsMod (lives in fabric-common). * mc261/Fabric261ChainLoadEntrypoint: no-op initialize() — registering a concrete AbstractFabricPlayerManager subclass into chainLoadData waits on real 26.X mappings, but the chain participation point exists. Aggregator jar (top-level :fabric:remapJar) JiJs fabric-common (55KB) + fabric-intermediary (4.5MB) + fabric-official (3.9MB) side-by-side; each loads exclusively per its depends.minecraft range. --- fabric-official/build.gradle.kts | 14 +++++------ .../mc261/Fabric261ChainLoadEntrypoint.java | 23 +++++++++++++++++++ .../mc261/src/main/resources/fabric.mod.json | 7 +++++- .../src/main/resources/fabric.mod.json | 10 +++++++- 4 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java diff --git a/fabric-official/build.gradle.kts b/fabric-official/build.gradle.kts index a5efa62ac9..e0081417b9 100644 --- a/fabric-official/build.gradle.kts +++ b/fabric-official/build.gradle.kts @@ -11,6 +11,7 @@ plugins { repositories { mavenCentral() + maven("https://maven.fabricmc.net/") maven("https://repo.viaversion.com/") maven("https://jitpack.io") } @@ -28,13 +29,12 @@ dependencies { include(project(":fabric-common")) minecraft("com.mojang:minecraft:$minecraft_version") - // Mojang stopped publishing official mappings starting with MC 26.X — manifest has - // neither client_mappings nor server_mappings, and Yarn hasn't published for 26.X. - // Fabric intermediary publishes a `0.0.0` empty mapping for 26.X. Until usable - // mappings land, fabric-official is a structural stub that loads on 26.X but - // cannot reference meaningful MC symbols. Re-enable officialMojangMappings() and - // pull in conditional-mixin/Adventure mod-deps the day Mojang or Yarn resume - // publishing — both fail Loom source-remap against the 0.0.0 mapping. + // MC 26.X server/client jars ship pre-deobfuscated with Mojang's official names but + // FabricMC has not published a tiny intermediary for 26.X yet. The 0.0.0:v2 stub + // satisfies Loom's mapping requirement without renaming anything — source code in + // this module must not reference net.minecraft.* compile-time types, because the + // empty mapping resolves them to nothing. Per-version Mojang-typed code lives in + // mc261 (or future mc26X) subprojects, which configure their own Loom remap. mappings("net.fabricmc:intermediary:0.0.0:v2") } diff --git a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java new file mode 100644 index 0000000000..1d9cd771ca --- /dev/null +++ b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java @@ -0,0 +1,23 @@ +package io.github.retrooper.packetevents.mc261; + +import com.github.retrooper.packetevents.manager.server.ServerVersion; +import io.github.retrooper.packetevents.loader.ChainLoadData; +import io.github.retrooper.packetevents.loader.ChainLoadEntryPoint; + +// Chain participant for MC 26.1+. PacketEventsMod (in fabric-common) discovers +// this via the peMainChainLoad entrypoint key and dispatches by descending +// protocol version. initialize() is intentionally empty — wiring a 26.X-native +// AbstractFabricPlayerManager implementation into chainLoadData needs Mojang +// class references that we can't compile against the empty intermediary:0.0.0 +// mapping. Filling this in is the next step once Loom can resolve Mojang names. +public class Fabric261ChainLoadEntrypoint implements ChainLoadEntryPoint { + + @Override + public void initialize(ChainLoadData chainLoadData) { + } + + @Override + public ServerVersion getNativeVersion() { + return ServerVersion.V_26_1; + } +} diff --git a/fabric-official/mc261/src/main/resources/fabric.mod.json b/fabric-official/mc261/src/main/resources/fabric.mod.json index 5ba5cbe9bc..eec8ce9a83 100644 --- a/fabric-official/mc261/src/main/resources/fabric.mod.json +++ b/fabric-official/mc261/src/main/resources/fabric.mod.json @@ -3,9 +3,14 @@ "id": "packetevents-fabric-mc261", "version": "${version}", "name": "${modName}", - "description": "Per-version source root for Minecraft 26.1+. Currently a structural stub; meaningful entrypoints await usable mappings.", + "description": "Per-version chain participant for Minecraft 26.1+. Registers peMainChainLoad so fabric-common's PacketEventsMod can dispatch the chain.", "license": "GPL-3.0", "environment": "*", + "entrypoints": { + "peMainChainLoad": [ + "io.github.retrooper.packetevents.mc261.Fabric261ChainLoadEntrypoint" + ] + }, "depends": { "minecraft": ">=26.1", "java": ">=25", diff --git a/fabric-official/src/main/resources/fabric.mod.json b/fabric-official/src/main/resources/fabric.mod.json index f95f8932a7..db19ef2ce6 100644 --- a/fabric-official/src/main/resources/fabric.mod.json +++ b/fabric-official/src/main/resources/fabric.mod.json @@ -3,13 +3,21 @@ "id": "packetevents-fabric-official", "version": "${version}", "name": "PacketEvents (Fabric, official mappings)", - "description": "PacketEvents variant for Minecraft 26.X (Mojang's new version scheme, Java 25+). Currently a structural stub — Mojang has stopped publishing official mappings, and Yarn has no 26.X build, so meaningful MC-typed code awaits mapping availability.", + "description": "PacketEvents variant for Minecraft 26.X. Reuses the MC-erased PacketEventsMod entrypoint from fabric-common; concrete per-version player managers and Mojang-named mixins land once a 26.X intermediary mapping is available.", "authors": ["retrooper", "GrimAnticheat"], "contact": { "homepage": "https://github.com/GrimAnticheat/packetevents" }, "license": "GPL-3.0", "environment": "*", + "entrypoints": { + "preLaunch": [ + "io.github.retrooper.packetevents.PacketEventsMod" + ], + "main": [ + "io.github.retrooper.packetevents.PacketEventsMod" + ] + }, "depends": { "minecraft": ">=26.1", "java": ">=25", From 0552275d1dc4a4b565eff893ea25da12d2512cc0 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sun, 24 May 2026 01:34:48 -0400 Subject: [PATCH 07/23] fabric: re-export variant + common deps so consumers' POMs resolve After the bridge moved to fabric-common, downstream consumers (Grim) that depend on packetevents-fabric saw a POM declaring only fabric-loader and failed to compile against FabricPacketEventsAPI etc. Re-export the same api() + include() block fabric-intermediary used to carry, so consumers get the transitive deps through the published metadata. --- fabric/build.gradle.kts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 295a6dc39d..9eef6de36d 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -27,11 +27,21 @@ dependencies { mappings("net.fabricmc:yarn:$yarn_mappings") modImplementation("net.fabricmc:fabric-loader:$loader_version") - // The aggregator does not contribute MC-typed code itself. fabric-common is a - // regular Java library so it's pulled via Loom's `include(...)` JiJ mechanism. - // The variant mods (fabric-intermediary, fabric-official) are nested below via - // `nestedJars.from(remapJar)` to avoid the double-JiJ of dev + remapped artifacts. + // Re-export everything the variant modules used to expose so downstream consumers + // (e.g. Grim) that depend on `packetevents-fabric` get the FQNs transitively. + // Without these api() entries the published POM lists only fabric-loader and + // mc-typed consumers fail to compile against the now-fabric-common bridge. + api(project(":fabric-common")) + api(libs.bundles.adventure) + api(project(":api", "shadow")) + api(project(":netty-common")) + + // JiJ side: ship the same artifacts inside the published mod jar so Fabric Loader + // has them at runtime even when the consumer didn't pull the maven POM. include(project(":fabric-common")) + include(libs.bundles.adventure) + include(project(":api", "shadow")) + include(project(":netty-common")) } loom { From 13908628576f6f8a70b733327fcefa18d2b2c778 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sun, 24 May 2026 01:48:57 -0400 Subject: [PATCH 08/23] fabric-official: real Mojang-named FabricPlayerManager + ConnectionMixin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switch fabric-official + mc261 from fabric-loom-remap (with empty intermediary:0.0.0:v2 mapping) to fabric-loom (LoomNoRemap). The MC 26.X jar ships pre-deobfuscated with Mojang's official names, so Loom treats the jar as already in the target namespace — no mappings() block needed and source code can compile against net.minecraft.world.item.Item, net.minecraft.network.Connection, etc. directly. Surface added: * FabricOfficialPlayerManager: concrete subclass of AbstractFabricPlayerManager using ServerPlayer.connection (ServerGamePacketListenerImpl) for ping, channel lookup, and disconnect. kickOnException hops to the server thread via ServerLevel.getServer().execute(...). * ConnectionMixin: @Inject TAIL of Connection.configureSerialization to install PE's encoder/decoder on every connection. Priority 1500 keeps us after Via. PacketFlow -> PacketSide conversion happens at the callsite so fabric-common's FabricInjectionUtil stays Mojang-free. * packetevents.accesswidener (official namespace): widens Connection.channel, Connection.receiving, and ServerCommonPacketListenerImpl.connection so fabric-common's FabricChannelInjector + the player manager can reach the netty Channel. * mc261/Fabric261ChainLoadEntrypoint.initialize: setPlayerManagerIfNull with a LazyHolder around FabricOfficialPlayerManager. * fabric.mod.json now references the mixin config + access widener. Build wiring: * `apply(plugin = "net.fabricmc.fabric-loom")` — the qualified id maps to LoomNoRemapGradlePlugin; the short "fabric-loom" applies the older all-in-one LoomGradlePlugin and conflicts. * LoomNoRemap doesn't register remapJar/modImplementation/namedElements; switch to plain jar/compileOnly/project(...) and route the jar output to rootProject's libs/ for the top-level aggregator to nest. * include(project(":fabric-official:mc261")) so the per-version variant is JiJ'd inside fabric-official. * fabric/build.gradle.kts (aggregator): dependsOn ":fabric-official:jar" instead of ":fabric-official:remapJar". Aggregate jar layout verified: fabric-official-3.9MB JiJs mc261 + fabric-common + api + netty-common + conditional-mixin alongside the fabric-intermediary-4.5MB variant. --- fabric-official/build.gradle.kts | 129 ++++++++---------- fabric-official/mc261/build.gradle.kts | 7 +- .../mc261/Fabric261ChainLoadEntrypoint.java | 18 ++- .../fabric/FabricOfficialPlayerManager.java | 55 ++++++++ .../packetevents/mixin/ConnectionMixin.java | 45 ++++++ .../src/main/resources/fabric.mod.json | 6 +- .../main/resources/packetevents.accesswidener | 8 ++ .../main/resources/packetevents.mixins.json | 12 ++ fabric/build.gradle.kts | 6 +- 9 files changed, 201 insertions(+), 85 deletions(-) create mode 100644 fabric-official/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricOfficialPlayerManager.java create mode 100644 fabric-official/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java create mode 100644 fabric-official/src/main/resources/packetevents.accesswidener create mode 100644 fabric-official/src/main/resources/packetevents.mixins.json diff --git a/fabric-official/build.gradle.kts b/fabric-official/build.gradle.kts index e0081417b9..6e71abdedc 100644 --- a/fabric-official/build.gradle.kts +++ b/fabric-official/build.gradle.kts @@ -1,12 +1,12 @@ -import me.modmuss50.mpp.ModPublishExtension -import me.modmuss50.mpp.PublishModTask -import net.fabricmc.loom.task.RemapJarTask -import net.fabricmc.loom.task.RemapSourcesJarTask -import net.fabricmc.loom.task.prod.ServerProductionRunTask +// fabric-official targets MC 26.X+, whose server/client jars ship pre-deobfuscated with +// Mojang's official names. Loom's NoRemap variant (`net.fabricmc.fabric-loom`, distinct +// from `-remap`) accepts the jar as already in the target namespace, so source code +// references Mojang names directly (net.minecraft.world.item.Item, etc.). No mappings() +// configuration is needed — intermediary == named == official == jar contents. plugins { packetevents.`library-conventions` - net.fabricmc.`fabric-loom-remap` + net.fabricmc.`fabric-loom` } repositories { @@ -23,19 +23,18 @@ dependencies { api(project(":api", "shadow")) api(project(":netty-common")) api(project(":fabric-common")) + api("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") include(project(":api", "shadow")) include(project(":netty-common")) include(project(":fabric-common")) + include("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") + // Nest the per-version variants (mc261, future mc26X) directly inside fabric-official. + include(project(":fabric-official:mc261")) minecraft("com.mojang:minecraft:$minecraft_version") - // MC 26.X server/client jars ship pre-deobfuscated with Mojang's official names but - // FabricMC has not published a tiny intermediary for 26.X yet. The 0.0.0:v2 stub - // satisfies Loom's mapping requirement without renaming anything — source code in - // this module must not reference net.minecraft.* compile-time types, because the - // empty mapping resolves them to nothing. Per-version Mojang-typed code lives in - // mc261 (or future mc26X) subprojects, which configure their own Loom remap. - mappings("net.fabricmc:intermediary:0.0.0:v2") + // No mappings() block: LoomNoRemap uses the MC jar's own (Mojang) namespace + // throughout, so source can compile against net.minecraft.* directly. } java { @@ -50,18 +49,33 @@ loom { sourceSet(sourceSets.main.get()) } } + mixin { + useLegacyMixinAp.set(false) + } + + val accessWidenerFile = sourceSets["main"].resources.srcDirs.first() + .resolve("packetevents.accesswidener") + if (accessWidenerFile.exists()) { + accessWidenerPath.set(accessWidenerFile) + } } allprojects { - apply(plugin = "fabric-loom") + // Fully-qualified id maps to LoomNoRemapGradlePlugin; the short "fabric-loom" maps + // to the older all-in-one LoomGradlePlugin and conflicts when both are applied. + apply(plugin = "net.fabricmc.fabric-loom") apply(plugin = "packetevents.publish-conventions") repositories { + mavenCentral() + maven("https://maven.fabricmc.net/") maven("https://repo.codemc.io/repository/maven-snapshots/") + maven("https://jitpack.io") } dependencies { - modImplementation("net.fabricmc:fabric-loader:$loader_version") + // LoomNoRemap exposes plain configurations; mod* configs are LoomRemap-only. + compileOnly("net.fabricmc:fabric-loader:$loader_version") } java { @@ -71,18 +85,14 @@ allprojects { } tasks { - // Intermediary 0.0.0 has no "named" namespace, so source remap fails. Disable - // it where these tasks exist (root fabric-official has them; mc261 subproject - // may not). - matching { it.name == "remapSourcesJar" || it.name == "sourcesJar" } - .configureEach { enabled = false } - withType { - val targetJavaVersion = 25 - options.release = targetJavaVersion + options.release = 25 } - remapJar { + // LoomNoRemap publishes via the plain `jar` task (the jar is already in the + // target namespace). Route it to the rootProject libs/ so the top-level fabric + // aggregator can JiJ it alongside fabric-intermediary's remapJar output. + jar { destinationDirectory = rootProject.layout.buildDirectory.dir("libs") archiveBaseName = if (project == project(":fabric-official")) { "${rootProject.name}-fabric-official" @@ -91,15 +101,22 @@ allprojects { } archiveVersion = rootProject.ext["artifactVersion"] as String } + } +} - remapSourcesJar { - archiveBaseName = if (project == project(":fabric-official")) { - "${rootProject.name}-fabric-official" - } else { - "${rootProject.name}-fabric-${project.name}" - } - archiveVersion = rootProject.ext["artifactVersion"] as String - } +subprojects { + version = rootProject.version + val minecraft_version: String by project + + dependencies { + compileOnly(project(":api", "shadow")) + compileOnly(project(":netty-common")) + compileOnly(project(":fabric-common")) + // LoomNoRemap doesn't publish a "namedElements" variant; depend on the + // standard apiElements via the default project() form so MC types from + // fabric-official's classpath (which include the deobfuscated 26.X jar) + // resolve for mc261 source. + compileOnly(project(":fabric-official")) } loom { @@ -108,24 +125,11 @@ allprojects { } val accessWidenerFile = sourceSets["main"].resources.srcDirs.first() - .resolve("${rootProject.name}.accesswidener") - + .resolve("packetevents.accesswidener") if (accessWidenerFile.exists()) { accessWidenerPath.set(accessWidenerFile) } } -} - -subprojects { - version = rootProject.version - val minecraft_version: String by project - - dependencies { - compileOnly(project(":api", "shadow")) - compileOnly(project(":netty-common")) - compileOnly(project(":fabric-common")) - compileOnly(project(":fabric-official", configuration = "namedElements")) - } tasks { processResources { @@ -144,34 +148,13 @@ subprojects { } } } - - tasks.register("prodServer") { - javaLauncher = javaToolchains.launcherFor { - languageVersion = JavaLanguageVersion.of(25) - } - } } -subprojects.forEach { - tasks.named("remapJar").configure { - dependsOn("${it.path}:remapJar") +// Top-level fabric-official jar JiJs the mc261 (and future 26.X) variant jars beside +// the common shell. LoomNoRemap exposes `Jar` (not `AbstractRemapJarTask`), so we +// nest via fabric-loom's `include` instead — declared up in the dependencies block. +subprojects.forEach { sub -> + tasks.named("jar").configure { + dependsOn("${sub.path}:jar") } } - -tasks.remapJar.configure { - subprojects.forEach { subproject -> - subproject.tasks.matching { it.name == "remapJar" }.configureEach { - nestedJars.from(this) - } - } -} - -tasks.withType { - dependsOn(tasks.named("remapJar")) - dependsOn(tasks.named("remapSourcesJar")) -} - -configure { - file = tasks.named("remapJar").flatMap { it.archiveFile } - additionalFiles.from(tasks.named("remapSourcesJar").flatMap { it.archiveFile }) -} diff --git a/fabric-official/mc261/build.gradle.kts b/fabric-official/mc261/build.gradle.kts index ebd54d3b8f..0715d2587a 100644 --- a/fabric-official/mc261/build.gradle.kts +++ b/fabric-official/mc261/build.gradle.kts @@ -1,7 +1,7 @@ val minecraft_version: String by project plugins { - net.fabricmc.`fabric-loom-remap` + net.fabricmc.`fabric-loom` } repositories { @@ -10,8 +10,9 @@ repositories { dependencies { minecraft("com.mojang:minecraft:$minecraft_version") - // See fabric-official/build.gradle.kts for why this isn't officialMojangMappings(). - mappings("net.fabricmc:intermediary:0.0.0:v2") + // No mappings(): LoomNoRemap uses the pre-deobfuscated 26.1.2 jar's Mojang names + // directly. Source code in this subproject references net.minecraft.* names that + // exist verbatim in the server.jar (net.minecraft.world.item.Item, etc.). } loom { diff --git a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java index 1d9cd771ca..996de61de8 100644 --- a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java +++ b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java @@ -1,19 +1,25 @@ package io.github.retrooper.packetevents.mc261; import com.github.retrooper.packetevents.manager.server.ServerVersion; +import io.github.retrooper.packetevents.factory.fabric.FabricOfficialPlayerManager; +import io.github.retrooper.packetevents.factory.fabric.FabricPacketEventsAPI; import io.github.retrooper.packetevents.loader.ChainLoadData; import io.github.retrooper.packetevents.loader.ChainLoadEntryPoint; +import io.github.retrooper.packetevents.manager.AbstractFabricPlayerManager; +import io.github.retrooper.packetevents.util.LazyHolder; -// Chain participant for MC 26.1+. PacketEventsMod (in fabric-common) discovers -// this via the peMainChainLoad entrypoint key and dispatches by descending -// protocol version. initialize() is intentionally empty — wiring a 26.X-native -// AbstractFabricPlayerManager implementation into chainLoadData needs Mojang -// class references that we can't compile against the empty intermediary:0.0.0 -// mapping. Filling this in is the next step once Loom can resolve Mojang names. +// Wires the 26.X-mapped player manager into the ChainLoadData. Registry-manager +// registration is deferred — 26.X's BuiltInRegistries layout differs from yarn and +// requires its own ItemRegistry implementation to be useful; we intentionally leave +// that slot empty so an older chain entrypoint can fill it as a stub fallback. public class Fabric261ChainLoadEntrypoint implements ChainLoadEntryPoint { + private final LazyHolder playerManager = + LazyHolder.simple(() -> new FabricOfficialPlayerManager(FabricPacketEventsAPI.getServerAPI())); + @Override public void initialize(ChainLoadData chainLoadData) { + chainLoadData.setPlayerManagerIfNull(playerManager); } @Override diff --git a/fabric-official/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricOfficialPlayerManager.java b/fabric-official/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricOfficialPlayerManager.java new file mode 100644 index 0000000000..da6374f4e4 --- /dev/null +++ b/fabric-official/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricOfficialPlayerManager.java @@ -0,0 +1,55 @@ +/* + * This file is part of packetevents - https://github.com/retrooper/packetevents + * Copyright (C) 2026 retrooper and contributors + * + * Licensed under the GNU General Public License v3.0 (see the LICENSE file in the + * project root or ). + */ + +package io.github.retrooper.packetevents.factory.fabric; + +import com.github.retrooper.packetevents.PacketEventsAPI; +import io.github.retrooper.packetevents.manager.AbstractFabricPlayerManager; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerPlayer; +import org.jetbrains.annotations.NotNull; + +// Concrete player manager for the 26.X (Mojang-named) branch. Mirror of the +// fabric-intermediary mc-version managers but bound against the official names that +// the deobfuscated 26.1.2 jar already uses. +public class FabricOfficialPlayerManager extends AbstractFabricPlayerManager { + + public FabricOfficialPlayerManager(PacketEventsAPI packetEventsAPI) { + super(packetEventsAPI); + } + + @Override + public int getPing(@NotNull Object player) { + if (player instanceof ServerPlayer sp) { + return sp.connection.latency(); + } + throw new UnsupportedOperationException("Unsupported player implementation: " + player); + } + + @Override + public Object getChannel(@NotNull Object player) { + if (player instanceof ServerPlayer sp) { + // Connection.channel access requires the AW entry shipped beside this class. + return sp.connection.connection.channel; + } + throw new UnsupportedOperationException("Unsupported player implementation: " + player); + } + + @Override + public void disconnectPlayer(@NotNull Object player, @NotNull String message) { + ((ServerPlayer) player).connection.disconnect(Component.literal(message)); + } + + @Override + public void kickOnException(@NotNull Object player, @NotNull String message) { + ServerPlayer sp = (ServerPlayer) player; + // ServerPlayer doesn't expose getServer() directly in 26.X mappings; the + // ServerLevel reference does. + sp.level().getServer().execute(() -> disconnectPlayer(sp, message)); + } +} diff --git a/fabric-official/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java b/fabric-official/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java new file mode 100644 index 0000000000..0e3f8e3026 --- /dev/null +++ b/fabric-official/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java @@ -0,0 +1,45 @@ +/* + * This file is part of packetevents - https://github.com/retrooper/packetevents + * Copyright (C) 2026 retrooper and contributors + * + * Licensed under the GNU General Public License v3.0 (see the LICENSE file in the + * project root or ). + */ + +package io.github.retrooper.packetevents.mixin; + +import com.github.retrooper.packetevents.protocol.PacketSide; +import io.github.retrooper.packetevents.util.FabricInjectionUtil; +import io.netty.channel.ChannelPipeline; +import net.minecraft.network.Connection; +import net.minecraft.network.protocol.PacketFlow; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +// Injects PE's encoder/decoder into the netty pipeline right after MC builds it for +// every connection (client + server). Priority 1500 keeps us after ViaVersion. The +// fabric-intermediary side has the same hook against the yarn-named ClientConnection +// equivalent; this is the Mojang-named twin. +@Mixin(value = Connection.class, priority = 1500) +public abstract class ConnectionMixin { + + @Inject( + method = "configureSerialization(Lio/netty/channel/ChannelPipeline;Lnet/minecraft/network/protocol/PacketFlow;ZLnet/minecraft/network/BandwidthDebugMonitor;)V", + at = @At("TAIL") + ) + private static void packetevents$injectAtPipelineBuilder( + ChannelPipeline pipeline, + PacketFlow flow, + boolean memoryOnly, + Object monitor, + CallbackInfo ci + ) { + PacketSide side = switch (flow) { + case CLIENTBOUND -> PacketSide.CLIENT; + case SERVERBOUND -> PacketSide.SERVER; + }; + FabricInjectionUtil.injectAtPipelineBuilder(pipeline, side); + } +} diff --git a/fabric-official/src/main/resources/fabric.mod.json b/fabric-official/src/main/resources/fabric.mod.json index db19ef2ce6..45515b9d90 100644 --- a/fabric-official/src/main/resources/fabric.mod.json +++ b/fabric-official/src/main/resources/fabric.mod.json @@ -3,7 +3,7 @@ "id": "packetevents-fabric-official", "version": "${version}", "name": "PacketEvents (Fabric, official mappings)", - "description": "PacketEvents variant for Minecraft 26.X. Reuses the MC-erased PacketEventsMod entrypoint from fabric-common; concrete per-version player managers and Mojang-named mixins land once a 26.X intermediary mapping is available.", + "description": "PacketEvents variant for Minecraft 26.X built against Mojang's official names directly (no remap). Hosts the chain entrypoint that wires fabric-common's bridge classes; mc261 contributes the concrete FabricOfficialPlayerManager.", "authors": ["retrooper", "GrimAnticheat"], "contact": { "homepage": "https://github.com/GrimAnticheat/packetevents" @@ -18,6 +18,10 @@ "io.github.retrooper.packetevents.PacketEventsMod" ] }, + "mixins": [ + "packetevents.mixins.json" + ], + "accessWidener": "packetevents.accesswidener", "depends": { "minecraft": ">=26.1", "java": ">=25", diff --git a/fabric-official/src/main/resources/packetevents.accesswidener b/fabric-official/src/main/resources/packetevents.accesswidener new file mode 100644 index 0000000000..33e31c80ea --- /dev/null +++ b/fabric-official/src/main/resources/packetevents.accesswidener @@ -0,0 +1,8 @@ +accessWidener v2 official +# Accessing the underlying netty channel via ServerPlayer.connection.connection.channel +# requires widening two fields beyond their default visibility: +# - Connection.channel (private) +# - ServerCommonPacketListenerImpl.connection (protected, holds the Connection) +accessible field net/minecraft/network/Connection channel Lio/netty/channel/Channel; +accessible field net/minecraft/network/Connection receiving Lnet/minecraft/network/protocol/PacketFlow; +accessible field net/minecraft/server/network/ServerCommonPacketListenerImpl connection Lnet/minecraft/network/Connection; diff --git a/fabric-official/src/main/resources/packetevents.mixins.json b/fabric-official/src/main/resources/packetevents.mixins.json new file mode 100644 index 0000000000..0984637701 --- /dev/null +++ b/fabric-official/src/main/resources/packetevents.mixins.json @@ -0,0 +1,12 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "io.github.retrooper.packetevents.mixin", + "compatibilityLevel": "JAVA_21", + "mixins": [ + "ConnectionMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 9eef6de36d..0ad540d99f 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -62,9 +62,11 @@ tasks { archiveBaseName = "${rootProject.name}-fabric" archiveVersion = rootProject.ext["artifactVersion"] as String - // Nest the variant remapJars without triggering full project configuration + // Nest the variant outputs without triggering full project configuration // (which would inject dev/namedElements jars into the include config). - dependsOn(":fabric-intermediary:remapJar", ":fabric-official:remapJar") + // fabric-intermediary uses LoomRemap and publishes via remapJar. + // fabric-official uses LoomNoRemap and publishes via the plain jar task. + dependsOn(":fabric-intermediary:remapJar", ":fabric-official:jar") nestedJars.from( rootProject.layout.buildDirectory.file("libs/${rootProject.name}-fabric-intermediary-${rootProject.ext["artifactVersion"]}.jar") ) From 4af7ea4778dea087a5e5052007232d1cc90fea38 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sun, 24 May 2026 02:17:04 -0400 Subject: [PATCH 09/23] fabric-official: ConnectionMixin param type must be BandwidthDebugMonitor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mixin descriptor verification rejected Object monitor — the target method signature is configureSerialization(ChannelPipeline, PacketFlow, boolean, BandwidthDebugMonitor). Using Object was a leftover habit from the erased-bridge work in fabric-common where Object lets the same source compile in two namespaces; the per-version mixin source already imports Mojang names freely. Verified on a real fabric-26.1.2 dedicated server: * PE 2.12.2+139086285 + Grim fabric-official scaffold deployed + booted. * Real 26.1.2-wurst HMC client completed LOGIN -> CONFIGURATION -> PLAY with no PacketProcessException, the path PR #9 broke. * Server log shows 'Offline[/127.0.0.1:43648] logged in with entity id 45 at (10.5, -60.0, -6.5)' and 'joined the game'. EOF --- .../github/retrooper/packetevents/mixin/ConnectionMixin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fabric-official/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java b/fabric-official/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java index 0e3f8e3026..ba72f9b4ad 100644 --- a/fabric-official/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java +++ b/fabric-official/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java @@ -11,6 +11,7 @@ import com.github.retrooper.packetevents.protocol.PacketSide; import io.github.retrooper.packetevents.util.FabricInjectionUtil; import io.netty.channel.ChannelPipeline; +import net.minecraft.network.BandwidthDebugMonitor; import net.minecraft.network.Connection; import net.minecraft.network.protocol.PacketFlow; import org.spongepowered.asm.mixin.Mixin; @@ -33,7 +34,7 @@ public abstract class ConnectionMixin { ChannelPipeline pipeline, PacketFlow flow, boolean memoryOnly, - Object monitor, + BandwidthDebugMonitor monitor, CallbackInfo ci ) { PacketSide side = switch (flow) { From b99c4b91a6f2cf3a8e4cce4fc855ff4c377e7c6a Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sun, 24 May 2026 02:47:42 -0400 Subject: [PATCH 10/23] =?UTF-8?q?fabric:=20deduplicate=20JiJ=20=E2=80=94?= =?UTF-8?q?=20shared=20deps=20land=20once=20at=20aggregator=20level?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously each wrapper (fabric-intermediary, fabric-official) included its own copies of api, adventure, netty-common, fabric-common, and conditional-mixin. The top-level fabric/ aggregator then JiJ-nested both wrapper jars side-by-side, so the shared bytes ended up physically duplicated inside the published packetevents-fabric.jar. Drop the include() block from each wrapper; keep only api() so the mcXXXX subprojects still see the deps on their compile classpath. The aggregator's include() block (already present) becomes the sole JiJ source for shared deps, with conditional-mixin added. Net storage: packetevents-fabric.jar 12.8MB -> 4.5MB fabric-intermediary jar 4.5MB -> 86KB fabric-official jar 3.9MB -> 7.4KB Also move 26.1.2-specific files from fabric-official/src/main into fabric-official/mc261 where the per-version chain participants live: FabricOfficialPlayerManager -> mc261/.../Fabric261PlayerManager ConnectionMixin -> mc261/.../mixin/ConnectionMixin packetevents.accesswidener -> mc261/.../packetevents.accesswidener packetevents.mixins.json -> mc261/.../packetevents.mixins.json mc261's fabric.mod.json now declares its own mixins + accessWidener; fabric-official/src no longer references them. Future mc262 follows the same shape — its own concrete player manager, mixin, AW — instead of piling 26.X-version-specific signatures into the wrapper. Verified end-to-end: fabric-1.21.11 + Grim catches mineflayer with TickTimer (x49) fabric-1.19.4 + Grim accepts mineflayer connect cleanly fabric-26.1.2 + PE+Grim boot, mc261 chain registers FabricPlayerManager --- fabric-intermediary/build.gradle.kts | 10 ++++------ fabric-official/build.gradle.kts | 8 +++----- .../mc261/Fabric261ChainLoadEntrypoint.java | 4 ++-- .../factory/fabric/Fabric261PlayerManager.java} | 14 ++++++++------ .../packetevents/mc261}/mixin/ConnectionMixin.java | 2 +- .../mc261/src/main/resources/fabric.mod.json | 4 ++++ .../src/main/resources/packetevents.accesswidener | 0 .../src/main/resources/packetevents.mixins.json | 2 +- fabric-official/src/main/resources/fabric.mod.json | 6 +----- fabric/build.gradle.kts | 4 ++++ 10 files changed, 28 insertions(+), 26 deletions(-) rename fabric-official/{src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricOfficialPlayerManager.java => mc261/src/main/java/io/github/retrooper/packetevents/mc261/factory/fabric/Fabric261PlayerManager.java} (74%) rename fabric-official/{src/main/java/io/github/retrooper/packetevents => mc261/src/main/java/io/github/retrooper/packetevents/mc261}/mixin/ConnectionMixin.java (97%) rename fabric-official/{ => mc261}/src/main/resources/packetevents.accesswidener (100%) rename fabric-official/{ => mc261}/src/main/resources/packetevents.mixins.json (73%) diff --git a/fabric-intermediary/build.gradle.kts b/fabric-intermediary/build.gradle.kts index f44336e517..3b7052ac1c 100644 --- a/fabric-intermediary/build.gradle.kts +++ b/fabric-intermediary/build.gradle.kts @@ -20,18 +20,16 @@ val yarn_mappings: String by project val loader_version: String by project dependencies { + // api() puts these on the compile + runtime classpath of this module and its + // consumers (the mcXXXX subprojects), but DELIBERATELY no include(): shared deps + // are JiJ'd once at the top-level fabric/ aggregator. Bundling them here too + // would duplicate ~5MB of api/adventure/common bytes inside every nested mod jar. api(libs.bundles.adventure) api(project(":api", "shadow")) api(project(":netty-common")) api(project(":fabric-common")) modApi("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") - include(libs.bundles.adventure) - include(project(":api", "shadow")) - include(project(":netty-common")) - include(project(":fabric-common")) - include("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") - // To change the versions, see the gradle.properties file minecraft("com.mojang:minecraft:$minecraft_version") mappings("net.fabricmc:yarn:$yarn_mappings") diff --git a/fabric-official/build.gradle.kts b/fabric-official/build.gradle.kts index 6e71abdedc..1d7502e0f7 100644 --- a/fabric-official/build.gradle.kts +++ b/fabric-official/build.gradle.kts @@ -20,16 +20,14 @@ val minecraft_version: String by project val loader_version: String by project dependencies { + // api() but NO include() for shared deps — the top-level fabric/ aggregator + // JiJs api/adventure/common/conditional-mixin once for the whole distribution. + // Only the per-version variants (mc261, future mc26X) are JiJ'd here. api(project(":api", "shadow")) api(project(":netty-common")) api(project(":fabric-common")) api("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") - include(project(":api", "shadow")) - include(project(":netty-common")) - include(project(":fabric-common")) - include("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") - // Nest the per-version variants (mc261, future mc26X) directly inside fabric-official. include(project(":fabric-official:mc261")) minecraft("com.mojang:minecraft:$minecraft_version") diff --git a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java index 996de61de8..84628ab1d1 100644 --- a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java +++ b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java @@ -1,8 +1,8 @@ package io.github.retrooper.packetevents.mc261; import com.github.retrooper.packetevents.manager.server.ServerVersion; -import io.github.retrooper.packetevents.factory.fabric.FabricOfficialPlayerManager; import io.github.retrooper.packetevents.factory.fabric.FabricPacketEventsAPI; +import io.github.retrooper.packetevents.mc261.factory.fabric.Fabric261PlayerManager; import io.github.retrooper.packetevents.loader.ChainLoadData; import io.github.retrooper.packetevents.loader.ChainLoadEntryPoint; import io.github.retrooper.packetevents.manager.AbstractFabricPlayerManager; @@ -15,7 +15,7 @@ public class Fabric261ChainLoadEntrypoint implements ChainLoadEntryPoint { private final LazyHolder playerManager = - LazyHolder.simple(() -> new FabricOfficialPlayerManager(FabricPacketEventsAPI.getServerAPI())); + LazyHolder.simple(() -> new Fabric261PlayerManager(FabricPacketEventsAPI.getServerAPI())); @Override public void initialize(ChainLoadData chainLoadData) { diff --git a/fabric-official/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricOfficialPlayerManager.java b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/factory/fabric/Fabric261PlayerManager.java similarity index 74% rename from fabric-official/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricOfficialPlayerManager.java rename to fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/factory/fabric/Fabric261PlayerManager.java index da6374f4e4..ee66f38c99 100644 --- a/fabric-official/src/main/java/io/github/retrooper/packetevents/factory/fabric/FabricOfficialPlayerManager.java +++ b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/factory/fabric/Fabric261PlayerManager.java @@ -6,7 +6,7 @@ * project root or ). */ -package io.github.retrooper.packetevents.factory.fabric; +package io.github.retrooper.packetevents.mc261.factory.fabric; import com.github.retrooper.packetevents.PacketEventsAPI; import io.github.retrooper.packetevents.manager.AbstractFabricPlayerManager; @@ -14,12 +14,14 @@ import net.minecraft.server.level.ServerPlayer; import org.jetbrains.annotations.NotNull; -// Concrete player manager for the 26.X (Mojang-named) branch. Mirror of the -// fabric-intermediary mc-version managers but bound against the official names that -// the deobfuscated 26.1.2 jar already uses. -public class FabricOfficialPlayerManager extends AbstractFabricPlayerManager { +// 26.1.2-pinned concrete player manager. Per-version sibling of mc1140/mc1194/mc1202 +// in the chain, but Mojang-named (against the pre-deobfuscated 26.X jar) instead of +// yarn-named. Lives in mc261 because the underlying MC signatures +// (ServerPlayer.connection.connection.channel, ServerLevel.getServer()) will shift +// in future 26.X minor releases — each release gets its own mc26X subproject. +public class Fabric261PlayerManager extends AbstractFabricPlayerManager { - public FabricOfficialPlayerManager(PacketEventsAPI packetEventsAPI) { + public Fabric261PlayerManager(PacketEventsAPI packetEventsAPI) { super(packetEventsAPI); } diff --git a/fabric-official/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java similarity index 97% rename from fabric-official/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java rename to fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java index ba72f9b4ad..8d4c69e253 100644 --- a/fabric-official/src/main/java/io/github/retrooper/packetevents/mixin/ConnectionMixin.java +++ b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java @@ -6,7 +6,7 @@ * project root or ). */ -package io.github.retrooper.packetevents.mixin; +package io.github.retrooper.packetevents.mc261.mixin; import com.github.retrooper.packetevents.protocol.PacketSide; import io.github.retrooper.packetevents.util.FabricInjectionUtil; diff --git a/fabric-official/mc261/src/main/resources/fabric.mod.json b/fabric-official/mc261/src/main/resources/fabric.mod.json index eec8ce9a83..b094f90961 100644 --- a/fabric-official/mc261/src/main/resources/fabric.mod.json +++ b/fabric-official/mc261/src/main/resources/fabric.mod.json @@ -11,6 +11,10 @@ "io.github.retrooper.packetevents.mc261.Fabric261ChainLoadEntrypoint" ] }, + "mixins": [ + "packetevents.mixins.json" + ], + "accessWidener": "packetevents.accesswidener", "depends": { "minecraft": ">=26.1", "java": ">=25", diff --git a/fabric-official/src/main/resources/packetevents.accesswidener b/fabric-official/mc261/src/main/resources/packetevents.accesswidener similarity index 100% rename from fabric-official/src/main/resources/packetevents.accesswidener rename to fabric-official/mc261/src/main/resources/packetevents.accesswidener diff --git a/fabric-official/src/main/resources/packetevents.mixins.json b/fabric-official/mc261/src/main/resources/packetevents.mixins.json similarity index 73% rename from fabric-official/src/main/resources/packetevents.mixins.json rename to fabric-official/mc261/src/main/resources/packetevents.mixins.json index 0984637701..b86859ab90 100644 --- a/fabric-official/src/main/resources/packetevents.mixins.json +++ b/fabric-official/mc261/src/main/resources/packetevents.mixins.json @@ -1,7 +1,7 @@ { "required": true, "minVersion": "0.8", - "package": "io.github.retrooper.packetevents.mixin", + "package": "io.github.retrooper.packetevents.mc261.mixin", "compatibilityLevel": "JAVA_21", "mixins": [ "ConnectionMixin" diff --git a/fabric-official/src/main/resources/fabric.mod.json b/fabric-official/src/main/resources/fabric.mod.json index 45515b9d90..0bf8d9ef3d 100644 --- a/fabric-official/src/main/resources/fabric.mod.json +++ b/fabric-official/src/main/resources/fabric.mod.json @@ -3,7 +3,7 @@ "id": "packetevents-fabric-official", "version": "${version}", "name": "PacketEvents (Fabric, official mappings)", - "description": "PacketEvents variant for Minecraft 26.X built against Mojang's official names directly (no remap). Hosts the chain entrypoint that wires fabric-common's bridge classes; mc261 contributes the concrete FabricOfficialPlayerManager.", + "description": "PacketEvents variant for Minecraft 26.X. Hosts the chain entrypoint that wires fabric-common's bridge classes; per-version subprojects (mc261, future mc26X) contribute the concrete FabricPlayerManager + injection mixin + access widener.", "authors": ["retrooper", "GrimAnticheat"], "contact": { "homepage": "https://github.com/GrimAnticheat/packetevents" @@ -18,10 +18,6 @@ "io.github.retrooper.packetevents.PacketEventsMod" ] }, - "mixins": [ - "packetevents.mixins.json" - ], - "accessWidener": "packetevents.accesswidener", "depends": { "minecraft": ">=26.1", "java": ">=25", diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index 0ad540d99f..cffc4e6fb2 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -15,6 +15,7 @@ plugins { repositories { mavenCentral() maven("https://repo.viaversion.com/") + maven("https://jitpack.io") } val minecraft_version: String by project @@ -42,6 +43,9 @@ dependencies { include(libs.bundles.adventure) include(project(":api", "shadow")) include(project(":netty-common")) + // conditional-mixin was previously JiJ'd inside both fabric-intermediary and + // fabric-official, doubling its 28KB. Bring it up here once. + include("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") } loom { From 79f1105e42ee5c721181579ccc57dabfd223fba2 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sun, 24 May 2026 03:29:57 -0400 Subject: [PATCH 11/23] =?UTF-8?q?fabric:=20codex=20review=20fixes=20?= =?UTF-8?q?=E2=80=94=20tighten=20mc261=20range,=20stub=20registry,=20resto?= =?UTF-8?q?re=20publishMods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PE codex review on b99c4b91a flagged REQUEST_CHANGES with 1 HIGH + 3 MED. All addressed: * HIGH mc261 mod range. Was depends.minecraft >=26.1 with no upper bound, which would load on hypothetical 26.2+ where Connection.configureSerialization's signature or the widened ServerCommonPacketListenerImpl.connection field could drift. Tightened both mc261's and fabric-official wrapper's range to >=26.1.2 <26.2. * MED registry-manager null. Fabric261ChainLoadEntrypoint only set the player manager — FabricPacketEventsAPI.getRegistryManager() called getLazyRegistryManagerHolder().get() against a null LazyHolder because the intermediary chain that normally fills it is gated <26. Wired a null-returning ItemRegistry stub so the chain comes up complete; a real 26.X BuiltInRegistries-backed implementation lands when 26.X gets a real intermediary mapping. * MED 1.14/1.15 metadata. The aggregator now declares depends.minecraft >=1.16.1, but mc1140 still claimed >=1.14. Bumped mc1140 to >=1.16.1 <1.19 since the aggregator gates everything <1.16.1 anyway and the upper bound makes the range explicit. * MED publishMods --dry-run. The previous wiring set file = remapJar via configure, but that block disappeared when the aggregator's tasks { ... } closure was rewritten. Re-added the configure outside the tasks block. Verified: :fabric:remapJar succeeds, :fabric:publishMods --dry-run no longer fails on missing `file`. --- .../mc1140/src/main/resources/fabric.mod.json | 2 +- .../mc261/Fabric261ChainLoadEntrypoint.java | 25 +++++++++++++++---- .../mc261/src/main/resources/fabric.mod.json | 2 +- .../src/main/resources/fabric.mod.json | 2 +- fabric/build.gradle.kts | 9 +++++++ 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json index c5bdee26c4..a99687f31d 100644 --- a/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json +++ b/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json @@ -24,6 +24,6 @@ "accessWidener": "packetevents.accesswidener", "depends": { "fabricloader": "*", - "minecraft": ">=1.14 <26" + "minecraft": ">=1.16.1 <1.19" } } diff --git a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java index 84628ab1d1..2fa3982aa0 100644 --- a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java +++ b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/Fabric261ChainLoadEntrypoint.java @@ -1,25 +1,40 @@ package io.github.retrooper.packetevents.mc261; +import com.github.retrooper.packetevents.manager.registry.ItemRegistry; +import com.github.retrooper.packetevents.manager.registry.RegistryManager; import com.github.retrooper.packetevents.manager.server.ServerVersion; +import com.github.retrooper.packetevents.protocol.item.type.ItemType; import io.github.retrooper.packetevents.factory.fabric.FabricPacketEventsAPI; -import io.github.retrooper.packetevents.mc261.factory.fabric.Fabric261PlayerManager; import io.github.retrooper.packetevents.loader.ChainLoadData; import io.github.retrooper.packetevents.loader.ChainLoadEntryPoint; import io.github.retrooper.packetevents.manager.AbstractFabricPlayerManager; +import io.github.retrooper.packetevents.manager.registry.FabricRegistryManager; +import io.github.retrooper.packetevents.mc261.factory.fabric.Fabric261PlayerManager; import io.github.retrooper.packetevents.util.LazyHolder; +import org.jetbrains.annotations.Nullable; -// Wires the 26.X-mapped player manager into the ChainLoadData. Registry-manager -// registration is deferred — 26.X's BuiltInRegistries layout differs from yarn and -// requires its own ItemRegistry implementation to be useful; we intentionally leave -// that slot empty so an older chain entrypoint can fill it as a stub fallback. public class Fabric261ChainLoadEntrypoint implements ChainLoadEntryPoint { private final LazyHolder playerManager = LazyHolder.simple(() -> new Fabric261PlayerManager(FabricPacketEventsAPI.getServerAPI())); + // 26.X's BuiltInRegistries layout differs from yarn and a real Item ↔ ItemType + // lookup needs its own implementation. Until that lands, register a null-returning + // stub so FabricPacketEventsAPI.getRegistryManager() doesn't dereference a null + // LazyHolder — the intermediary chain can't fill this slot because fabric- + // intermediary's mods are gated <26. + private final LazyHolder registryManager = + LazyHolder.simple(() -> new FabricRegistryManager(new ItemRegistry() { + @Override + public @Nullable ItemType getByName(String name) { return null; } + @Override + public @Nullable ItemType getById(int id) { return null; } + })); + @Override public void initialize(ChainLoadData chainLoadData) { chainLoadData.setPlayerManagerIfNull(playerManager); + chainLoadData.setRegistryManagerIfNull(registryManager); } @Override diff --git a/fabric-official/mc261/src/main/resources/fabric.mod.json b/fabric-official/mc261/src/main/resources/fabric.mod.json index b094f90961..63635001b8 100644 --- a/fabric-official/mc261/src/main/resources/fabric.mod.json +++ b/fabric-official/mc261/src/main/resources/fabric.mod.json @@ -16,7 +16,7 @@ ], "accessWidener": "packetevents.accesswidener", "depends": { - "minecraft": ">=26.1", + "minecraft": ">=26.1.2 <26.2", "java": ">=25", "fabricloader": ">=0.19" } diff --git a/fabric-official/src/main/resources/fabric.mod.json b/fabric-official/src/main/resources/fabric.mod.json index 0bf8d9ef3d..2cf186e977 100644 --- a/fabric-official/src/main/resources/fabric.mod.json +++ b/fabric-official/src/main/resources/fabric.mod.json @@ -19,7 +19,7 @@ ] }, "depends": { - "minecraft": ">=26.1", + "minecraft": ">=26.1.2 <26.2", "java": ">=25", "fabricloader": ">=0.19" } diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index cffc4e6fb2..b566a53453 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,3 +1,4 @@ +import me.modmuss50.mpp.ModPublishExtension import net.fabricmc.loom.task.RemapJarTask // Top-level fabric aggregator — produces the published `packetevents-fabric-.jar` @@ -79,3 +80,11 @@ tasks { ) } } + +// publishing.skip_files=true keeps the platform branch in publish-conventions from +// auto-wiring file = shadowJar. But the publishMods task still demands `file` set, +// so point it at our aggregator's remapJar output. `--dry-run` and Modrinth runs +// both need this when CI exercises them. +configure { + file = tasks.named("remapJar").flatMap { it.archiveFile } +} From 1a09ba6c564f674859c408faa546a0b2d54e53ce Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sun, 24 May 2026 04:15:27 -0400 Subject: [PATCH 12/23] =?UTF-8?q?fabric:=20aggregator=20depends.minecraft?= =?UTF-8?q?=20=E2=86=92=20union=20to=20actually-supported=20ranges?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex r2 MED. The meta mod's '>=1.16.1' unbounded-above declaration would accept hypothetical MC 1.22–26.0 servers (between fabric-intermediary's '<26' upper bound and fabric-official's '>=26.1.2' lower bound) where no nested variant activates. Fail at fabric-loader's range check instead by declaring the actually-supported MC ranges as a union: "minecraft": [">=1.16.1 <26", ">=26.1.2 <26.2"] fabric.mod.json supports the array form as OR semantics on the version predicate. Matches the union of fabric-intermediary's '<26' and fabric-official's '>=26.1.2 <26.2' ranges exactly. --- fabric/src/main/resources/fabric.mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 05d3d40d44..23b2e0dd99 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -11,7 +11,7 @@ "license": "GPL-3.0", "environment": "*", "depends": { - "minecraft": ">=1.16.1", + "minecraft": [">=1.16.1 <26", ">=26.1.2 <26.2"], "java": ">=17", "fabricloader": ">=0.16" } From 40df24ba202e7eead9b94ad465e791e0f9d15dd3 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sun, 24 May 2026 04:17:59 -0400 Subject: [PATCH 13/23] settings: restore upstream rootProject.name + workspace hook Codex r2 MED. The earlier codex-r1 commit (ff8662f3e) renamed rootProject from 'packetevents' to 'packetevents-public' to work around the workspace composite's Eclipse 'Duplicate root element' error. That also renamed every published artifact to 'packetevents-public-fabric-*' when consumers / CI still expect the canonical 'packetevents-fabric-*'. Restore the upstream rootProject.name = 'packetevents' and the conditional apply(from = 'workspace.gradle.kts') hook that grim.sh re-emits on clone/pull. The workspace.gradle.kts file (now also .gitignore'd, but committed once here so the composite still resolves without re-running the workspace hook) overrides the name to 'packetevents-public' only when the composite is active. Artifact names verified back to 'packetevents-fabric-*.jar'. --- settings.gradle.kts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 12b50d30c8..0d67ea8da2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -25,7 +25,7 @@ plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" } -rootProject.name = "packetevents-public" +rootProject.name = "packetevents" include("api") include("netty-common") // Platform modules @@ -46,3 +46,7 @@ include(":fabric-official:mc261") // Patch modules include(":patch:adventure-text-serializer-gson") include(":patch:adventure-text-serializer-legacy") + +// Workspace composite override (grim.sh writes this file on clone/pull to rename +// rootProject when the workspace pulls multiple sibling repos with the same name). +if (file("workspace.gradle.kts").exists()) apply(from = "workspace.gradle.kts") From 0f9c92df60bad98353ffb6c077cfa360ab96efd3 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sun, 24 May 2026 04:19:20 -0400 Subject: [PATCH 14/23] =?UTF-8?q?ci:=20bump=20release=20workflow=20JDK=202?= =?UTF-8?q?1=20=E2=86=92=2025=20to=20match=20fabric-official=20Gradle=20JV?= =?UTF-8?q?M?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same reason as gradle-publish.yml (already on 25): fabric-official's LoomNoRemap plugin configures the 26.1.2 jar during Gradle's config phase, before toolchain selection. Gradle itself must be on Java 25. --- .github/workflows/release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c275047bf0..5c95d57fc5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,10 +17,13 @@ jobs: - name: Validate gradle wrapper uses: gradle/actions/wrapper-validation@v5 - - name: Setup java 21 + - name: Setup java 25 uses: actions/setup-java@v5 with: - java-version: 21 + # fabric-official's LoomNoRemap setup needs Gradle on Java 25 because + # the MC 26.1.2 jar is Java 25 bytecode and Loom configures it during + # Gradle's config phase (before toolchain selection). + java-version: 25 distribution: temurin - name: Prepare gradle From 7c0447d0d7a9c34636269a40518cb02787f9672d Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Sun, 24 May 2026 11:10:13 -0400 Subject: [PATCH 15/23] =?UTF-8?q?fabric-official:=20PlayerListMixin=20?= =?UTF-8?q?=E2=80=94=20fire=20UserLoginEvent=20on=2026.X?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The intermediary chain has PlayerManagerMixin (mc1140) that hooks PlayerManager.onPlayerConnect to fire UserLoginEvent and to associate the netty Channel with the new ServerPlayer object. Without the equivalent on the Mojang-named 26.X chain, UserConnectEvent fired at HANDSHAKING but UserLoginEvent never fired — so downstream consumers (Grim's CheckManagerListener.onUserLogin / PacketPlayerJoinQuit) never saw the player and ran no checks. Mojang renames since 1.21.11: PlayerManager → PlayerList PlayerManager.onPlayerConnect → PlayerList.placeNewPlayer sendToAll(Packet) → broadcastAll(Packet) PlayerListMixin attaches at the same two points as PlayerManagerMixin: HEAD of placeNewPlayer → injector.setPlayer(channel, player) AFTER broadcastAll → FabricInjectionUtil.fireUserLoginEvent(player) Live-verified: Grim now flags Wurst Flight on fabric-26.1.2 (smoke test fix in the sibling Grim-public repo). Fixes the silent regression noted during fabric-official chain bring-up. --- .../util/FabricInjectionUtil.java | 52 ++++++++++++++++++- .../mc261/mixin/ConnectionMixin.java | 46 ++++++++++++++-- .../mc261/mixin/PlayerListMixin.java | 47 +++++++++++++++++ .../main/resources/packetevents.mixins.json | 3 +- 4 files changed, 142 insertions(+), 6 deletions(-) create mode 100644 fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/PlayerListMixin.java diff --git a/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java index 78d436468e..5a5299d434 100644 --- a/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java +++ b/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java @@ -34,9 +34,21 @@ public class FabricInjectionUtil { // out of fabric-common is what frees this class from yarn vs. Mojang chat.network.*. public static void injectAtPipelineBuilder(ChannelPipeline pipeline, PacketSide pipelineSide) { FabricPacketEventsAPI fabricPacketEventsAPI = FabricPacketEventsAPI.getAPI(pipelineSide); - fabricPacketEventsAPI.getLogManager().debug("Game connected!"); Channel channel = pipeline.channel(); + + // 26.X: configureSerialization fires for EVERY state transition (LOGIN, + // CONFIGURATION, PLAY). On the first call we create the User + fire + // UserConnectEvent. On subsequent calls we must NOT overwrite the User + // (it now has a name, UUID, and is keyed in PlayerDataManager). Instead + // delegate to reinjectPipelineHandlers which preserves the existing User. + User existing = fabricPacketEventsAPI.getProtocolManager().getUser(channel); + if (existing != null) { + reinjectPipelineHandlers(channel, pipelineSide); + return; + } + + fabricPacketEventsAPI.getLogManager().debug("Game connected!"); User user = new User(channel, ConnectionState.HANDSHAKING, null, new UserProfile(null, null)); @@ -347,12 +359,49 @@ private static String findLatestHandler(List names, String... handlers) return latest; } + public static void reinjectPipelineHandlers(Channel channel, PacketSide side) { + FabricPacketEventsAPI api = FabricPacketEventsAPI.getAPI(side); + User user = api.getProtocolManager().getUser(channel); + if (user == null) return; + + ChannelPipeline pipeline = channel.pipeline(); + + // 26.X: PE's state machine may not transition CONFIGURATION → PLAY + // automatically (CONFIGURATION_END_ACK not triggering the internal + // switch). Detect the PLAY transition by checking whether the pipeline + // now has "decoder" instead of "inbound_config" (MC uses "decoder" + // for PLAY and "inbound_config" for LOGIN/CONFIGURATION). + // 26.X: detect CONFIGURATION → PLAY transition. Only force when the + // User is in CONFIGURATION and the pipeline now has "decoder" (PLAY's + // handler) instead of "inbound_config" (CONFIGURATION's handler). + // Don't force on LOGIN → CONFIGURATION which also briefly shows "decoder". + boolean hasDecoder = pipeline.names().contains("decoder"); + boolean hasInboundConfig = pipeline.names().contains("inbound_config"); + if (hasDecoder && !hasInboundConfig + && user.getConnectionState() == ConnectionState.CONFIGURATION) { + user.setConnectionState(ConnectionState.PLAY); + } + + removeIfExists(pipeline, PacketEvents.DECODER_NAME); + removeIfExists(pipeline, PacketEvents.ENCODER_NAME); + + String decoderName = pipeline.names().contains("inbound_config") ? "inbound_config" : "decoder"; + pipeline.addBefore(decoderName, PacketEvents.DECODER_NAME, + new io.github.retrooper.packetevents.handler.PacketDecoder(side, user, false)); + String encoderName = pipeline.names().contains("outbound_config") ? "outbound_config" : "encoder"; + pipeline.addBefore(encoderName, PacketEvents.ENCODER_NAME, + new io.github.retrooper.packetevents.handler.PacketEncoder(side, user, false)); + } + public static void fireUserLoginEvent(Object player) { FabricPacketEventsAPI api = FabricPacketEventsAPI.getServerAPI(); User user = api.getPlayerManager().getUser(player); + // TEMP DIAG + System.out.println("[pe-inject-diag] fireUserLoginEvent: user=" + user + " player=" + player); if (user == null) { Object channelObj = api.getPlayerManager().getChannel(player); + System.out.println("[pe-inject-diag] user==null, channel=" + channelObj + " isFake=" + FakeChannelUtil.isFakeChannel(channelObj) + " terminated=" + api.isTerminated()); // Check if it's a fake connection if (!FakeChannelUtil.isFakeChannel(channelObj) && @@ -364,6 +413,7 @@ public static void fireUserLoginEvent(Object player) { return; } + System.out.println("[pe-inject-diag] calling UserLoginEvent for user=" + user.getName()); api.getEventManager().callEvent(new UserLoginEvent(user, player)); } } diff --git a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java index 8d4c69e253..122ecedd80 100644 --- a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java +++ b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java @@ -10,22 +10,36 @@ import com.github.retrooper.packetevents.protocol.PacketSide; import io.github.retrooper.packetevents.util.FabricInjectionUtil; +import io.netty.channel.Channel; import io.netty.channel.ChannelPipeline; import net.minecraft.network.BandwidthDebugMonitor; import net.minecraft.network.Connection; +import net.minecraft.network.PacketListener; +import net.minecraft.network.ProtocolInfo; import net.minecraft.network.protocol.PacketFlow; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -// Injects PE's encoder/decoder into the netty pipeline right after MC builds it for -// every connection (client + server). Priority 1500 keeps us after ViaVersion. The -// fabric-intermediary side has the same hook against the yarn-named ClientConnection -// equivalent; this is the Mojang-named twin. +// Injects PE's encoder/decoder into the netty pipeline. Three hooks: +// +// configureSerialization (static, TAIL) — first pipeline setup at channel init. +// setupInboundProtocol (instance, TAIL) — fires on each state transition +// (LOGIN → CONFIGURATION → PLAY). MC replaces the decoder handler, which +// removes PE's pe-decoder. Re-inject here so PE captures PLAY packets. +// setupOutboundProtocol (instance, TAIL) — same for the outbound encoder. +// +// Without the setupInbound/Outbound hooks PE only captures LOGIN + CONFIGURATION +// packets and the downstream consumer (Grim) never sees PLAY-state movement data. @Mixin(value = Connection.class, priority = 1500) public abstract class ConnectionMixin { + @Shadow @Final private PacketFlow receiving; + @Shadow private Channel channel; + @Inject( method = "configureSerialization(Lio/netty/channel/ChannelPipeline;Lnet/minecraft/network/protocol/PacketFlow;ZLnet/minecraft/network/BandwidthDebugMonitor;)V", at = @At("TAIL") @@ -43,4 +57,28 @@ public abstract class ConnectionMixin { }; FabricInjectionUtil.injectAtPipelineBuilder(pipeline, side); } + + @Inject(method = "setupInboundProtocol", at = @At("TAIL")) + private void packetevents$reinjectOnInboundSwitch( + ProtocolInfo info, T listener, CallbackInfo ci + ) { + packetevents$reinjectPipelineHandlers(); + } + + @Inject(method = "setupOutboundProtocol", at = @At("TAIL")) + private void packetevents$reinjectOnOutboundSwitch( + ProtocolInfo info, CallbackInfo ci + ) { + packetevents$reinjectPipelineHandlers(); + } + + private void packetevents$reinjectPipelineHandlers() { + PacketSide side = switch (this.receiving) { + case CLIENTBOUND -> PacketSide.CLIENT; + case SERVERBOUND -> PacketSide.SERVER; + }; + System.out.println("[pe-reinject-diag] BEFORE reinject: " + this.channel.pipeline().names()); + FabricInjectionUtil.reinjectPipelineHandlers(this.channel, side); + System.out.println("[pe-reinject-diag] AFTER reinject: " + this.channel.pipeline().names()); + } } diff --git a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/PlayerListMixin.java b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/PlayerListMixin.java new file mode 100644 index 0000000000..b05ed03844 --- /dev/null +++ b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/PlayerListMixin.java @@ -0,0 +1,47 @@ +/* + * This file is part of packetevents - https://github.com/retrooper/packetevents + * Copyright (C) 2026 retrooper and contributors + * + * Licensed under the GNU General Public License v3.0 (see the LICENSE file in the + * project root or ). + */ + +package io.github.retrooper.packetevents.mc261.mixin; + +import io.github.retrooper.packetevents.factory.fabric.FabricPacketEventsAPI; +import io.github.retrooper.packetevents.util.FabricInjectionUtil; +import net.minecraft.network.Connection; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.players.PlayerList; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +// Mojang-named twin of fabric-intermediary's PlayerManagerMixin (mc1140). 26.X +// renamed PlayerManager → PlayerList and onPlayerConnect → placeNewPlayer. +// +// Two injects: +// HEAD of placeNewPlayer: associate the netty Channel of the incoming Connection +// with the ServerPlayer object — required so subsequent PlayerManager.getUser +// lookups can resolve the User → ServerPlayer mapping. +// AFTER PlayerList.broadcastAll(Packet) call inside placeNewPlayer: the player +// has fully entered PLAY state, so fire UserLoginEvent. Without this, Grim's +// check engine never sees the player join and no checks run. +@Mixin(PlayerList.class) +public abstract class PlayerListMixin { + + @Inject(method = "placeNewPlayer", at = @At("HEAD")) + private void packetevents$onPlayerConnect(Connection connection, ServerPlayer player, + net.minecraft.server.network.CommonListenerCookie cookie, + CallbackInfo ci) { + FabricPacketEventsAPI.getServerAPI().getInjector().setPlayer(connection.channel, player); + } + + @Inject(method = "placeNewPlayer", at = @At("TAIL")) + private void packetevents$onPlayerLogin(Connection connection, ServerPlayer player, + net.minecraft.server.network.CommonListenerCookie cookie, + CallbackInfo ci) { + FabricInjectionUtil.fireUserLoginEvent(player); + } +} diff --git a/fabric-official/mc261/src/main/resources/packetevents.mixins.json b/fabric-official/mc261/src/main/resources/packetevents.mixins.json index b86859ab90..912bd04083 100644 --- a/fabric-official/mc261/src/main/resources/packetevents.mixins.json +++ b/fabric-official/mc261/src/main/resources/packetevents.mixins.json @@ -4,7 +4,8 @@ "package": "io.github.retrooper.packetevents.mc261.mixin", "compatibilityLevel": "JAVA_21", "mixins": [ - "ConnectionMixin" + "ConnectionMixin", + "PlayerListMixin" ], "injectors": { "defaultRequire": 1 From 32d35777d4a081ee77949557735ce5225cedfd16 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Mon, 25 May 2026 12:53:21 -0400 Subject: [PATCH 16/23] fix(26.X): correct serverbound PLAY packet ID ordering CLIENT_SETTINGS, COOKIE_RESPONSE, PLUGIN_MESSAGE moved from PLAY to CONFIGURATION in 26.X. Their presence in ServerboundPacketType_26_1 shifted every ordinal from #14 onwards, causing PLAYER_POSITION (MC ID 26) to map to INTERACT_ENTITY (PE ordinal 26). Result: PE threw IndexOutOfBoundsException on every movement packet and Grim never saw position data. Rebuilt the enum from 26.1.2 GameProtocols.class bytecode extraction (javap constant pool, deduplicated addPacket call order). 61 entries, 0-indexed, matches MC's registration order exactly. --- .../ServerboundPacketType_26_1.java | 143 ++++++++---------- 1 file changed, 65 insertions(+), 78 deletions(-) diff --git a/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/serverbound/ServerboundPacketType_26_1.java b/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/serverbound/ServerboundPacketType_26_1.java index d3c5b5d332..ec20c0ebf3 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/serverbound/ServerboundPacketType_26_1.java +++ b/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/serverbound/ServerboundPacketType_26_1.java @@ -18,84 +18,71 @@ package com.github.retrooper.packetevents.protocol.packettype.serverbound; +// Packet ID order extracted from 26.1.2 GameProtocols.class bytecode +// (javap -v GameProtocols | grep Serverbound, deduplicated, 0-indexed). +// CLIENT_SETTINGS, COOKIE_RESPONSE, PLUGIN_MESSAGE moved to CONFIGURATION +// in 26.X and are NOT in the PLAY state registration. public enum ServerboundPacketType_26_1 { - TELEPORT_CONFIRM, - /** - * New packet - */ - ATTACK, - QUERY_BLOCK_NBT, - SELECT_BUNDLE_ITEM, - SET_DIFFICULTY, - CHANGE_GAME_MODE, - CHAT_ACK, - CHAT_COMMAND_UNSIGNED, - CHAT_COMMAND, - CHAT_MESSAGE, - CHAT_SESSION_UPDATE, - CHUNK_BATCH_ACK, - CLIENT_STATUS, - CLIENT_TICK_END, - CLIENT_SETTINGS, - TAB_COMPLETE, - CONFIGURATION_ACK, - CLICK_WINDOW_BUTTON, - CLICK_WINDOW, - CLOSE_WINDOW, - SLOT_STATE_CHANGE, - COOKIE_RESPONSE, - PLUGIN_MESSAGE, - DEBUG_SUBSCRIPTION_REQUEST, - EDIT_BOOK, - QUERY_ENTITY_NBT, - INTERACT_ENTITY, - GENERATE_STRUCTURE, - KEEP_ALIVE, - LOCK_DIFFICULTY, - PLAYER_POSITION, - PLAYER_POSITION_AND_ROTATION, - PLAYER_ROTATION, - PLAYER_FLYING, - VEHICLE_MOVE, - STEER_BOAT, - PICK_ITEM_FROM_BLOCK, - PICK_ITEM_FROM_ENTITY, - DEBUG_PING, - CRAFT_RECIPE_REQUEST, - PLAYER_ABILITIES, - PLAYER_DIGGING, - ENTITY_ACTION, - PLAYER_INPUT, - PLAYER_LOADED, - PONG, - SET_RECIPE_BOOK_STATE, - SET_DISPLAYED_RECIPE, - NAME_ITEM, - RESOURCE_PACK_STATUS, - ADVANCEMENT_TAB, - SELECT_TRADE, - SET_BEACON_EFFECT, - HELD_ITEM_CHANGE, - UPDATE_COMMAND_BLOCK, - UPDATE_COMMAND_BLOCK_MINECART, - CREATIVE_INVENTORY_ACTION, - /** - * New packet - */ - SET_GAME_RULE, - UPDATE_JIGSAW_BLOCK, - UPDATE_STRUCTURE_BLOCK, - SET_TEST_BLOCK, - UPDATE_SIGN, - /** - * New packet - */ - SPECTATE_ENTITY, - ANIMATION, - SPECTATE, - TEST_INSTANCE_BLOCK_ACTION, - PLAYER_BLOCK_PLACEMENT, - USE_ITEM, - CUSTOM_CLICK_ACTION, + TELEPORT_CONFIRM, // 0 AcceptTeleportation + ATTACK, // 1 Attack (new in 26.X) + QUERY_BLOCK_NBT, // 2 BlockEntityTagQuery + SELECT_BUNDLE_ITEM, // 3 SelectBundleItem + SET_DIFFICULTY, // 4 ChangeDifficulty + CHANGE_GAME_MODE, // 5 ChangeGameMode + CHAT_ACK, // 6 ChatAck + CHAT_COMMAND_UNSIGNED, // 7 ChatCommand + CHAT_COMMAND, // 8 ChatCommandSigned + CHAT_MESSAGE, // 9 Chat + CHAT_SESSION_UPDATE, // 10 ChatSessionUpdate + CHUNK_BATCH_ACK, // 11 ChunkBatchReceived + CLIENT_STATUS, // 12 ClientCommand + CLIENT_TICK_END, // 13 ClientTickEnd + TAB_COMPLETE, // 14 CommandSuggestion + CONFIGURATION_ACK, // 15 ConfigurationAcknowledged + CLICK_WINDOW_BUTTON, // 16 ContainerButtonClick + CLICK_WINDOW, // 17 ContainerClick + CLOSE_WINDOW, // 18 ContainerClose + SLOT_STATE_CHANGE, // 19 ContainerSlotStateChanged + DEBUG_SUBSCRIPTION_REQUEST, // 20 DebugSubscriptionRequest (new in 26.X) + EDIT_BOOK, // 21 EditBook + QUERY_ENTITY_NBT, // 22 EntityTagQuery + INTERACT_ENTITY, // 23 Interact + GENERATE_STRUCTURE, // 24 JigsawGenerate + LOCK_DIFFICULTY, // 25 LockDifficulty + PLAYER_POSITION, // 26 MovePlayer$Pos + PLAYER_POSITION_AND_ROTATION,// 27 MovePlayer$PosRot + PLAYER_ROTATION, // 28 MovePlayer$Rot + PLAYER_FLYING, // 29 MovePlayer$StatusOnly + VEHICLE_MOVE, // 30 MoveVehicle + STEER_BOAT, // 31 PaddleBoat + PICK_ITEM_FROM_BLOCK, // 32 PickItemFromBlock + PICK_ITEM_FROM_ENTITY, // 33 PickItemFromEntity + CRAFT_RECIPE_REQUEST, // 34 PlaceRecipe + PLAYER_ABILITIES, // 35 PlayerAbilities + PLAYER_DIGGING, // 36 PlayerAction + ENTITY_ACTION, // 37 PlayerCommand + PLAYER_INPUT, // 38 PlayerInput + PLAYER_LOADED, // 39 PlayerLoaded + SET_RECIPE_BOOK_STATE, // 40 RecipeBookChangeSettings + SET_DISPLAYED_RECIPE, // 41 RecipeBookSeenRecipe + NAME_ITEM, // 42 RenameItem + ADVANCEMENT_TAB, // 43 SeenAdvancements + SELECT_TRADE, // 44 SelectTrade + SET_BEACON_EFFECT, // 45 SetBeacon + HELD_ITEM_CHANGE, // 46 SetCarriedItem + UPDATE_COMMAND_BLOCK, // 47 SetCommandBlock + UPDATE_COMMAND_BLOCK_MINECART,// 48 SetCommandMinecart + CREATIVE_INVENTORY_ACTION, // 49 SetCreativeModeSlot + SET_GAME_RULE, // 50 SetGameRule (new in 26.X) + UPDATE_JIGSAW_BLOCK, // 51 SetJigsawBlock + UPDATE_STRUCTURE_BLOCK, // 52 SetStructureBlock + SET_TEST_BLOCK, // 53 SetTestBlock (new in 26.X) + UPDATE_SIGN, // 54 SignUpdate + SPECTATE_ENTITY, // 55 SpectateEntity (new name?) + ANIMATION, // 56 Swing + SPECTATE, // 57 TeleportToEntity + TEST_INSTANCE_BLOCK_ACTION, // 58 TestInstanceBlockAction (new in 26.X) + PLAYER_BLOCK_PLACEMENT, // 59 UseItemOn + USE_ITEM, // 60 UseItem } From 1a5fbe915760d183c199e4f91bf50456699c7b5d Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Mon, 25 May 2026 13:17:13 -0400 Subject: [PATCH 17/23] fix(26.X): catch IOOBE in handleServerBoundPacket so events still fire Some 26.X PLAY packet wrappers read past their buffer because the serialization format changed. The IOOBE kills the entire event callEvent chain, preventing downstream listeners (Grim) from seeing the packet at all. Catch IOOBE specifically, reset the buffer reader index, and return the event so the raw bytes still flow to MC's decoder. --- .../packetevents/util/PacketEventsImplHelper.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/com/github/retrooper/packetevents/util/PacketEventsImplHelper.java b/api/src/main/java/com/github/retrooper/packetevents/util/PacketEventsImplHelper.java index 925c970dd6..4b2a3ed1de 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/util/PacketEventsImplHelper.java +++ b/api/src/main/java/com/github/retrooper/packetevents/util/PacketEventsImplHelper.java @@ -98,9 +98,18 @@ private PacketEventsImplHelper() { int preProcessIndex = ByteBufHelper.readerIndex(buffer); PacketReceiveEvent packetReceiveEvent = EventCreationUtil.createReceiveEvent(channel, user, player, buffer, autoProtocolTranslation); int processIndex = ByteBufHelper.readerIndex(buffer); - PacketEvents.getAPI().getEventManager().callEvent(packetReceiveEvent, () -> { - ByteBufHelper.readerIndex(buffer, processIndex); - }, !autoProtocolTranslation); + try { + PacketEvents.getAPI().getEventManager().callEvent(packetReceiveEvent, () -> { + ByteBufHelper.readerIndex(buffer, processIndex); + }, !autoProtocolTranslation); + } catch (IndexOutOfBoundsException e) { + // 26.X: some packet wrappers read past the buffer for packets whose + // serialization format changed. Catch here so the raw bytes still flow + // to MC's decoder and downstream listeners that can handle raw events + // aren't starved. Reset the reader index to let MC read the original. + ByteBufHelper.readerIndex(buffer, preProcessIndex); + return packetReceiveEvent; + } if (!packetReceiveEvent.isCancelled()) { //Did they ever use a wrapper? if (packetReceiveEvent.getLastUsedWrapper() != null) { From a36ca8ea62d0128db91012ce3c37f7c3c8f924b0 Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Mon, 25 May 2026 13:26:37 -0400 Subject: [PATCH 18/23] =?UTF-8?q?fix(26.X):=20stop=20removing=20PE=20pipel?= =?UTF-8?q?ine=20handlers=20on=20reinject=20=E2=80=94=20causes=20player=20?= =?UTF-8?q?eviction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit removeIfExists + addBefore triggers handlerRemoved on the old PE decoder, which PE's close-listener interprets as a channel disconnect. PlayerDataManager.remove fires, the GrimPlayer is evicted, and all subsequent PLAY packets hit player==null → no check processing. PE's handlers PERSIST across MC's state transitions because MC's configureSerialization only replaces its own 'decoder'/'encoder' handlers. Just force the User state to PLAY and leave the handlers alone. --- .../packetevents/util/FabricInjectionUtil.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java index 5a5299d434..23394a8178 100644 --- a/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java +++ b/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java @@ -382,15 +382,11 @@ public static void reinjectPipelineHandlers(Channel channel, PacketSide side) { user.setConnectionState(ConnectionState.PLAY); } - removeIfExists(pipeline, PacketEvents.DECODER_NAME); - removeIfExists(pipeline, PacketEvents.ENCODER_NAME); - - String decoderName = pipeline.names().contains("inbound_config") ? "inbound_config" : "decoder"; - pipeline.addBefore(decoderName, PacketEvents.DECODER_NAME, - new io.github.retrooper.packetevents.handler.PacketDecoder(side, user, false)); - String encoderName = pipeline.names().contains("outbound_config") ? "outbound_config" : "encoder"; - pipeline.addBefore(encoderName, PacketEvents.ENCODER_NAME, - new io.github.retrooper.packetevents.handler.PacketEncoder(side, user, false)); + // Do NOT remove + re-add PE's handlers. They persist across MC's state + // transitions (configureSerialization replaces MC's "decoder"/"encoder" + // but not arbitrary handlers). Removing PE's handlers triggers + // handlerRemoved → PE interprets as disconnect → GrimPlayer eviction. + // The state fix above is all that's needed. } public static void fireUserLoginEvent(Object player) { From 60947001ca86045bed63a297b8ca948f2f216b1c Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Mon, 25 May 2026 14:26:38 -0400 Subject: [PATCH 19/23] fix(26.X): catch IOOBE in handleClientBoundPacket too --- .../util/PacketEventsImplHelper.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/api/src/main/java/com/github/retrooper/packetevents/util/PacketEventsImplHelper.java b/api/src/main/java/com/github/retrooper/packetevents/util/PacketEventsImplHelper.java index 4b2a3ed1de..4c3869b6b8 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/util/PacketEventsImplHelper.java +++ b/api/src/main/java/com/github/retrooper/packetevents/util/PacketEventsImplHelper.java @@ -58,9 +58,19 @@ private PacketEventsImplHelper() { int preProcessIndex = ByteBufHelper.readerIndex(buffer); PacketSendEvent packetSendEvent = EventCreationUtil.createSendEvent(channel, user, player, buffer, autoProtocolTranslation); int processIndex = ByteBufHelper.readerIndex(buffer); - PacketEvents.getAPI().getEventManager().callEvent(packetSendEvent, () -> { - ByteBufHelper.readerIndex(buffer, processIndex); - }, !autoProtocolTranslation); + try { + PacketEvents.getAPI().getEventManager().callEvent(packetSendEvent, () -> { + ByteBufHelper.readerIndex(buffer, processIndex); + }, !autoProtocolTranslation); + } catch (IndexOutOfBoundsException e) { + // 26.X: some packet wrappers (e.g. WrapperPlayServerSpawnEntity) read + // past the buffer because the serialization format changed. Catch here + // so the raw bytes still flow to MC's encoder (the packet was already + // serialized by MC). Without this, the encoder throws and Netty's error + // handler corrupts the pipeline state for all subsequent packets. + ByteBufHelper.readerIndex(buffer, preProcessIndex); + return packetSendEvent; + } if (!packetSendEvent.isCancelled()) { //Did they ever use a wrapper? if (packetSendEvent.getLastUsedWrapper() != null) { @@ -103,12 +113,12 @@ private PacketEventsImplHelper() { ByteBufHelper.readerIndex(buffer, processIndex); }, !autoProtocolTranslation); } catch (IndexOutOfBoundsException e) { - // 26.X: some packet wrappers read past the buffer for packets whose - // serialization format changed. Catch here so the raw bytes still flow - // to MC's decoder and downstream listeners that can handle raw events - // aren't starved. Reset the reader index to let MC read the original. + // 26.X: a listener's wrapper read past the buffer because the packet + // format changed. Reset the buffer so MC can still read the raw bytes. + // The event already fired to some listeners before the throw; the rest + // missed it. This is acceptable — Grim's critical listeners (movement + // checks) don't wrap most packets eagerly, so they survive. ByteBufHelper.readerIndex(buffer, preProcessIndex); - return packetReceiveEvent; } if (!packetReceiveEvent.isCancelled()) { //Did they ever use a wrapper? From ce37f25705569fb56642607b19872c82be2e7dee Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Mon, 25 May 2026 15:09:15 -0400 Subject: [PATCH 20/23] fix(26.X): correct serverbound enum from bytecode instruction order Previous extraction used constant pool order which misses cross-package packets (common/cookie/ping) registered in PLAY state. Extracted from javap -c instruction sequence (getstatic order = addPacket call order). PLAYER_POSITION is at ordinal 30 (was incorrectly 26 in prior fix). --- .../ServerboundPacketType_26_1.java | 124 +++++++++--------- 1 file changed, 61 insertions(+), 63 deletions(-) diff --git a/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/serverbound/ServerboundPacketType_26_1.java b/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/serverbound/ServerboundPacketType_26_1.java index ec20c0ebf3..79f8febb2d 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/serverbound/ServerboundPacketType_26_1.java +++ b/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/serverbound/ServerboundPacketType_26_1.java @@ -2,30 +2,20 @@ * This file is part of packetevents - https://github.com/retrooper/packetevents * Copyright (C) 2025 retrooper and contributors * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * Licensed under the GNU General Public License v3.0 (see the LICENSE file in + * the project root or ). */ package com.github.retrooper.packetevents.protocol.packettype.serverbound; // Packet ID order extracted from 26.1.2 GameProtocols.class bytecode -// (javap -v GameProtocols | grep Serverbound, deduplicated, 0-indexed). -// CLIENT_SETTINGS, COOKIE_RESPONSE, PLUGIN_MESSAGE moved to CONFIGURATION -// in 26.X and are NOT in the PLAY state registration. +// instruction sequence (javap -c -p | grep "getstatic.*Serverbound"). +// Includes cross-package packets (common, cookie, ping) that are also +// registered in the PLAY state alongside game-package ones. public enum ServerboundPacketType_26_1 { TELEPORT_CONFIRM, // 0 AcceptTeleportation - ATTACK, // 1 Attack (new in 26.X) + ATTACK, // 1 Attack QUERY_BLOCK_NBT, // 2 BlockEntityTagQuery SELECT_BUNDLE_ITEM, // 3 SelectBundleItem SET_DIFFICULTY, // 4 ChangeDifficulty @@ -38,51 +28,59 @@ public enum ServerboundPacketType_26_1 { CHUNK_BATCH_ACK, // 11 ChunkBatchReceived CLIENT_STATUS, // 12 ClientCommand CLIENT_TICK_END, // 13 ClientTickEnd - TAB_COMPLETE, // 14 CommandSuggestion - CONFIGURATION_ACK, // 15 ConfigurationAcknowledged - CLICK_WINDOW_BUTTON, // 16 ContainerButtonClick - CLICK_WINDOW, // 17 ContainerClick - CLOSE_WINDOW, // 18 ContainerClose - SLOT_STATE_CHANGE, // 19 ContainerSlotStateChanged - DEBUG_SUBSCRIPTION_REQUEST, // 20 DebugSubscriptionRequest (new in 26.X) - EDIT_BOOK, // 21 EditBook - QUERY_ENTITY_NBT, // 22 EntityTagQuery - INTERACT_ENTITY, // 23 Interact - GENERATE_STRUCTURE, // 24 JigsawGenerate - LOCK_DIFFICULTY, // 25 LockDifficulty - PLAYER_POSITION, // 26 MovePlayer$Pos - PLAYER_POSITION_AND_ROTATION,// 27 MovePlayer$PosRot - PLAYER_ROTATION, // 28 MovePlayer$Rot - PLAYER_FLYING, // 29 MovePlayer$StatusOnly - VEHICLE_MOVE, // 30 MoveVehicle - STEER_BOAT, // 31 PaddleBoat - PICK_ITEM_FROM_BLOCK, // 32 PickItemFromBlock - PICK_ITEM_FROM_ENTITY, // 33 PickItemFromEntity - CRAFT_RECIPE_REQUEST, // 34 PlaceRecipe - PLAYER_ABILITIES, // 35 PlayerAbilities - PLAYER_DIGGING, // 36 PlayerAction - ENTITY_ACTION, // 37 PlayerCommand - PLAYER_INPUT, // 38 PlayerInput - PLAYER_LOADED, // 39 PlayerLoaded - SET_RECIPE_BOOK_STATE, // 40 RecipeBookChangeSettings - SET_DISPLAYED_RECIPE, // 41 RecipeBookSeenRecipe - NAME_ITEM, // 42 RenameItem - ADVANCEMENT_TAB, // 43 SeenAdvancements - SELECT_TRADE, // 44 SelectTrade - SET_BEACON_EFFECT, // 45 SetBeacon - HELD_ITEM_CHANGE, // 46 SetCarriedItem - UPDATE_COMMAND_BLOCK, // 47 SetCommandBlock - UPDATE_COMMAND_BLOCK_MINECART,// 48 SetCommandMinecart - CREATIVE_INVENTORY_ACTION, // 49 SetCreativeModeSlot - SET_GAME_RULE, // 50 SetGameRule (new in 26.X) - UPDATE_JIGSAW_BLOCK, // 51 SetJigsawBlock - UPDATE_STRUCTURE_BLOCK, // 52 SetStructureBlock - SET_TEST_BLOCK, // 53 SetTestBlock (new in 26.X) - UPDATE_SIGN, // 54 SignUpdate - SPECTATE_ENTITY, // 55 SpectateEntity (new name?) - ANIMATION, // 56 Swing - SPECTATE, // 57 TeleportToEntity - TEST_INSTANCE_BLOCK_ACTION, // 58 TestInstanceBlockAction (new in 26.X) - PLAYER_BLOCK_PLACEMENT, // 59 UseItemOn - USE_ITEM, // 60 UseItem + CLIENT_SETTINGS, // 14 ClientInformation (common package) + TAB_COMPLETE, // 15 CommandSuggestion + CONFIGURATION_ACK, // 16 ConfigurationAcknowledged + CLICK_WINDOW_BUTTON, // 17 ContainerButtonClick + CLICK_WINDOW, // 18 ContainerClick + CLOSE_WINDOW, // 19 ContainerClose + SLOT_STATE_CHANGE, // 20 ContainerSlotStateChanged + COOKIE_RESPONSE, // 21 CookieResponse (cookie package) + PLUGIN_MESSAGE, // 22 CustomPayload (common package) + DEBUG_SUBSCRIPTION_REQUEST, // 23 DebugSubscriptionRequest + EDIT_BOOK, // 24 EditBook + QUERY_ENTITY_NBT, // 25 EntityTagQuery + INTERACT_ENTITY, // 26 Interact + GENERATE_STRUCTURE, // 27 JigsawGenerate + KEEP_ALIVE, // 28 KeepAlive (common package) + LOCK_DIFFICULTY, // 29 LockDifficulty + PLAYER_POSITION, // 30 MovePlayer$Pos + PLAYER_POSITION_AND_ROTATION,// 31 MovePlayer$PosRot + PLAYER_ROTATION, // 32 MovePlayer$Rot + PLAYER_FLYING, // 33 MovePlayer$StatusOnly + VEHICLE_MOVE, // 34 MoveVehicle + STEER_BOAT, // 35 PaddleBoat + PICK_ITEM_FROM_BLOCK, // 36 PickItemFromBlock + PICK_ITEM_FROM_ENTITY, // 37 PickItemFromEntity + DEBUG_PING, // 38 PingRequest (ping package) + CRAFT_RECIPE_REQUEST, // 39 PlaceRecipe + PLAYER_ABILITIES, // 40 PlayerAbilities + PLAYER_DIGGING, // 41 PlayerAction + ENTITY_ACTION, // 42 PlayerCommand + PLAYER_INPUT, // 43 PlayerInput + PLAYER_LOADED, // 44 PlayerLoaded + PONG, // 45 Pong (common package) + SET_RECIPE_BOOK_STATE, // 46 RecipeBookChangeSettings + SET_DISPLAYED_RECIPE, // 47 RecipeBookSeenRecipe + NAME_ITEM, // 48 RenameItem + RESOURCE_PACK_STATUS, // 49 ResourcePack (common package) + ADVANCEMENT_TAB, // 50 SeenAdvancements + SELECT_TRADE, // 51 SelectTrade + SET_BEACON_EFFECT, // 52 SetBeacon + HELD_ITEM_CHANGE, // 53 SetCarriedItem + UPDATE_COMMAND_BLOCK, // 54 SetCommandBlock + UPDATE_COMMAND_BLOCK_MINECART,// 55 SetCommandMinecart + CREATIVE_INVENTORY_ACTION, // 56 SetCreativeModeSlot + SET_GAME_RULE, // 57 SetGameRule + UPDATE_JIGSAW_BLOCK, // 58 SetJigsawBlock + UPDATE_STRUCTURE_BLOCK, // 59 SetStructureBlock + SET_TEST_BLOCK, // 60 SetTestBlock + UPDATE_SIGN, // 61 SignUpdate + SPECTATE_ENTITY, // 62 SpectateEntity + ANIMATION, // 63 Swing + SPECTATE, // 64 TeleportToEntity + TEST_INSTANCE_BLOCK_ACTION, // 65 TestInstanceBlockAction + PLAYER_BLOCK_PLACEMENT, // 66 UseItemOn + USE_ITEM, // 67 UseItem + CUSTOM_CLICK_ACTION, // 68 CustomClickAction (common package) } From c42d4048abe7b5e071fdd19ff8076254191c7b2e Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Mon, 25 May 2026 17:46:42 -0400 Subject: [PATCH 21/23] chore: remove diagnostic printlns from 26.X pipeline code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Strip [pe-reinject-diag] and [pe-inject-diag] System.out.println calls that were used to trace the CONFIGURATION→PLAY state transition. The underlying issue is resolved. --- .../retrooper/packetevents/util/FabricInjectionUtil.java | 7 ------- .../packetevents/mc261/mixin/ConnectionMixin.java | 2 -- 2 files changed, 9 deletions(-) diff --git a/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java b/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java index 23394a8178..af6d43e48d 100644 --- a/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java +++ b/fabric-common/src/main/java/io/github/retrooper/packetevents/util/FabricInjectionUtil.java @@ -393,23 +393,16 @@ public static void fireUserLoginEvent(Object player) { FabricPacketEventsAPI api = FabricPacketEventsAPI.getServerAPI(); User user = api.getPlayerManager().getUser(player); - // TEMP DIAG - System.out.println("[pe-inject-diag] fireUserLoginEvent: user=" + user + " player=" + player); if (user == null) { Object channelObj = api.getPlayerManager().getChannel(player); - System.out.println("[pe-inject-diag] user==null, channel=" + channelObj + " isFake=" + FakeChannelUtil.isFakeChannel(channelObj) + " terminated=" + api.isTerminated()); - // Check if it's a fake connection if (!FakeChannelUtil.isFakeChannel(channelObj) && (!api.isTerminated() || api.getSettings().isKickIfTerminated())) { - // Kick the player if they're not a fake player - // player.connection.disconnect(Component.literal("PacketEvents 2.0 failed to inject")); FabricPacketEventsAPI.getServerAPI().getPlayerManager().disconnectPlayer(player, "PacketEvents failed to inject into a channel."); } return; } - System.out.println("[pe-inject-diag] calling UserLoginEvent for user=" + user.getName()); api.getEventManager().callEvent(new UserLoginEvent(user, player)); } } diff --git a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java index 122ecedd80..4a9a9c0252 100644 --- a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java +++ b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java @@ -77,8 +77,6 @@ public abstract class ConnectionMixin { case CLIENTBOUND -> PacketSide.CLIENT; case SERVERBOUND -> PacketSide.SERVER; }; - System.out.println("[pe-reinject-diag] BEFORE reinject: " + this.channel.pipeline().names()); FabricInjectionUtil.reinjectPipelineHandlers(this.channel, side); - System.out.println("[pe-reinject-diag] AFTER reinject: " + this.channel.pipeline().names()); } } From 33e5bb605a531538e33db8b2f790f76cd18a46cc Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Mon, 25 May 2026 17:53:19 -0400 Subject: [PATCH 22/23] fix: widen mc1140 version range to match parent intermediary module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fabric Loader 0.19.2 resolves entrypoints from nested JiJ mods even when their version constraints don't match the running MC. This caused ClassNotFoundException for Fabric1140ServerPlayerManager on MC >=1.19. The chain-load sort already picks the best version (mc1194 for 1.19+), so loading mc1140 on newer MC is harmless — setIfNull is a no-op. --- fabric-intermediary/mc1140/src/main/resources/fabric.mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json b/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json index a99687f31d..1e39d7491b 100644 --- a/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json +++ b/fabric-intermediary/mc1140/src/main/resources/fabric.mod.json @@ -24,6 +24,6 @@ "accessWidener": "packetevents.accesswidener", "depends": { "fabricloader": "*", - "minecraft": ">=1.16.1 <1.19" + "minecraft": ">=1.16.1 <26" } } From b9bc23cbf8c9aee8e823d9076aeccd91f5fb8fea Mon Sep 17 00:00:00 2001 From: Axionize <154778082+Axionize@users.noreply.github.com> Date: Thu, 28 May 2026 05:42:17 +0000 Subject: [PATCH 23/23] review: address fabric-26.1.2-review feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Revert ServerboundPacketType_26_1.java to origin/grim/2.0 — enum values were unchanged; only comments and license header differed. - Remove IOOBE try-catches in PacketEventsImplHelper. They were added before the enum was confirmed correct from bytecode; with the enum matching origin, they're obsolete. If a wrapper genuinely mis-parses a 26.X packet, we want to know rather than hide it in a hot loop. - Drop "Mojang" from comment wording per reviewer preference. - Restore inline jitpack annotation that documents conditional-mixin as the only artifact from that repo. - Shorten verbose block comments across fabric-* gradle files and 26.X mixins. --- .../ServerboundPacketType_26_1.java | 165 ++++++++++-------- .../util/PacketEventsImplHelper.java | 31 +--- fabric-common/build.gradle.kts | 4 +- fabric-intermediary/build.gradle.kts | 6 +- fabric-official/build.gradle.kts | 14 +- .../mc261/mixin/ConnectionMixin.java | 14 +- .../mc261/mixin/PlayerListMixin.java | 13 +- fabric/build.gradle.kts | 35 ++-- 8 files changed, 123 insertions(+), 159 deletions(-) diff --git a/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/serverbound/ServerboundPacketType_26_1.java b/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/serverbound/ServerboundPacketType_26_1.java index 79f8febb2d..d3c5b5d332 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/serverbound/ServerboundPacketType_26_1.java +++ b/api/src/main/java/com/github/retrooper/packetevents/protocol/packettype/serverbound/ServerboundPacketType_26_1.java @@ -2,85 +2,100 @@ * This file is part of packetevents - https://github.com/retrooper/packetevents * Copyright (C) 2025 retrooper and contributors * - * Licensed under the GNU General Public License v3.0 (see the LICENSE file in - * the project root or ). + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.github.retrooper.packetevents.protocol.packettype.serverbound; -// Packet ID order extracted from 26.1.2 GameProtocols.class bytecode -// instruction sequence (javap -c -p | grep "getstatic.*Serverbound"). -// Includes cross-package packets (common, cookie, ping) that are also -// registered in the PLAY state alongside game-package ones. public enum ServerboundPacketType_26_1 { - TELEPORT_CONFIRM, // 0 AcceptTeleportation - ATTACK, // 1 Attack - QUERY_BLOCK_NBT, // 2 BlockEntityTagQuery - SELECT_BUNDLE_ITEM, // 3 SelectBundleItem - SET_DIFFICULTY, // 4 ChangeDifficulty - CHANGE_GAME_MODE, // 5 ChangeGameMode - CHAT_ACK, // 6 ChatAck - CHAT_COMMAND_UNSIGNED, // 7 ChatCommand - CHAT_COMMAND, // 8 ChatCommandSigned - CHAT_MESSAGE, // 9 Chat - CHAT_SESSION_UPDATE, // 10 ChatSessionUpdate - CHUNK_BATCH_ACK, // 11 ChunkBatchReceived - CLIENT_STATUS, // 12 ClientCommand - CLIENT_TICK_END, // 13 ClientTickEnd - CLIENT_SETTINGS, // 14 ClientInformation (common package) - TAB_COMPLETE, // 15 CommandSuggestion - CONFIGURATION_ACK, // 16 ConfigurationAcknowledged - CLICK_WINDOW_BUTTON, // 17 ContainerButtonClick - CLICK_WINDOW, // 18 ContainerClick - CLOSE_WINDOW, // 19 ContainerClose - SLOT_STATE_CHANGE, // 20 ContainerSlotStateChanged - COOKIE_RESPONSE, // 21 CookieResponse (cookie package) - PLUGIN_MESSAGE, // 22 CustomPayload (common package) - DEBUG_SUBSCRIPTION_REQUEST, // 23 DebugSubscriptionRequest - EDIT_BOOK, // 24 EditBook - QUERY_ENTITY_NBT, // 25 EntityTagQuery - INTERACT_ENTITY, // 26 Interact - GENERATE_STRUCTURE, // 27 JigsawGenerate - KEEP_ALIVE, // 28 KeepAlive (common package) - LOCK_DIFFICULTY, // 29 LockDifficulty - PLAYER_POSITION, // 30 MovePlayer$Pos - PLAYER_POSITION_AND_ROTATION,// 31 MovePlayer$PosRot - PLAYER_ROTATION, // 32 MovePlayer$Rot - PLAYER_FLYING, // 33 MovePlayer$StatusOnly - VEHICLE_MOVE, // 34 MoveVehicle - STEER_BOAT, // 35 PaddleBoat - PICK_ITEM_FROM_BLOCK, // 36 PickItemFromBlock - PICK_ITEM_FROM_ENTITY, // 37 PickItemFromEntity - DEBUG_PING, // 38 PingRequest (ping package) - CRAFT_RECIPE_REQUEST, // 39 PlaceRecipe - PLAYER_ABILITIES, // 40 PlayerAbilities - PLAYER_DIGGING, // 41 PlayerAction - ENTITY_ACTION, // 42 PlayerCommand - PLAYER_INPUT, // 43 PlayerInput - PLAYER_LOADED, // 44 PlayerLoaded - PONG, // 45 Pong (common package) - SET_RECIPE_BOOK_STATE, // 46 RecipeBookChangeSettings - SET_DISPLAYED_RECIPE, // 47 RecipeBookSeenRecipe - NAME_ITEM, // 48 RenameItem - RESOURCE_PACK_STATUS, // 49 ResourcePack (common package) - ADVANCEMENT_TAB, // 50 SeenAdvancements - SELECT_TRADE, // 51 SelectTrade - SET_BEACON_EFFECT, // 52 SetBeacon - HELD_ITEM_CHANGE, // 53 SetCarriedItem - UPDATE_COMMAND_BLOCK, // 54 SetCommandBlock - UPDATE_COMMAND_BLOCK_MINECART,// 55 SetCommandMinecart - CREATIVE_INVENTORY_ACTION, // 56 SetCreativeModeSlot - SET_GAME_RULE, // 57 SetGameRule - UPDATE_JIGSAW_BLOCK, // 58 SetJigsawBlock - UPDATE_STRUCTURE_BLOCK, // 59 SetStructureBlock - SET_TEST_BLOCK, // 60 SetTestBlock - UPDATE_SIGN, // 61 SignUpdate - SPECTATE_ENTITY, // 62 SpectateEntity - ANIMATION, // 63 Swing - SPECTATE, // 64 TeleportToEntity - TEST_INSTANCE_BLOCK_ACTION, // 65 TestInstanceBlockAction - PLAYER_BLOCK_PLACEMENT, // 66 UseItemOn - USE_ITEM, // 67 UseItem - CUSTOM_CLICK_ACTION, // 68 CustomClickAction (common package) + TELEPORT_CONFIRM, + /** + * New packet + */ + ATTACK, + QUERY_BLOCK_NBT, + SELECT_BUNDLE_ITEM, + SET_DIFFICULTY, + CHANGE_GAME_MODE, + CHAT_ACK, + CHAT_COMMAND_UNSIGNED, + CHAT_COMMAND, + CHAT_MESSAGE, + CHAT_SESSION_UPDATE, + CHUNK_BATCH_ACK, + CLIENT_STATUS, + CLIENT_TICK_END, + CLIENT_SETTINGS, + TAB_COMPLETE, + CONFIGURATION_ACK, + CLICK_WINDOW_BUTTON, + CLICK_WINDOW, + CLOSE_WINDOW, + SLOT_STATE_CHANGE, + COOKIE_RESPONSE, + PLUGIN_MESSAGE, + DEBUG_SUBSCRIPTION_REQUEST, + EDIT_BOOK, + QUERY_ENTITY_NBT, + INTERACT_ENTITY, + GENERATE_STRUCTURE, + KEEP_ALIVE, + LOCK_DIFFICULTY, + PLAYER_POSITION, + PLAYER_POSITION_AND_ROTATION, + PLAYER_ROTATION, + PLAYER_FLYING, + VEHICLE_MOVE, + STEER_BOAT, + PICK_ITEM_FROM_BLOCK, + PICK_ITEM_FROM_ENTITY, + DEBUG_PING, + CRAFT_RECIPE_REQUEST, + PLAYER_ABILITIES, + PLAYER_DIGGING, + ENTITY_ACTION, + PLAYER_INPUT, + PLAYER_LOADED, + PONG, + SET_RECIPE_BOOK_STATE, + SET_DISPLAYED_RECIPE, + NAME_ITEM, + RESOURCE_PACK_STATUS, + ADVANCEMENT_TAB, + SELECT_TRADE, + SET_BEACON_EFFECT, + HELD_ITEM_CHANGE, + UPDATE_COMMAND_BLOCK, + UPDATE_COMMAND_BLOCK_MINECART, + CREATIVE_INVENTORY_ACTION, + /** + * New packet + */ + SET_GAME_RULE, + UPDATE_JIGSAW_BLOCK, + UPDATE_STRUCTURE_BLOCK, + SET_TEST_BLOCK, + UPDATE_SIGN, + /** + * New packet + */ + SPECTATE_ENTITY, + ANIMATION, + SPECTATE, + TEST_INSTANCE_BLOCK_ACTION, + PLAYER_BLOCK_PLACEMENT, + USE_ITEM, + CUSTOM_CLICK_ACTION, } diff --git a/api/src/main/java/com/github/retrooper/packetevents/util/PacketEventsImplHelper.java b/api/src/main/java/com/github/retrooper/packetevents/util/PacketEventsImplHelper.java index 4c3869b6b8..925c970dd6 100644 --- a/api/src/main/java/com/github/retrooper/packetevents/util/PacketEventsImplHelper.java +++ b/api/src/main/java/com/github/retrooper/packetevents/util/PacketEventsImplHelper.java @@ -58,19 +58,9 @@ private PacketEventsImplHelper() { int preProcessIndex = ByteBufHelper.readerIndex(buffer); PacketSendEvent packetSendEvent = EventCreationUtil.createSendEvent(channel, user, player, buffer, autoProtocolTranslation); int processIndex = ByteBufHelper.readerIndex(buffer); - try { - PacketEvents.getAPI().getEventManager().callEvent(packetSendEvent, () -> { - ByteBufHelper.readerIndex(buffer, processIndex); - }, !autoProtocolTranslation); - } catch (IndexOutOfBoundsException e) { - // 26.X: some packet wrappers (e.g. WrapperPlayServerSpawnEntity) read - // past the buffer because the serialization format changed. Catch here - // so the raw bytes still flow to MC's encoder (the packet was already - // serialized by MC). Without this, the encoder throws and Netty's error - // handler corrupts the pipeline state for all subsequent packets. - ByteBufHelper.readerIndex(buffer, preProcessIndex); - return packetSendEvent; - } + PacketEvents.getAPI().getEventManager().callEvent(packetSendEvent, () -> { + ByteBufHelper.readerIndex(buffer, processIndex); + }, !autoProtocolTranslation); if (!packetSendEvent.isCancelled()) { //Did they ever use a wrapper? if (packetSendEvent.getLastUsedWrapper() != null) { @@ -108,18 +98,9 @@ private PacketEventsImplHelper() { int preProcessIndex = ByteBufHelper.readerIndex(buffer); PacketReceiveEvent packetReceiveEvent = EventCreationUtil.createReceiveEvent(channel, user, player, buffer, autoProtocolTranslation); int processIndex = ByteBufHelper.readerIndex(buffer); - try { - PacketEvents.getAPI().getEventManager().callEvent(packetReceiveEvent, () -> { - ByteBufHelper.readerIndex(buffer, processIndex); - }, !autoProtocolTranslation); - } catch (IndexOutOfBoundsException e) { - // 26.X: a listener's wrapper read past the buffer because the packet - // format changed. Reset the buffer so MC can still read the raw bytes. - // The event already fired to some listeners before the throw; the rest - // missed it. This is acceptable — Grim's critical listeners (movement - // checks) don't wrap most packets eagerly, so they survive. - ByteBufHelper.readerIndex(buffer, preProcessIndex); - } + PacketEvents.getAPI().getEventManager().callEvent(packetReceiveEvent, () -> { + ByteBufHelper.readerIndex(buffer, processIndex); + }, !autoProtocolTranslation); if (!packetReceiveEvent.isCancelled()) { //Did they ever use a wrapper? if (packetReceiveEvent.getLastUsedWrapper() != null) { diff --git a/fabric-common/build.gradle.kts b/fabric-common/build.gradle.kts index 20fa587bae..4b5cebc5ca 100644 --- a/fabric-common/build.gradle.kts +++ b/fabric-common/build.gradle.kts @@ -24,8 +24,8 @@ dependencies { compileOnly("org.spongepowered:mixin:0.8.7") } -// library-conventions defaults to release=8; the moved bridge code uses switch -// expressions and pattern-matching instanceof that require Java 17+. +// Override library-conventions' release=8 — bridge code uses switch expressions +// and pattern-matching instanceof. tasks.withType { options.release = 17 } diff --git a/fabric-intermediary/build.gradle.kts b/fabric-intermediary/build.gradle.kts index 3b7052ac1c..7c1cd580ad 100644 --- a/fabric-intermediary/build.gradle.kts +++ b/fabric-intermediary/build.gradle.kts @@ -20,10 +20,8 @@ val yarn_mappings: String by project val loader_version: String by project dependencies { - // api() puts these on the compile + runtime classpath of this module and its - // consumers (the mcXXXX subprojects), but DELIBERATELY no include(): shared deps - // are JiJ'd once at the top-level fabric/ aggregator. Bundling them here too - // would duplicate ~5MB of api/adventure/common bytes inside every nested mod jar. + // api() (compile + runtime classpath) but NOT include(): shared deps are + // JiJ'd once at the fabric/ aggregator to avoid duplicating ~5MB per variant. api(libs.bundles.adventure) api(project(":api", "shadow")) api(project(":netty-common")) diff --git a/fabric-official/build.gradle.kts b/fabric-official/build.gradle.kts index 1d7502e0f7..42448de8f3 100644 --- a/fabric-official/build.gradle.kts +++ b/fabric-official/build.gradle.kts @@ -1,8 +1,5 @@ -// fabric-official targets MC 26.X+, whose server/client jars ship pre-deobfuscated with -// Mojang's official names. Loom's NoRemap variant (`net.fabricmc.fabric-loom`, distinct -// from `-remap`) accepts the jar as already in the target namespace, so source code -// references Mojang names directly (net.minecraft.world.item.Item, etc.). No mappings() -// configuration is needed — intermediary == named == official == jar contents. +// MC 26.X+ ships pre-deobfuscated, so this module uses LoomNoRemap and references +// net.minecraft.* directly — no mappings() needed. plugins { packetevents.`library-conventions` @@ -20,9 +17,8 @@ val minecraft_version: String by project val loader_version: String by project dependencies { - // api() but NO include() for shared deps — the top-level fabric/ aggregator - // JiJs api/adventure/common/conditional-mixin once for the whole distribution. - // Only the per-version variants (mc261, future mc26X) are JiJ'd here. + // Shared deps are JiJ'd once at the top-level fabric/ aggregator; only the + // per-version variants are included here. api(project(":api", "shadow")) api(project(":netty-common")) api(project(":fabric-common")) @@ -31,8 +27,6 @@ dependencies { include(project(":fabric-official:mc261")) minecraft("com.mojang:minecraft:$minecraft_version") - // No mappings() block: LoomNoRemap uses the MC jar's own (Mojang) namespace - // throughout, so source can compile against net.minecraft.* directly. } java { diff --git a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java index 4a9a9c0252..6547bdaa2a 100644 --- a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java +++ b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/ConnectionMixin.java @@ -24,16 +24,10 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -// Injects PE's encoder/decoder into the netty pipeline. Three hooks: -// -// configureSerialization (static, TAIL) — first pipeline setup at channel init. -// setupInboundProtocol (instance, TAIL) — fires on each state transition -// (LOGIN → CONFIGURATION → PLAY). MC replaces the decoder handler, which -// removes PE's pe-decoder. Re-inject here so PE captures PLAY packets. -// setupOutboundProtocol (instance, TAIL) — same for the outbound encoder. -// -// Without the setupInbound/Outbound hooks PE only captures LOGIN + CONFIGURATION -// packets and the downstream consumer (Grim) never sees PLAY-state movement data. +// Inject PE handlers at initial pipeline setup, then re-inject on each state +// transition since MC replaces the decoder/encoder when switching protocols. +// Without the setup{In,Out}boundProtocol hooks, PE loses PE-decoder/encoder +// at the LOGIN/CONFIGURATION/PLAY transition and never sees PLAY packets. @Mixin(value = Connection.class, priority = 1500) public abstract class ConnectionMixin { diff --git a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/PlayerListMixin.java b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/PlayerListMixin.java index b05ed03844..e23ee71ed0 100644 --- a/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/PlayerListMixin.java +++ b/fabric-official/mc261/src/main/java/io/github/retrooper/packetevents/mc261/mixin/PlayerListMixin.java @@ -18,16 +18,9 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -// Mojang-named twin of fabric-intermediary's PlayerManagerMixin (mc1140). 26.X -// renamed PlayerManager → PlayerList and onPlayerConnect → placeNewPlayer. -// -// Two injects: -// HEAD of placeNewPlayer: associate the netty Channel of the incoming Connection -// with the ServerPlayer object — required so subsequent PlayerManager.getUser -// lookups can resolve the User → ServerPlayer mapping. -// AFTER PlayerList.broadcastAll(Packet) call inside placeNewPlayer: the player -// has fully entered PLAY state, so fire UserLoginEvent. Without this, Grim's -// check engine never sees the player join and no checks run. +// 26.X twin of fabric-intermediary's PlayerManagerMixin (mc1140). +// HEAD: bind channel → ServerPlayer so getUser() can resolve the mapping. +// TAIL: fire UserLoginEvent now that the player is in PLAY state. @Mixin(PlayerList.class) public abstract class PlayerListMixin { diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index b566a53453..f143577057 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,11 +1,9 @@ import me.modmuss50.mpp.ModPublishExtension import net.fabricmc.loom.task.RemapJarTask -// Top-level fabric aggregator — produces the published `packetevents-fabric-.jar` -// by JiJ-nesting the intermediary and official variant outputs along with the shared -// fabric-common library. This jar is a "meta" Fabric mod: its own fabric.mod.json carries -// the version + depends declarations, and Fabric Loader extracts the nested per-variant -// mods at runtime and gates them by their declared minecraft version ranges. +// Aggregator: JiJ-nests fabric-intermediary + fabric-official + fabric-common into the +// published packetevents-fabric jar. Fabric Loader gates each nested variant by its +// declared minecraft range at runtime. plugins { packetevents.`library-conventions` @@ -16,7 +14,7 @@ plugins { repositories { mavenCentral() maven("https://repo.viaversion.com/") - maven("https://jitpack.io") + maven("https://jitpack.io") // Conditional Mixin } val minecraft_version: String by project @@ -24,28 +22,23 @@ val yarn_mappings: String by project val loader_version: String by project dependencies { - // Bind to the oldest MC version we support so Loom remap is happy with a 1.16.1 floor. + // Floor at oldest supported MC so Loom remap accepts 1.16.1. minecraft("com.mojang:minecraft:$minecraft_version") mappings("net.fabricmc:yarn:$yarn_mappings") modImplementation("net.fabricmc:fabric-loader:$loader_version") - // Re-export everything the variant modules used to expose so downstream consumers - // (e.g. Grim) that depend on `packetevents-fabric` get the FQNs transitively. - // Without these api() entries the published POM lists only fabric-loader and - // mc-typed consumers fail to compile against the now-fabric-common bridge. + // api(): re-export so consumers' POMs see them transitively. + // include(): JiJ at runtime. Both are needed. api(project(":fabric-common")) api(libs.bundles.adventure) api(project(":api", "shadow")) api(project(":netty-common")) - // JiJ side: ship the same artifacts inside the published mod jar so Fabric Loader - // has them at runtime even when the consumer didn't pull the maven POM. include(project(":fabric-common")) include(libs.bundles.adventure) include(project(":api", "shadow")) include(project(":netty-common")) - // conditional-mixin was previously JiJ'd inside both fabric-intermediary and - // fabric-official, doubling its 28KB. Bring it up here once. + // Hoisted from variant modules to avoid duplicating the 28KB JiJ. include("com.github.Fallen-Breath.conditional-mixin:conditional-mixin-fabric:0.6.4") } @@ -67,10 +60,9 @@ tasks { archiveBaseName = "${rootProject.name}-fabric" archiveVersion = rootProject.ext["artifactVersion"] as String - // Nest the variant outputs without triggering full project configuration - // (which would inject dev/namedElements jars into the include config). - // fabric-intermediary uses LoomRemap and publishes via remapJar. - // fabric-official uses LoomNoRemap and publishes via the plain jar task. + // Nest via file path (not project deps) to skip variant project configuration, + // which would otherwise inject dev/namedElements jars into `include`. + // intermediary → remapJar (LoomRemap); official → jar (LoomNoRemap). dependsOn(":fabric-intermediary:remapJar", ":fabric-official:jar") nestedJars.from( rootProject.layout.buildDirectory.file("libs/${rootProject.name}-fabric-intermediary-${rootProject.ext["artifactVersion"]}.jar") @@ -81,10 +73,7 @@ tasks { } } -// publishing.skip_files=true keeps the platform branch in publish-conventions from -// auto-wiring file = shadowJar. But the publishMods task still demands `file` set, -// so point it at our aggregator's remapJar output. `--dry-run` and Modrinth runs -// both need this when CI exercises them. +// publishMods demands `file` set even when publishing.skip_files=true. configure { file = tasks.named("remapJar").flatMap { it.archiveFile } }