Search in sources :

Example 86 with PotionEffect

use of net.minecraft.potion.PotionEffect in project takumicraft by TNTModders.

the class EntityTransCreeper method takumiExplodeEvent.

@Override
public boolean takumiExplodeEvent(Detonate event) {
    event.getAffectedEntities().forEach(entity -> {
        if (entity instanceof EntityPlayer) {
            ((EntityPlayer) entity).addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 60));
            ((EntityPlayer) entity).addPotionEffect(new PotionEffect(TakumiPotionCore.INVERSION, 60));
        }
    });
    return true;
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 87 with PotionEffect

use of net.minecraft.potion.PotionEffect in project takumicraft by TNTModders.

the class EntityTransCreeper method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    this.bossInfo.setPercent(this.getHealth() / this.getMaxHealth());
    this.world.playerEntities.forEach(player -> {
        if (this.getDistanceSqToEntity(player) < 16) {
            player.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 60));
            player.addPotionEffect(new PotionEffect(TakumiPotionCore.INVERSION, 60));
        }
    });
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect)

Example 88 with PotionEffect

use of net.minecraft.potion.PotionEffect in project takumicraft by TNTModders.

the class EntitySpiderCreeper method onInitialSpawn.

/**
 * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
 * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
 */
@Override
@Nullable
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) {
    livingdata = super.onInitialSpawn(difficulty, livingdata);
    if (this.world.rand.nextInt(100) == 0) {
        EntitySkeleton entityskeleton = new EntitySkeleton(this.world);
        entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
        entityskeleton.onInitialSpawn(difficulty, null);
        this.world.spawnEntity(entityskeleton);
        entityskeleton.startRiding(this);
    }
    if (livingdata == null) {
        livingdata = new GroupData();
        if (this.world.getDifficulty() == EnumDifficulty.HARD && this.world.rand.nextFloat() < 0.1F * difficulty.getClampedAdditionalDifficulty()) {
            ((GroupData) livingdata).setRandomEffect(this.world.rand);
        }
    }
    if (livingdata instanceof GroupData) {
        Potion potion = ((GroupData) livingdata).effect;
        if (potion != null) {
            this.addPotionEffect(new PotionEffect(potion, Integer.MAX_VALUE));
        }
    }
    return livingdata;
}
Also used : Potion(net.minecraft.potion.Potion) PotionEffect(net.minecraft.potion.PotionEffect) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) Nullable(javax.annotation.Nullable)

Example 89 with PotionEffect

use of net.minecraft.potion.PotionEffect in project takumicraft by TNTModders.

the class EntityLightCreeper method takumiExplodeEvent.

@Override
public boolean takumiExplodeEvent(Detonate event) {
    for (Entity entity : event.getAffectedEntities()) {
        if (entity instanceof EntityLivingBase) {
            ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.GLOWING, 400, 0));
        }
    }
    float power = this.getPowered() ? 6f : 3f;
    if (event.getExplosion() instanceof TakumiExplosion) {
        power = ((TakumiExplosion) event.getExplosion()).getSize();
    }
    if (power > 0.5) {
        for (BlockPos pos : event.getAffectedBlocks()) {
            if (!this.world.isRemote && this.world.getBlockState(pos).getBlock().getLightValue(this.world.getBlockState(pos)) > 0.5f && TakumiUtils.takumiGetBlockResistance(this, this.world.getBlockState(pos), pos) != -1) {
                this.world.setBlockToAir(pos);
                TakumiUtils.takumiCreateExplosion(this.world, this, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, power - 0.2f, false, true);
            }
        }
    }
    return true;
}
Also used : TakumiExplosion(com.tntmodders.takumi.world.TakumiExplosion) Entity(net.minecraft.entity.Entity) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos)

Example 90 with PotionEffect

use of net.minecraft.potion.PotionEffect in project takumicraft by TNTModders.

the class EntityLuckCreeper method takumiExplodeEvent.

@Override
public boolean takumiExplodeEvent(Detonate event) {
    for (Entity entity : event.getAffectedEntities()) {
        if (entity instanceof EntityLivingBase) {
            ((EntityLivingBase) entity).heal(((EntityLivingBase) entity).getMaxHealth());
            ((EntityLivingBase) entity).curePotionEffects(new ItemStack(Items.MILK_BUCKET));
            ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.LUCK, 600, 1));
        }
    }
    event.getAffectedEntities().clear();
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ItemStack(net.minecraft.item.ItemStack)

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