Java Code Examples for cn.nukkit.event.entity.EntityDamageEvent#getCause()
The following examples show how to use
cn.nukkit.event.entity.EntityDamageEvent#getCause() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnchantmentProtectionFall.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public float getProtectionFactor(EntityDamageEvent e) { DamageCause cause = e.getCause(); if (level <= 0 || (cause != DamageCause.FALL)) { return 0; } return (float) (getLevel() * getTypeModifier()); }
Example 2
Source File: EnchantmentProtectionExplosion.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public float getProtectionFactor(EntityDamageEvent e) { DamageCause cause = e.getCause(); if (level <= 0 || (cause != DamageCause.ENTITY_EXPLOSION && cause != DamageCause.BLOCK_EXPLOSION)) { return 0; } return (float) (getLevel() * getTypeModifier()); }
Example 3
Source File: Player.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean attack(EntityDamageEvent source) { if (!this.isAlive()) { return false; } if (this.isSpectator() || (this.isCreative() && source.getCause() != DamageCause.SUICIDE)) { //source.setCancelled(); return false; } else if (this.getAdventureSettings().get(Type.ALLOW_FLIGHT) && source.getCause() == DamageCause.FALL) { //source.setCancelled(); return false; } else if (source.getCause() == DamageCause.FALL) { if (this.getLevel().getBlock(this.getPosition().floor().add(0.5, -1, 0.5)).getId() == Block.SLIME_BLOCK) { if (!this.isSneaking()) { //source.setCancelled(); this.resetFallDistance(); return false; } } } if (super.attack(source)) { //!source.isCancelled() if (this.getLastDamageCause() == source && this.spawned) { if (source instanceof EntityDamageByEntityEvent) { Entity damager = ((EntityDamageByEntityEvent) source).getDamager(); if (damager instanceof Player) { ((Player) damager).getFoodData().updateFoodExpLevel(0.3); } } EntityEventPacket pk = new EntityEventPacket(); pk.eid = this.id; pk.event = EntityEventPacket.HURT_ANIMATION; this.dataPacket(pk); } return true; } else { return false; } }
Example 4
Source File: EnchantmentProtectionProjectile.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public float getProtectionFactor(EntityDamageEvent e) { DamageCause cause = e.getCause(); if (level <= 0 || (cause != DamageCause.PROJECTILE)) { return 0; } return (float) (getLevel() * getTypeModifier()); }
Example 5
Source File: EntityItem.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean attack(EntityDamageEvent source) { return (source.getCause() == DamageCause.VOID || source.getCause() == DamageCause.FIRE_TICK || source.getCause() == DamageCause.ENTITY_EXPLOSION || source.getCause() == DamageCause.BLOCK_EXPLOSION) && super.attack(source); }
Example 6
Source File: EntityEndCrystal.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean attack(EntityDamageEvent source) { if (source.getCause() == EntityDamageEvent.DamageCause.FIRE || source.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK || source.getCause() == EntityDamageEvent.DamageCause.LAVA) { return false; } if (!super.attack(source)) { return false; } explode(); return true; }
Example 7
Source File: EntityFirework.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean attack(EntityDamageEvent source) { return (source.getCause() == DamageCause.VOID || source.getCause() == DamageCause.FIRE_TICK || source.getCause() == DamageCause.ENTITY_EXPLOSION || source.getCause() == DamageCause.BLOCK_EXPLOSION) && super.attack(source); }
Example 8
Source File: EntityXPOrb.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean attack(EntityDamageEvent source) { return (source.getCause() == DamageCause.VOID || source.getCause() == DamageCause.FIRE_TICK || (source.getCause() == DamageCause.ENTITY_EXPLOSION || source.getCause() == DamageCause.BLOCK_EXPLOSION) && !this.isInsideOfWater()) && super.attack(source); }
Example 9
Source File: EntityItem.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean attack(EntityDamageEvent source) { return (source.getCause() == DamageCause.VOID || source.getCause() == DamageCause.CONTACT || source.getCause() == DamageCause.FIRE_TICK || (source.getCause() == DamageCause.ENTITY_EXPLOSION || source.getCause() == DamageCause.BLOCK_EXPLOSION) && !this.isInsideOfWater() && (this.item == null || this.item.getId() != Item.NETHER_STAR)) && super.attack(source); }
Example 10
Source File: EntityItem.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean attack(EntityDamageEvent source) { return (source.getCause() == DamageCause.VOID || source.getCause() == DamageCause.FIRE_TICK || source.getCause() == DamageCause.ENTITY_EXPLOSION || source.getCause() == DamageCause.BLOCK_EXPLOSION) && super.attack(source); }
Example 11
Source File: EnchantmentProtectionFire.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public float getDamageProtection(EntityDamageEvent e) { DamageCause cause = e.getCause(); if (level <= 0 || (cause != DamageCause.LAVA && cause != DamageCause.FIRE && cause != DamageCause.FIRE_TICK)) { return 0; } return (float) (getLevel() * getTypeModifier()); }
Example 12
Source File: EnchantmentProtectionExplosion.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public float getDamageProtection(EntityDamageEvent e) { DamageCause cause = e.getCause(); if (level <= 0 || (cause != DamageCause.ENTITY_EXPLOSION && cause != DamageCause.BLOCK_EXPLOSION)) { return 0; } return (float) (getLevel() * getTypeModifier()); }
Example 13
Source File: EntityXPOrb.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public boolean attack(EntityDamageEvent source) { return (source.getCause() == DamageCause.VOID || source.getCause() == DamageCause.FIRE_TICK || source.getCause() == DamageCause.ENTITY_EXPLOSION || source.getCause() == DamageCause.BLOCK_EXPLOSION) && super.attack(source); }
Example 14
Source File: EnchantmentProtectionFall.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public float getDamageProtection(EntityDamageEvent e) { DamageCause cause = e.getCause(); if (level <= 0 || (cause != DamageCause.FALL)) { return 0; } return (float) (getLevel() * getTypeModifier()); }
Example 15
Source File: EnchantmentProtectionFire.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public float getDamageProtection(EntityDamageEvent e) { DamageCause cause = e.getCause(); if (level <= 0 || (cause != DamageCause.LAVA && cause != DamageCause.FIRE && cause != DamageCause.FIRE_TICK)) { return 0; } return (float) (getLevel() * getTypeModifier()); }
Example 16
Source File: EnchantmentProtectionExplosion.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public float getDamageProtection(EntityDamageEvent e) { DamageCause cause = e.getCause(); if (level <= 0 || (cause != DamageCause.ENTITY_EXPLOSION && cause != DamageCause.BLOCK_EXPLOSION)) { return 0; } return (float) (getLevel() * getTypeModifier()); }
Example 17
Source File: EnchantmentProtectionProjectile.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public float getDamageProtection(EntityDamageEvent e) { DamageCause cause = e.getCause(); if (level <= 0 || (cause != DamageCause.PROJECTILE)) { return 0; } return (float) (getLevel() * getTypeModifier()); }
Example 18
Source File: EntityXPOrb.java From Jupiter with GNU General Public License v3.0 | 5 votes |
@Override public boolean attack(EntityDamageEvent source) { return (source.getCause() == DamageCause.VOID || source.getCause() == DamageCause.FIRE_TICK || source.getCause() == DamageCause.ENTITY_EXPLOSION || source.getCause() == DamageCause.BLOCK_EXPLOSION) && super.attack(source); }
Example 19
Source File: EntityFallingBlock.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public boolean attack(EntityDamageEvent source) { return source.getCause() == DamageCause.VOID && super.attack(source); }
Example 20
Source File: EntityFallingBlock.java From Jupiter with GNU General Public License v3.0 | 4 votes |
@Override public boolean attack(EntityDamageEvent source) { return source.getCause() == DamageCause.VOID && super.attack(source); }