net.minecraft.item.ItemPotion Java Examples

The following examples show how to use net.minecraft.item.ItemPotion. 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: FastEat.java    From ehacks-pro with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onTicks() {
    if (this.isActive() && Mouse.getEventButton() == 1 && Mouse.isButtonDown(1)) {
        if (this.mode == 1) {
            int[] ignoredBlockIds = new int[]{23, 25, 26, 54, 58, 61, 62, 64, 69, 71, 77, 84, 92, 96, 107, 116, 117, 118, 120, 130, 137, 143, 145, 146, 149, 150, 154, 158};
            for (int id : ignoredBlockIds) {
                if (Block.getIdFromBlock(Wrapper.INSTANCE.world().getBlock(Wrapper.INSTANCE.mc().objectMouseOver.blockX, Wrapper.INSTANCE.mc().objectMouseOver.blockY, Wrapper.INSTANCE.mc().objectMouseOver.blockZ)) != id) {
                    continue;
                }
                return;
            }
        }
        if (Wrapper.INSTANCE.player().inventory.getCurrentItem() == null) {
            return;
        }
        Item item = Wrapper.INSTANCE.player().inventory.getCurrentItem().getItem();
        if (Wrapper.INSTANCE.player().onGround && (item instanceof ItemFood || item instanceof ItemPotion) && (Wrapper.INSTANCE.player().getFoodStats().needFood() || item instanceof ItemPotion || item instanceof ItemAppleGold)) {
            Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C09PacketHeldItemChange(Wrapper.INSTANCE.player().inventory.currentItem));
            for (int i = 0; i < 1000; ++i) {
                Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C03PacketPlayer(false));
            }
            Wrapper.INSTANCE.player().sendQueue.addToSendQueue(new C07PacketPlayerDigging(5, 0, 0, 0, 255));
        }
    }
}
 
Example #2
Source File: ItemPotionMetaProvider.java    From OpenPeripheral-Integration with MIT License 6 votes vote down vote up
@Override
public Object getMeta(ItemPotion target, ItemStack stack) {
	final Map<String, Object> results = Maps.newHashMap();

	results.put("splash", ItemPotion.isSplash(stack.getItemDamage()));

	final List<Map<String, Object>> effectsInfo = Lists.newArrayList();

	@SuppressWarnings("unchecked")
	final List<PotionEffect> effects = target.getEffects(stack);
	if (effects != null) {
		for (PotionEffect effect : effects) {
			final Map<String, Object> entry = Maps.newHashMap();

			entry.put("duration", effect.getDuration() / 20); // ticks!
			entry.put("amplifier", effect.getAmplifier());
			entry.put("effect", getPotionInfo(effect.getPotionID()));

			effectsInfo.add(entry);
		}
	}

	results.put("effects", effectsInfo);

	return results;
}
 
Example #3
Source File: ElectricBoogaloo.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void itemToolTipEvent(ItemTooltipEvent event) {
    if (twosList == null || twosList.length < 1 || event.getToolTip().isEmpty())
        return;
    boolean isPotion = event.getItemStack().getItem() instanceof ItemPotion || event.getItemStack().getItem() instanceof ItemArrow;

    for (int i = 0; i < event.getToolTip().size(); i++) {
        String toolTip = event.getToolTip().get(i);
        String lowerTip = toolTip.toLowerCase();
        boolean relocateReset = false;
        if (lowerTip.endsWith("§r")) {
            lowerTip = lowerTip.substring(0, lowerTip.length() - 2);
            toolTip = toolTip.substring(0, toolTip.length() - 2);
            relocateReset = true;
        }
        for (String to : twosList) {
            String boogaloo = null;
            if (isPotion && TIMER_PATTERN.matcher(lowerTip).find()) {
                String potionName = lowerTip.substring(0, lowerTip.indexOf('(') - 1);
                if (potionName.endsWith(to)) {
                    int index = toolTip.indexOf('(') - 1;
                    String beforeTimer = toolTip.substring(0, index);
                    String timer = toolTip.substring(index);
                    boogaloo = I18n.format("tooltip.community_mod.electric", beforeTimer) + timer;
                }
            }
            if (lowerTip.endsWith(to)) {
                boogaloo = I18n.format("tooltip.community_mod.electric", toolTip);
                if (relocateReset)
                    boogaloo += "§r";
            }
            if (!Strings.isNullOrEmpty(boogaloo))
                event.getToolTip().set(i, boogaloo);
        }
    }
}
 
Example #4
Source File: HyperiumRenderItem.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean renderShinyPot(ItemStack stack, IBakedModel model, boolean isInv) {
    boolean renderedAsPotion = false;
    if (Settings.SHINY_POTS && isInv && stack.getItem() != null && stack.getItem() instanceof ItemPotion) {
        int glintColor = getPotionColor(stack);
        renderPot(model, glintColor);

        renderedAsPotion = true;
    }
    return renderedAsPotion;
}
 
Example #5
Source File: ContainerNewBrewingStand.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
	if (stack.getItem() instanceof ItemPotion && stack.getItemDamage() > 0)
		player.addStat(AchievementList.potion, 1);

	super.onPickupFromSlot(player, stack);
}
 
