net.minecraft.potion.Potion Java Examples

The following examples show how to use net.minecraft.potion.Potion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HypixelHop.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onMotion() {
    if(MovementUtils.isMoving()) {

        if(mc.thePlayer.onGround) {
            mc.thePlayer.jump();

            float speed = MovementUtils.getSpeed() < 0.56F ? MovementUtils.getSpeed() * 1.045F : 0.56F;

            if(mc.thePlayer.onGround && mc.thePlayer.isPotionActive(Potion.moveSpeed))
                speed *= 1F + 0.13F * (1 + mc.thePlayer.getActivePotionEffect(Potion.moveSpeed).getAmplifier());

            MovementUtils.strafe(speed);
            return;
        }else if(mc.thePlayer.motionY < 0.2D)
            mc.thePlayer.motionY -= 0.02D;

        MovementUtils.strafe(MovementUtils.getSpeed() * 1.01889F);
    }else{
        mc.thePlayer.motionX = mc.thePlayer.motionZ = 0D;
    }
}
 
Example #2
Source File: Fullbright.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@EventTarget(ignoreCondition = true)
public void onUpdate(final UpdateEvent event) {
    if (getState() || LiquidBounce.moduleManager.getModule(XRay.class).getState()) {
        switch(modeValue.get().toLowerCase()) {
            case "gamma":
                if(mc.gameSettings.gammaSetting <= 100F)
                    mc.gameSettings.gammaSetting++;
                break;
            case "nightvision":
                mc.thePlayer.addPotionEffect(new PotionEffect(Potion.nightVision.id, 1337, 1));
                break;
        }
    }else if(prevGamma != -1) {
        mc.gameSettings.gammaSetting = prevGamma;
        prevGamma = -1;
    }
}
 
Example #3
Source File: WitherProtectionRing.java    From NewHorizonsCoreMod with GNU General Public License v3.0 6 votes vote down vote up
@Override
    public void onWornTick(ItemStack arg0, EntityLivingBase pEntity) {
        if (!(pEntity instanceof EntityPlayer)) {
            return;
        }

        if (_mRnd.nextInt(20) == 0)
        {         
            EntityPlayer tPlayer = (EntityPlayer)pEntity;
            InventoryBaubles tBaubles = PlayerHandler.getPlayerBaubles(tPlayer);
            //PotionEffect tEff = getNBTPotionEffect(arg0);
            //int tStoredVictus = GetNBTVictusVis(arg0);
            
            /*if (tEff == null || tStoredVictus < 1)
            {
                return;
            }
*/
            Potion tPot = Potion.wither;
            if (tPlayer.isPotionActive(tPot))
            {
                tPlayer.removePotionEffect(tPot.id);
                //DamageItem(arg0);
            }
        }
    }
 
Example #4
Source File: CraftAreaEffectCloud.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean removeCustomEffect(PotionEffectType effect) {
    int effectId = effect.getId();
    net.minecraft.potion.PotionEffect existing = null;
    for (net.minecraft.potion.PotionEffect mobEffect : getHandle().effects) {
        if (Potion.getIdFromPotion(mobEffect.getPotion()) == effectId) {
            existing = mobEffect;
        }
    }
    if (existing == null) {
        return false;
    }
    getHandle().effects.remove(existing);
    getHandle().refreshEffects();
    return true;
}
 
Example #5
Source File: MixinEntityLivingBase.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
protected void jump() {
    final JumpEvent jumpEvent = new JumpEvent(this.getJumpUpwardsMotion());
    LiquidBounce.eventManager.callEvent(jumpEvent);
    if(jumpEvent.isCancelled())
        return;

    this.motionY = jumpEvent.getMotion();

    if(this.isPotionActive(Potion.jump))
        this.motionY += (double) ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);

    if(this.isSprinting()) {
        float f = this.rotationYaw * 0.017453292F;
        this.motionX -= (double) (MathHelper.sin(f) * 0.2F);
        this.motionZ += (double) (MathHelper.cos(f) * 0.2F);
    }

    this.isAirBorne = true;
}
 
