Search in sources :

Example 51 with PotionEffect

use of net.minecraft.potion.PotionEffect in project BaseMetals by MinecraftModDevelopmentMods.

the class TraitToxic method afterHit.

@Override
public void afterHit(@Nonnull final ItemStack tool, @Nonnull final EntityLivingBase player, @Nonnull final EntityLivingBase target, @Nonnull final float damageDealt, @Nonnull final boolean wasCritical, @Nonnull final boolean wasHit) {
    if (wasHit && target.isEntityAlive()) {
        target.addPotionEffect(new PotionEffect(MobEffects.POISON, 100, 2));
        target.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 50));
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect)

Example 52 with PotionEffect

use of net.minecraft.potion.PotionEffect in project BaseMetals by MinecraftModDevelopmentMods.

the class ModifierToxic method afterHit.

@Override
public void afterHit(@Nonnull final ItemStack tool, @Nonnull final EntityLivingBase player, @Nonnull final EntityLivingBase target, @Nonnull final float damageDealt, @Nonnull final boolean wasCritical, @Nonnull final boolean wasHit) {
    if (wasHit && target.isEntityAlive()) {
        target.addPotionEffect(new PotionEffect(MobEffects.POISON, 50, 1));
        target.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 10));
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect)

Example 53 with PotionEffect

use of net.minecraft.potion.PotionEffect in project BaseMetals by MinecraftModDevelopmentMods.

the class Fluids method addFluidBlock.

@Nullable
protected static BlockFluidClassic addFluidBlock(@Nonnull final MMDMaterial material) {
    if (material.getFluidBlock() != null) {
        return material.getFluidBlock();
    }
    BlockFluidClassic block;
    String name = material.getName();
    if (name == null) {
        return null;
    }
    if (!name.equals(MaterialNames.MERCURY)) {
        block = new BlockFluidClassic(material.getFluid(), Material.LAVA);
    } else {
        block = new InteractiveFluidBlock(getFluidByName(name), false, (World w, EntityLivingBase e) -> {
            if (w.rand.nextInt(32) == 0) {
                e.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 30 * 20, 2));
            }
        });
    }
    // fullName
    block.setRegistryName(name);
    block.setUnlocalizedName(block.getRegistryName().getResourceDomain() + "." + name);
    material.addNewBlock("fluid", block);
    block.setCreativeTab(CreativeTabs.MISC);
    final ItemBlock itemBlock = new ItemBlock(block);
    // fullName
    itemBlock.setRegistryName(name);
    itemBlock.setUnlocalizedName(block.getRegistryName().getResourceDomain() + "." + name);
    material.addNewItem("fluidItemBlock", itemBlock);
    material.setFluidBlock(block);
    return fluidBlockRegistry.put(name, block);
}
Also used : BlockFluidClassic(net.minecraftforge.fluids.BlockFluidClassic) PotionEffect(net.minecraft.potion.PotionEffect) InteractiveFluidBlock(com.mcmoddev.lib.block.InteractiveFluidBlock) EntityLivingBase(net.minecraft.entity.EntityLivingBase) World(net.minecraft.world.World) ItemBlock(net.minecraft.item.ItemBlock) Nullable(javax.annotation.Nullable)

Example 54 with PotionEffect

use of net.minecraft.potion.PotionEffect in project ForestryMC by ForestryMC.

the class AlleleEffectPotion method doEffectThrottled.

@Override
public IEffectData doEffectThrottled(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
    World world = housing.getWorldObj();
    List<EntityLivingBase> entities = getEntitiesInRange(genome, housing, EntityLivingBase.class);
    for (EntityLivingBase entity : entities) {
        if (world.rand.nextFloat() >= chance) {
            continue;
        }
        int dur = this.duration;
        if (potion.isBadEffect()) {
            // Entities are not attacked if they wear a full set of apiarist's armor.
            int count = BeeManager.armorApiaristHelper.wearsItems(entity, getUID(), true);
            if (count >= 4) {
                // Full set, no damage/effect
                continue;
            } else if (count == 3) {
                dur = this.duration / 4;
            } else if (count == 2) {
                dur = this.duration / 2;
            } else if (count == 1) {
                dur = this.duration * 3 / 4;
            }
        } else {
            // don't apply positive effects to mobs
            if (entity instanceof IMob) {
                continue;
            }
        }
        entity.addPotionEffect(new PotionEffect(potion, dur, 0));
    }
    return storedData;
}
Also used : IMob(net.minecraft.entity.monster.IMob) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) World(net.minecraft.world.World)

Example 55 with PotionEffect

use of net.minecraft.potion.PotionEffect in project Tropicraft by Tropicraft.

the class EntityPoisonBlot method onImpact.

@Override
protected void onImpact(RayTraceResult mop) {
    if (mop.entityHit != null) {
        if (mop.entityHit instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) mop.entityHit;
            player.addPotionEffect(new PotionEffect(MobEffects.POISON, 12 * 20, 0));
            this.setDead();
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Aggregations

PotionEffect (net.minecraft.potion.PotionEffect)367 EntityLivingBase (net.minecraft.entity.EntityLivingBase)115 EntityPlayer (net.minecraft.entity.player.EntityPlayer)89 ItemStack (net.minecraft.item.ItemStack)62 BlockPos (net.minecraft.util.math.BlockPos)48 Entity (net.minecraft.entity.Entity)36 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)35 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)34 World (net.minecraft.world.World)26 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)24 Potion (net.minecraft.potion.Potion)21 IBlockState (net.minecraft.block.state.IBlockState)20 ArrayList (java.util.ArrayList)19 WorldServer (net.minecraft.world.WorldServer)19 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)17 List (java.util.List)14 Random (java.util.Random)14 NBTTagList (net.minecraft.nbt.NBTTagList)14 TileEntity (net.minecraft.tileentity.TileEntity)13 SPacketEntityEffect (net.minecraft.network.play.server.SPacketEntityEffect)9