Search in sources :

Example 61 with PotionEffect

use of net.minecraft.potion.PotionEffect in project Waystones by blay09.

the class WaystoneManager method transferPlayerToDimension.

/**
 * Taken from CoFHCore's EntityHelper (https://github.com/CoFH/CoFHCore/blob/1.12/src/main/java/cofh/core/util/helpers/EntityHelper.java)
 */
private static void transferPlayerToDimension(EntityPlayerMP player, int dimension, PlayerList manager) {
    int oldDim = player.dimension;
    WorldServer oldWorld = manager.getServerInstance().getWorld(player.dimension);
    player.dimension = dimension;
    WorldServer newWorld = manager.getServerInstance().getWorld(player.dimension);
    player.connection.sendPacket(new SPacketRespawn(player.dimension, newWorld.getDifficulty(), newWorld.getWorldInfo().getTerrainType(), player.interactionManager.getGameType()));
    oldWorld.removeEntityDangerously(player);
    if (player.isBeingRidden()) {
        player.removePassengers();
    }
    if (player.isRiding()) {
        player.dismountRidingEntity();
    }
    player.isDead = false;
    transferEntityToWorld(player, oldWorld, newWorld);
    manager.preparePlayer(player, oldWorld);
    player.connection.setPlayerLocation(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
    player.interactionManager.setWorld(newWorld);
    manager.updateTimeAndWeatherForPlayer(player, newWorld);
    manager.syncPlayerInventory(player);
    for (PotionEffect potioneffect : player.getActivePotionEffects()) {
        player.connection.sendPacket(new SPacketEntityEffect(player.getEntityId(), potioneffect));
    }
    FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, oldDim, dimension);
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) WorldServer(net.minecraft.world.WorldServer) SPacketRespawn(net.minecraft.network.play.server.SPacketRespawn) SPacketEntityEffect(net.minecraft.network.play.server.SPacketEntityEffect)

Example 62 with PotionEffect

use of net.minecraft.potion.PotionEffect in project Bewitchment by Um-Mitternacht.

the class VampireAbilityHandler method abilityHandler.

@SubscribeEvent
public void abilityHandler(PlayerTickEvent evt) {
    if (evt.phase == Phase.START && !evt.player.world.isRemote) {
        PotionEffect nv = evt.player.getActivePotionEffect(MobEffects.NIGHT_VISION);
        if ((nv == null || nv.getDuration() <= 220) && evt.player.getCapability(CapabilityTransformationData.CAPABILITY, null).isNightVisionActive()) {
            if (BewitchmentAPI.getAPI().addVampireBlood(evt.player, -2)) {
                evt.player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, 300, 0, true, false));
            } else {
                evt.player.sendStatusMessage(new TextComponentTranslation("vampire.nightvision.low_blood"), true);
                evt.player.getCapability(CapabilityTransformationData.CAPABILITY, null).setNightVision(false);
            }
        }
    }
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) PotionEffect(net.minecraft.potion.PotionEffect) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 63 with PotionEffect

use of net.minecraft.potion.PotionEffect in project Bewitchment by Um-Mitternacht.

the class MarsWaterBrew method onStart.

@Override
public void onStart(World world, BlockPos pos, EntityLivingBase entity, int amplifier) {
    entity.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 1500, 0));
    entity.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 1500, 0));
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect)

Example 64 with PotionEffect

use of net.minecraft.potion.PotionEffect in project Bewitchment by Um-Mitternacht.

the class NotchedBrew method apply.

@Override
public void apply(World world, BlockPos pos, EntityLivingBase entity, int amplifier, int tick) {
    entity.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1));
    entity.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 6000, 0));
    entity.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 6000, 0));
    entity.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 2400, 3));
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect)

Example 65 with PotionEffect

use of net.minecraft.potion.PotionEffect in project Bewitchment by Um-Mitternacht.

the class EntityBrew method doSplash.

private void doSplash() {
    AxisAlignedBB axisalignedbb = this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D);
    List<EntityLivingBase> list = this.world.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
    if (!list.isEmpty()) {
        Tuple<List<BrewEffect>, List<PotionEffect>> tuple = BrewUtils.deSerialize(NBTHelper.fixNBT(getBrew()));
        for (EntityLivingBase entity : list) {
            double distance = this.getDistanceSq(entity);
            if (distance < 16.0D) {
                for (BrewEffect effect : tuple.getFirst()) {
                    BrewStorageHandler.addEntityBrewEffect(entity, effect.copy());
                }
                for (PotionEffect potioneffect : tuple.getSecond()) {
                    entity.addPotionEffect(new PotionEffect(potioneffect));
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BrewEffect(com.bewitchment.common.brew.BrewEffect) PotionEffect(net.minecraft.potion.PotionEffect) EntityLivingBase(net.minecraft.entity.EntityLivingBase) List(java.util.List)

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