From 153d6944e1b72eaecd10dccd24b9ac7d71274567 Mon Sep 17 00:00:00 2001 From: Notenoughmail <78008321+Notenoughmail@users.noreply.github.com> Date: Sun, 19 May 2024 14:17:27 -0700 Subject: [PATCH] No Good Deed Goes Unpunished - Fix particle provider registration firing too late --- .../client/KubeJSClientEventHandler.java | 5 ----- .../core/mixin/common/ParticleEngineMixin.java | 18 ++++++++++++++++++ .../mods/kubejs/misc/ParticleTypeBuilder.java | 1 - .../main/resources/kubejs-common.mixins.json | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 common/src/main/java/dev/latvian/mods/kubejs/core/mixin/common/ParticleEngineMixin.java diff --git a/common/src/main/java/dev/latvian/mods/kubejs/client/KubeJSClientEventHandler.java b/common/src/main/java/dev/latvian/mods/kubejs/client/KubeJSClientEventHandler.java index b2ff91297..cd8759bda 100644 --- a/common/src/main/java/dev/latvian/mods/kubejs/client/KubeJSClientEventHandler.java +++ b/common/src/main/java/dev/latvian/mods/kubejs/client/KubeJSClientEventHandler.java @@ -58,7 +58,6 @@ public void init() { ClientGuiEvent.RENDER_POST.register(Painter.INSTANCE::guiScreenDraw); ClientGuiEvent.INIT_PRE.register(this::guiPreInit); ClientGuiEvent.INIT_POST.register(this::guiPostInit); - ClientLifecycleEvent.CLIENT_SETUP.register(this::clientSetup); //ClientTextureStitchEvent.POST.register(this::postAtlasStitch); } @@ -172,10 +171,6 @@ private void guiPostInit(Screen screen, ScreenAccess access) { } } - private void clientSetup(Minecraft mc) { - ClientEvents.PARTICLE_PROVIDER_REGISTRY.post(new ParticleProviderRegistryEventJS()); - } - /*private void postAtlasStitch(TextureAtlas atlas) { if (!ClientProperties.get().getExportAtlases()) { return; diff --git a/common/src/main/java/dev/latvian/mods/kubejs/core/mixin/common/ParticleEngineMixin.java b/common/src/main/java/dev/latvian/mods/kubejs/core/mixin/common/ParticleEngineMixin.java new file mode 100644 index 000000000..21a4bdff3 --- /dev/null +++ b/common/src/main/java/dev/latvian/mods/kubejs/core/mixin/common/ParticleEngineMixin.java @@ -0,0 +1,18 @@ +package dev.latvian.mods.kubejs.core.mixin.common; + +import dev.latvian.mods.kubejs.bindings.event.ClientEvents; +import dev.latvian.mods.kubejs.client.ParticleProviderRegistryEventJS; +import net.minecraft.client.particle.ParticleEngine; +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; + +@Mixin(ParticleEngine.class) +public abstract class ParticleEngineMixin { + + @Inject(method = "registerProviders", at = @At("RETURN")) + private void registerParticleProvidersKJS(CallbackInfo ci) { + ClientEvents.PARTICLE_PROVIDER_REGISTRY.post(new ParticleProviderRegistryEventJS()); + } +} diff --git a/common/src/main/java/dev/latvian/mods/kubejs/misc/ParticleTypeBuilder.java b/common/src/main/java/dev/latvian/mods/kubejs/misc/ParticleTypeBuilder.java index 23b2bceb6..147e40e70 100644 --- a/common/src/main/java/dev/latvian/mods/kubejs/misc/ParticleTypeBuilder.java +++ b/common/src/main/java/dev/latvian/mods/kubejs/misc/ParticleTypeBuilder.java @@ -51,7 +51,6 @@ public ParticleTypeBuilder deserializer(ParticleOptions.Deserializer d) { return this; } - // TODO: For some reason this does NOT work on first resource load without the breakpoints in ParticleEngine @Override public void generateAssetJsons(AssetJsonGenerator generator) { generator.particle(id, assetGen); diff --git a/common/src/main/resources/kubejs-common.mixins.json b/common/src/main/resources/kubejs-common.mixins.json index 176a78b95..ee64c5076 100644 --- a/common/src/main/resources/kubejs-common.mixins.json +++ b/common/src/main/resources/kubejs-common.mixins.json @@ -55,6 +55,7 @@ "LocalPlayerMixin", "MinecraftClientMixin", "OptionsMixin", + "ParticleEngineMixin", "ScreenMixin", "WindowMixin", "WorldOpenFlowsMixin",