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