org.spongepowered.api.effect.particle.ParticleEffect Java Examples

The following examples show how to use org.spongepowered.api.effect.particle.ParticleEffect. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParticlesUtil.java    From EagleFactions with MIT License 6 votes vote down vote up
@Override
		public void accept(Task task)
		{
//			double x = this.location.getX() + r * Math.cos(Math.toDegrees(angle));
//			double z = this.location.getZ() + r * Math.sin(Math.toDegrees(angle));

			double x = this.location.getX() + r * Math.cos(angle);
			double z = this.location.getZ() + r * Math.sin(angle);


			world.spawnParticles(ParticleEffect.builder().type(ParticleTypes.END_ROD).quantity(5).offset(Vector3d.from(0, 0.5, 0)).build(), Vector3d.from(x, location.getY() + 0.5, z));

			if (angle + angleIncrement > 360)
			{
				angle = (angle + angleIncrement) - 360;
			}
			else
			{
				angle += angleIncrement;
			}

			//TODO: This code runs forever until player changes location. We should count delay seconds here as well maybe?
			if (!this.lastBlockPosition.equals(this.player.getLocation().getBlockPosition()))
				task.cancel();
		}
 
Example #2
Source File: ParticlesUtil.java    From EagleFactions with MIT License 5 votes vote down vote up
public static void spawnAddAccessParticles(final Claim claim)
{
	final Optional<World> optionalWorld = Sponge.getServer().getWorld(claim.getWorldUUID());
	if(!optionalWorld.isPresent())
		return;

	final World world = optionalWorld.get();
	final Vector3d position = getChunkCenter(world, claim.getChunkPosition());
	world.spawnParticles(ParticleEffect.builder().type(ParticleTypes.FIREWORKS_SPARK).option(ParticleOptions.VELOCITY, new Vector3d(0, 0.15, 0)).quantity(400).offset(new Vector3d(8, 2, 8)).build(), position);
	world.playSound(SoundTypes.ENTITY_EXPERIENCE_ORB_PICKUP, position, 5, 10);
}
 
Example #3
Source File: ParticlesUtil.java    From EagleFactions with MIT License 5 votes vote down vote up
public static void spawnRemoveAccessParticles(final Claim claim)
{
	final Optional<World> optionalWorld = Sponge.getServer().getWorld(claim.getWorldUUID());
	if(!optionalWorld.isPresent())
		return;

	final World world = optionalWorld.get();
	final Vector3d position = getChunkCenter(world, claim.getChunkPosition());
	world.spawnParticles(ParticleEffect.builder().type(ParticleTypes.LARGE_SMOKE).option(ParticleOptions.VELOCITY, new Vector3d(0, 0.15, 0)).quantity(400).offset(new Vector3d(8, 1, 8)).build(), position);
	world.playSound(SoundTypes.ITEM_FIRECHARGE_USE, position, 5, -10);
}
 
Example #4
Source File: ParticlesUtil.java    From EagleFactions with MIT License 5 votes vote down vote up
public static void spawnClaimParticles(final Claim claim)
{
	final Optional<World> optionalWorld = Sponge.getServer().getWorld(claim.getWorldUUID());
	if(!optionalWorld.isPresent())
		return;

	final World world = optionalWorld.get();
	final Vector3d position = getChunkCenter(world, claim.getChunkPosition());
	world.spawnParticles(ParticleEffect.builder().type(ParticleTypes.END_ROD).option(ParticleOptions.VELOCITY, new Vector3d(0, 0.15, 0)).quantity(400).offset(new Vector3d(8, 1, 8)).build(), position);
	world.playSound(SoundTypes.BLOCK_ENDERCHEST_OPEN, position, 5, -20);
}
 
Example #5
Source File: ParticlesUtil.java    From EagleFactions with MIT License 5 votes vote down vote up
public static void spawnUnclaimParticles(final Claim claim)
{
	final Optional<World> optionalWorld = Sponge.getServer().getWorld(claim.getWorldUUID());
	if(!optionalWorld.isPresent())
		return;

	final World world = optionalWorld.get();
	final Vector3d position = getChunkCenter(world, claim.getChunkPosition());
	world.spawnParticles(ParticleEffect.builder().type(ParticleTypes.CLOUD).option(ParticleOptions.VELOCITY, new Vector3d(0, 0.15, 0)).quantity(800).offset(new Vector3d(8, 1, 8)).build(), position);
	world.playSound(SoundTypes.ENTITY_SHULKER_SHOOT, position, 5, -20);
}
 
Example #6
Source File: ParticlesUtil.java    From EagleFactions with MIT License 5 votes vote down vote up
public static void spawnDestroyClaimParticles(final Claim claim)
{
	final Optional<World> optionalWorld = Sponge.getServer().getWorld(claim.getWorldUUID());
	if(!optionalWorld.isPresent())
		return;

	final World world = optionalWorld.get();
	final Vector3d position = getChunkCenter(world, claim.getChunkPosition());
	world.spawnParticles(ParticleEffect.builder().type(ParticleTypes.FLAME).option(ParticleOptions.VELOCITY, new Vector3d(0, 0.15, 0)).quantity(800).offset(new Vector3d(8, 1, 8)).build(), position);
	world.playSound(SoundTypes.ENTITY_BLAZE_SHOOT, position, 5, -20);
}
 