Example #6
Source File: EntityTippedArrow.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@Override
public void onCollideWithPlayer(EntityPlayer player) {
	boolean inGround = false;
	try {
		inGround = ReflectionHelper.getPrivateValue(EntityArrow.class, this, "inGround", "field_70254_i");
	} catch (Exception e) {
	}

	if (!worldObj.isRemote && inGround && arrowShake <= 0 && isEffectValid()) {
		boolean flag = canBePickedUp == 1 || canBePickedUp == 2 && player.capabilities.isCreativeMode;

		ItemStack stack = new ItemStack(ModItems.tipped_arrow);
		TippedArrow.setEffect(stack, Potion.potionTypes[effect.getPotionID()], effect.getDuration());

		if (canBePickedUp == 1 && !player.inventory.addItemStackToInventory(stack))
			flag = false;

		if (flag) {
			playSound("random.pop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
			player.onItemPickup(this, 1);
			setDead();
		}
	}
}
 
Example #7
Source File: MixinEntityLivingBase.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
protected void jump() {
    final JumpEvent jumpEvent = new JumpEvent(this.getJumpUpwardsMotion());
    LiquidBounce.eventManager.callEvent(jumpEvent);
    if(jumpEvent.isCancelled())
        return;

    this.motionY = jumpEvent.getMotion();

    if(this.isPotionActive(Potion.jump))
        this.motionY += (double) ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F);

    if(this.isSprinting()) {
        float f = this.rotationYaw * 0.017453292F;
        this.motionX -= (double) (MathHelper.sin(f) * 0.2F);
        this.motionZ += (double) (MathHelper.cos(f) * 0.2F);
    }

    this.isAirBorne = true;
}
 
Example #8
Source File: DataHelper.java    From GokiStats with MIT License 6 votes vote down vote up
public static float getDamageDealt(EntityPlayer player, Entity target, DamageSource source) {
    float damage = (float) player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    float bonusDamage = 0.0F;
    boolean targetIsLiving = target instanceof EntityLivingBase;
    boolean critical;
    ItemStack stack = player.getHeldItemMainhand();
    if (targetIsLiving) {
        bonusDamage = EnchantmentHelper.getModifierForCreature(stack, ((EntityLivingBase) target).getCreatureAttribute());
    }
    if ((damage > 0.0F) || (bonusDamage > 0.0F)) {
        critical = (player.fallDistance > 0.0F) && (!player.onGround) && (!player.isOnLadder()) && (!player.isInWater()) && (!player.isPotionActive(Potion.getPotionFromResourceLocation("blindness"))) && (player.getRidingEntity() == null) && (targetIsLiving);
        if ((critical) && (damage > 0.0F)) {
            damage *= 1.5F;
        }
        damage += bonusDamage;
    }
    return damage;
}
 
Example #9
Source File: MoCEntityKomodo.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void attackEntity(Entity entity, float f)
{
    
    if (attackTime <= 0 && (f < 3.0D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY))
    {
        attackTime = 20;
        boolean flag = (entity instanceof EntityPlayer);
        if (flag)
        {
            MoCreatures.poisonPlayer((EntityPlayer) entity);
        }
        ((EntityLiving) entity).addPotionEffect(new PotionEffect(Potion.poison.id, 150, 0));
        entity.attackEntityFrom(DamageSource.causeMobDamage(this), 2);
    }
}
 
Example #10
Source File: IPotionEffectExplodable.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
default void explode(Entity entityIn) {
	if (potions.isEmpty()) {
		potions.add(1);
		potions.add(3);
		potions.add(5);
		potions.add(8);
		potions.add(11);
		potions.add(12);
		potions.add(21);
	}

	Random rand = new Random();
	int range = 5;
	List<EntityLivingBase> entities = entityIn.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(entityIn.posX - range, entityIn.posY - range, entityIn.posZ - range, entityIn.posX + range, entityIn.posY + range, entityIn.posZ + range));
	for (EntityLivingBase e : entities)
		e.addPotionEffect(new PotionEffect(Potion.getPotionById(potions.get(rand.nextInt(potions.size()))), rand.nextInt(30) * 20, rand.nextInt(2) + 1));

	ClientRunnable.run(new ClientRunnable() {
		@Override
		@SideOnly(Side.CLIENT)
		public void runIfClient() {
			LibParticles.FIZZING_EXPLOSION(entityIn.world, entityIn.getPositionVector());
		}
	});
}
 
