This allows you to add items to the game!

Create the Item Representation

Link to create-the-item-representation

Before you can add the item, you need to create an Item Representation which will allow you to set the properties of the item you want to add.
This is where the VanillaFactory comes in:

ZenScript
Copy
mods.contenttweaker.VanillaFactory.createItem(String unlocalizedName);

Import the representation Package

Link to import-the-representation-package

It might be required for you to import the package if you encounter any issues, so better be safe than sorry and add the import.
import mods.contenttweaker.Item;

To get/set the properties you can either use the respecting ZenGetters/Setters or the ZenMethods:

ZenScript
Copy
//property name: maxStackSize
//ZenGetter
print(item.maxStackSize);
//ZenSetter
item.maxStackSize = 16;
//ZenMethods
item.getMaxStackSize();
item.setMaxStackSize(64);
Property NameTypeRequiredDefault ValueDescription/Notes
Property Name
beaconPayment
Type
boolean
Required
No
Default Value
false
Description/Notes
Can be given to a beacon to enable bonuses
Property Name
creativeTab
Type
ICreativeTab
Required
No
Default Value
Misc
Description/Notes
The Creative tab the item will be put in
Property Name
glowing
Type
boolean
Required
No
Default Value
false
Description/Notes
Can be used to give your item the glowing effect (as if it were enchanted).
Property Name
itemColorSupplier
Type
IItemColorSupplier
Required
No
Default Value
-1 as color
Description/Notes
The item's color
Property Name
itemDestroyedBlock
Type
IItemDestroyedBlock
Required
No
Default Value
false
Description/Notes
What happens when the item just destroyed a block?
Property Name
itemDestroySpeed
Type
IItemDestroySpeed
Required
No
Default Value
null
Description/Notes
Determines the Item's block breaking speed.
Property Name
itemGetContainerItem
Type
IItemGetContainerItem
Required
No
Default Value
null
Description/Notes
What will remain in the crafting grid when this item was used in a recipe?
Property Name
itemInteractionForEntity
Type
IItemInteractionForEntity
Required
No
Default Value
null
Description/Notes
Called when the player right clicks on an entity with the item (NOTE: not available until version after 4.10.0 is released)
Property Name
itemRightClick
Type
IItemRightClick
Required
No
Default Value
Description/Notes
Called when the player right clicks with the item
Property Name
itemUseAction
Type
EnumUseAction
Required
No
Default Value
"NONE"
Description/Notes
What animation the item use will have ("NONE", "EAT", "DRINK", "BLOCK", "BOW")
Property Name
localizedNameSupplier
Type
ILocalizedNameSupplier
Required
No
Default Value
null
Description/Notes
Can be used to programmatically determine your item's display name
Property Name
maxDamage
Type
int
Required
No
Default Value
-1
Description/Notes
How many uses does the item have? Less than 0 means it cannot be damaged
Property Name
maxStackSize
Type
int
Required
No
Default Value
64
Description/Notes
How many items can fit in one Stack? Less than 0 means standart stack size (64)
Property Name
onItemUpdate
Type
IItemUpdate
Required
No
Default Value
null
Description/Notes
Called every tick as long as the item is in a player's inventory
Property Name
onItemUse
Type
IItemUse
Required
No
Default Value
null
Description/Notes
Called when the player right click on a block with the item
Property Name
onItemUseFinish
Type
IItemUseFinish
Required
No
Default Value
null
Description/Notes
Called when the player finishes using the item
Property Name
rarity
Type
EnumRarity
Required
No
Default Value
COMMON
Description/Notes
How rare an item is, determines ToolTip color ("COMMON", "UNCOMMON", "RARE", "EPIC")
Property Name
smeltingExprerience
Type
float
Required
No
Default Value
-1
Description/Notes
How much experienve the player earns for smelting that item in a furnace?
Property Name
textureLocation
Type
CTResourceLocation
Required
No
Default Value
null
Description/Notes
The item's resource location, used for textures etc.
Property Name
toolClass
Type
string
Required
No
Default Value
Description/Notes
What block types the tool can break
Property Name
toolLevel
Type
int
Required
No
Default Value
-1
Description/Notes
The level of blocks can be broken
Property Name
unlocalizedName
Type
string
Required
Yes
Default Value
Description/Notes
Name, should be all lowercase

Registering the item

Link to registering-the-item

You need to call this method to register the item in the game!
Otherwise nothing will happen!
After you have called this function, you cannot un-register the item or change any of it's properties!

ZenScript
Copy
item.register();
ZenScript
Copy
#loader contenttweaker
import mods.contenttweaker.VanillaFactory;
import mods.contenttweaker.Item;
import mods.contenttweaker.IItemRightClick;
import mods.contenttweaker.Commands;

var zsItem = VanillaFactory.createItem("zs_item");
zsItem.maxStackSize = 8;
zsItem.rarity = "rare";
zsItem.creativeTab = zsCreativeTab;
zsItem.smeltingExperience = 10;
zsItem.toolClass = "pickaxe";
zsItem.toolLevel = 5;
zsItem.beaconPayment = true;
zsItem.itemRightClick = function(stack, world, player, hand) {
    Commands.call("scoreboard players set @p name 5", player, world);
    return "Pass";
};
zsItem.register();

Localising the item

Link to localising-the-item

You will need to add item.contenttweaker.itemName.name=Localized Name to the responding language files.
Example in en_us.lang file item.contenttweaker.zsItem.name=Your itemName Here will show Your itemName Here in the game.

Alternatively, you could use CraftTweaker's localization feature, though it's recommended using the language files!