Example #7
Source File: DataHandler.java    From Nations with MIT License 4 votes vote down vote up
public static void toggleMarkJob(Player player)
{
	if (markJobs.containsKey(player.getUniqueId()))
	{
		Sponge.getScheduler().getTaskById(markJobs.get(player.getUniqueId())).ifPresent(task -> {task.cancel();});
		markJobs.remove(player.getUniqueId());
		return;
	}
	ParticleEffect nationParticule = ParticleEffect.builder().type(ParticleTypes.DRAGON_BREATH).quantity(1).build();
	ParticleEffect zoneParticule = ParticleEffect.builder().type(ParticleTypes.HAPPY_VILLAGER).quantity(1).build();
	Task t = Sponge.getScheduler()
			.createTaskBuilder()
			.execute(task -> {
				if (!player.isOnline())
				{
					task.cancel();
					markJobs.remove(player.getUniqueId());
					return;
				}
				Location<World> loc = player.getLocation().add(0, 2, 0);
				loc = loc.sub(8, 0, 8);
				for (int x = 0; x < 16; ++x)
				{
					for (int y = 0; y < 16; ++y)
					{
						Nation nation = DataHandler.getNation(loc);
						if (nation != null)
						{
							BlockRay<World> blockRay = BlockRay.from(loc).direction(new Vector3d(0, -1, 0)).distanceLimit(50).stopFilter(BlockRay.blockTypeFilter(BlockTypes.AIR)).build();
							Optional<BlockRayHit<World>> block = blockRay.end();
							if (block.isPresent())
							{
								if (nation.getZone(loc) != null)
								{
									player.spawnParticles(zoneParticule, block.get().getPosition(), 60);
								}
								else
								{
									player.spawnParticles(nationParticule, block.get().getPosition(), 60);
								}
							}
						}
						loc = loc.add(0,0,1);
					}
					loc = loc.add(1,0,0);
					loc = loc.sub(0,0,16);
				}
			})
			.delay(1, TimeUnit.SECONDS)
			.interval(1, TimeUnit.SECONDS)
			.async()
			.submit(NationsPlugin.getInstance());
	markJobs.put(player.getUniqueId(), t.getUniqueId());
}
 
Example #8
Source File: Region.java    From RedProtect with GNU General Public License v3.0 4 votes vote down vote up
private void checkParticle() {
    Sponge.getScheduler().createSyncExecutor(RedProtect.get().container).schedule(() -> {
        if (this.flags.containsKey("particles")) {
            if (task == null) {

                task = Sponge.getScheduler().createTaskBuilder().execute(() -> {
                    if (this.flags.containsKey("particles")) {
                        String[] part = flags.get("particles").toString().split(" ");
                        for (int i = 0; i < Integer.valueOf(part[1]); i++) {
                            Location locMin = getMinLocation();
                            Location locMax = getMaxLocation();

                            int dx = locMax.getBlockX() - locMin.getBlockX();
                            int dy = locMax.getBlockY() - locMin.getBlockY();
                            int dz = locMax.getBlockZ() - locMin.getBlockZ();
                            Random random = new Random();
                            int x = random.nextInt(Math.abs(dx) + 1) + locMin.getBlockX();
                            int y = random.nextInt(Math.abs(dy) + 1) + locMin.getBlockY();
                            int z = random.nextInt(Math.abs(dz) + 1) + locMin.getBlockZ();

                            ParticleType p = Sponge.getRegistry().getType(ParticleType.class, part[0]).get();
                            World w = Sponge.getServer().getWorld(world).get();
                            //ParticleTypes.FIRE
                            Location<World> loc = new Location<>(w, x + new Random().nextDouble(), y + new Random().nextDouble(), z + new Random().nextDouble());
                            if (loc.getBlock().getType().equals(BlockTypes.AIR)) {
                                ParticleEffect.Builder pf = ParticleEffect.builder().type(p).quantity(1);


                                if (part.length == 5) {
                                    pf.offset(new Vector3d(Double.parseDouble(part[2]), Double.parseDouble(part[3]), Double.parseDouble(part[4])));
                                }
                                if (part.length == 6) {
                                    pf.offset(new Vector3d(Double.parseDouble(part[2]), Double.parseDouble(part[3]), Double.parseDouble(part[4])));
                                    double multi = Double.parseDouble(part[5]);
                                    pf.velocity(new Vector3d((new Random().nextDouble() * 2 - 1) * multi, (new Random().nextDouble() * 2 - 1) * multi, (new Random().nextDouble() * 2 - 1) * multi));
                                }

                                if (!w.getEntities(ent -> ent instanceof Player && loc.getPosition().distance(ent.getLocation().getPosition()) <= 30).isEmpty()) {
                                    w.spawnParticles(pf.build(), loc.getPosition());
                                }
                            }
                        }
                    }
                }).intervalTicks(1).submit(RedProtect.get().container);
            }
        } else if (task != null) {
            notifyRemove();
        }
    }, 1, TimeUnit.SECONDS);
}
 
Example #9
Source File: BloodEffect.java    From UltimateCore with MIT License 4 votes vote down vote up
public ParticleEffect getEffect() {
    ParticleEffect particle = ParticleEffect.builder().type(ParticleTypes.BLOCK_CRACK).option(ParticleOptions.BLOCK_STATE, state).option(ParticleOptions.QUANTITY, count).offset(p_offset).build();
    return particle;
}