Search in sources :

Example 1 with ISpaceMob

use of stevekung.mods.moreplanets.utils.entity.ISpaceMob in project MorePlanets by SteveKunG.

the class BlockInfectedVines method onEntityCollision.

@Override
public void onEntityCollision(World world, BlockPos pos, IBlockState state, Entity entity) {
    if (entity instanceof EntityLivingBase) {
        EntityLivingBase living = (EntityLivingBase) entity;
        if (living instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) entity;
            InventoryPlayer inventory = player.inventory;
            for (int i = 0; i < 4; i++) {
                if (inventory.armorInventory.get(i).isEmpty() || !(inventory.armorInventory.get(i).getItem() instanceof ItemArmor)) {
                    if (!player.capabilities.isCreativeMode) {
                        player.attackEntityFrom(DamageSourceMP.INFECTED_GAS, (int) (4.0D * 0.1D + 1.0D));
                        player.addPotionEffect(new PotionEffect(MobEffects.POISON, 50, 1));
                    }
                }
            }
        }
        if (!(living instanceof EntityPlayer) && !(entity instanceof ISpaceMob && ((ISpaceMob) entity).getMobType() == EnumMobType.NIBIRU)) {
            living.attackEntityFrom(DamageSourceMP.INFECTED_GAS, (int) (4.0D * 0.1D + 1.0D));
            living.addPotionEffect(new PotionEffect(MobEffects.POISON, 50, 1));
        }
    }
}
Also used : InventoryPlayer(net.minecraft.entity.player.InventoryPlayer) ISpaceMob(stevekung.mods.moreplanets.utils.entity.ISpaceMob) PotionEffect(net.minecraft.potion.PotionEffect) ItemArmor(net.minecraft.item.ItemArmor) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1 ItemArmor (net.minecraft.item.ItemArmor)1 PotionEffect (net.minecraft.potion.PotionEffect)1 ISpaceMob (stevekung.mods.moreplanets.utils.entity.ISpaceMob)1