Example #11
Source File: MoCEntityWyvern.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void attackEntity(Entity entity, float f)
{
    
    if (attackTime <= 0 && (f < 3.0D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY))
    {
        attackTime = 20;
        boolean flag = (rand.nextInt(3) == 0);
        if (flag)
        {
            if (entity instanceof EntityPlayer) 
            {
            	MoCreatures.poisonPlayer((EntityPlayer) entity);
            }
            ((EntityLiving) entity).addPotionEffect(new PotionEffect(Potion.poison.id, 200, 0));
            MoCTools.playCustomSound(this, "wyvernpoisoning", worldObj);
        }
        
        int dmg = 5;
        if (getType() >= 5) dmg = 10;
        entity.attackEntityFrom(DamageSource.causeMobDamage(this), dmg);
        openMouth();
    }
}
 
Example #12
Source File: InfernalWandUpdate.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
    if(player.ticksExisted % 100 == 0){
        if(player.worldObj.provider.dimensionId == -1){
            for(int x = 0;x < primals.length;x++){
                if(((ItemWandCasting)itemstack.getItem()).getVis(itemstack, primals[x]) < ((ItemWandCasting)itemstack.getItem()).getMaxVis(itemstack) / 10) {
                    ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
                }
            }
        }
        
        if(((ItemWandCasting)itemstack.getItem()).getVis(itemstack, Aspect.FIRE) < ((ItemWandCasting)itemstack.getItem()).getMaxVis(itemstack) / 5) {
            ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, Aspect.FIRE, 1, true);
        }
    }
    
    if(player.isBurning())
        player.extinguish();
        
    if(player.isPotionActive(Potion.wither.id)) {
        if(player.worldObj.isRemote)
            player.removePotionEffectClient(Potion.wither.id);
        else
            player.removePotionEffect(Potion.wither.id);
    }
}
 
Example #13
Source File: ItemRidingCrop.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 6 votes vote down vote up
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase victim, EntityLivingBase player) {
    stack.damageItem(1, player);
    if (victim instanceof EntityHorse || victim instanceof EntityPig)
        victim.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 5));
    else if (victim instanceof EntityPlayer || victim instanceof EntityGolem) {
        victim.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 1));
        victim.addPotionEffect(new PotionEffect(Potion.digSpeed.id, 200, 1));
        victim.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 200, 1));
    }
    if (!player.worldObj.isRemote && !Config.noLust && player.worldObj.provider.dimensionId == -1 && player.worldObj.rand.nextInt(15) == 1) {
        EntityItem ent = victim.entityDropItem(new ItemStack(ForbiddenItems.deadlyShards, 1, 4), 1.0F);
        ent.motionY += player.worldObj.rand.nextFloat() * 0.05F;
        ent.motionX += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F;
        ent.motionZ += (player.worldObj.rand.nextFloat() - player.worldObj.rand.nextFloat()) * 0.1F;
    }
    return true;
}
 
Example #14
Source File: ItemThiefArmor.java    From HexxitGear with GNU General Public License v3.0 6 votes vote down vote up
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot,
                              int layer) {
    if (entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        if (player.isPotionActive(Potion.invisibility))
            return "/textures/armor/invisible.png";
    }

    // If the helmet slot, return helmet texture map
    if (slot == 0)
        return "/textures/maps/HoodHelmet.png";

    if (stack.itemID == HexxitGear.thiefLeggings.itemID)
        return "/textures/armor/thief2.png";

    return "/textures/armor/thief.png";
}
 
Example #15
Source File: WrappedPotionEffectImpl.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public PotionEffect getPotionEffect()
{
    Potion potion = Potion.REGISTRY.getObject(id);
    if (potion == null)
    {
        return null;
    } else
    {
        return new PotionEffect(potion, duration, amplifier, false, showParticles);
    }
}
 
Example #16
Source File: EntityJoinWorld.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void OnEntityJoinWorld(EntityJoinWorldEvent event) {
	
	World world = event.getWorld();
	if(world.isRemote) return;
	
	Entity entity = event.getEntity();
	
	// slimes do not extend EntityMob for some reason
	if(!(entity instanceof EntityMob || entity instanceof EntitySlime)){
		return;
	}
	
	EntityLiving mob = (EntityLiving) entity;
	
	Collection<?> effects = mob.getActivePotionEffects();
	for(Object buff : effects){
		if(Potion.getIdFromPotion(((PotionEffect) buff).getPotion()) == 4){
			int level = ((PotionEffect) buff).getAmplifier();
			
			IEntity metaEntity = new MetaEntity((Entity)mob);
			MonsterProfile.equip(world, world.rand, level, metaEntity);
			if(entity.isDead) event.setCanceled(true);
			return;
		}
	}
}
 
