Posted December 18, 20204 yr I'm making a custom particle to ake the game more "alive", but I've never done particles, so this is fun. Anyway, heres the code for the part where I register the factory: @Mod.EventBusSubscriber(modid = WildCraft.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public class ParticleUtil { @SubscribeEvent() public static void registerParticles(ParticleFactoryRegisterEvent event) { Minecraft.getInstance().particles.registerFactory(Registry.SPIDER_PARTICLE.get(), SpiderParticle.Factory::new); } } I'm assuming there something wrong with the particle class itself also, so I'll put its code here also: @OnlyIn(Dist.CLIENT) public class SpiderParticle extends SpriteTexturedParticle { public SpiderParticle(ClientWorld world, double x, double y, double z, double motionX, double motionY, double motionZ) { super(world, x, y, z, motionX, motionY, motionZ); float f = this.rand.nextFloat() * 1.0F; this.particleRed = f; this.particleGreen = f; this.particleBlue = f; this.setSize(0.02F, 0.02F); this.particleScale *= this.rand.nextFloat() * 1.1F; this.motionX *= (double)0.02F; this.motionY *= (double)0.02F; this.motionZ *= (double)0.02F; this.maxAge = (int)(20.0D / (Math.random() * 1.0D)); } @Override public IParticleRenderType getRenderType() { return IParticleRenderType.PARTICLE_SHEET_OPAQUE; } @Override public void tick() { this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; if(this.maxAge-- <= 0) { this.setExpired(); } else { this.move(this.motionX, this.motionY, this.motionZ); this.motionX *= 1.0D; this.motionY *= 1.0D; this.motionZ *= 1.0D; } } @OnlyIn(Dist.CLIENT) public static class Factory implements IParticleFactory<BasicParticleType> { private final IAnimatedSprite spriteSet; public Factory(IAnimatedSprite sprite) { this.spriteSet = sprite; } @Override public Particle makeParticle(BasicParticleType typeIn, ClientWorld worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { SpiderParticle spiderParticle = new SpiderParticle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed); spiderParticle.setColor(1.0F, 1.0F, 1.0F); spiderParticle.selectSpriteRandomly(spriteSet); return spiderParticle; } } } Any help is appreciated, thanks. Have some lorem ispum.
December 18, 20204 yr You should also show where you register the particle and if the deferred register is attached to the mod event bus as that is where the error is located. Edited December 18, 20204 yr by ChampionAsh5357
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.