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


Java LivingEntity.addPotionEffect方法代码示例

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


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

示例1: onAttack

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
	if(event.isCancelled()) return;
	if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
	{
		Player player = (Player)event.getDamager();
		ItemStack mainItem = player.getInventory().getItemInMainHand();
		LivingEntity enemy = (LivingEntity)event.getEntity();

		Random rand = new Random();
		
		if(mainItem.getType() == Material.GOLD_AXE)
		{
			enemy.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 480, 2, false));
			enemy.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 480, 0, false));
           	enemy.getLocation().getWorld().playSound(enemy.getLocation(), Sound.ENTITY_WITHER_SPAWN, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:21,代码来源:StarBattleaxeWither.java

示例2: onPotionSplash

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
 * Patching witch's potions
 *
 * @param event Event
 */
@EventHandler
public void onPotionSplash(PotionSplashEvent event)
{
    ThrownPotion potion = event.getPotion();

    if (potion.getShooter() instanceof Witch)
    {
        event.setCancelled(true);

        List<PotionEffectType> potionEffects = new ArrayList<>();
        potionEffects.add(PotionEffectType.SLOW_DIGGING);
        potionEffects.add(PotionEffectType.CONFUSION);
        potionEffects.add(PotionEffectType.NIGHT_VISION);
        potionEffects.add(PotionEffectType.HUNGER);
        potionEffects.add(PotionEffectType.BLINDNESS);

        PotionEffect selected = new PotionEffect(potionEffects.get(new Random().nextInt(potionEffects.size())), 20 * 15, 1);

        for (LivingEntity ent : event.getAffectedEntities())
            ent.addPotionEffect(selected);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:28,代码来源:NaturalListener.java

示例3: execute

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@Override
public void execute(KingdomFactionsPlayer player) {

	setLocation(player.getPlayer().getTargetBlock((Set<Material>) null, 80).getLocation());

	SpellExecuteEvent event = new SpellExecuteEvent(executeLocation, this, player);
	if (event.isCancelled())
		return;
	playEffect(executeLocation);
	for (Entity e : Utils.getInstance().getNearbyEntities(executeLocation, 3)) {
		if (e instanceof LivingEntity) {
			LivingEntity en = (LivingEntity) e;

			if (e instanceof Player) {
				Player p = (Player) e;
				if (PlayerModule.getInstance().getPlayer(p).isVanished()) continue;
			    en.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 5 * 20, 1));
			    en.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 5 * 20, 1));
			    en.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 5 * 20, 1));
			}
		}
	}

}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:25,代码来源:Confuse.java

示例4: onAttack

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onAttack(EntityDamageByEntityEvent event)
{
	if(event.isCancelled()) return;
	if(event.getDamager() instanceof Player && event.getEntity() instanceof LivingEntity && event.getCause() == DamageCause.ENTITY_ATTACK)
	{
		Player player = (Player)event.getDamager();
		ItemStack mainItem = player.getInventory().getItemInMainHand();
		LivingEntity enemy = (LivingEntity)event.getEntity();
		
		if(mainItem.getType() == Material.GOLD_SPADE)
		{
			enemy.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 100, 0, false));
			enemy.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 0, false));
			player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 48, 2, true));
			Location particleLoc = player.getLocation();
			particleLoc.setY(particleLoc.getY() + 2);
               ParticleEffect.HEART.display(0.5f, 0, 0.5f, 1, 2, particleLoc, 64);
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:22,代码来源:ObsidianMaceWeakness.java

示例5: spawn

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_8_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:18,代码来源:CustomRabbit.java

示例6: onPotionEffectAdd

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPotionEffectAdd(PotionEffectAddEvent event) {
    LivingEntity entity = event.getEntity();
    if (entity instanceof Player && event.getCause() == PotionEffectAddEvent.EffectCause.BEACON) {
        PotionEffect effect = event.getEffect();
        if (effect.getAmplifier() > 1 && effect.getType().equals(PotionEffectType.INCREASE_DAMAGE)) {
            entity.addPotionEffect(new PotionEffect(effect.getType(), effect.getDuration(), 0, effect.isAmbient()));
            event.setCancelled(true);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:12,代码来源:BeaconStrengthFixListener.java

示例7: spawn

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_9_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:18,代码来源:CustomRabbit.java

示例8: spawn

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_9_R2.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:18,代码来源:CustomRabbit.java

示例9: apply

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@Override
public void apply(LivingEntity entity) {
    if (this.getFromId() != null && entity.hasPotionEffect(this.getFromId())) {
        entity.removePotionEffect(this.getFromId());
    }
    entity.addPotionEffect(new PotionEffect(this.getFromId(), this.duration, this.strength, this.ambient));
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:8,代码来源:FastPotioneffect.java

示例10: spawn

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_10_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:18,代码来源:CustomZombie.java

示例11: spawn

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_12_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:18,代码来源:CustomRabbit.java

示例12: spawn

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_12_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:18,代码来源:CustomZombie.java

示例13: spawn

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_11_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:18,代码来源:CustomRabbit.java

示例14: spawn

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_11_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:18,代码来源:CustomZombie.java

示例15: spawn

import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_8_R3.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:18,代码来源:CustomRabbit.java


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