Java Code Examples for net.minecraft.potion.Potion

The following are top voted examples for showing how to use net.minecraft.potion.Potion. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ProgressiveDifficulty   File: PotionCloudModifier.java   View source code 6 votes vote down vote up
private static void constructFromConfig(String ID,
                             Potion effect,
                             String enableKey,
                             String enableComment,
                             int maxLevelDefault,
                             int defaultDifficultyCost,
                             double defaultWeight,
                             List<DifficultyModifier> returns,
                             Configuration config) {
    Property modifierEnabledProp = config.get(ID,
            enableKey, true, enableComment);
    boolean modifierEnabled = modifierEnabledProp.getBoolean();
    Property MaxLevelProp = config.get(ID,
            "ModifierMaxLevel", maxLevelDefault, "Maximum level of this effect added to the target player when entering the cloud.");
    int maxLevel = MaxLevelProp.getInt();
    Property difficultyCostPerLevelProp = config.get(ID,
            "DifficultyCostPerLevel", defaultDifficultyCost, "Cost of each level of the effect applied to the target player.");
    int diffCostPerLevel = difficultyCostPerLevelProp.getInt();
    Property selectionWeightProp = config.get(ID,
            "ModifierWeight", defaultWeight, "Weight that affects how often this modifier is selected.");
    double selectionWeight = selectionWeightProp.getDouble();
    if (modifierEnabled && maxLevel > 0 && diffCostPerLevel > 0 && selectionWeight > 0) {
        returns.add(new PotionCloudModifier(effect, maxLevel, diffCostPerLevel, selectionWeight, ID));
    }
}
 
Example 2
Project: needtobreath   File: PotionEffectConfig.java   View source code 6 votes vote down vote up
public PotionEffectConfig(String desc) {
    String[] split = StringUtils.split(desc, ',');
    if (split.length < 2) {
        throw new RuntimeException("Expected <poison>,<effect[@<amplitude>]>");
    }
    poisonThresshold = Integer.parseInt(split[0]);
    if (split[1].contains("@")) {
        split = StringUtils.split(split[1], '@');
        potion = Potion.REGISTRY.getObject(new ResourceLocation(split[0]));
        amplitude = Integer.parseInt(split[1]);
    } else {
        potion = Potion.REGISTRY.getObject(new ResourceLocation(split[1]));
        amplitude = 0;
    }
    if (potion == null) {
        throw new RuntimeException("Invalid potion descriptor: " + desc);
    }
}
 
Example 3
Project: Backmemed   File: CustomColors.java   View source code 6 votes vote down vote up
private static int getMaxPotionId()
{
    int i = 0;

    for (ResourceLocation resourcelocation : Potion.REGISTRY.getKeys())
    {
        Potion potion = (Potion)Potion.REGISTRY.getObject(resourcelocation);
        int j = Potion.getIdFromPotion(potion);

        if (j > i)
        {
            i = j;
        }
    }

    return i;
}
 
Example 4
Project: Backmemed   File: NetHandlerPlayClient.java   View source code 6 votes vote down vote up
public void handleEntityEffect(SPacketEntityEffect packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

    if (entity instanceof EntityLivingBase)
    {
        Potion potion = Potion.getPotionById(packetIn.getEffectId());

        if (potion != null)
        {
            PotionEffect potioneffect = new PotionEffect(potion, packetIn.getDuration(), packetIn.getAmplifier(), packetIn.getIsAmbient(), packetIn.doesShowParticles());
            potioneffect.setPotionDurationMax(packetIn.isMaxDuration());
            ((EntityLivingBase)entity).addPotionEffect(potioneffect);
        }
    }
}
 
