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

world.spawnParticle("happyVillager", xCoord, yCoord+1, zCoord, 0, 0, 0);

 

it seems that my particle is not seen.

(I allowed particles when debugging)

Particles are client side.

 

Show you spawning code.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

I planned something like this in my TE:

 

double x = entity.posX;

double y = entity.posY;

double z = entity.posZ;

if (world.isRemote) {

world.spawnParticle("happyVillager", xCoord, yCoord+1, zCoord, 0, 0, 0);

world.spawnParticle("happyVillager", x, y, z, 0, 0, 0);

}

I'll just say - if you think you wrote something well and it's not working - the problem is NOT THERE.

 

Please - full code.

 

What is you entity? Are you sure you are grabbing right one? DId you register (created) particle? (EDIT: Its vanilla particle, isn't it?) Are they working elsewhere? Have you tried SIMPLE debugging (printing x/y/z for one)?

1.7.10 is no longer supported by forge, you are on your own.

  • Author

In the meantime, what does the code do?

 

I mean, it spawns a particle at x, y, z, with speed...?

I need help on that speed.

  • Author

Found out that I noobedly call that function on server side... Need to deal with that for a bit...

But can anyone explain that "velocity" part? The last 3 argument ofWorld#spawnParticle()?

Velocity simply means motion - i.e. the direction(s) in which the particle will be moving. Each is further modified (randomly) based on the particles type, so you can start with all zeroes and see what it looks like, then go from there.

 

Experimentation is key to getting particle motions looking right, and learning how they work.

I read a lot of questions that can be solved with a bit of java knowledge.

 

Anyway, the way to make a custom particle is by simply extending the EntityFX.Class. On the bottum of this post Ill put an example which I use in one of my mods.

And with this line you can spawn in your particle:

mc.effectRenderer.addEffect(new YourParticle(World, x, y, z, motionX, motionY, motionZ));

And thats basically all to it.

PS. take a look at the vanilla particle classes, it contains a lot of examples!

 

package mechanical_crafting_table.client.particles.entityfx;

import static org.lwjgl.opengl.GL11.*;
import mechanical_crafting_table.Main;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class EntityWeldSparkFX extends EntityFX
{
private static final ResourceLocation WellingFXTexture = new ResourceLocation(Main.MODID, "textures/particles/WellingSpark.png");

public EntityWeldSparkFX(World world, double x, double y, double z, double mX, double mY, double mZ)
{
	super(world, x, y, z, mX, mY, mZ);
	this.motionX = mX;
	this.motionY = mY;
	this.motionZ = mZ;
	this.particleScale *= 0.04F;
	this.particleAlpha = 1.0F;
	this.particleMaxAge = 7 + this.rand.nextInt(5);
	this.particleGravity = 1F;
	this.noClip = false;
}

 public void renderParticle(Tessellator tess, float partialTick, float x, float y, float z, float u, float v)
 {
	if(this.particleAge < this.particleMaxAge)
	{
		Minecraft.getMinecraft().renderEngine.bindTexture(WellingFXTexture);

		glDepthMask(false);
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glAlphaFunc(GL_GREATER, 0.003921569F);
		glAlphaFunc(GL_GREATER, 0.6F - ((float)this.particleAge + partialTick - 1.0F) * 0.25F * 0.5F);

		float f10 = 0.1F * this.particleScale;
		float f11 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX);
        float f12 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY);
        float f13 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ);

        tess.startDrawingQuads();
        tess.setBrightness(getBrightnessForRender(partialTick));
        
        tess.addVertexWithUV((double)(f11 - x * f10 - u * f10), (double)(f12 - y * f10), (double)(f13 - z * f10 - v * f10), 0, 0);
        tess.addVertexWithUV((double)(f11 - x * f10 + u * f10), (double)(f12 + y * f10), (double)(f13 - z * f10 + v * f10), 0, 1);
        tess.addVertexWithUV((double)(f11 + x * f10 + u * f10), (double)(f12 + y * f10), (double)(f13 + z * f10 + v * f10), 1, 1);
        tess.addVertexWithUV((double)(f11 + x * f10 - u * f10), (double)(f12 - y * f10), (double)(f13 + z * f10 - v * f10), 1, 0);
        tess.draw();
        
		glDisable(GL_BLEND);
		glDepthMask(true);
		glAlphaFunc(GL_GREATER, 0.1F);
	}
}

public void onUpdate()
{
	this.prevPosX = this.posX;
	this.prevPosY = this.posY;
	this.prevPosZ = this.posZ;

	if (this.particleAge++ >= this.particleMaxAge)
	{
		this.setDead();
	}

	if (this.particleAge > this.particleMaxAge / 2)
	{
		this.setAlphaF(1.0F - ((float) this.particleAge - (float) (this.particleMaxAge / 2)) / (float) this.particleMaxAge);
	}

	this.motionY -= 0.004D * (double)this.particleGravity;;
	this.moveEntity(this.motionX, this.motionY, this.motionZ);
	this.motionX *= 0.8D;
	this.motionY *= 0.05D;
	this.motionZ *= 0.8D;
	this.setRBGColorF(this.particleRed, this.particleBlue, this.particleGreen);

	if (this.onGround) {
		this.motionX *= 0.699999988079071D;
		this.motionZ *= 0.699999988079071D;
	}

	if (this.particleAge < this.particleMaxAge / 2 && (this.particleAge + this.particleMaxAge) % 2 == 0)
	{
		EntityWeldSparkFX EntityWell = new EntityWeldSparkFX(this.worldObj, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
		EntityWell.particleAge = EntityWell.particleMaxAge / 2;
		Minecraft.getMinecraft().effectRenderer.addEffect(EntityWell);
	}
}

public int getBrightnessForRender(float brightnessFR)
{
	return 15728880;
}

public float getBrightness(float brightness)
{
	return 1.0F;
}

    public boolean canBePushed()
    {
        return true;
    }
    
    public int getFXLayer()
    {
        return 3;
    }
    
    public AxisAlignedBB getBoundingBox()
    {
        return null;
    }
}

 

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

I need help on how to tell Forge to look at my image sources for my particles.

 

Use a resource location. Look at the example above your post.

This part gets your texture:

private static final ResourceLocation yourTexture = new ResourceLocation(Main.YOURMODID, "textures/particles/yourTextureFile.png");

 

And you bind it with the following:

Minecraft.getMinecraft().renderEngine.bindTexture(yourTexture );

 

you can do it with openGL, but that means you got to convert/load in  your texture so it can passed through as an Integer.

(sound realy strange, but look up a tutorial of opengl, and you'll see what Im talking about)

 

That being said, Minecraft made it way easier for us to bind a texture. (with the example above) So I would suggest using it. :D

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.