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


Java DamageCause.SUFFOCATION属性代码示例

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


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

示例1: onEntityDamage

@EventHandler
public void onEntityDamage(final EntityDamageEvent event) {

	if (event.getCause() == DamageCause.DROWNING || event.getCause() == DamageCause.SUFFOCATION || event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.LAVA) {

		// Ok so an entity damage event begins
		// Find the nearest gate!
		final WorldCoord entityCoord = new WorldCoord(event.getEntity().getLocation());
		final WorldCoord entityCoordUp = new WorldCoord(event.getEntity().getLocation().getBlock().getRelative(BlockFace.UP));
		final Gate nearestGate = GateUtil.nearestGate(entityCoord, false);
		final Gate nearestGateUp = GateUtil.nearestGate(entityCoordUp, false);

		if (nearestGate != null || nearestGateUp != null) {
			event.setCancelled(true);
			event.getEntity().setFireTicks(0);
		}
	}
}
 
开发者ID:NoChanceSD,项目名称:AncientGates,代码行数:18,代码来源:PluginEntityListener.java

示例2: toBukkit

public static DamageCause toBukkit(cn.nukkit.event.entity.EntityDamageEvent.DamageCause nukkit) {
	// TODO Direct mapping via DamageCause.valueOf?
	switch (nukkit) {
		case CONTACT:
			return DamageCause.CONTACT;
		case ENTITY_ATTACK:
			return DamageCause.ENTITY_ATTACK;
		case PROJECTILE:
			return DamageCause.PROJECTILE;
		case SUFFOCATION:
			return DamageCause.SUFFOCATION;
		case FALL:
			return DamageCause.FALL;
		case FIRE:
			return DamageCause.FIRE;
		case FIRE_TICK:
			return DamageCause.FIRE_TICK;
		case LAVA:
			return DamageCause.LAVA;
		case DROWNING:
			return DamageCause.DROWNING;
		case BLOCK_EXPLOSION:
			return DamageCause.BLOCK_EXPLOSION;
		case ENTITY_EXPLOSION:
			return DamageCause.ENTITY_EXPLOSION;
		case VOID:
			return DamageCause.VOID;
		case SUICIDE:
			return DamageCause.SUICIDE;
		case MAGIC:
			return DamageCause.MAGIC;
		case LIGHTNING:
			return DamageCause.LIGHTNING;
		case CUSTOM:
		default:
			return DamageCause.CUSTOM;
	}
}
 
开发者ID:rutgerkok,项目名称:Pokkit,代码行数:38,代码来源:PokkitDamageCause.java

示例3: onEntityDamage

@EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event)
{
	
	//cancel if on periscope
	if( event.getEntity() instanceof Player )
	{
		Player player = (Player)event.getEntity();


		for( Periscope p: NavyCraft.allPeriscopes )
		{
			if( p.user == player )
			{
				event.setCancelled(true);
    			return;
			}
		}
		
		if( event.getCause() == DamageCause.SUFFOCATION )
		{
			Craft c = Craft.getCraft(player.getLocation().getBlockX(),player.getLocation().getBlockY(), player.getLocation().getBlockZ());
			if( c != null )
			{
				event.setCancelled(true);
    			return;
			}
				
		}
		
	}
	
	if ( event instanceof EntityDamageByEntityEvent ) 
	{


		Entity attacker = ((EntityDamageByEntityEvent) event).getDamager();
		if( attacker instanceof Egg )
		{
			if( NavyCraft.explosiveEggsList.contains((Egg)attacker) )
			{	
				event.setDamage(5);
			}
		}
	}

}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:47,代码来源:MoveCraft_EntityListener.java

示例4: damageEntity

