Java 类org.bukkit.entity.Giant 实例源码

项目:WC    文件:WorldInteract.java   
@EventHandler
public void onMobDie(EntityDeathEvent e){
    AllItems items = new AllItems();
    Location l = e.getEntity().getLocation();
    World w = l.getWorld();

    e.getDrops().clear();
    e.setDroppedExp(0);

    if (e.getEntity() instanceof Zombie){
        if (new Random().nextInt(5) >= 3){
            w.dropItemNaturally(l, new ItemMaker(Material.EMERALD).setAmount(new Random().nextInt(4) + 1).build());
            if (new Random().nextBoolean()){
                w.dropItemNaturally(l, items.weapons.get(new Random().nextInt(items.weapons.size())));
            } else {
                w.dropItemNaturally(l, items.health.get(new Random().nextInt(items.health.size())));
            }
        }
    }

    if (e.getEntity() instanceof Giant){
        if (new Random().nextInt(5) > 3){
            w.dropItemNaturally(l, new ItemMaker(Material.NETHER_STAR).setAmount(new Random().nextInt(4) + 1).build());
        }
    }
}
项目:tregmine    文件:GrinchListener.java   
@EventHandler
public void onGrinchArrowHitPlayer(EntityDamageByEntityEvent e){
    Entity e1 = e.getEntity();
    Entity d1 = e.getDamager();

    if(e.getEntity().getWorld().getName() != "Christmas"){
        return;
    }

    if(e1 instanceof Player && d1 instanceof Arrow){
        if(((Arrow)d1).getShooter() instanceof Giant){
            Player hurt = (Player) e1;
            hurt.setFireTicks(hurt.getFireTicks() + 20);
        }
    }
}
项目:tregmine    文件:GrinchListener.java   
@EventHandler
public void onPlayerDamage(final EntityDamageByEntityEvent e) {
    World w = e.getEntity().getWorld();
    if(e.getEntity().getWorld().getName() != "Christmas"){
        return;
    }
    if (e.getEntity() instanceof Giant) {
        if (e.getDamager() instanceof Player) {
            final Player p = (Player) e.getDamager();
            if(p.getLocation().subtract(0,1,0).getBlock().getType() == Material.AIR){
                e.setCancelled(true);
                Location ALoc = new Location(p.getLocation().getWorld(),p.getLocation().getX(), w.getHighestBlockYAt(p.getLocation()), p.getLocation().getZ(), p.getLocation().getYaw(), p.getLocation().getPitch());
                p.teleport(ALoc);
            }else{
                Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                    public void run() {

                        e.getEntity().getWorld().createExplosion(e.getEntity().getLocation(), 10.0F);
                    }
                },20 * 2);
            }
        }else{
            e.setCancelled(true);
        }
    }
}
项目:OldBukkit    文件:BossListener.java   
@EventHandler
void onDamage(EntityDamageByEntityEvent e) {
    if (Metodos.boss == null) return;

    if (e.getEntity() == Metodos.boss) {
        ((Giant)Metodos.boss).setCustomName(Main.getInstance().getConfig().getString("BossName").replace("&", "§").replace("{vida}", String.valueOf(((Giant) Metodos.boss).getHealth())).replace("<3", "♥").replace("{max}", String.valueOf(Main.getInstance().getConfig().getInt("BossHealth"))));
        e.setDamage((int) (e.getDamage() * 1.3));
    } 
}
项目:tregmine    文件:GrinchListener.java   
public static void spawnGrinchGiant(final Player p, final Block b){
    final Location bLoc = b.getLocation();
    final World w = p.getWorld();

    final Giant g = (Giant)w.spawnEntity(bLoc, EntityType.GIANT);
    g.setCanPickupItems(false);
    g.setCustomName(ChatColor.GREEN + "The Grinch!");
    g.setRemoveWhenFarAway(false);
    g.setMaxHealth(200.0);
    g.setHealth(200.0);
    g.setTarget((LivingEntity)p);
    g.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 1000000, 1000000));

    final int id = plugin.getServer().getScheduler().runTaskTimer(plugin, new Runnable() {
        public void run() {
            final Arrow arrow = ((LivingEntity) g).launchProjectile(Arrow.class);
            arrow.setShooter(((LivingEntity) g));

            if(!(arrow.isOnGround()) || arrow.isDead() == false || arrow.isValid() == true){

                arrow.getWorld().playEffect(arrow.getLocation(), Effect.STEP_SOUND, Material.EMERALD_BLOCK);
                arrow.getWorld().playEffect(arrow.getLocation(), Effect.STEP_SOUND, Material.REDSTONE_BLOCK);
            } 
        }
    }, 1L, 1L).getTaskId();

    Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
        public void run() {
            if (spawnedGrinch == 0){
                plugin.getServer().getScheduler().cancelTask(id);
            }
        }
    }, 0, 20L);
}
项目:WC    文件:MobAttack.java   
public static void giantAttacks(Giant boss, Player damager){
    int attack = r.nextInt(8);
    List<Player> near = new ArrayList<>();

    boss.getNearbyEntities(7, 7, 7).forEach(en -> {
        if (en instanceof Player) {
            near.add((Player) en);
        }
    });

    switch (attack){
        case 0:
            near.forEach(p -> {
                if (!p.equals(damager)) {
                    p.getWorld().strikeLightningEffect(p.getLocation());
                    p.damage(0.5);

                    if (r.nextBoolean()) p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 40, 0));
                    if (r.nextBoolean()) p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 30, 0));
                }
            });

            damager.getWorld().strikeLightningEffect(damager.getLocation());
            damager.damage(0.5);

            if (r.nextBoolean()) damager.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 40, 0));
            if (r.nextBoolean()) damager.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 30, 0));
            break;
        case 1:
            ArrayList<Location> locs = Utils.getCircle(boss.getEyeLocation(), 7, 30);

            locs.forEach(l -> { //Change Color
                ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(100, 60, 50), l, 50);
                ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(200, 60, 50), l.subtract(0, 7, 0), 50);
            });

            near.forEach(p -> {
                if (!p.equals(damager)) {
                    ParticleEffect.EXPLOSION_NORMAL.display(new Vector(0, 0, 0), 4, p.getLocation(), 50);
                    p.damage(0.5);
                }
            });

            ParticleEffect.EXPLOSION_NORMAL.display(new Vector(0, 0, 0), 4, damager.getLocation(), 50);
            damager.damage(0.5);
            break;
        case 2:
            if (boss.getHealth() + 20 >= boss.getMaxHealth()) boss.setHealth(boss.getMaxHealth());
            boss.setHealth(boss.getHealth() + 20);
            break;
        default:
            break;
    }
}
项目:PA    文件:BossAttacks.java   
public static void giantAttacks(Giant boss, Player damager){
    int attack = r.nextInt(8);
    List<Player> near = new ArrayList<>();

    boss.getNearbyEntities(7, 7, 7).forEach(en -> {
        if (en instanceof Player) {
            near.add((Player) en);
        }
    });

    switch (attack){
        case 0:
            near.forEach(p -> {
                if (!p.equals(damager)) {
                    p.getWorld().strikeLightningEffect(p.getLocation());
                    plugin.getHealth().damage(TOA.getPlayer(p), 10);

                    if (r.nextBoolean()) p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 40, 0));
                    if (r.nextBoolean()) p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 30, 0));
                }
            });

            damager.getWorld().strikeLightningEffect(damager.getLocation());
            plugin.getHealth().damage(TOA.getPlayer(damager), 20);

            if (r.nextBoolean()) damager.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 40, 0));
            if (r.nextBoolean()) damager.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 30, 0));
            break;
        case 1:
            ArrayList<Location> locs = Utils.getCircle(boss.getEyeLocation(), 7, 30);

            locs.forEach(l -> {
                ParticleEffect.REDSTONE.sendColor(plugin.getServer().getOnlinePlayers(), l, Color.fromBGR(100, 60, 50));
                ParticleEffect.REDSTONE.sendColor(plugin.getServer().getOnlinePlayers(), l.subtract(0, 7, 0), Color.fromBGR(200, 60, 50));
            });

            near.forEach(p -> {
                if (!p.equals(damager)) {
                    ParticleEffect.EXPLOSION_NORMAL.send(plugin.getServer().getOnlinePlayers(), p.getLocation(), 0, 0, 0, 1, 10);
                    plugin.getHealth().damage(TOA.getPlayer(p), 30);
                }
            });
            ParticleEffect.EXPLOSION_NORMAL.send(plugin.getServer().getOnlinePlayers(), damager.getLocation(), 0, 0, 0, 1, 10);
            plugin.getHealth().damage(TOA.getPlayer(damager), 30);
            break;
        case 2:
            if (boss.getHealth() + 20 >= boss.getMaxHealth()) boss.setHealth(boss.getMaxHealth());
            boss.setHealth(boss.getHealth() + 20);
            break;
        default:
            break;
    }
}
项目:OldBukkit    文件:Metodos.java   
public static int getBossHealth() {
    if (boss == null) {
        return 0;
    }
    return ((Giant) boss).getHealth();
}
项目:OldBukkit    文件:BossListener.java   
@EventHandler
void onBossDeath(EntityDeathEvent e) {
    if (e.getEntity().getKiller() instanceof Player && e.getEntity() instanceof Giant && isAcontecendo()) {
        setGanhador(e.getEntity().getKiller());
    }
}
项目:PA    文件:Boss.java   
public void bossGiant() {
    Giant giant = (Giant) l.getWorld().spawnEntity(l, EntityType.GIANT);

    giant.setMaxHealth(1500);
    giant.setHealth(giant.getMaxHealth());

    giant.setCustomName("Zombie Gigante");

    giant.teleport(l);
}