Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Particles are displaying in all worlds #18

Closed
GabrielAtlas opened this issue Aug 27, 2021 · 2 comments
Closed

Particles are displaying in all worlds #18

GabrielAtlas opened this issue Aug 27, 2021 · 2 comments

Comments

@GabrielAtlas
Copy link

Hello, i trying to display a Helix with particles in one world and one location, but my code with your library is displaying the helix in all worlds in the same X , Y and Z. (Video https://www.youtube.com/watch?v=jr_dwEfkwiU)

Can you help me?

private int createNPCHelix(Entity npc) {
		if(npc == null) return 0;
		final int radius = 1;
		Location npcLocation = npc.getLocation();
		List<Object> packets = new ArrayList<>();
		ParticleBuilder particleBuilder = new ParticleBuilder(particle);
		for(int t = 0; t < 20; t++) {
			double x = radius * Math.cos(t);
			double z = radius * Math.sin(t);
			packets.add(particleBuilder.setLocation(npcLocation.clone().add(x, 0.5, z)).toPacket());
		}
		ParticleTask task = new GlobalTask(packets, 3);
		return TaskManager.getTaskManager().startTask(task);
	}
@ByteZ1337
Copy link
Owner

I'm aware of the issue (see #16). Sadly, Mojang doesn't serialize the world into the particle packets, which leads to them being displayed in every world. The only thing you can do right now is implement your own ParticleTask class. This should do the trick:

public final class WorldTask extends ParticleTask {
    
    private final World world;
    
    public WorldTask(List<Object> packets, int tickDelay, World world) {
        super(packets, tickDelay);
        this.world = world;
    }
    
    @Override
    public Collection<Player> getTargetPlayers() {
        return world.getPlayers();
    }
}

I'll keep the issue open as a reminder to include it in the next version.

@ByteZ1337
Copy link
Owner

WorldTasks are now added in 1.6.5. The Wiki example has been updated as well to include this new implementation.
This version also includes a fix for another plugin field issue. So you now have to use ReflectionUtils#setPlugin instead of just setting the ReflectionUtils#plugin field.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants