use of net.minecraft.entity.boss.dragon.EnderDragonEntity in project BluePower by Qmunity.
the class BPEventHandler method onEntityAttack.
@SubscribeEvent
public void onEntityAttack(LivingAttackEvent event) {
if (!isAttacking && event.getSource() instanceof EntityDamageSource) {
// this event will be trigger recursively by EntityLiving#hurt,
// so we need to stop the loop.
EntityDamageSource entitySource = (EntityDamageSource) event.getSource();
if (entitySource.getEntity() instanceof PlayerEntity) {
PlayerEntity killer = (PlayerEntity) entitySource.getEntity();
if (!killer.inventory.getSelected().isEmpty()) {
if (EnchantmentHelper.getEnchantments(killer.inventory.getSelected()).containsKey(BPEnchantments.disjunction)) {
if (event.getEntityLiving() instanceof EndermanEntity || event.getEntityLiving() instanceof EnderDragonEntity) {
int level = EnchantmentHelper.getItemEnchantmentLevel(BPEnchantments.disjunction, killer.inventory.getSelected());
isAttacking = true;
event.getEntityLiving().hurt(event.getSource(), event.getAmount() * (level * 0.5F + 1));
isAttacking = false;
}
}
}
}
}
}
Aggregations