Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.