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

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;
}

}

Instead of spawning the entity try adding it to the effect renderer:

 

Minecraft.getMinecraft().effectRenderer.addEffect(effect);

 

 

 

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

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.