Java Code Examples for net.minecraft.init.Items#potionitem()

The following examples show how to use net.minecraft.init.Items#potionitem() . 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: InfusionVisualDisguiseArmor.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ItemStack getCurrentDisguise() {
    if(transparent) {
        return new ItemStack(Items.potionitem, 1, POTION_METAS[(int)((System.currentTimeMillis() / 1000) % POTION_METAS.length)]);
    }

    Random random = new Random(System.currentTimeMillis() / 1000);
    int first = getRecipeInput(random);
    int firstPos = EntityLiving.getArmorPosition(armorItems[first]);

    int next;
    do {
        next = random.nextInt(armorItems.length);
    }
    while (next == first || EntityLiving.getArmorPosition(armorItems[next]) != firstPos || !canSee(armorItems[next]));
    return armorItems[next];
}
 
Example 2
Source File: RecipeGunAmmo.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ItemStack getCraftingResult(InventoryCrafting invCrafting){
    ItemStack potion = null;
    ItemStack ammo = null;
    for(int i = 0; i < invCrafting.getSizeInventory(); i++) {
        ItemStack stack = invCrafting.getStackInSlot(i);
        if(stack != null) {
            if(stack.getItem() == Items.potionitem) {
                potion = stack;
            } else {
                ammo = stack;
            }
        }
    }
    ammo = ammo.copy();
    ItemGunAmmo.setPotion(ammo, potion);
    return ammo;
}
 
Example 3
Source File: InfusionDisguiseArmor.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static ItemStack disguiseStack(ItemStack stack, ItemStack disguise) {
    ItemStack out = stack.copy();
    NBTTagCompound compound = NBTHelper.getPersistentData(out);
    if(disguise.getItem() == Items.potionitem) {
        compound.setBoolean("disguise", true);
    } else {
        compound.setTag("disguise", disguise.writeToNBT(new NBTTagCompound()));
    }
    return out;
}
 
Example 4
Source File: InfusionDisguiseArmor.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean isInvisItem(ItemStack disguise) {
    if(disguise.getItem() == Items.potionitem) {
        List effects = Items.potionitem.getEffects(disguise);
        for(Object obj : effects) {
            if(obj instanceof PotionEffect) {
                if(((PotionEffect)obj).getPotionID() == Potion.invisibility.getId()) {
                    return true;
                }
            }
        }
    }
    return false;
}
 
Example 5
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 6
Source File: RecipeGunAmmo.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean matches(InventoryCrafting invCrafting, World world){
    int itemCount = 0;
    boolean foundPotion = false;
    boolean foundAmmo = false;
    for(int i = 0; i < invCrafting.getSizeInventory(); i++) {
        ItemStack stack = invCrafting.getStackInSlot(i);
        if(stack != null) {
            itemCount++;
            if(stack.getItem() == Items.potionitem) foundPotion = true;
            if(stack.getItem() == Itemss.gunAmmo) foundAmmo = true;
        }
    }
    return foundPotion && foundAmmo && itemCount == 2;
}
 
Example 7
Source File: BrewingRecipeHandler.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public NEIBrewingRecipe(ItemStack ingred, int basePotionID, int resultDamage) {
    input = new PositionedStack(new ItemStack(Items.potionitem, 1, basePotionID), 51, 35);
    output = new PositionedStack(new ItemStack(Items.potionitem, 1, resultDamage), 97, 35);
    ingredient = new PositionedStack(ingred, 74, 6);
}
 
Example 8
Source File: TileEntityAirCannon.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
private void updateDestination(){
    doneTurning = false;
    // take dispenser upgrade in account
    double payloadFrictionY = 0.98D;// this value will differ when a
                                    // dispenser upgrade is inserted.
    double payloadFrictionX = 0.98D;
    double payloadGravity = 0.04D;
    if(getUpgrades(ItemMachineUpgrade.UPGRADE_ENTITY_TRACKER) > 0) {
        payloadFrictionY = 0.98D;
        payloadFrictionX = 0.91D;
        payloadGravity = 0.08D;
    } else if(getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE, getUpgradeSlots()) > 0 && inventory[0] != null) {// if
        // there
        // is
        // a
        // dispenser
        // upgrade
        // inserted.
        Item item = inventory[0].getItem();
        if(item == Items.potionitem || item == Items.experience_bottle || item == Items.egg || item == Items.snowball) {// EntityThrowable
            payloadFrictionY = 0.99D;
            payloadGravity = 0.03D;
        } else if(item == Items.arrow) {
            payloadFrictionY = 0.99D;
            payloadGravity = 0.05D;
        } else if(item == Items.minecart || item == Items.chest_minecart || item == Items.hopper_minecart || item == Items.tnt_minecart || item == Items.furnace_minecart) {
            payloadFrictionY = 0.95D;
        }
        // else if(itemID == Item.fireballCharge.itemID){
        // payloadGravity = 0.0D;
        // }

        // family items (throwable) which only differ in gravity.
        if(item == Items.potionitem) payloadGravity = 0.05D;
        else if(item == Items.experience_bottle) payloadGravity = 0.07D;

        payloadFrictionX = payloadFrictionY;

        // items which have different frictions for each axis.
        if(item == Items.boat) {
            payloadFrictionX = 0.99D;
            payloadFrictionY = 0.95D;
        }
        if(item == Items.spawn_egg) {
            payloadFrictionY = 0.98D;
            payloadFrictionX = 0.91D;
            payloadGravity = 0.08D;
        }
    }

    // calculate the heading.
    double deltaX = gpsX - xCoord;
    double deltaZ = gpsZ - zCoord;
    float calculatedRotationAngle;
    if(deltaX >= 0 && deltaZ < 0) {
        calculatedRotationAngle = (float)(Math.atan(Math.abs(deltaX / deltaZ)) / Math.PI * 180D);
    } else if(deltaX >= 0 && deltaZ >= 0) {
        calculatedRotationAngle = (float)(Math.atan(Math.abs(deltaZ / deltaX)) / Math.PI * 180D) + 90;
    } else if(deltaX < 0 && deltaZ >= 0) {
        calculatedRotationAngle = (float)(Math.atan(Math.abs(deltaX / deltaZ)) / Math.PI * 180D) + 180;
    } else {
        calculatedRotationAngle = (float)(Math.atan(Math.abs(deltaZ / deltaX)) / Math.PI * 180D) + 270;
    }

    // calculate the height angle.
    double distance = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
    double deltaY = gpsY - yCoord;
    float calculatedHeightAngle = calculateBestHeightAngle(distance, deltaY, getForce(), payloadGravity, payloadFrictionX, payloadFrictionY);

    setTargetAngles(calculatedRotationAngle, calculatedHeightAngle);
}