[SOLVED] How do you spawn Particles?

I’m trying to spawn a particle when a player issues a command, using this

Player player = (Player) commandSource;
Location oPos = player.getLocation();
GameRegistry reg = plugin.game.getRegistry();
Vector3d origin = new Vector3d(oPos.getPosition().getX(), oPos.getPosition().getY() + 1, oPos.getPosition().getZ());
player.getLocation().getExtent().spawnParticles(reg.createParticleEffectBuilder(ParticleTypes.ENCHANTMENT_TABLE).count(2000).build(), origin, 1);

but I just can’t seem to get anything to happen.

This my be of use

Yeah, that is where I got the base process from but when i try to use it nothing happens, no errors, just acts like it’s not even there,

Quick tip

can be written as:

Vector3d origin = oPos.add(0, 1, 0);

I did hear that there were some bugs with particle effects more than 1 block away from the player’s feet.

@JBYoshi is right, but you already defined a radius of 1 … (or did u just edit that in? :smiley: )
A radius of 1 however is not enough, is it? ^^
Try 50 or so.

The problem is that the effect of particle table is that it is very small, and at 0,1,0 offset, will be contained entirely within the torso of a character, and not visible outside of the model.

That’s what i was thinking, i got it to display, but is it like a radius or a point of origin?

all parrticles are spawned at a point, some are bigger than others though, the table effect is a small character about 1/8th of a block height tall, 1/12th wide about its center. The radius is how far away that is viewable, provideed it is viewable - inside of a block you cant see it, inside of a player model, you cant see it.
All 2000 of your particles will occupy the exact same tiny volume of space overlapped.

A little snippet from the working code TY all that helped :stuck_out_tongue_winking_eye:

public CommandResult {

public static Game game;
Player player = (Player) commandSource;
GameRegistry reg = game.getRegistry();
Vector3d motion = new Vector3d(0, 2, 0);
Location oPos = player.getLocation();
Vector3d origin = oPos.getPosition();

ParticleEffectBuilder eFF1 = reg.createParticleEffectBuilder(ParticleTypes.PORTAL).count(20).motion(motion);

for (double incr = 0; incr < 3.14; incr += 0.1) {

                player.getLocation().getExtent().spawnParticles(eFF1.motion(motion.add(Math.cos(incr), 0, Math.sin(incr))).build(), origin, 500);
                player.getLocation().getExtent().spawnParticles(eFF1.motion(motion.add(Math.cos(incr), 0, -Math.sin(incr))).build(), origin, 500);
                player.getLocation().getExtent().spawnParticles(eFF1.motion(motion.add(-Math.cos(incr), 0, Math.sin(incr))).build(), origin, 500);
                player.getLocation().getExtent().spawnParticles(eFF1.motion(motion.add(-Math.cos(incr), 0, -Math.sin(incr))).build(), origin, 500);

            }

}

The last argument to spawnParticles is just a workaround for Player.spawnParticles() with no integer parameter results in no particles equalto or greater than 1.0 distance away · Issue #386 · SpongePowered/SpongeForge · GitHub. Once the issue is fixed, it will no longer be needed.