Jump to content

[Solved][1.10.2] Custom Particle not rendering


Codasylph

Recommended Posts

I'm trying to create a custom particle effect that renders above a block. Right now I don't get any errors, but it doesn't render. I'm hoping someone has some insight as to what I'm doing wrong.

 

What I did: I extended Particle, for now I'm literally just trying to get *something* to render above the block, so I didn't touch renderParticle or any else, just set a TextureAtlasSprite and overrided (overrode?) getFXLayer. I'll worry about getting the particle to behave the way I want when I can see it. :)

 

My code is below:

 

Particle Class

 

 

public class SuParticle extends Particle
{
public ResourceLocation texture = new ResourceLocation("demesne:particles/test");

public SuParticle(World world, double xCoord, double yCoord, double zCoord, double xSpeed, double ySpeed, double zSpeed)
    {
    	super(world, zSpeed, zSpeed, zSpeed, zSpeed, zSpeed, zSpeed);
    	
    	TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(texture.toString());
    	
    	this.setParticleTexture(sprite);
    }

public SuParticle(World world, double x, double y, double z)
{
	this(world, x, y, z, 0.0D, 0.0D, 0.0D);
}

@Override
    public int getFXLayer()
    {
        return 1;
    }
}

 

 

 

In ClientProxy

 

 

@Override
public void spawnParticle(World world, double x, double y, double z, int particleId)
{
	Particle particle = null;

	switch(particleId)
	{
	case 0:
		particle = new SuParticle(world, x, y, z);
	default:

	}
	if(particle != null)
	{
		Minecraft.getMinecraft().effectRenderer.addEffect(particle);
	}
}

 

 

 

Function call in block class

 

 

    @Override
    @SideOnly(Side.CLIENT)
    public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand)
    {
    	Demesne.proxy.spawnParticle(world, pos.getX() + 0.5D, pos.getY() + 1.5D, pos.getZ() + 0.5D, 0);
    }

 

 

 

edit: added code tags for clarity

Link to comment
Share on other sites

Try using

Minecraft.getMinecraft().renderGlobal.spawnParticle()

instead of

Minecraft.getMinecraft().effectRenderer.addEffect()

 

RenderGlobal#spawnParticle doesn't take a Particle as a parameter, it either takes a int for the particle id which corresponds to vanilla EnumParticleTypes or it takes an EnumParticleTypes. I have something called a particleId, but only so I can use the same method when I add a new particle to my mod, it doesn't correspond to a vanilla Particle it corresponds my mod's custom particles, of which there is currently only one. 

 

Unless I am missing something, using your suggested adjustment with my current code would just cause vanilla explosion particles (I believe those are the 0th vanilla particle type) to render above my block.

 

Am I missing something?

Link to comment
Share on other sites

SuParticle.java -> public SuParticle()...

 

super(world, zSpeed, zSpeed, zSpeed, zSpeed, zSpeed, zSpeed);

I think this is the mistake youre looking for... The particle is getting spawned but not at the correct coordinates.

 

Try this instead:

super(xCoord, yCoord, zCoord, xSpeed, ySpeed, zSpeed);

Link to comment
Share on other sites

SuParticle.java -> public SuParticle()...

 

super(world, zSpeed, zSpeed, zSpeed, zSpeed, zSpeed, zSpeed);

 

Thank you!! I can't believe I missed that.  I don't even really get how that happened.  I feel very thick now, but thank you much.  Some times I guess it just takes a second set of eyes.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

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