當前位置: 首頁>>代碼示例>>Java>>正文


Java Creeper.getLocation方法代碼示例

本文整理匯總了Java中org.bukkit.entity.Creeper.getLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java Creeper.getLocation方法的具體用法?Java Creeper.getLocation怎麽用?Java Creeper.getLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.entity.Creeper的用法示例。


在下文中一共展示了Creeper.getLocation方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: on

import org.bukkit.entity.Creeper; //導入方法依賴的package包/類
@EventHandler
public void on(EntityDeathEvent event) {
    if (!(event.getEntity() instanceof Creeper)) return;

    Creeper creeper = (Creeper) event.getEntity();

    // explode after 2 seconds ticks
    ExplosionTask task = new ExplosionTask(creeper.getLocation(), creeper.isPowered() ? 6 : 3, false);
    task.runTaskLater(plugin, 40);

    // set up some layered smoke effects
    for (int i = 0; i < 5; i++) {
        // increase the count over time
        ImpendingExplosionParticleTask smoke = new ImpendingExplosionParticleTask(creeper.getLocation(), 20 * (i+1));
        smoke.runTaskLater(plugin, 10 + (i * 10));
    }
}
 
開發者ID:Eluinhost,項目名稱:UberHardcore,代碼行數:18,代碼來源:CreeperDeathHandler.java

示例2: onCreeperDeath

import org.bukkit.entity.Creeper; //導入方法依賴的package包/類
/**
 * On creeper death, drop fireworks and heads with a configurable chance.
 */
@EventHandler(ignoreCancelled = true)
public void onCreeperDeath(EntityDeathEvent event) {
    if (!CONFIG.isAffectedWorld(event)) {
        return;
    }

    Entity entity = event.getEntity();
    if (entity.getType() == EntityType.CREEPER && entity.hasMetadata(SPECIAL_KEY)) {
        Creeper creeper = (Creeper) entity;

        // Require recent player damage on the creeper for special drops.
        Long damageTime = getPlayerDamageTime(entity);
        if (damageTime != null) {
            Location loc = creeper.getLocation();
            if (loc.getWorld().getFullTime() - damageTime < PLAYER_DAMAGE_TICKS) {
                if (Math.random() < CONFIG.FIREWORK_DROP_CHANCE) {
                    // Replace the default drops.
                    event.getDrops().clear();
                    final int amount = random(CONFIG.MIN_FIREWORK_DROPS, CONFIG.MAX_FIREWORK_DROPS);
                    for (int i = 0; i < amount; ++i) {
                        ItemStack firework = new ItemStack(Material.FIREWORK);
                        FireworkMeta meta = (FireworkMeta) firework.getItemMeta();
                        meta.setPower(random(0, 3));
                        meta.addEffect(randomFireworkFffect(false));
                        firework.setItemMeta(meta);
                        event.getDrops().add(firework);
                    }
                }

                // Powered creepers may drop a creeper skull in addition to
                // fireworks.
                if (creeper.isPowered() && Math.random() < CONFIG.CHARGED_CREEPER_SKULL_CHANCE) {
                    event.getDrops().add(new ItemStack(Material.SKULL_ITEM, 1, (short) 4));
                }
            }
        }
    }
}
 
開發者ID:NerdNu,項目名稱:Creepocalypse,代碼行數:42,代碼來源:Creepocalypse.java


注:本文中的org.bukkit.entity.Creeper.getLocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。