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 NameTypeRequiredStandardwertDescription/Notes
Property Name
beaconPayment
Type
boolean
Required
No
Standardwert
false
Description/Notes
Can be given to a beacon to enable bonuses
Property Name
creativeTab
Type
ICreativeTab
Required
No
Standardwert
Misc
Description/Notes
The Creative tab the item will be put in
Property Name
glowing
Type
boolean
Required
No
Standardwert
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
Standardwert
-1 as color
Description/Notes
The item's color
Property Name
itemDestroyedBlock
Type
IItemDestroyedBlock
Required
No
Standardwert
false
Description/Notes
What happens when the item just destroyed a block?
Property Name
itemDestroySpeed
Type
IItemDestroySpeed
Required
No
Standardwert
null
Description/Notes
Determines the Item's block breaking speed.
Property Name
itemGetContainerItem
Type
IItemGetContainerItem
Required
No
Standardwert
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
Standardwert
null
Description/Notes
Called when the player right clicks on an entity with the item
Property Name
itemRightClick
Type
IItemRightClick
Required
No
Standardwert
Description/Notes
Called when the player right clicks with the item
Property Name
itemUseAction
Type
EnumUseAction
Required
No
Standardwert
"NONE"
Description/Notes
What animation the item use will have ("NONE", "EAT", "DRINK", "BLOCK", "BOW")
Property Name
localizedNameSupplier
Type
ILocalizedNameSupplier
Required
No
Standardwert
null
Description/Notes
Can be used to programmatically determine your item's display name
Property Name
maxDamage
Type
int
Required
No
Standardwert
-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
Standardwert
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
Standardwert
null
Description/Notes
Called every tick as long as the item is in a player's inventory
Property Name
onItemUse
Type
IItemUse
Required
No
Standardwert
null
Description/Notes
Called when the player right click on a block with the item
Property Name
onItemUseFinish
Type
IItemUseFinish
Required
No
Standardwert
null
Description/Notes
Called when the player finishes using the item
Property Name
rarity
Type
EnumRarity
Required
No
Standardwert
COMMON
Description/Notes
How rare an item is, determines ToolTip color ("COMMON", "UNCOMMON", "RARE", "EPIC")
Property Name
smeltingExprerience
Type
float
Required
No
Standardwert
-1
Description/Notes
How much experienve the player earns for smelting that item in a furnace?
Property Name
textureLocation
Type
CTResourceLocation
Required
No
Standardwert
null
Description/Notes
The item's resource location, used for textures etc.
Property Name
toolClass
Type
string
Required
No
Standardwert
Description/Notes
What block types the tool can break
Property Name
toolLevel
Type
int
Required
No
Standardwert
-1
Description/Notes
The level of blocks can be broken
Property Name
unlocalizedName
Type
string
Required
Yes
Standardwert
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!