Jump to content

Particle invisible


zerodeaths000

Recommended Posts

I couldn't give a better title. I have a code that generates some particles when an item gets thrown. I just don't understand why the particles are invisible. Im using wolrd.addParticle() to add them to the world. My code: 

public class ThrowFireEvent {
	@SubscribeEvent
	public static void ThrowFireEvent(ItemTossEvent event) {
		ItemEntity item = event.getEntityItem();
		World world = item.getEntityWorld();
		double x = (double)item.getPosition().getX();
		double y = (double)item.getPosition().getY();
		double z = (double)item.getPosition().getZ();
		world.addParticle(ParticleTypes.CAMPFIRE_COSY_SMOKE, true, x, y, z, 0.0D, 0.05D, 0.0D);
	}
}

There are no errors in the code and once I printed out the world and the coordinates and they were all right. I also took a look at minecraft's torch block and It does it at the same way. Hopefully you know the answer, and every bit of help is appreciated. (Sorry for bad English, and plus note, I'm using 1.15.2)

 

Edit: It does work when I call it in other events.

Edited by zerodeaths000
Link to comment
Share on other sites

Hi

 

I think it's probably a client vs server thing.  The method you're calling does nothing on the client, and I'm guessing that ItemTossEvent is only ever called on the Server.

 

You could try checking that the world is a ServerWorld, and if it is then casting it to ServerWorld and calling spawnParticle().  That sends a packet to the client to spawn the particle you want.

 

-TGG

 

 

Link to comment
Share on other sites

37 minutes ago, TheGreyGhost said:

Hi

 

I think it's probably a client vs server thing.  The method you're calling does nothing on the client, and I'm guessing that ItemTossEvent is only ever called on the Server.

 

You could try checking that the world is a ServerWorld, and if it is then casting it to ServerWorld and calling spawnParticle().  That sends a packet to the client to spawn the particle you want.

 

-TGG

 

 

Im not entirely sure of what I'm supposed to do, I don't really understand how to call spawnParticles(), could you send an example? Have a nice day!

 

Link to comment
Share on other sites

Hi

 

You'll probably find this link useful

https://gist.github.com/williewillus/353c872bcf1a6ace9921189f6100d09a

 

This example project might help if you decide to go down the path of sending a custom packet to spawn particles (mbe60 uses this with the TargetEffectMessageToClient example, i.e. the server sends a network message to the client to say "spawn some particles at this [x,y,z] location").

 

https://github.com/TheGreyGhost/MinecraftByExample

 

-TGG

Link to comment
Share on other sites

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.