The ItemUtils interface provides various item utils.
It can be accessed using the itemUtils keyword.

Creating Potions

Link to creating-potions

The createPotions function allows you to create custom potions.
Returns the potion as IItemStack.
As the Parameter for this function is a vararg, you can either provide one Object[][] or many Object[].
In both cases each Object[] needs to contain

  1. An IPotion
  2. An int describing the effect amplifier/strength
  3. An int describing the effect duration.

If an Object[] is not of this length or not in this order, it will be ignored.

//createPotion([effect,strength,duration],[effect2, strength2,duration2],...);
//createPotion([[effect,strength,duration],[effect2, strength2,duration2],...]);
val potion = itemUtils.createPotion([[<potion:minecraft:strength>, 1, 1]]);

Get Items by name

Link to get-items-by-name

These two functions both return an IItemStack[] containing all matching items.
The first checks against the items' registry names, the 2nd uses the unlocalized names.

//getItemsByRegexRegistryName(String Regex)
itemUtils.getItemsByRegexRegistryName(".*sword.*"); // all things that have sword in the name
itemUtils.getItemsByRegexRegistryName(".*thermal.*"); // all thermal expansion/foundation/dynamics items

//getItemsByRegexUnlocalizedName(String Regex)
itemUtils.getItemsByRegexUnlocalizedName(".*pink.*"); // pink things!! <3

Imitate the Item Bracket Handler

Link to imitate-the-item-bracket-handler

This method does the same as the Item Bracket Handler. This allows you to use string variables in the item name by concatenating it in.
Unlike the bracket handler though, you need to provide the meta as optional parameter.
If you want to use the wildcard meta, use 32767.

//getItem(location, @Optional meta);
itemUtils.getItem("minecraft:iron_ingot");    //<minecraft:iron_ingot>
itemUtils.getItem("minecraft:dye", 1);        //<minecraft:dye:1>
itemUtils.getItem("minecraft:wool", 32767);   //<minecraft:wool:*>

Create Spawn Egg

Link to create-spawn-egg

The createSpawnEgg function allows you to create custom mod spawn eggs.
The customNBT is OPTIONAL and can override the entity tag.
Returns the spawn egg as IItemStack.

//createSpawnEgg(entity, @optional customNBT)
//NBT overrides entity (this creates a creeper egg!)
val egg = itemUtils.createSpawnEgg(<entity:minecraft:sheep>, {EntityTag:{id:"minecraft:creeper",NoAI:1 as byte,PersistenceRequired:1 as byte}});