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


Java Giant.setHealth方法代码示例

本文整理汇总了Java中org.bukkit.entity.Giant.setHealth方法的典型用法代码示例。如果您正苦于以下问题:Java Giant.setHealth方法的具体用法?Java Giant.setHealth怎么用?Java Giant.setHealth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Giant的用法示例。


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

示例1: spawnGrinchGiant

import org.bukkit.entity.Giant; //导入方法依赖的package包/类
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);
}
 
开发者ID:EmilHernvall,项目名称:tregmine,代码行数:35,代码来源:GrinchListener.java

示例2: giantAttacks

import org.bukkit.entity.Giant; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:cadox8,项目名称:WC,代码行数:55,代码来源:MobAttack.java

示例3: giantAttacks

import org.bukkit.entity.Giant; //导入方法依赖的package包/类
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;
    }
}
 
开发者ID:cadox8,项目名称:PA,代码行数:54,代码来源:BossAttacks.java

示例4: bossGiant

import org.bukkit.entity.Giant; //导入方法依赖的package包/类
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);
}
 
开发者ID:cadox8,项目名称:PA,代码行数:11,代码来源:Boss.java


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