Posted January 30, 20223 yr so i made a particle but when i enter in the world it crashes (yes i did register the ModParticles class in Main class) lightning_particle.json file { "textures": [ "modid:lightning_particle" ] } ModParticles class: public class ModParticles { public static final DeferredRegister<ParticleType<?>> PARTICLES = DeferredRegister.create(ForgeRegistries.PARTICLE_TYPES, Main.MOD_ID); public static final RegistryObject<BasicParticleType> LIGHTNING_PARTICLE = PARTICLES.register("lightning_particle", () -> new BasicParticleType(true)); } LightningParticle class: @OnlyIn(Dist.CLIENT) public class LightningParticle extends SpriteTexturedParticle { protected LightningParticle(ClientWorld world, double xCoord, double yCoord, double zCoord, double motionX, double motionY, double motionZ) { super(world, xCoord, yCoord, zCoord, motionX, motionY, motionZ); float f = this.rand.nextFloat() * 1.0f; this.particleRed = f; this.particleGreen = f; this.particleBlue = f; this.setSize(0.1F,0.1F); 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); } } @OnlyIn(Dist.CLIENT) public static class Factory implements IParticleFactory<BasicParticleType> { private final IAnimatedSprite sprite; public Factory(IAnimatedSprite sprite) { this.sprite = sprite; } @Override public Particle makeParticle(BasicParticleType typeIn, ClientWorld worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { LightningParticle myParticle = new LightningParticle(worldIn,x,y,z,xSpeed,ySpeed,zSpeed); myParticle.setColor(1.0f,1.0f,1.0f); myParticle.selectSpriteRandomly(sprite); return myParticle; } } } ParticleEvent class: @Mod.EventBusSubscriber(modid = Main.MOD_ID) public class ParticleEvent { @SubscribeEvent(priority = EventPriority.LOWEST) public static void registerParticles(ParticleFactoryRegisterEvent event) { Minecraft.getInstance().particles.registerFactory(ModParticles.LIGHTNING_PARTICLE.get(), LightningParticle.Factory::new); } } Edited January 30, 20223 yr by ElTotisPro50
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.