Skip to content

[Crash] Spawning SmokeParticle manually causes a crash #48

@mchorse

Description

@mchorse

Hello!

I have a system in place where my mod can spawn particles from the registry. All of vanilla particles seem to be working correctly, however, spawning the net.superkat.explosiveenhancement.particles.SmokeParticle caused a crash. Here is the crash log:

crash-2024-12-30_18.29.49-client.txt

The ID of the particle is explosiveenhancement:sparks. Is it an issue coming from my mod, or from your mod? This is how I spawn the particle:

World world = entity.getWorld();
boolean paused = this.form.paused.get(0F);

if (world != null && !paused)
{
    float velocity = this.form.velocity.get(0F);
    int count = this.form.count.get(0F);
    int frequency = this.form.frequency.get(0F);

    if (this.tick <= 0)
    {
        Matrix3f m = Matrices.TEMP_3F;
        Vector3f v = Vectors.TEMP_3F;
        ParticleSettings settings = this.form.settings.get(0F);
        ParticleType type = Registries.PARTICLE_TYPE.get(settings.particle); // This is how I get the type
        ParticleEffect effect = ParticleTypes.FLAME;

        try
        {
            if (type != null)
            {
                effect = type.getParametersFactory().read(type, new StringReader(" " + settings.arguments)); // And this is how I get type with extra string parameters
            }
        }
        catch (Exception e)
        {}

        for (int i = 0; i < count; i++)
        {
            float velocityX = this.vel.x * velocity;
            float velocityY = this.vel.y * velocity;
            float velocityZ = this.vel.z * velocity;
            float sh = MathUtils.toRad(this.form.scatteringYaw.get(0F)) * (float) (Math.random() - 0.5D);
            float sv = MathUtils.toRad(this.form.scatteringPitch.get(0F)) * (float) (Math.random() - 0.5D);

            m.identity()
                .rotateY(sh)
                .rotateX(sv)
                .transform(v.set(velocityX, velocityY, velocityZ));

            double x = this.pos.x + ((Math.random() * 2F - 1F) * this.form.offsetX.get(0F));
            double y = this.pos.y + ((Math.random() * 2F - 1F) * this.form.offsetY.get(0F));
            double z = this.pos.z + ((Math.random() * 2F - 1F) * this.form.offsetZ.get(0F));

            world.addParticle(effect, true, x, y, z, v.x, v.y, v.z);
        }

        this.tick = frequency;
    }

    this.tick -= 1;
}

I'm not sure how exactly it could happen on my end, so it would be nice if you could point out what could I be doing wrong.

Thank you for attention, and Happy Holidays! 🎄🎉

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions