Search in sources :

Example 41 with PotionEffect

use of net.minecraft.potion.PotionEffect in project NewHorizonsCoreMod by GTNewHorizons.

the class ExtendedFluidCollection method populateFermentedBacterialSludge.

private static void populateFermentedBacterialSludge() {
    Fluid tFermentedBacterialSludge = ModFluidManager.GetNewFluid("FermentedBacterialSludge");
    tFermentedBacterialSludge.setGaseous(false);
    tFermentedBacterialSludge.setViscosity(1000);
    tFermentedBacterialSludge.setDensity(1);
    tFermentedBacterialSludge.setLuminosity(8);
    tFermentedBacterialSludge.setTemperature(300);
    // The rarity of the fluid. Used primarily in tool tips.
    tFermentedBacterialSludge.setRarity(EnumRarity.epic);
    _mFermentedBacterialSludge = new ModSimpleBaseFluid(tFermentedBacterialSludge, Material.water);
    // Add potion effects to the fluid if player steps into a pool
    // Syntax is: new PotionEffect(<potionID>, <duration in ticks>, <level>)
    // Level 0: Potion Level I
    // Level 1: Potion Level II
    // ...
    // For the duration: Set it low to vanish the effect as soon as the player leaves the pool
    // If you set the duration to 200, the potion timer will start to tick for 10 seconds after
    // the player has left the pool.
    // Same for stacking potion effects, except that you want to set the duration to the amount which will be
    // ADDED about each 0,5 seconds. So this poison-effect will increase as long as the player has contact with the
    // fluid block
    _mFermentedBacterialSludge.addStackingPotionEffect(new PotionEffect(bop_loaded ? 24 : Potion.poison.id, 20, 0));
    _mFermentedBacterialSludge.addStackingPotionEffect(new PotionEffect(bop_loaded ? 25 : Potion.moveSlowdown.id, 20, 0));
    // don't register a bucket
    _mFermentedBacterialSludge.setRegisterBucket(true);
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) ModSimpleBaseFluid(eu.usrv.yamcore.fluids.ModSimpleBaseFluid) Fluid(net.minecraftforge.fluids.Fluid) ModSimpleBaseFluid(eu.usrv.yamcore.fluids.ModSimpleBaseFluid)

Example 42 with PotionEffect

use of net.minecraft.potion.PotionEffect in project NewHorizonsCoreMod by GTNewHorizons.

the class ExtendedFluidCollection method populateEnrichedBacterialSludge.

private static void populateEnrichedBacterialSludge() {
    Fluid tEnrichedBacterialSludge = ModFluidManager.GetNewFluid("EnrichedBacterialSludge");
    tEnrichedBacterialSludge.setGaseous(false);
    tEnrichedBacterialSludge.setViscosity(1000);
    tEnrichedBacterialSludge.setDensity(1);
    tEnrichedBacterialSludge.setLuminosity(15);
    tEnrichedBacterialSludge.setTemperature(300);
    // The rarity of the fluid. Used primarily in tool tips.
    tEnrichedBacterialSludge.setRarity(EnumRarity.epic);
    _mEnrichedBacterialSludge = new ModSimpleBaseFluid(tEnrichedBacterialSludge, Material.water);
    // Add potion effects to the fluid if player steps into a pool
    // Syntax is: new PotionEffect(<potionID>, <duration in ticks>, <level>)
    // Level 0: Potion Level I
    // Level 1: Potion Level II
    // ...
    // For the duration: Set it low to vanish the effect as soon as the player leaves the pool
    // If you set the duration to 200, the potion timer will start to tick for 10 seconds after
    // the player has left the pool.
    // Same for stacking potion effects, except that you want to set the duration to the amount which will be
    // ADDED about each 0,5 seconds. So this poison-effect will increase as long as the player has contact with the
    // fluid block
    _mEnrichedBacterialSludge.addStackingPotionEffect(new PotionEffect(bop_loaded ? 24 : Potion.poison.id, 40, 0));
    _mEnrichedBacterialSludge.addStackingPotionEffect(new PotionEffect(bop_loaded ? 25 : Potion.moveSlowdown.id, 40, 0));
    // don't register a bucket
    _mEnrichedBacterialSludge.setRegisterBucket(true);
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) ModSimpleBaseFluid(eu.usrv.yamcore.fluids.ModSimpleBaseFluid) Fluid(net.minecraftforge.fluids.Fluid) ModSimpleBaseFluid(eu.usrv.yamcore.fluids.ModSimpleBaseFluid)

Example 43 with PotionEffect

use of net.minecraft.potion.PotionEffect in project BetterWithAddons by DaedalusGame.

the class EntityKarateZombie method fall.

@Override
public void fall(float distance, float damageMultiplier) {
    float mult = damageMultiplier;
    List<Entity> passengers = getPassengers();
    if (getCurrentMove() == MartialArts.Suplex) {
        passengers.forEach(this::forceDismount);
        float[] ret = net.minecraftforge.common.ForgeHooks.onLivingFall(this, distance, damageMultiplier);
        if (ret == null)
            return;
        distance = ret[0];
        damageMultiplier = ret[1];
        PotionEffect potioneffect = this.getActivePotionEffect(MobEffects.JUMP_BOOST);
        float f = potioneffect == null ? 0.0F : (float) (potioneffect.getAmplifier() + 1);
        int i = MathHelper.ceil((distance - 3.0F - f) * damageMultiplier);
        if (i > 0) {
            this.playSound(this.getFallSound(i), 1.0F, 1.0F);
            for (Entity passenger : passengers) {
                passenger.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
            }
        }
        mult = 0;
        randomizeMove();
    }
    super.fall(distance, mult);
}
Also used : EntityAIAvoidEntity(net.minecraft.entity.ai.EntityAIAvoidEntity) Entity(net.minecraft.entity.Entity) PotionEffect(net.minecraft.potion.PotionEffect)

Example 44 with PotionEffect

use of net.minecraft.potion.PotionEffect in project BetterWithAddons by DaedalusGame.

the class AnimalCrossbreedHandler method crossBreedAnimal.

@SubscribeEvent
public void crossBreedAnimal(LivingEvent.LivingUpdateEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    World world = entity.world;
    BlockPos pos = entity.getPosition();
    try {
        if (!world.isRemote && entity instanceof EntityAnimal) {
            EntityAnimal animal = (EntityAnimal) entity;
            if (!animal.isInLove())
                return;
            if (world.getLight(pos) >= 8 || (int) inLove.get(animal) > 20)
                return;
            // Instead of expanding entity bounding box, expand block bounding box because it makes more sense this way probably
            AxisAlignedBB aabb = new AxisAlignedBB(pos).expand(8, 8, 8);
            List<EntityAnimal> others = world.getEntitiesWithinAABB(EntityAnimal.class, aabb);
            EntityAnimal found = null;
            for (EntityAnimal other : others) {
                if (other == animal || !other.isInLove())
                    continue;
                if (isSameSpecies(animal, other))
                    return;
                if (animal.getPositionVector().squareDistanceTo(other.getPositionVector()) > 3.5 * 3.5)
                    continue;
                if (!isNotSitting(other) || world.getLight(other.getPosition()) >= 8)
                    continue;
                found = other;
                break;
            }
            if (found == null)
                return;
            Vec3d spawnPos = new Vec3d((found.posX + animal.posX) / 2, (found.posY + animal.posY) / 2, (found.posZ + animal.posZ) / 2);
            BlockPos spawnBlockPos = new BlockPos(spawnPos);
            // TODO: Habitat check
            final EntityAnimal finalFound = found;
            ArrayList<AnimalMutation> mutations = mutationSet.stream().map(x -> x.copy().updateWeight(world, spawnPos, finalFound, animal)).collect(Collectors.toCollection(ArrayList::new));
            AnimalMutation mutation = WeightedRandom.getRandomItem(world.rand, mutations);
            if (mutation != null)
                mutation.spawner.spawn(world, spawnPos, found, animal);
            animal.resetInLove();
            animal.setGrowingAge(6000);
            found.resetInLove();
            found.setGrowingAge(6000);
            animal.playLivingSound();
            found.playLivingSound();
            animal.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 6000));
            found.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 6000));
        }
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) net.minecraft.entity.passive(net.minecraft.entity.passive) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntitySlime(net.minecraft.entity.monster.EntitySlime) ReflectionHelper(net.minecraftforge.fml.relauncher.ReflectionHelper) EntityAgeable(net.minecraft.entity.EntityAgeable) ArrayList(java.util.ArrayList) PotionEffect(net.minecraft.potion.PotionEffect) EntitySilverfish(net.minecraft.entity.monster.EntitySilverfish) Vec3d(net.minecraft.util.math.Vec3d) BiomeDictionary(net.minecraftforge.common.BiomeDictionary) Entity(net.minecraft.entity.Entity) World(net.minecraft.world.World) BlockPos(net.minecraft.util.math.BlockPos) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) IBlockState(net.minecraft.block.state.IBlockState) List(java.util.List) LivingEvent(net.minecraftforge.event.entity.living.LivingEvent) Material(net.minecraft.block.material.Material) EntityLivingBase(net.minecraft.entity.EntityLivingBase) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) EntityCaveSpider(net.minecraft.entity.monster.EntityCaveSpider) MobEffects(net.minecraft.init.MobEffects) Biome(net.minecraft.world.biome.Biome) WeightedRandom(net.minecraft.util.WeightedRandom) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 45 with PotionEffect

