Search in sources :

Example 6 with DamageSource

use of net.minecraft.entity.damage.DamageSource in project MCDungeonsWeapons by chronosacaria.

the class AOEHelper method electrocute.

public static void electrocute(LivingEntity attacker, LivingEntity victim, float damageAmount) {
    createVisualLightningBoltOnEntity(victim);
    DamageSource electricShockDamageSource = new ElectricShockDamageSource(attacker).setUsesMagic();
    victim.damage(electricShockDamageSource, damageAmount);
}
Also used : ElectricShockDamageSource(chronosacaria.mcdw.damagesource.ElectricShockDamageSource) DamageSource(net.minecraft.entity.damage.DamageSource) ElectricShockDamageSource(chronosacaria.mcdw.damagesource.ElectricShockDamageSource)

Example 7 with DamageSource

use of net.minecraft.entity.damage.DamageSource in project MCDoom by AzureDoom.

the class EnergyCellEntity method onEntityHit.

@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
    Entity entity = entityHitResult.getEntity();
    if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
    Entity entity2 = this.getOwner();
    DamageSource damageSource2;
    if (entity2 == null) {
        damageSource2 = DamageSource.arrow(this, this);
    } else {
        damageSource2 = DamageSource.arrow(this, entity2);
        if (entity2 instanceof LivingEntity) {
            ((LivingEntity) entity2).onAttacking(entity);
        }
    }
    if (entity.damage(damageSource2, projectiledamage)) {
        if (entity instanceof LivingEntity) {
            LivingEntity livingEntity = (LivingEntity) entity;
            if (!this.world.isClient && entity2 instanceof LivingEntity) {
                EnchantmentHelper.onUserDamaged(livingEntity, entity2);
                EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
                this.remove(Entity.RemovalReason.DISCARDED);
            }
            this.onHit(livingEntity);
            if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
                ((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
            }
        }
    } else {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) GameStateChangeS2CPacket(net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket) DamageSource(net.minecraft.entity.damage.DamageSource) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 8 with DamageSource

use of net.minecraft.entity.damage.DamageSource in project MCDoom by AzureDoom.

the class UnmaykrBoltEntity method onEntityHit.

@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
    Entity entity = entityHitResult.getEntity();
    if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
    Entity entity2 = this.getOwner();
    DamageSource damageSource2;
    if (entity2 == null) {
        damageSource2 = DamageSource.magic(this, this);
    } else {
        damageSource2 = DamageSource.magic(this, entity2);
        if (entity2 instanceof LivingEntity) {
            ((LivingEntity) entity2).onAttacking(entity);
        }
    }
    if (entity.damage(damageSource2, projectiledamage)) {
        if (entity instanceof LivingEntity) {
            LivingEntity livingEntity = (LivingEntity) entity;
            if (!this.world.isClient && entity2 instanceof LivingEntity) {
                EnchantmentHelper.onUserDamaged(livingEntity, entity2);
                EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
                this.remove(Entity.RemovalReason.DISCARDED);
            }
            this.onHit(livingEntity);
            if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
                ((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
            }
        }
    } else {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) BlockEntity(net.minecraft.block.entity.BlockEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) TickingLightEntity(mod.azure.doom.entity.tileentity.TickingLightEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) GameStateChangeS2CPacket(net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket) DamageSource(net.minecraft.entity.damage.DamageSource) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 9 with DamageSource

use of net.minecraft.entity.damage.DamageSource in project MCDoom by AzureDoom.

the class ArgentBoltEntity method onEntityHit.

@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
    Entity entity = entityHitResult.getEntity();
    if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
    Entity entity2 = this.getOwner();
    DamageSource damageSource2;
    if (entity2 == null) {
        damageSource2 = DamageSource.arrow(this, this);
    } else {
        damageSource2 = DamageSource.arrow(this, entity2);
        if (entity2 instanceof LivingEntity) {
            ((LivingEntity) entity2).onAttacking(entity);
        }
    }
    if (entity.damage(damageSource2, DoomMod.config.weapons.argent_bolt_damage)) {
        if (entity instanceof LivingEntity) {
            LivingEntity livingEntity = (LivingEntity) entity;
            if (!this.world.isClient && entity2 instanceof LivingEntity) {
                EnchantmentHelper.onUserDamaged(livingEntity, entity2);
                EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
                this.world.createExplosion(this, this.getX(), this.getBodyY(0.0625D), this.getZ(), 1.5F, Explosion.DestructionType.NONE);
            }
            this.remove(Entity.RemovalReason.DISCARDED);
            this.onHit(livingEntity);
            if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
                ((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
            }
        }
    } else {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) BlockEntity(net.minecraft.block.entity.BlockEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) TickingLightEntity(mod.azure.doom.entity.tileentity.TickingLightEntity) AreaEffectCloudEntity(net.minecraft.entity.AreaEffectCloudEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) GameStateChangeS2CPacket(net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket) DamageSource(net.minecraft.entity.damage.DamageSource) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 10 with DamageSource

use of net.minecraft.entity.damage.DamageSource in project MCDoom by AzureDoom.

the class BulletEntity method onEntityHit.

@Override
protected void onEntityHit(EntityHitResult entityHitResult) {
    Entity entity = entityHitResult.getEntity();
    if (entityHitResult.getType() != HitResult.Type.ENTITY || !((EntityHitResult) entityHitResult).getEntity().isPartOf(entity)) {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
    Entity entity2 = this.getOwner();
    DamageSource damageSource2;
    if (entity2 == null) {
        damageSource2 = DamageSource.arrow(this, this);
    } else {
        damageSource2 = DamageSource.arrow(this, entity2);
        if (entity2 instanceof LivingEntity) {
            ((LivingEntity) entity2).onAttacking(entity);
        }
    }
    if (entity.damage(damageSource2, projectiledamage)) {
        if (entity instanceof LivingEntity) {
            LivingEntity livingEntity = (LivingEntity) entity;
            if (!this.world.isClient && entity2 instanceof LivingEntity) {
                EnchantmentHelper.onUserDamaged(livingEntity, entity2);
                EnchantmentHelper.onTargetDamaged((LivingEntity) entity2, livingEntity);
                this.remove(Entity.RemovalReason.DISCARDED);
            }
            this.onHit(livingEntity);
            if (entity2 != null && livingEntity != entity2 && livingEntity instanceof PlayerEntity && entity2 instanceof ServerPlayerEntity && !this.isSilent()) {
                ((ServerPlayerEntity) entity2).networkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.PROJECTILE_HIT_PLAYER, 0.0F));
            }
        }
    } else {
        if (!this.world.isClient) {
            this.remove(Entity.RemovalReason.DISCARDED);
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) GameStateChangeS2CPacket(net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket) DamageSource(net.minecraft.entity.damage.DamageSource) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Aggregations

DamageSource (net.minecraft.entity.damage.DamageSource)11 PlayerEntity (net.minecraft.entity.player.PlayerEntity)8 LivingEntity (net.minecraft.entity.LivingEntity)7 IconofsinEntity (mod.azure.doom.entity.tierboss.IconofsinEntity)6 Entity (net.minecraft.entity.Entity)6 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)6 GameStateChangeS2CPacket (net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket)6 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)6 BlockEntity (net.minecraft.block.entity.BlockEntity)3 TickingLightEntity (mod.azure.doom.entity.tileentity.TickingLightEntity)2 ItemStack (net.minecraft.item.ItemStack)2 ElectricShockDamageSource (chronosacaria.mcdw.damagesource.ElectricShockDamageSource)1 AetherNonLivingEntity (com.aether.entities.AetherNonLivingEntity)1 SlotReference (dev.emi.trinkets.api.SlotReference)1 TrinketsApi (dev.emi.trinkets.api.TrinketsApi)1 List (java.util.List)1 DoomItems (mod.azure.doom.util.registry.DoomItems)1 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)1 ItemEntity (net.minecraft.entity.ItemEntity)1 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)1