Example #17
Source File: CraftPotionUtil.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public static PotionEffect toBukkit(net.minecraft.potion.PotionEffect effect) {
    PotionEffectType type = PotionEffectType.getById(Potion.getIdFromPotion(effect.getPotion()));
    int amp = effect.getAmplifier();
    int duration = effect.getDuration();
    boolean ambient = effect.getIsAmbient();
    boolean particles = effect.doesShowParticles();
    return new PotionEffect(type, duration, amp, ambient, particles);
}
 
Example #18
Source File: TippedArrow.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings({ "rawtypes", "unchecked" })
public void getSubItems(Item item, CreativeTabs tab, List list) {
	List<ItemStack> potions = new ArrayList<ItemStack>();
	ModItems.lingering_potion.getSubItems(ModItems.lingering_potion, tab, potions);
	for (ItemStack potion : potions) {
		List<PotionEffect> effects = PotionHelper.getPotionEffects(potion.getItemDamage(), false);
		if (effects != null && !effects.isEmpty())
			for (PotionEffect effect : effects)
				list.add(setEffect(new ItemStack(this), Potion.potionTypes[effect.getPotionID()], effect.getDuration() / 2));
	}
}
 
Example #19
Source File: AntiPotion.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onTicks() {
    if (Wrapper.INSTANCE.player().isPotionActive(Potion.blindness)) {
        Wrapper.INSTANCE.player().removePotionEffect(Potion.blindness.id);
    }
    if (Wrapper.INSTANCE.player().isPotionActive(Potion.confusion)) {
        Wrapper.INSTANCE.player().removePotionEffect(Potion.confusion.id);
    }
    if (Wrapper.INSTANCE.player().isPotionActive(Potion.digSlowdown)) {
        Wrapper.INSTANCE.player().removePotionEffect(Potion.digSlowdown.id);
    }
    if (Wrapper.INSTANCE.player().onGround) {
        for (Potion effect : this.badEffects) {
            if (!Wrapper.INSTANCE.player().isPotionActive(effect)) {
                continue;
            }
            for (int a2 = 0; a2 <= 20; ++a2) {
                Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(Wrapper.INSTANCE.player().rotationYaw, Wrapper.INSTANCE.player().rotationPitch, Wrapper.INSTANCE.player().onGround));
            }
        }
        if (Wrapper.INSTANCE.player().getHealth() <= 15.0f && Wrapper.INSTANCE.player().isPotionActive(Potion.regeneration)) {
            for (int a3 = 0; a3 <= 10; ++a3) {
                Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(Wrapper.INSTANCE.player().rotationYaw, Wrapper.INSTANCE.player().rotationPitch, Wrapper.INSTANCE.player().onGround));
            }
        }
    }
}
 
Example #20
Source File: ItemSpicyChicken.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) {
	if (!worldIn.isRemote) {
		int burnSeconds = 30;
		player.addPotionEffect(new PotionEffect(Potion.getPotionById(12), burnSeconds * 20));
		player.setFire(burnSeconds);
	}
}
 
Example #21
Source File: SubTileBloodthorn.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public void onUpdate() {
    super.onUpdate();
    if(redstoneSignal > 0)
        return;
    final int range = 6;
    final int cost = 40;
    List<EntityLivingBase> entities = supertile.getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(supertile.xCoord - range, supertile.yCoord - range, supertile.zCoord - range, supertile.xCoord + range, supertile.yCoord + range, supertile.zCoord + range));
    for(EntityLivingBase entity : entities) {
        if(!(entity instanceof EntityPlayer) && entity.getActivePotionEffect(Potion.weakness) == null && mana >= cost && !entity.worldObj.isRemote) {
            entity.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2));
            mana -= cost;
        }
    }
}
 
