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

Hello everybody,, i have a question:

When/where am i supposed to spawn particles on client?

 

So:

I have a config option for particle rendering which can be different for each client, that's why i'm spawning it on client and not on server||&client.

I tried to spawn it at ClientTick.pre, RenderTick.pre and WorldTick.pre and non of them is working.

I know that code for spawning (world.spawnParticle) is reached (console).

But i don't see any particles...

 

If you know when/where i have to spawn particles on client - tell me please!

 

I don't think you need any code, but if you do - i can give it!

 

 

Thanks for help!

If you have any questions - just ask!

Hi

 

It should work fine to spawn particles on client in ClientTick, RenderTick, WorldTick, or anywhere else actually. 

 

Perhaps you are spawning them at the wrong location, or they are invisible.

 

Show code?

 

-TGG

  • Author

Hi

 

It should work fine to spawn particles on client in ClientTick, RenderTick, WorldTick, or anywhere else actually. 

 

Perhaps you are spawning them at the wrong location, or they are invisible.

 

Show code?

 

-TGG

Ok, that the code responsible for spawning particles next to player.

It is called from [event], and succesfully reaches spawnParticle (console).

@Override
public void createParticles(EntityLivingBase entity, boolean b){
	if(b){
		if(vectoredAffect(entity)){
			World world = entity.worldObj;
			Vec3 look = entity.getLookVec();
			for(int i = 0; i < particleAmount(); i++){
				world.spawnParticle(getParticle(), entity.posX + randomRangedPNDouble(getParticlePosRandomizerRange()), entity.posY + randomRangedPNDouble(getParticlePosRandomizerRange()), entity.posZ + randomRangedPNDouble(getParticlePosRandomizerRange()), look.xCoord * 10 + randomRangedPNDouble(getParticleVelocityRandomizerRange()),  look.yCoord * 10 + randomRangedPNDouble(getParticleVelocityRandomizerRange()),  look.zCoord * 10 + randomRangedPNDouble(getParticleVelocityRandomizerRange()));
			}
		}
	}
}

 

Helper methods:

public String getParticle() {
	return "smoke";
}

public double randomRangedPNDouble(double range) {
	return random.nextBoolean() ? random.nextInt((int) (range * 1000000)) / 1000000 : -random.nextInt((int) (range * 1000000)) / 1000000;
}

public double getParticlePosRandomizerRange() {
	return 0.5;
}

public double getParticleVelocityRandomizerRange() {
	return 0.125;
}

public int particleAmount(){
	return 10 * getAmplifier();
}

Hi

 

This is 1.7.10 yeah?

 

I suggest first thing is to comment out this

for(int i = 0; i < particleAmount(); i++){
				world.spawnParticle(getParticle(), entity.posX + randomRangedPNDouble(getParticlePosRandomizerRange()), entity.posY + randomRangedPNDouble(getParticlePosRandomizerRange()), entity.posZ + randomRangedPNDouble(getParticlePosRandomizerRange()), look.xCoord * 10 + randomRangedPNDouble(getParticleVelocityRandomizerRange()),  look.yCoord * 10 + randomRangedPNDouble(getParticleVelocityRandomizerRange()),  look.zCoord * 10 + randomRangedPNDouble(getParticleVelocityRandomizerRange()));
			}

and replace it with (going from memory here)

world.spawnParticle("smoke", entity.posX, entity.posY, entity.posZ, 0.05, 0.05, 0.05);

 

That should help narrow down the possible problems

 

-TGG

 

-TGG

  • Author

Hi

 

This is 1.7.10 yeah?

 

I suggest first thing is to comment out this

for(int i = 0; i < particleAmount(); i++){
				world.spawnParticle(getParticle(), entity.posX + randomRangedPNDouble(getParticlePosRandomizerRange()), entity.posY + randomRangedPNDouble(getParticlePosRandomizerRange()), entity.posZ + randomRangedPNDouble(getParticlePosRandomizerRange()), look.xCoord * 10 + randomRangedPNDouble(getParticleVelocityRandomizerRange()),  look.yCoord * 10 + randomRangedPNDouble(getParticleVelocityRandomizerRange()),  look.zCoord * 10 + randomRangedPNDouble(getParticleVelocityRandomizerRange()));
			}

and replace it with (going from memory here)

world.spawnParticle("smoke", entity.posX, entity.posY, entity.posZ, 0.05, 0.05, 0.05);

 

That should help narrow down the possible problems

 

-TGG

 

-TGG

Ok, i'll try...

 

EDIT 1:  ??? this works... let me re-add my previouscode...

 

EDIT 2:  :o :o :o wtf? re-adding my previous code, and it works like i wanted...  :o :o :o

 

Thanks... And i still don't understand why be removing and then re adding code, it worked... but it's working now... so yeah, thanks...  :o...

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.