Example #6
Source File: TileEntityNewBrewingStand.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
private boolean canBrew() {
	if (fuel > 0 && inventory[3] != null && inventory[3].stackSize > 0) {
		ItemStack itemstack = inventory[3];

		if (!itemstack.getItem().isPotionIngredient(itemstack))
			return false;
		else if (itemstack.getItem() == ModItems.dragon_breath) {
			for (int i = 0; i < 3; i++)
				if (inventory[i] != null && inventory[i].getItem() == Items.potionitem)
					if (ItemPotion.isSplash(inventory[i].getItemDamage()))
						return true;
			return false;
		} else {
			boolean flag = false;

			for (int i = 0; i < 3; i++)
				if (inventory[i] != null && inventory[i].getItem() instanceof ItemPotion) {
					int j = inventory[i].getItemDamage();
					int k = applyIngredient(j, itemstack);

					if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k)) {
						flag = true;
						break;
					}

					List<?> list = Items.potionitem.getEffects(j);
					List<?> list1 = Items.potionitem.getEffects(k);

					if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null) && j != k) {
						flag = true;
						break;
					}
				}

			return flag;
		}
	} else
		return false;
}
 
Example #7
Source File: TileEntityNewBrewingStand.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
private void brewPotions() {
	if (ForgeEventFactory.onPotionAttemptBreaw(new ItemStack[] { inventory[0], inventory[1], inventory[2], inventory[3] }))
		return;
	if (canBrew()) {
		for (int i = 0; i < 3; i++)
			if (inventory[i] != null && inventory[i].getItem() instanceof ItemPotion) {
				int j = inventory[i].getItemDamage();
				if (ItemPotion.isSplash(j) && inventory[3].getItem() == ModItems.dragon_breath)
					inventory[i] = new ItemStack(ModItems.lingering_potion, inventory[i].stackSize, inventory[i].getItemDamage());
				else {
					int k = applyIngredient(j, inventory[3]);
					List<?> list = Items.potionitem.getEffects(j);
					List<?> list1 = Items.potionitem.getEffects(k);

					if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null)) {
						if (j != k)
							inventory[i].setItemDamage(k);
					} else if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k))
						inventory[i].setItemDamage(k);
				}
			}

		boolean hasContainerItem = inventory[3].getItem().hasContainerItem(inventory[3]);
		if (--inventory[3].stackSize <= 0)
			inventory[3] = hasContainerItem ? inventory[3].getItem().getContainerItem(inventory[3]) : null;
		else if (hasContainerItem && !worldObj.isRemote) {
			float f = 0.7F;
			double x = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
			double y = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
			double z = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
			EntityItem entityitem = new EntityItem(worldObj, xCoord + x, yCoord + y, zCoord + z, inventory[3].getItem().getContainerItem(inventory[3]));
			entityitem.delayBeforeCanPickup = 10;
			worldObj.spawnEntityInWorld(entityitem);
		}

		fuel--;
		ForgeEventFactory.onPotionBrewed(new ItemStack[] { inventory[0], inventory[1], inventory[2], inventory[3] });
		worldObj.playSound(xCoord, yCoord, zCoord, Reference.MOD_ID + ":block.brewing_stand.brew", 1.0F, 1.0F, true);
	}
}
 
Example #8
Source File: TileEntityNewBrewingStand.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack) {
	if (slot == 4)
		return stack.getItem() == Items.blaze_powder;
	else if (slot == 3)
		return stack.getItem().isPotionIngredient(stack);
	else
		return stack.getItem() instanceof ItemPotion || stack.getItem() == Items.glass_bottle;
}
 
Example #9
Source File: ContainerPotionCreator.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public boolean isItemValid(ItemStack stack) {
    return stack.getItem() instanceof ItemPotion;
}
 
Example #10
Source File: ContainerPotionCreator.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public boolean isItemValid(ItemStack stack) {
    return stack.getItem() instanceof ItemPotion;
}
 
Example #11
Source File: ContainerNewBrewingStand.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
public static boolean canHoldPotion(ItemStack stack) {
	return stack != null && (stack.getItem() instanceof ItemPotion || stack.getItem() == Items.glass_bottle);
}
 
Example #12
Source File: ContainerPotionCreator.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public boolean isItemValid(ItemStack stack) {
    return stack.getItem() instanceof ItemPotion;
}
 
Example #13
Source File: ContainerPotionCreator.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public boolean isItemValid(ItemStack stack) {
    return stack.getItem() instanceof ItemPotion;
}
 
Example #14
Source File: DispenserBehaviorPotion.java    From Artifacts with MIT License 4 votes vote down vote up
/**
 * Dispenses the specified ItemStack from a dispenser.
 */
public ItemStack dispense(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
{
    return ItemPotion.isSplash(par2ItemStack.getItemDamage()) ? (new DispenserBehaviorPotionProjectile(this, par2ItemStack)).dispense(par1IBlockSource, par2ItemStack) : this.defaultDispenserItemBehavior.dispense(par1IBlockSource, par2ItemStack);
}