use of net.minecraft.potion.PotionEffect in project BetterWithAddons by DaedalusGame.

the class RenewablesHandler method feedBlaze.

@SubscribeEvent
public void feedBlaze(LivingEvent.LivingUpdateEvent event) {
    if (!InteractionBWR.BLAZE_BREEDING)
        return;
    Entity entity = event.getEntity();
    World world = entity.world;
    Random random = world.rand;
    BlockPos pos = entity.getPosition();
    if (!world.isRemote && entity instanceof EntityBlaze) {
        EntityBlaze blaze = (EntityBlaze) entity;
        ArtificialBlaze blazeCap = blaze.getCapability(ARTIFICIAL_BLAZE_CAP, null);
        blazeCap.breedingDelay--;
        if (blazeCap.breedingDelay > 0)
            return;
        if (blazeCap.isArtificial) {
            blaze.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 60000));
        }
        BlockPos checkPos = pos.add(random.nextInt(7) - 3, random.nextInt(7) - 3, random.nextInt(7) - 3);
        if (!BiomeDictionary.hasType(world.getBiome(checkPos), BiomeDictionary.Type.NETHER)) {
            blazeCap.breedingDelay = 6000;
            return;
        }
        if (world.getBlockState(checkPos).getMaterial() != Material.FIRE)
            return;
        if (!consumeNearbyBlazeFood(world, pos))
            return;
        spawnArtificalBlaze(world, checkPos, blazeCap.isArtificial);
        world.setBlockToAir(checkPos);
        blazeCap.breedingDelay = 6000;
    }
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) Random(java.util.Random) PotionEffect(net.minecraft.potion.PotionEffect) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) EntityBlaze(net.minecraft.entity.monster.EntityBlaze) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

PotionEffect (net.minecraft.potion.PotionEffect)135 EntityLivingBase (net.minecraft.entity.EntityLivingBase)43 EntityPlayer (net.minecraft.entity.player.EntityPlayer)41 ItemStack (net.minecraft.item.ItemStack)27 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)19 BlockPos (net.minecraft.util.math.BlockPos)17 Entity (net.minecraft.entity.Entity)12 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 World (net.minecraft.world.World)12 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)12 IBlockState (net.minecraft.block.state.IBlockState)11 Potion (net.minecraft.potion.Potion)9 Fluid (net.minecraftforge.fluids.Fluid)9 ArrayList (java.util.ArrayList)8 ModSimpleBaseFluid (eu.usrv.yamcore.fluids.ModSimpleBaseFluid)7 WorldServer (net.minecraft.world.WorldServer)7 Random (java.util.Random)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)6 NBTTagList (net.minecraft.nbt.NBTTagList)6 TileEntity (net.minecraft.tileentity.TileEntity)6