Skip to content

Commit

Permalink
Fix race condition in Forge Particle Factory registration loading
Browse files Browse the repository at this point in the history
itsmeow committed Apr 19, 2022
1 parent b36938f commit d5d179e
Showing 6 changed files with 31 additions and 10 deletions.
4 changes: 1 addition & 3 deletions common/src/main/resources/whisperwoods.mixins.json
Original file line number Diff line number Diff line change
@@ -8,9 +8,7 @@
"LivingEntityMixin",
"GroundPathNavigationMixin"
],
"client": [
"ParticleEngineMixin"
],
"client": [],
"injectors": {
"defaultRequire": 1
}
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@

import dev.itsmeow.whisperwoods.client.init.ClientLifecycleHandler;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import org.spongepowered.asm.mixin.Mixin;
3 changes: 2 additions & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -27,7 +27,8 @@
},
"mixins": [
"mixin.imdlib.json",
"whisperwoods.mixins.json"
"whisperwoods.mixins.json",
"whisperwoods-fabric.mixins.json"
],
"custom": {
"modmenu": {
13 changes: 13 additions & 0 deletions fabric/src/main/resources/whisperwoods-fabric.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"required": true,
"package": "dev.itsmeow.whisperwoods.mixin",
"compatibilityLevel": "JAVA_8",
"minVersion": "0.8",
"mixins": [],
"client": [
"ParticleEngineMixin"
],
"injectors": {
"defaultRequire": 1
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package dev.itsmeow.whisperwoods;

import dev.itsmeow.whisperwoods.client.WhisperwoodsClientForge;
import me.shedaniel.architectury.platform.forge.EventBuses;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

@@ -18,6 +16,5 @@ public WhisperwoodsModForge() {
modBus.<FMLCommonSetupEvent>addListener(e -> {
WhisperwoodsMod.init(e::enqueueWork);
});
modBus.<FMLClientSetupEvent>addListener(e -> new WhisperwoodsClientForge().clientSetup(e));
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
package dev.itsmeow.whisperwoods.client;

import dev.itsmeow.whisperwoods.WhisperwoodsMod;
import dev.itsmeow.whisperwoods.client.init.ClientLifecycleHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.ParticleEngine;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

@Mod.EventBusSubscriber(modid = WhisperwoodsMod.MODID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
public class WhisperwoodsClientForge {
public void clientSetup(FMLClientSetupEvent event) {
@SubscribeEvent
public static void clientSetup(FMLClientSetupEvent event) {
ClientLifecycleHandler.clientInit();
}

@SubscribeEvent
public static void registerParticleFactory(ParticleFactoryRegisterEvent event) {
ClientLifecycleHandler.registerParticles((type, provider) -> Minecraft.getInstance().particleEngine.register(type, (ParticleEngine.SpriteParticleRegistration) spriteSet -> provider.apply(spriteSet)));
}
}

0 comments on commit d5d179e

Please sign in to comment.