Posted January 9, 20214 yr [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 January 9, 20214 yr by Funyaah
January 9, 20214 yr 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 January 9, 20214 yr by Guru
January 9, 20214 yr Author 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.
January 9, 20214 yr You could have the armor spawn little entities that produce the particles. Could possibly be a typo: player.getEntityWorld(); to: player.getEntityInWorld();
January 9, 20214 yr 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 January 9, 20214 yr by Guru
January 9, 20214 yr 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.
January 9, 20214 yr 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 January 9, 20214 yr by Guru
January 9, 20214 yr 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.
January 9, 20214 yr Author 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.
January 10, 20214 yr 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.