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 Name类型Required默认值Description/Notes
Property Name
beaconPayment
类型
布尔值
Required
No
默认值
false
Description/Notes
Can be given to a beacon to enable bonuses
Property Name
creativeTab
类型
ICreativeTab
Required
No
默认值
Misc
Description/Notes
The Creative tab the item will be put in
Property Name
glowing
类型
布尔值
Required
No
默认值
false
Description/Notes
Can be used to give your item the glowing effect (as if it were enchanted).
Property Name
itemColorSupplier
类型
IItemColorSupplier
Required
No
默认值
-1 as color
Description/Notes
The item's color
Property Name
itemDestroyedBlock
类型
IItemDestroyedBlock
Required
No
默认值
false
Description/Notes
What happens when the item just destroyed a block?
Property Name
itemDestroySpeed
类型
IItemDestroySpeed
Required
No
默认值
null
Description/Notes
Determines the Item's block breaking speed.
Property Name
itemGetContainerItem
类型
IItemGetContainerItem
Required
No
默认值
null
Description/Notes
What will remain in the crafting grid when this item was used in a recipe?
Property Name
itemInteractionForEntity
类型
IItemInteractionForEntity
Required
No
默认值
null
Description/Notes
Called when the player right clicks on an entity with the item
Property Name
itemRightClick
类型
IItemRightClick
Required
No
默认值
Description/Notes
Called when the player right clicks with the item
Property Name
itemUseAction
类型
EnumUseAction
Required
No
默认值
"NONE"
Description/Notes
What animation the item use will have ("NONE", "EAT", "DRINK", "BLOCK", "BOW")
Property Name
localizedNameSupplier
类型
ILocalizedNameSupplier
Required
No
默认值
null
Description/Notes
Can be used to programmatically determine your item's display name
Property Name
maxDamage
类型
int
Required
No
默认值
-1
Description/Notes
How many uses does the item have? Less than 0 means it cannot be damaged
Property Name
maxStackSize
类型
int
Required
No
默认值
64
Description/Notes
How many items can fit in one Stack? Less than 0 means standart stack size (64)
Property Name
onItemUpdate
类型
IItemUpdate
Required
No
默认值
null
Description/Notes
Called every tick as long as the item is in a player's inventory
Property Name
onItemUse
类型
IItemUse
Required
No
默认值
null
Description/Notes
Called when the player right click on a block with the item
Property Name
onItemUseFinish
类型
IItemUseFinish
Required
No
默认值
null
Description/Notes
Called when the player finishes using the item
Property Name
rarity
类型
EnumRarity
Required
No
默认值
COMMON
Description/Notes
How rare an item is, determines ToolTip color ("COMMON", "UNCOMMON", "RARE", "EPIC")
Property Name
smeltingExprerience
类型
float
Required
No
默认值
-1
Description/Notes
How much experienve the player earns for smelting that item in a furnace?
Property Name
textureLocation(材质位置)
类型
CTResourceLocation
Required
No
默认值
null
Description/Notes
The item's resource location, used for textures etc.
Property Name
toolClass
类型
string
Required
No
默认值
Description/Notes
What block types the tool can break
Property Name
toolLevel
类型
int
Required
No
默认值
-1
Description/Notes
The level of blocks can be broken
Property Name
unlocalizedName
类型
string
Required
Yes
默认值
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!