@Override
public boolean damageEntity(DamageSource source, float damage) {
    if (invulnerable || noDamageTicks > 0) {
        return false;
    }

    DamageCause cause = null;
    org.bukkit.entity.Entity bEntity = null;
    if (source instanceof EntityDamageSource) {
        Entity damager = source.getEntity();
        cause = DamageCause.ENTITY_ATTACK;
        if (source instanceof EntityDamageSourceIndirect) {
            damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
            if (damager.getBukkitEntity() instanceof ThrownPotion) {
                cause = DamageCause.MAGIC;
            } else if (damager.getBukkitEntity() instanceof Projectile) {
                cause = DamageCause.PROJECTILE;
            }
        }

        bEntity = damager.getBukkitEntity();
    } else if (source == DamageSource.FIRE)
        cause = DamageCause.FIRE;
    else if (source == DamageSource.STARVE)
        cause = DamageCause.STARVATION;
    else if (source == DamageSource.WITHER)
        cause = DamageCause.WITHER;
    else if (source == DamageSource.STUCK)
        cause = DamageCause.SUFFOCATION;
    else if (source == DamageSource.DROWN)
        cause = DamageCause.DROWNING;
    else if (source == DamageSource.BURN)
        cause = DamageCause.FIRE_TICK;
    else if (source == CraftEventFactory.MELTING)
        cause = DamageCause.MELTING;
    else if (source == CraftEventFactory.POISON)
        cause = DamageCause.POISON;
    else if (source == DamageSource.MAGIC) {
        cause = DamageCause.MAGIC;
    } else if (source == DamageSource.OUT_OF_WORLD) {
        cause = DamageCause.VOID;
    }

    if (cause != null) {
        NPCDamageEvent event = new NPCDamageEvent(npc, bEntity, cause, (double) damage);
        Bukkit.getPluginManager().callEvent(event);
        if (!event.isCancelled()) {
            return super.damageEntity(source, (float) event.getDamage());
        } else {
            return false;
        }
    }

    if (super.damageEntity(source, damage)) {
        if (bEntity != null) {
            Entity e = ((CraftEntity) bEntity).getHandle();
            double d0 = e.locX - this.locX;

            double d1;
            for (d1 = e.locZ - this.locZ; d0 * d0 + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) {
                d0 = (Math.random() - Math.random()) * 0.01D;
            }

            a(e, damage, d0, d1);
        }

        return true;
    } else {
        return false;
    }
}
 
开发者ID:johnnywoof,项目名称:NoHack,代码行数:71,代码来源:NPCEntity.java

示例5: damageEntity

@Override
public boolean damageEntity(DamageSource source, float damage) {
    if(godmode || noDamageTicks > 0) {
        return false;
    }

    DamageCause cause = null;
    org.bukkit.entity.Entity bEntity = null;
    if(source instanceof EntityDamageSource) {
        Entity damager = source.getEntity();
        cause = DamageCause.ENTITY_ATTACK;
        if(source instanceof EntityDamageSourceIndirect) {
            damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
            if(damager.getBukkitEntity() instanceof ThrownPotion) {
                cause = DamageCause.MAGIC;
            } else if(damager.getBukkitEntity() instanceof Projectile) {
                cause = DamageCause.PROJECTILE;
            }
        }

        bEntity = damager.getBukkitEntity();
    } else if(source == DamageSource.FIRE)
        cause = DamageCause.FIRE;
    else if(source == DamageSource.STARVE)
        cause = DamageCause.STARVATION;
    else if(source == DamageSource.WITHER)
        cause = DamageCause.WITHER;
    else if(source == DamageSource.STUCK)
        cause = DamageCause.SUFFOCATION;
    else if(source == DamageSource.DROWN)
        cause = DamageCause.DROWNING;
    else if(source == DamageSource.BURN)
        cause = DamageCause.FIRE_TICK;
    else if(source == CraftEventFactory.MELTING)
        cause = DamageCause.MELTING;
    else if(source == CraftEventFactory.POISON)
        cause = DamageCause.POISON;
    else if(source == DamageSource.MAGIC) {
        cause = DamageCause.MAGIC;
    } else if(source == DamageSource.OUT_OF_WORLD) {
        cause = DamageCause.VOID;
    }

    if(cause != null) {
        NPCDamageEvent event = new NPCDamageEvent(this, bEntity, cause, (double) damage);
        Bukkit.getPluginManager().callEvent(event);
        if(!event.isCancelled()) {
            return super.damageEntity(source, (float) event.getDamage());
        } else {
            return false;
        }
    }

    if(super.damageEntity(source, damage)) {
        if(bEntity != null) {
            Entity e = ((CraftEntity) bEntity).getHandle();
            double d0 = e.locX - this.locX;

            double d1;
            for(d1 = e.locZ - this.locZ; d0 * d0 + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) {
                d0 = (Math.random() - Math.random()) * 0.01D;
            }

            a(e, damage, d0, d1);
        }

        return true;
    } else {
        return false;
    }
}
 
开发者ID:lenis0012,项目名称:NPCFactory,代码行数:71,代码来源:NPCEntity.java

示例6: onSteveHurt

@EventHandler
public void onSteveHurt(EntityDamageEvent e) {
	if(e.getEntity() instanceof Player) {
		Player p = (Player) e.getEntity();
		//p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
		if(e.getCause() == DamageCause.BLOCK_EXPLOSION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.DROWNING) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.ENTITY_ATTACK) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.ENTITY_EXPLOSION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.FALL) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.FALLING_BLOCK) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.FIRE_TICK) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.LIGHTNING) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.MELTING) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.POISON) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.PROJECTILE) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.STARVATION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.SUFFOCATION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.SUICIDE) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.THORNS) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.VOID) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.WITHER) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		}
	}
}
 
开发者ID:xize,项目名称:xEssentials_old_Source,代码行数:59,代码来源:steveHurtSound.java


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