当前位置: 首页>>代码示例>>Java>>正文


Java Particle类代码示例

本文整理汇总了Java中org.bukkit.Particle的典型用法代码示例。如果您正苦于以下问题:Java Particle类的具体用法?Java Particle怎么用?Java Particle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Particle类属于org.bukkit包,在下文中一共展示了Particle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: flightPath

import org.bukkit.Particle; //导入依赖的package包/类
/**
 * Override this class, you can use it to provide particle effects along travel path. 
 * 
 * It is called after all other handling is done. Keep it lightweight
 * 
 * @param start The start location of flight
 * @param end The end location of impact / miss
 * @param type the type of bullet in play
 * @param endOfFlight is the bullet still flying after this or has it impacted?
 */
public void flightPath(Location start, Location end, Bullet type, boolean endOfFlight) {
	// no special flight path stuff. maybe a whizzing sound?

	World world = start.getWorld();
	if (endOfFlight) {
		// make a new sound where it hits.
		world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f);
	}
	if (type.getFireChance() > 0.0d) {
		if (start != null) {
			double distance = end.distance(start);

			Vector vector = end.subtract(start).toVector();
			vector = vector.multiply(0.1d / distance);
			for (int i = 0; i < distance; i++) {
				world.spawnParticle(Particle.SMOKE_NORMAL, start.add(vector), 5, 0.01, 0.01, 0.01, 0.001);
			}
		}
	}
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:31,代码来源:StandardGun.java

示例2: tick

