Skip to content

Commit

Permalink
No Good Deed Goes Unpunished
Browse files Browse the repository at this point in the history
- Fix particle provider registration firing too late
  • Loading branch information
Notenoughmail committed May 19, 2024
1 parent 72ed429 commit 153d694
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/kubejs-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"LocalPlayerMixin",
"MinecraftClientMixin",
"OptionsMixin",
"ParticleEngineMixin",
"ScreenMixin",
"WindowMixin",
"WorldOpenFlowsMixin",
Expand Down

0 comments on commit 153d694

Please sign in to comment.