Example #22
Source File: CraftLivingEntity.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public boolean addPotionEffect(PotionEffect effect, boolean force) {
    if (hasPotionEffect(effect.getType())) {
        if (!force) {
            return false;
        }
        removePotionEffect(effect.getType());
    }
    getHandle().addPotionEffect(new net.minecraft.potion.PotionEffect(Potion.getPotionById(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
    return true;
}
 
Example #23
Source File: TippedArrow.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
public static ItemStack setEffect(ItemStack stack, Potion potion, int duration) {
	stack.setTagCompound(new NBTTagCompound());
	NBTTagCompound nbt = new NBTTagCompound();
	stack.getTagCompound().setTag("Potion", nbt);

	PotionEffect effect = new PotionEffect(potion.getId(), potion.isInstant() ? 1 : duration);
	effect.writeCustomPotionEffectToNBT(nbt);

	return stack;
}
 
Example #24
Source File: ItemFruitTainted.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player) {
    if(!world.isRemote && player instanceof EntityPlayerMP) {
        Thaumcraft.addStickyWarpToPlayer(player, 1);
        player.addPotionEffect(getEffect(PotionFluxTaint.instance.id, 600, false));
        player.addPotionEffect(getEffect(Potion.hunger.id, 600, false));
        if(world.rand.nextFloat() < 0.4F){
            player.addChatMessage(new ChatComponentText(EnumChatFormatting.DARK_PURPLE + StatCollector.translateToLocal("warp.text.15")));
            player.addPotionEffect(getEffect(PotionThaumarhia.instance.id, 600, true));
        }
    }
    return super.onEaten(stack, world, player);
}
 
Example #25
Source File: RecipeTippedArrow.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public ItemStack getCraftingResult(InventoryCrafting grid) {
	ItemStack potion = grid.getStackInRowAndColumn(1, 1);
	List<PotionEffect> effects = ((LingeringPotion) ModItems.lingering_potion).getEffects(potion);

	ItemStack stack = new ItemStack(ModItems.tipped_arrow, 8);
	if (!effects.isEmpty()) {
		PotionEffect effect = effects.get(0);
		TippedArrow.setEffect(stack, Potion.potionTypes[effect.getPotionID()], effect.getDuration());
	}

	return stack;
}
 
Example #26
Source File: EntityTippedArrow.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public void onUpdate() {
	super.onUpdate();
	if (isEffectValid()) {
		Color colour = new Color(Potion.potionTypes[effect.getPotionID()].getLiquidColor());
		worldObj.spawnParticle("mobSpell", posX, posY, posZ, colour.getRed() / 255F, colour.getGreen() / 255F, colour.getBlue() / 255F);
	}
}
 
Example #27
Source File: CraftLivingEntity.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public Collection<PotionEffect> getActivePotionEffects() {
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    for (net.minecraft.potion.PotionEffect handle : getHandle().getActivePotionMap().values()) {
        effects.add(new PotionEffect(PotionEffectType.getById(Potion.getIdFromPotion(handle.getPotion())), handle.getDuration(), handle.getAmplifier(), handle.getIsAmbient(), handle.doesShowParticles()));
    }
    return effects;
}
 
Example #28
Source File: ContainerPotionCreator.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public void setPotionEffect(Potion potion, int duration, int amplifier) {
    PacketCustom packet = NEIClientPacketHandler.createContainerPacket();
    packet.writeBoolean(true);
    packet.writeByte(Potion.getIdFromPotion(potion));
    packet.writeInt(duration);
    packet.writeByte(amplifier);
    packet.sendToServer();
}
 
Example #29
Source File: ItemPotionMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
public static Map<String, Object> getPotionInfo(int potionId) {
	if (potionId < 0 || potionId >= Potion.potionTypes.length) return null;

	final Map<String, Object> result = Maps.newHashMap();

	final Potion potion = Potion.potionTypes[potionId];
	result.put("name", potion.getName());
	result.put("instant", potion.isInstant());
	result.put("color", potion.getLiquidColor());

	return result;
}
 
Example #30
Source File: VanillaEnhancementsHud.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
private double getArmorPotentional(boolean getProj) {
    EntityPlayer player = mc.thePlayer;
    double armor = 0.0;
    int epf = 0;
    int resistance = 0;
    if (player.isPotionActive(Potion.resistance)) {
        resistance = player.getActivePotionEffect(Potion.resistance).getAmplifier() + 1;
    }

    for (ItemStack stack : player.inventory.armorInventory) {
        if (stack != null) {
            if (stack.getItem() instanceof ItemArmor) {
                ItemArmor armorItem = (ItemArmor) stack.getItem();
                armor += armorItem.damageReduceAmount * 0.04;
            }

            if (stack.isItemEnchanted()) {
                epf += getEffProtPoints(EnchantmentHelper.getEnchantmentLevel(0, stack));
            }

            if (getProj && stack.isItemEnchanted()) {
                epf += getEffProtPoints(EnchantmentHelper.getEnchantmentLevel(4, stack));
            }
        }
    }

    epf = (Math.min(epf, 25));
    double avgDef = addArmorProtResistance(armor, calcProtection(epf), resistance);
    return roundDouble(avgDef * 100.0);
}