Example 5
Project: BaseClient   File: EntitySkeleton.java   View source code 6 votes vote down vote up
public boolean attackEntityAsMob(Entity entityIn)
{
    if (super.attackEntityAsMob(entityIn))
    {
        if (this.getSkeletonType() == 1 && entityIn instanceof EntityLivingBase)
        {
            ((EntityLivingBase)entityIn).addPotionEffect(new PotionEffect(Potion.wither.id, 200));
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 6
Project: Zombe-Modpack   File: NetHandlerPlayClient.java   View source code 6 votes vote down vote up
public void handleEntityEffect(SPacketEntityEffect packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

    if (entity instanceof EntityLivingBase)
    {
        Potion potion = Potion.getPotionById(packetIn.getEffectId());

        if (potion != null)
        {
            PotionEffect potioneffect = new PotionEffect(potion, packetIn.getDuration(), packetIn.getAmplifier(), packetIn.getIsAmbient(), packetIn.doesShowParticles());
            potioneffect.setPotionDurationMax(packetIn.isMaxDuration());
            ((EntityLivingBase)entity).addPotionEffect(potioneffect);
        }
    }
}
 
Example 7
Project: SerenityCE   File: StatusEffects.java   View source code 6 votes vote down vote up
public StatusEffects() {
    super("Status Effects", 0xAEDEFF, ModuleCategory.OVERLAY);
    setHidden(true);

    OverlayContextManager.INSTANCE.register(OverlayArea.BOTTOM_RIGHT, 1000, ctx -> {
        for (final Potion potion : Potion.potionTypes) {
            if (potion == null)
                continue;

            final PotionEffect effect = mc.thePlayer.getActivePotionEffect(potion);
            if (effect == null)
                continue;

            StringBuilder builder = new StringBuilder(I18n.format(potion.getName(), new Object[0]));
            builder.append(" (");
            if (effect.getAmplifier() > 0) {
                builder.append(effect.getAmplifier() + 1);
                builder.append(" : ");
            }
            builder.append(Potion.getDurationString(effect));
            builder.append(")");
            ctx.drawString(builder.toString(), potion.getLiquidColor(), true);
        }
    }, this::isEnabled, () -> !mc.gameSettings.showDebugInfo);
}
 
Example 8
Project: DecompiledMinecraft   File: EntityLivingBase.java   View source code 6 votes vote down vote up
/**
 * Causes this entity to do an upwards motion (jumping).
 */
protected void jump()
{
    this.motionY = (double)this.getJumpUpwardsMotion();

    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 9
Project: CustomWorldGen   File: InventoryEffectRenderer.java   View source code 6 votes vote down vote up
protected void updateActivePotionEffects()
{
    boolean hasVisibleEffect = false;
    for(PotionEffect potioneffect : this.mc.thePlayer.getActivePotionEffects()) {
        Potion potion = potioneffect.getPotion();
        if(potion.shouldRender(potioneffect)) { hasVisibleEffect = true; break; }
    }
    if (this.mc.thePlayer.getActivePotionEffects().isEmpty() || !hasVisibleEffect)
    {
        this.guiLeft = (this.width - this.xSize) / 2;
        this.hasActivePotionEffects = false;
    }
    else
    {
        if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.PotionShiftEvent(this))) this.guiLeft = (this.width - this.xSize) / 2; else
        this.guiLeft = 160 + (this.width - this.xSize - 200) / 2;
        this.hasActivePotionEffects = true;
    }
}
 
Example 10
Project: BaseClient   File: EntityLivingBase.java   View source code 6 votes vote down vote up
/**
 * Clears potion metadata values if the entity has no potion effects. Otherwise, updates potion effect color,
 * ambience, and invisibility metadata values
 */
protected void updatePotionMetadata()
{
    if (this.activePotionsMap.isEmpty())
    {
        this.resetPotionEffectMetadata();
        this.setInvisible(false);
    }
    else
    {
        int i = PotionHelper.calcPotionLiquidColor(this.activePotionsMap.values());
        this.dataWatcher.updateObject(8, Byte.valueOf((byte)(PotionHelper.getAreAmbient(this.activePotionsMap.values()) ? 1 : 0)));
        this.dataWatcher.updateObject(7, Integer.valueOf(i));
        this.setInvisible(this.isPotionActive(Potion.invisibility.id));
    }
}
 
Example 11
Project: BaseClient   File: EntityLivingBase.java   View source code 6 votes vote down vote up
/**
 * Clears potion metadata values if the entity has no potion effects. Otherwise, updates potion effect color,
 * ambience, and invisibility metadata values
 */
protected void updatePotionMetadata()
{
    if (this.activePotionsMap.isEmpty())
    {
        this.resetPotionEffectMetadata();
        this.setInvisible(false);
    }
    else
    {
        int i = PotionHelper.calcPotionLiquidColor(this.activePotionsMap.values());
        this.dataWatcher.updateObject(8, Byte.valueOf((byte)(PotionHelper.getAreAmbient(this.activePotionsMap.values()) ? 1 : 0)));
        this.dataWatcher.updateObject(7, Integer.valueOf(i));
        this.setInvisible(this.isPotionActive(Potion.invisibility.id));
    }
}
 
Example 12
Project: DecompiledMinecraft   File: EntitySpider.java   View source code 6 votes vote down vote up
public void func_111104_a(Random rand)
{
    int i = rand.nextInt(5);

    if (i <= 1)
    {
        this.potionEffectId = Potion.moveSpeed.id;
    }
    else if (i <= 2)
    {
        this.potionEffectId = Potion.damageBoost.id;
    }
    else if (i <= 3)
    {
        this.potionEffectId = Potion.regeneration.id;
    }
    else if (i <= 4)
    {
        this.potionEffectId = Potion.invisibility.id;
    }
}
 
Example 13
Project: connor41-etfuturum2   File: RabbitFoot.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
public RabbitFoot() {
	setTextureName("rabbit_foot");
	setUnlocalizedName(Utils.getUnlocalisedName("rabbit_foot"));
	setCreativeTab(EtFuturum.enableRabbit ? EtFuturum.creativeTab : null);

	if (EtFuturum.enableRabbit)
		try {
			Field f = ReflectionHelper.findField(PotionHelper.class, "potionRequirements", "field_77927_l");
			f.setAccessible(true);
			HashMap<Integer, String> potionRequirements = (HashMap<Integer, String>) f.get(null);
			potionRequirements.put(Potion.jump.getId(), "0 & 1 & !2 & 3");

			Field f2 = ReflectionHelper.findField(PotionHelper.class, "potionAmplifiers", "field_77928_m");
			f2.setAccessible(true);
			HashMap<Integer, String> potionAmplifiers = (HashMap<Integer, String>) f2.get(null);
			potionAmplifiers.put(Potion.jump.getId(), "5");

			Field f3 = ReflectionHelper.findField(Potion.class, "liquidColor", "field_76414_N");
			f3.setAccessible(true);
			f3.set(Potion.jump, 0x22FF4C);
		} catch (Exception e) {
		}
}
 
Example 14
Project: BaseClient   File: EntityLivingBase.java   View source code 6 votes vote down vote up
/**
 * Causes this entity to do an upwards motion (jumping).
 */
protected void jump()
{
    this.motionY = (double)this.getJumpUpwardsMotion();

    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 15
Project: BaseClient   File: AutoPot.java   View source code 6 votes vote down vote up
private int getPotionFromInventory() {
    int pot = -1;
    int counter = 0;
    int i = 1;
    while (i < 45) {
        ItemStack is;
        ItemPotion potion;
        Item item;
        if (this.mc.thePlayer.inventoryContainer.getSlot(i).getHasStack() && (item = (is = this.mc.thePlayer.inventoryContainer.getSlot(i).getStack()).getItem()) instanceof ItemPotion && (potion = (ItemPotion)item).getEffects(is) != null) {
            for (Object o : potion.getEffects(is)) {
                PotionEffect effect = (PotionEffect)o;
                if (effect.getPotionID() != Potion.heal.id || !ItemPotion.isSplash((int)is.getItemDamage())) continue;
                ++counter;
                pot = i;
            }
        }
        ++i;
    }
    Character colorFormatCharacter = new Character('\u00a7');
    this.suffix = OptionManager.getOption((String)"Hyphen", (Module)ModuleManager.getModule(HUD.class)).value ? colorFormatCharacter + "7 - " + counter : colorFormatCharacter + "7 " + counter;
    return pot;
}
 
Example 16
Project: connor41-etfuturum2   File: EntityZombieVillager.java   View source code 6 votes vote down vote up
@Override
protected void convertToVillager() {
	EntityVillager villager = new EntityVillager(worldObj);
	villager.copyLocationAndAnglesFrom(this);
	villager.onSpawnWithEgg((IEntityLivingData) null);
	villager.setLookingForHome();
	villager.setProfession(getType());

	if (isChild())
		villager.setGrowingAge(-24000);

	worldObj.removeEntity(this);
	worldObj.spawnEntityInWorld(villager);
	villager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0));
	worldObj.playAuxSFXAtEntity(null, 1017, (int) posX, (int) posY, (int) posZ, 0);
}
 
Example 17
Project: DecompiledMinecraft   File: EntitySkeleton.java   View source code 6 votes vote down vote up
public boolean attackEntityAsMob(Entity entityIn)
{
    if (super.attackEntityAsMob(entityIn))
    {
        if (this.getSkeletonType() == 1 && entityIn instanceof EntityLivingBase)
        {
            ((EntityLivingBase)entityIn).addPotionEffect(new PotionEffect(Potion.wither.id, 200));
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 18
Project: Backmemed   File: TileEntityBeacon.java   View source code 6 votes vote down vote up
public int getField(int id)
{
    switch (id)
    {
        case 0:
            return this.levels;

        case 1:
            return Potion.getIdFromPotion(this.primaryEffect);

        case 2:
            return Potion.getIdFromPotion(this.secondaryEffect);

        default:
            return 0;
    }
}
 
Example 19
Project: Backmemed   File: Bootstrap.java   View source code 6 votes vote down vote up
/**
 * Registers blocks, items, stats, etc.
 */
public static void register()
{
    if (!alreadyRegistered)
    {
        alreadyRegistered = true;
        redirectOutputToLog();
        SoundEvent.registerSounds();
        Block.registerBlocks();
        BlockFire.init();
        Potion.registerPotions();
        Enchantment.registerEnchantments();
        Item.registerItems();
        PotionType.registerPotionTypes();
        PotionHelper.init();
        EntityList.init();
        StatList.init();
        Biome.registerBiomes();
        registerDispenserBehaviors();
    }
}
 
Example 20
Project: Soot   File: Registry.java   View source code 5 votes vote down vote up
@SubscribeEvent
public static void registerPotions(RegistryEvent.Register<Potion> event) {
    event.getRegistry().register(new PotionAle().setRegistryName(Soot.MODID,"ale"));
    event.getRegistry().register(new PotionStoutness().setRegistryName(Soot.MODID,"stoutness"));
    event.getRegistry().register(new PotionInnerFire().setRegistryName(Soot.MODID,"inner_fire"));
    event.getRegistry().register(new PotionFireLung().setRegistryName(Soot.MODID,"fire_lung"));
}
 
Example 21
Project: ProgressiveDifficulty   File: OnHitEffectModifier.java   View source code 5 votes vote down vote up
public OnHitEffectModifier(Potion effect, int duration, int maxInstances, int costPerLevel, double selectionWeight, String identifier){
    this.maxInstances = maxInstances;
    this.costPerLevel = costPerLevel;
    this.selectionWeight = selectionWeight;
    this.effect = effect;
    this.duration = duration;
    this.identifier = identifier;
}
 
Example 22
Project: JustJunk   File: ItemSurstromming.java   View source code 5 votes vote down vote up
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
    super.onItemUseFinish(stack, worldIn, entityLiving);
    entityLiving.addPotionEffect((new PotionEffect(Potion.getPotionById(30), 50, 0))); // Sick
    entityLiving.addPotionEffect((new PotionEffect(Potion.getPotionById(9), 300, 0))); // Nausea
    entityLiving.addPotionEffect((new PotionEffect(Potion.getPotionById(17), 160, 0))); // Hunger
    return new ItemStack(ModItems.emptysurstrommingcan);
}
 
Example 23
Project: BaseClient   File: ItemFishFood.java   View source code 5 votes vote down vote up
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
    ItemFishFood.FishType itemfishfood$fishtype = ItemFishFood.FishType.byItemStack(stack);

    if (itemfishfood$fishtype == ItemFishFood.FishType.PUFFERFISH)
    {
        player.addPotionEffect(new PotionEffect(Potion.poison.id, 1200, 3));
        player.addPotionEffect(new PotionEffect(Potion.hunger.id, 300, 2));
        player.addPotionEffect(new PotionEffect(Potion.confusion.id, 300, 1));
    }

    super.onFoodEaten(stack, worldIn, player);
}
 
Example 24
Project: BaseClient   File: GuiBeacon.java   View source code 5 votes vote down vote up
public void drawButtonForegroundLayer(int mouseX, int mouseY)
{
    String s = I18n.format(Potion.potionTypes[this.field_146149_p].getName(), new Object[0]);

    if (this.field_146148_q >= 3 && this.field_146149_p != Potion.regeneration.id)
    {
        s = s + " II";
    }

    GuiBeacon.this.drawCreativeTabHoveringText(s, mouseX, mouseY);
}
 
Example 25
Project: BaseClient   File: EntityGuardian.java   View source code 5 votes vote down vote up
protected void updateAITasks()
{
    super.updateAITasks();

    if (this.isElder())
    {
        int i = 1200;
        int j = 1200;
        int k = 6000;
        int l = 2;

        if ((this.ticksExisted + this.getEntityId()) % 1200 == 0)
        {
            Potion potion = Potion.digSlowdown;

            for (EntityPlayerMP entityplayermp : this.worldObj.getPlayers(EntityPlayerMP.class, new Predicate<EntityPlayerMP>()
        {
            public boolean apply(EntityPlayerMP p_apply_1_)
                {
                    return EntityGuardian.this.getDistanceSqToEntity(p_apply_1_) < 2500.0D && p_apply_1_.theItemInWorldManager.survivalOrAdventure();
                }
            }))
            {
                if (!entityplayermp.isPotionActive(potion) || entityplayermp.getActivePotionEffect(potion).getAmplifier() < 2 || entityplayermp.getActivePotionEffect(potion).getDuration() < 1200)
                {
                    entityplayermp.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(10, 0.0F));
                    entityplayermp.addPotionEffect(new PotionEffect(potion.id, 6000, 2));
                }
            }
        }

        if (!this.hasHome())
        {
            this.setHomePosAndDistance(new BlockPos(this), 16);
        }
    }
}
 
Example 26
Project: Backmemed   File: Fullbright.java   View source code 5 votes vote down vote up
@Override
public void onUpdate(EntityPlayerSP player) {
	if(isEnabled()) {
		if(player != null && !player.isPotionActive(Potion.getPotionById(16))) {
			PotionEffect nightVision = new PotionEffect(Potion.getPotionById(16), Integer.MAX_VALUE, 0);
			nightVision.setPotionDurationMax(true);
			player.addPotionEffect(nightVision);
		}
	}
}
 
Example 27
Project: Backmemed   File: EntityElderGuardian.java   View source code 5 votes vote down vote up
protected void updateAITasks()
{
    super.updateAITasks();
    int i = 1200;

    if ((this.ticksExisted + this.getEntityId()) % 1200 == 0)
    {
        Potion potion = MobEffects.MINING_FATIGUE;
        List<EntityPlayerMP> list = this.world.<EntityPlayerMP>getPlayers(EntityPlayerMP.class, new Predicate<EntityPlayerMP>()
        {
            public boolean apply(@Nullable EntityPlayerMP p_apply_1_)
            {
                return EntityElderGuardian.this.getDistanceSqToEntity(p_apply_1_) < 2500.0D && p_apply_1_.interactionManager.survivalOrAdventure();
            }
        });
        int j = 2;
        int k = 6000;
        int l = 1200;

        for (EntityPlayerMP entityplayermp : list)
        {
            if (!entityplayermp.isPotionActive(potion) || entityplayermp.getActivePotionEffect(potion).getAmplifier() < 2 || entityplayermp.getActivePotionEffect(potion).getDuration() < 1200)
            {
                entityplayermp.connection.sendPacket(new SPacketChangeGameState(10, 0.0F));
                entityplayermp.addPotionEffect(new PotionEffect(potion, 6000, 2));
            }
        }
    }

    if (!this.hasHome())
    {
        this.setHomePosAndDistance(new BlockPos(this), 16);
    }
}
 
Example 28
Project: bit-client   File: ModuleFullbright.java   View source code 5 votes vote down vote up
@Override
protected void onDisable() {
    if (Wrapper.thePlayer().func_70644_a(Potion.field_76439_r))
        Wrapper.thePlayer().func_82170_o(Potion.field_76439_r.field_76415_H);

    super.onDisable();
}
 
Example 29
Project: BaseClient   File: ItemFishFood.java   View source code 5 votes vote down vote up
protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player)
{
    ItemFishFood.FishType itemfishfood$fishtype = ItemFishFood.FishType.byItemStack(stack);

    if (itemfishfood$fishtype == ItemFishFood.FishType.PUFFERFISH)
    {
        player.addPotionEffect(new PotionEffect(Potion.poison.id, 1200, 3));
        player.addPotionEffect(new PotionEffect(Potion.hunger.id, 300, 2));
        player.addPotionEffect(new PotionEffect(Potion.confusion.id, 300, 1));
    }

    super.onFoodEaten(stack, worldIn, player);
}
 