import org.bukkit.Particle; //导入依赖的package包/类
@Repeatable(scope = MatchScope.RUNNING)
public void tick() {
    EntityUtils.entities(match.getWorld(), Projectile.class)
         .filter(projectile -> projectile.hasMetadata(TRAIL_META))
         .forEach(projectile -> {
             if(projectile.isDead() || projectile.isOnGround()) {
                 projectile.removeMetadata(TRAIL_META, PGM.get());
             } else {
                 final Color color = (Color) projectile.getMetadata(TRAIL_META, PGM.get()).value();
                 // Certain particles can have a specific color if:
                 // - Count is 0
                 // - Speed is 1
                 // - Delta vectors are RGB values from (0,1]
                 match.getWorld().spawnParticle(
                     Particle.REDSTONE,
                     projectile.getLocation(),
                     0,
                     rgbToParticle(color.getRed()),
                     rgbToParticle(color.getGreen()),
                     rgbToParticle(color.getBlue()),
                     1
                 );
             }
         });
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:26,代码来源:ProjectileTrailMatchModule.java

示例3: craft

import org.bukkit.Particle; //导入依赖的package包/类
public boolean craft(Player crafter) {
	// TODO Block crafting operation when not allowed for player
	String spell = getSpell();
	if (spell != null) {
		ItemStack tome = SpellTome.getSpellTome(spell, crafter);
		Location spawnLoc = block.getLocation().add(0.5, 1.5, 0.5);
		spawnLoc.getWorld().spawnParticle(Particle.ENCHANTMENT_TABLE, spawnLoc, 40);
		for (Entry<Item, BukkitRunnable> entry : items.entrySet()) {
			Item item = entry.getKey();
			item.remove();
			entry.getValue().cancel();
		}
		book.setCustomNameVisible(false);
		new BukkitRunnable() {
			public void run() {
				book.setItemStack(tome);
				book.setGlowing(false);
				book.setPickupDelay(0);
				book.getWorld().playSound(book.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
			}
		}.runTaskLater(MystiCraft.getInstance(), 32);
		return true;
	} else {
		return false;
	}
}
 
开发者ID:mcardy,项目名称:MystiCraft,代码行数:27,代码来源:CraftingOperation.java

示例4: addItems

import org.bukkit.Particle; //导入依赖的package包/类
@Override
public void addItems() {
    Particle effect = getWrapper().getEffect();
    for (Particle p : getParticles())
        if (p != Particle.MOB_APPEARANCE)
            addItem(Material.REDSTONE, ChatColor.GREEN + Utils.capitalize(p.name()),
                    "Click here to activate this particle effect.")
                    .anyClick(e -> {
                        getPlayer().sendMessage(ChatColor.GREEN + "Activated " + Utils.capitalize(p.name()) + ".");
                        getWrapper().setEffect(p);
                        reconstruct();
                    }).setGlowing(p == effect);

    toRight(2);

    if (effect != null)
        addItem(Material.INK_SACK, ChatColor.RED + "Disable Particles", "Click here to disable your active effect.")
                .anyClick(e -> {
                    getWrapper().setEffect(null);
                    getPlayer().sendMessage(ChatColor.RED + "Particles disabled.");
                    reconstruct();
                });

    addBackButton();
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:26,代码来源:GUIParticles.java

示例5: handleDetonate

import org.bukkit.Particle; //导入依赖的package包/类
private void handleDetonate(Player player, Rune rune) {
	player.spawnParticle(Particle.EXPLOSION_HUGE, player.getLocation(), 1);
	player.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1F, 1F);
	for(Entity entity : player.getNearbyEntities(3D, 3D, 3D)) {
		if(!(entity instanceof Player)) {
			continue;
		}
		Player target = (Player) entity;
		
		if(Utility.canAttack(player, target)) {
			if(target.getHealth() > 6) {
				target.setHealth(target.getHealth() - 6);
			}
			else {
				target.damage(1000000D, player);
			}
		}
	}
	finish(player, false);
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:21,代码来源:RuneManager.java

示例6: particle

import org.bukkit.Particle; //导入依赖的package包/类
/**
 * パーティクルを発生させる
 * @param loc
 */
@SuppressWarnings("unused")
private void particle(Location loc) {
	//loc.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, loc,10);
	/*
	loc.getWorld().spawnParticle(
			Particle.VILLAGER_HAPPY,
			loc,
			50,
			10, // 散開させるXの範囲
			10, // 散開させるYの範囲
			10 // 散開させるZの範囲
	);//*/
	//*
	loc.getWorld().spawnParticle(
			Particle.CLOUD,
			loc,
			500,
			10, // 散開させるXの範囲
			10, // 散開させるYの範囲
			10, // 散開させるZの範囲
			0.1 // 速度?
	);//*/
}
 
开发者ID:HimaJyun,项目名称:BukkitPluginDevelopment,代码行数:28,代码来源:Main.java

示例7: checkParticle

import org.bukkit.Particle; //导入依赖的package包/类
public boolean checkParticle(){
    if(wild.getConfig().getBoolean("DoParticle")) {
        try {
            String[] tmp = Bukkit.getVersion().split("MC: ");
            String version = tmp[tmp.length - 1].substring(0, 3);
            Particle particle;
            Effect effect;
            if (version.equals("1.9") || version.equals("1.1"))
                particle = Particle.valueOf(wild.getConfig().getString("Particle").toUpperCase());
            else
                effect = Effect.valueOf(wild.getConfig().getString("Particle").toUpperCase());
        } catch (IllegalArgumentException e) {
            return false;
        }
    }else
        return true;
    return true;
}
 
开发者ID:Qballl,项目名称:WildernessTp,代码行数:19,代码来源:CheckConfig.java

示例8: t

import org.bukkit.Particle; //导入依赖的package包/类
@TaskHandler(name = "HealthRegionTask", delay = TASK_DELAY)
public void t() {
	WorldModule worldModule = this.module.getModule(WorldModule.class).orElse(null);
	if (worldModule == null) { debug("t", "Failed to find worldModule"); return; }
	
	if (!healthRegion.isPresent()) {
		if (searched) { debug("t", "Didnt find healthRegion in the past"); return; }

		Optional<Region> region = worldModule.getRegion(Utility.getMainWorld(), "health_region_1");
		if (region.isPresent()) { this.healthRegion = region; debug("t", "Found healthregion"); }
		else { searched = true; debug("t", "Failed to find healthregion"); return; }
	}
	
	Location3i minPos = healthRegion.get().getMinLoc();
	Location3i maxPos = healthRegion.get().getMaxLoc();

	int x = Utility.randomInt(minPos.getX(), maxPos.getX());
	int y = Utility.randomInt(minPos.getY(), maxPos.getY());
	int z = Utility.randomInt(minPos.getZ(), maxPos.getZ());

	debug("t", "x: " + x + ", y: " + y + ",  z: " + z);
	
	minPos.getWorld().spawnParticle(Particle.HEART, x, y, z, 1);
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:25,代码来源:HealthRegionComponent.java

示例9: displayProt

import org.bukkit.Particle; //导入依赖的package包/类
void displayProt(final Player player, final Protection prot) {
	if (prot instanceof EntityProtection) {
		Optional<Entity> entity = ((EntityProtection) prot).getStoredEntity().getEntity();
		if (entity.isPresent()) {
			final Location loc = entity.get().getLocation();

			if (prot.getOwner().getUniqueId().equals(player.getUniqueId())) {
				player.spawnParticle(Particle.SPELL_INSTANT, loc.getBlockX() + 0.5, loc.getBlockX() + 0.5, loc.getBlockX() + 0.5, 10);
			}
			else {
				player.spawnParticle(Particle.SPELL_WITCH, loc.getBlockX() + 0.5, loc.getBlockY() + 0.5, loc.getBlockZ() + 0.5, 10);
			}
			
			return;
		}
	}

	if (prot.getOwner().getUniqueId().equals(player.getUniqueId())) {
		player.spawnParticle(Particle.SPELL_INSTANT, prot.getX() + 0.5, prot.getY() + 0.5, prot.getZ() + 0.5, 10);
	}
	else {
		player.spawnParticle(Particle.SPELL_WITCH, prot.getX() + 0.5, prot.getY() + 0.5, prot.getZ() + 0.5, 10);
	}
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:25,代码来源:ProtectionEffectListener.java

示例10: spawnParticle

import org.bukkit.Particle; //导入依赖的package包/类
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
    if (data != null && !particle.getDataType().isInstance(data)) {
        throw new IllegalArgumentException("data should be " + particle.getDataType() + " got " + data.getClass());
    }
    getHandle().sendParticles(
            null, // Sender
            CraftParticle.toNMS(particle), // Particle
            true, // Extended range
            x, y, z, // Position
            count,  // Count
            offsetX, offsetY, offsetZ, // Random offset
            extra, // Speed?
            CraftParticle.toData(particle, data)

    );

}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:19,代码来源:CraftWorld.java

示例11: toData

import org.bukkit.Particle; //导入依赖的package包/类
public static int[] toData(Particle particle, Object obj) {
    if (particle.getDataType().equals(Void.class)) {
        return new int[0];
    }
    if (particle.getDataType().equals(ItemStack.class)) {
        if (obj == null) {
            return new int[]{0, 0};
        }
        ItemStack itemStack = (ItemStack) obj;
        return new int[]{itemStack.getType().getId(), itemStack.getDurability()};
    }
    if (particle.getDataType().equals(MaterialData.class)) {
        if (obj == null) {
            return new int[]{0};
        }
        MaterialData data = (MaterialData) obj;
        return new int[]{data.getItemTypeId() + ((int)(data.getData()) << 12)};
    }
    throw new IllegalArgumentException(particle.getDataType().toString());
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:21,代码来源:CraftParticle.java

示例12: CaulCraftSuccessEvent

import org.bukkit.Particle; //导入依赖的package包/类
public CaulCraftSuccessEvent(CraftArray craft, Player player, Block cauldron, Particle particle, Sound sound) {
	this.craft = craft;
	this.player = player;
	this.cauldron = cauldron;
	this.particle = particle;
	this.setSound(sound);
}
 
开发者ID:Slaymd,项目名称:CaulCrafting,代码行数:8,代码来源:CaulCraftSuccessEvent.java

示例13: CaulCraftFailEvent

import org.bukkit.Particle; //导入依赖的package包/类
public CaulCraftFailEvent(ArrayList<ItemStack> items, Player player, Block cauldron, Particle particle, Sound sound) {
	this.setItems(items);
	this.setPlayer(player);
	this.setCauldron(cauldron);
	this.setParticle(particle);
	this.setSound(sound);
}
 
开发者ID:Slaymd,项目名称:CaulCrafting,代码行数:8,代码来源:CaulCraftFailEvent.java

示例14: preHit

import org.bukkit.Particle; //导入依赖的package包/类
/**
 * Subclasses are encouraged to override this.
 * Default behavior is to eject off of what you are riding, play a sound and spawn particle.
 *
 * 
 * @param hitData Data matrix showing hit
 * @param hit What entity was hit
 * @param bullet The bullet data.
 */
public void preHit(HitDigest hitData, Entity hit, Projectile bullet, Bullet type) {
	Location end = hitData.hitLocation;
	World world = end.getWorld();
	hit.eject(); // eject the player
	hit.getPassengers().forEach(e -> e.eject()); // and ejects your passengers
	// make a new sound where it hits.
	world.playSound(end, Sound.ENTITY_FIREWORK_BLAST, 1.0f, 1.5f);
	// make a splash
	world.spawnParticle(Particle.SMOKE_NORMAL, end, 35, 0.1, 0.1, 0.1, 0.1);
}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:20,代码来源:StandardGun.java

示例15: resetPlayer

import org.bukkit.Particle; //导入依赖的package包/类
public static void resetPlayer(Player player) {
    player.getInventory().clear();
    player.getInventory().setChestplate(new ItemBuilder().material(Material.ELYTRA).unbreakable(true).get());
    player.setGameMode(GameMode.ADVENTURE);
    player.setAllowFlight(player.hasPermission("lobby.fly"));
    player.setWalkSpeed(0.2f);
    player.setFlySpeed(0.1f);
    player.setPotionParticles(false);
    player.hideTitle();
    player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation(), 15, 0.5, 0.5, 0.5, 0);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:12,代码来源:Utils.java


注:本文中的org.bukkit.Particle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。