From eabbae365d7f75924dd8bd96ccf4ceae10942c34 Mon Sep 17 00:00:00 2001 From: apple502j <33279053+apple502j@users.noreply.github.com> Date: Fri, 26 Jan 2024 19:19:02 +0900 Subject: [PATCH] Fix TAGS_LOADED event not being invoked on client join --- .../client/ClientPlayNetworkHandlerMixin.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/fabric-lifecycle-events-v1/src/client/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java b/fabric-lifecycle-events-v1/src/client/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java index 7c4bf81f25..a88d419c2a 100644 --- a/fabric-lifecycle-events-v1/src/client/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java +++ b/fabric-lifecycle-events-v1/src/client/java/net/fabricmc/fabric/mixin/event/lifecycle/client/ClientPlayNetworkHandlerMixin.java @@ -26,7 +26,6 @@ import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; -import net.minecraft.network.packet.s2c.common.SynchronizeTagsS2CPacket; import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket; import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket; import net.minecraft.world.chunk.WorldChunk; @@ -96,16 +95,12 @@ private void onClearWorld(CallbackInfo ci) { } } + /** + * Also invoked during GameJoin, but before Networking API fires the Ready event. + */ @SuppressWarnings("ConstantConditions") - @Inject( - method = "onSynchronizeTags", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/network/ClientCommonNetworkHandler;onSynchronizeTags(Lnet/minecraft/network/packet/s2c/common/SynchronizeTagsS2CPacket;)V", - shift = At.Shift.AFTER, by = 1 - ) - ) - private void hookOnSynchronizeTags(SynchronizeTagsS2CPacket packet, CallbackInfo ci) { + @Inject(method = "refreshTagBasedData", at = @At("RETURN")) + private void hookOnSynchronizeTags(CallbackInfo ci) { ClientPlayNetworkHandler self = (ClientPlayNetworkHandler) (Object) this; CommonLifecycleEvents.TAGS_LOADED.invoker().onTagsLoaded(self.getRegistryManager(), true); }