Example 30
Project: DecompiledMinecraft   File: EntityLivingBase.java   View source code 5 votes vote down vote up
public boolean isPotionApplicable(PotionEffect potioneffectIn)
{
    if (this.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD)
    {
        int i = potioneffectIn.getPotionID();

        if (i == Potion.regeneration.id || i == Potion.poison.id)
        {
            return false;
        }
    }

    return true;
}
 
Example 31
Project: DecompiledMinecraft   File: EntityLivingBase.java   View source code 5 votes vote down vote up
protected void onFinishedPotionEffect(PotionEffect p_70688_1_)
{
    this.potionsNeedUpdate = true;

    if (!this.worldObj.isRemote)
    {
        Potion.potionTypes[p_70688_1_.getPotionID()].removeAttributesModifiersFromEntity(this, this.getAttributeMap(), p_70688_1_.getAmplifier());
    }
}
 
Example 32
Project: Wurst-MC-1.12   File: InventoryUtils.java   View source code 5 votes vote down vote up
public static boolean hasEffect(ItemStack stack, Potion potion)
{
	for(PotionEffect effect : PotionUtils.getEffectsFromStack(stack))
		if(effect.getPotion() == potion)
			return true;
		
	return false;
}
 
Example 33
Project: DecompiledMinecraft   File: EntityZombie.java   View source code 5 votes vote down vote up
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.getCurrentEquippedItem();

    if (itemstack != null && itemstack.getItem() == Items.golden_apple && itemstack.getMetadata() == 0 && this.isVillager() && this.isPotionActive(Potion.weakness))
    {
        if (!player.capabilities.isCreativeMode)
        {
            --itemstack.stackSize;
        }

        if (itemstack.stackSize <= 0)
        {
            player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
        }

        if (!this.worldObj.isRemote)
        {
            this.startConversion(this.rand.nextInt(2401) + 3600);
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 34
Project: DecompiledMinecraft   File: EntityZombie.java   View source code 5 votes vote down vote up
/**
 * Starts converting this zombie into a villager. The zombie converts into a villager after the specified time in
 * ticks.
 */
protected void startConversion(int ticks)
{
    this.conversionTime = ticks;
    this.getDataWatcher().updateObject(14, Byte.valueOf((byte)1));
    this.removePotionEffect(Potion.weakness.id);
    this.addPotionEffect(new PotionEffect(Potion.damageBoost.id, ticks, Math.min(this.worldObj.getDifficulty().getDifficultyId() - 1, 0)));
    this.worldObj.setEntityState(this, (byte)16);
}
 
Example 35
Project: BaseClient   File: EntityWitch.java   View source code 5 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    if (!this.getAggressive())
    {
        EntityPotion entitypotion = new EntityPotion(this.worldObj, this, 32732);
        double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
        entitypotion.rotationPitch -= -20.0F;
        double d1 = p_82196_1_.posX + p_82196_1_.motionX - this.posX;
        double d2 = d0 - this.posY;
        double d3 = p_82196_1_.posZ + p_82196_1_.motionZ - this.posZ;
        float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3);

        if (f >= 8.0F && !p_82196_1_.isPotionActive(Potion.moveSlowdown))
        {
            entitypotion.setPotionDamage(32698);
        }
        else if (p_82196_1_.getHealth() >= 8.0F && !p_82196_1_.isPotionActive(Potion.poison))
        {
            entitypotion.setPotionDamage(32660);
        }
        else if (f <= 3.0F && !p_82196_1_.isPotionActive(Potion.weakness) && this.rand.nextFloat() < 0.25F)
        {
            entitypotion.setPotionDamage(32696);
        }

        entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
        this.worldObj.spawnEntityInWorld(entitypotion);
    }
}
 
