Search in sources :

Example 11 with DamageSource

use of net.minecraft.entity.damage.DamageSource in project Paradise-Lost by devs-immortal.

the class FloatingBlockEntity method handleFallDamage.

@Override
public boolean handleFallDamage(float distance, float damageMultiplier) {
    if (this.hurtEntities) {
        int i = MathHelper.ceil(distance - 1.0F);
        if (i > 0) {
            List<Entity> list = Lists.newArrayList(this.world.getOtherEntities(this, this.getBoundingBox()));
            boolean flag = this.blockState.isIn(BlockTags.ANVIL);
            DamageSource damagesource = flag ? DamageSource.ANVIL : DamageSource.FALLING_BLOCK;
            for (Entity entity : list) entity.damage(damagesource, Math.min(MathHelper.floor(i * this.floatHurtAmount), this.floatHurtMax));
            if (flag && this.random.nextFloat() < 0.05F + i * 0.05F) {
                BlockState blockstate = AnvilBlock.getLandingState(this.blockState);
                if (blockstate == null)
                    this.destroyedOnLanding = true;
                else
                    this.blockState = blockstate;
            }
        }
    }
    return false;
}
Also used : BlockEntity(net.minecraft.block.entity.BlockEntity) AetherNonLivingEntity(com.aether.entities.AetherNonLivingEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) DamageSource(net.minecraft.entity.damage.DamageSource)

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