Jump to content

Recommended Posts

Posted

Hey, i setupped a custom particle in my mod, but it just render like a grey cube... Here's my class code:

'

@SideOnly(Side.CLIENT)
    @Override
public void randomDisplayTick(World world, int x, int y, int z, Random rdm)
    {
        int l = world.getBlockMetadata(x, y, z);
        double d0 = (double)((float)x + 0.5F);
        double d1 = (double)((float)y + 0.7F);
        double d2 = (double)((float)z + 0.5F);
        double d3 = 0.2199999988079071D;
        double d4 = 0.27000001072883606D;
        ResourceLocation texture = new ResourceLocation(ProjectX.MODID , "textures/particle/glow.png");

        if (l == 1)
        {
        	world.spawnEntityInWorld(new EntityCustomFX(world, d0-d4, d1+d3, d2, texture, 1, 1.0f, 1.0f, 0x37F9FE, l));
        }
        else if (l == 2)
        {
        	world.spawnEntityInWorld(new EntityCustomFX(world, d0-d4, d1+d3, d2, texture, 1,1.0f, 1.0f, 0x37F9FE, 1));
        }
        else if (l == 3)
        {
        	world.spawnEntityInWorld(new EntityCustomFX(world, d0, d1+d3, d2-d4, texture, 1, 1.0f, 1.0f, 0x37F9FE, 1));
        }
        else if (l == 4)
        {
        	world.spawnEntityInWorld(new EntityCustomFX(world, d0,d1+d3,d2+d4, texture, 1, 1.0f, 1.0f, 0x37F9FE, 1));

        }
        else
        {
        	world.spawnEntityInWorld(new EntityCustomFX(world, d0,d1,d2, texture, 1, 1.0f, 1.0f, 0x37F9FE, 1));
        }
    }

 

And here's my EntityCustomFX class :


public class EntityCustomFX extends EntityFX
{

private ResourceLocation texture;
private int colorApp;
private int colorAlpha;

public EntityCustomFX(World world, double x, double y, double z, ResourceLocation texture, int age, float gravity, float scale, int color, int alpha)
{
	super(world, x, y, z);
	this.texture = texture;
	setMaxAge(age);
	setGravity(gravity);
	setScale(scale);
	colorApp = color;
	colorAlpha = alpha;
}

@Override
public void renderParticle(Tessellator tess, float partialTics, float par3, float par4, float par5, float par6, float par7)
{
	Minecraft.getMinecraft().getTextureManager().bindTexture(texture);

	glDepthMask(false);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glAlphaFunc(GL_GREATER, 0.003921569F);
	tess.setBrightness(getBrightnessForRender(partialTics));
	tess.setColorRGBA_I(colorApp, colorAlpha);
	float scale = 0.1F*particleScale;
	float x = (float)(prevPosX + (posX - prevPosX) * partialTics - interpPosX);
	float y = (float)(prevPosY + (posY - prevPosY) * partialTics - interpPosY);
	float z = (float)(prevPosZ + (posZ - prevPosZ) * partialTics - interpPosZ);
	{
		tess.addVertexWithUV(x - par3 * scale - par6 * scale, y - par4 * scale, z - par5 * scale - par7 * scale, 0, 1);
		tess.addVertexWithUV(x - par3 * scale + par6 * scale, y + par4 * scale, z - par5 * scale + par7 * scale, 0, 0);
		tess.addVertexWithUV(x + par3 * scale + par6 * scale, y + par4 * scale, z + par5 * scale + par7 * scale, 1, 0);
		tess.addVertexWithUV(x + par3 * scale - par6 * scale, y - par4 * scale, z + par5 * scale - par7 * scale, 1, 1);
	}
	glDisable(GL_BLEND);
	glDepthMask(true);
	glAlphaFunc(GL_GREATER, 0.1F);
}

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

public EntityCustomFX setMaxAge(int age)
{
	particleMaxAge = age;
	return this;
}

public EntityCustomFX setGravity(float grav)
{
	particleGravity = grav;
	return this;
}

public EntityCustomFX setScale(float scale)
{
	particleScale = scale;
	return this;
}

}

Posted

As OreCruncer said, you need to spawn the particles through: Minecraft.getMinecraft().effectRenderer.addEffect(new myParticle([param]));.

 

On little side note, I would use FXLayer 3 instead of 1. For some reason MC is not capable of handling texture changes, unless you use the vanilla particleTextures file. Meaning that if you were about to spawn the particle, and its raining at the same time for example, all the rain particles would be rendered with the vanilla texture + your customParticleTexture.

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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