Jump to content

Recommended Posts

Posted

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

}

Posted

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)?

  Quote

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

Posted

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()?

Posted

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.

Posted

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

Posted
  On 6/18/2015 at 5:30 AM, BuddingDev said:

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.

Posted

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

×   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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
    • sorry, I might be stupid, but how do I open it? because the only options I have are too X out, copy it, which doesn't work and send crash report, which doesn't show it to me, also, sorry for taking so long.
    • Can you reproduce this with version 55.0.21? A whole lot of plant placement issues were just fixed in this PR.
    • Necro'ing that thread to ask if you found a solution ? I'm encountering the same crash on loading the world. I created the world in Creative to test my MP, went into survival to test combat, died, crashed on respawn and since then crash on loading the world. Deactivating Oculus isn't fixing it either, and I don't have Optifine (Twilight forest is incompatible)
  • Topics

×
×
  • Create New...

Important Information

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