Example 36
Project: UniversalRemote   File: EntityPlayerMPProxy.java   View source code 5 votes vote down vote up
@Override
public PotionEffect getActivePotionEffect(Potion potionIn) {
	if (m_realPlayer == null) {
		return super.getActivePotionEffect(potionIn);
	} else {
		syncToRealPlayer();
		return syncPublicFieldsFromRealAndReturn(m_realPlayer.getActivePotionEffect(potionIn));
	}
}
 
Example 37
Project: UniversalRemote   File: EntityPlayerProxy.java   View source code 5 votes vote down vote up
@Override
public Map<Potion, PotionEffect> getActivePotionMap() {
	if (m_realPlayer == null) {
		return super.getActivePotionMap();
	} else {
		return m_realPlayer.getActivePotionMap();
	}
}
 
Example 38
Project: BaseClient   File: EntityLivingBase.java   View source code 5 votes vote down vote up
protected void onChangedPotionEffect(PotionEffect id, boolean p_70695_2_)
{
    this.potionsNeedUpdate = true;

    if (p_70695_2_ && !this.worldObj.isRemote)
    {
        Potion.potionTypes[id.getPotionID()].removeAttributesModifiersFromEntity(this, this.getAttributeMap(), id.getAmplifier());
        Potion.potionTypes[id.getPotionID()].applyAttributesModifiersToEntity(this, this.getAttributeMap(), id.getAmplifier());
    }
}
 
Example 39
Project: UniversalRemote   File: EntityPlayerMPProxy.java   View source code 5 votes vote down vote up
@Override
public void removePotionEffect(Potion potionIn) {
	if (m_realPlayer == null) {
		super.removePotionEffect(potionIn);
	} else {
		syncToRealPlayer();
		m_realPlayer.removePotionEffect(potionIn);
		syncPublicFieldsFromReal();
	}
}
 
Example 40
Project: Thermionics   File: ItemMistcloak.java   View source code 5 votes vote down vote up
public ItemMistcloak() {
	super("cloak");
	this.setHasSubtypes(true);
	this.setMaxDamage(0);
	this.setMaxStackSize(1);
	this.setCreativeTab(Thermionics.TAB_THERMIONICS);
	
	POTION_INVIS = Potion.getPotionFromResourceLocation("minecraft:invisibility");
}