Jump to content

Particles only appear on a player's client who made an action but other players cannot see them


Recommended Posts

Posted (edited)

[1.16.4]

Hello, I'm pretty new to forge modding.

 

Recently I made a mod that spawns particles when player jumps with specific suite of armour, and it certainly shows particles in multi player mode,

but other players said they can't see them. 

(Using LivingJumpEvent)

 

I also made a mod which spawns particles when player swing a special sword, but everyone can see the particles. (Using SwordItem.onEntitySwing)

 

I don't quite get difference between those two. Can anyone tell me why there's gap on those? 

 

Here's the event subscriber for jump event:

	@Mod.EventBusSubscriber
	public static class ClientEvents {
		@SubscribeEvent
		public static void onJumping(final LivingEvent.LivingJumpEvent event) {
			LivingEntity player = event.getEntityLiving();
			World world = player.getEntityWorld();
			if (world.isRemote && isPlayerWearingTheArmours(player)) {
				ClientWorld clientWorld = (ClientWorld) world;
				for (int i = 0; i < 15; ++i) {
					clientWorld.addParticle(ParticleTypes.PORTAL, player.getPosXRandom(0.2D),
							player.getPosYRandom() - 0.25D, player.getPosZRandom(0.2D),
							(clientWorld.rand.nextDouble() - 0.25D) * 2.0D, -clientWorld.rand.nextDouble(),
							(clientWorld.rand.nextDouble() - 0.25D) * 2.0D);
				}
			}

		}
	}

 

 

Thank you very much in advance!

 

Funyaah

Edited by Funyaah
Posted (edited)

You could use world.isRemote or !world.isRemote to see if this produces a difference in particles.

 

If it is or it isn't.

 

Could be that there is a speed that the individual particle is favored to being online play.

Or something.

 

It would make more sense if you were addressing worldObj almost that the player is wearing armor rather than establishing to the world itself that in a world that the entire world is a player and it wears armor.

 

does getEntityPosition work instead of getentityliving?

Edited by Guru
Posted

I can't use !world.isRemote since I cast world into ClientWorld in order to call implemented addParticle (ServerWorld.addParticle does not anything according to documentaiton).

 

I also tried ServerWorld.spawnParticle, but result was same. 

Posted

You could have the armor spawn little entities that produce the particles.

 

 

Could possibly be a typo:

player.getEntityWorld();

 

 

to:

player.getEntityInWorld();

Posted (edited)
16 minutes ago, Funyaah said:

player.getEntityInWorld();

That function does not exist.

There is the player... and you are getting which world the player is in.

If the player's world is nearby and it's wearing armor, then everything to the right of your &'s is not read because there are two sets of () in the expression to specify that the player is not the world wearing the suit of armor.

 

The way around that is to target everything that is not a mob wearing the armor.

 

Which is !player instead of player though.

Edited by Guru
Posted
1 hour ago, diesieben07 said:

LivingJumpEvent probably does not fire on the client for other players.

You will need to use server side version of particle spawning which sends packets (see the methods in ServerWorld).

This is the incorrect method please use appropriate tab spacing.

Posted (edited)
3 minutes ago, diesieben07 said:

What?

player.getPosYRandom

 

This is technically incorrect because the player exists on a plane or does it, therefor does not have a random position of Y,

assuming that x,y,z are coordinate values.

Edited by Guru
Posted

In other words if you were to try to register the particles the other way then they would not render because there is not a reference to the item that is being specified.

 

What is being referenced to is player or world.

Posted
7 hours ago, diesieben07 said:

LivingJumpEvent probably does not fire on the client for other players.

You will need to use server side version of particle spawning which sends packets (see the methods in ServerWorld).

Thank you for reply, actually I already did "ServerWorld.spawnParticles" but result was same. I'm trying to use PlayerTickEvent to spawn particle using ClientWorld.addParticles... 

But to me it's odd because "SwordItem.onEntitySwing" could show particles for everyone on a server using ClientWorld.addParticles. 

This is also what I want to know.

Posted

You have to specify the location of the player or it could be when the player is not performing an action, such as while in combat to reduce lag.

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.