ItemBuilder
The item builder is to… build items (surprise!)
It allows you to set various properties that will change how the item behaves and what it can do. You can also use [mods.contenttweaker.item.ItemBuilder#withType](/mods/contenttweaker/API/item/ItemBuilder/#withtype) to switch to a more specialized builder, if there exist any.
To tell CoT that you want the item to appear ingame you need to call [mods.contenttweaker.item.ItemBuilder#build(String)](/mods/contenttweaker/API/item/ItemBuilder/#build) and specify a valid resource location path.
This class was added by a mod with mod-id contenttweaker
. So you need to have this mod installed if you want to use this feature.
Importing the class
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import.
Implemented Interfaces
ItemBuilder implements the following interfaces. That means any method available to them can also be used on this class.
Constructors
Creates a new ItemBuilder. Remember that this will not create a new block in the game, you need to call mods.contenttweaker.item.ItemBuilder#build(String) for that.
Methods
build
Instructs CoT to actually build whatever this builder is supposed to be building.
Parameter | Type | Description |
---|---|---|
Parameter resourceLocation | Type String | Description The resource path to give this block |
withItemGroup
Allows you to set the item group that this item will appear in.
By default, items will land in misc
Returns: This builder, used for method chaining
Return type: mods.contenttweaker.item.ItemBuilder
Parameter | Type | Description |
---|---|---|
Parameter itemGroup | Type mods.contenttweaker.item.MCItemGroup | Description The item group this item should appear in |
withMaxDamage
Allows you to set the maximum damage for this item.
Be warned that this cannot be used in combination with mods.contenttweaker.item.ItemBuilder#withMaxStackSize!
Returns: This builder, used for method chaining
Return type: mods.contenttweaker.item.ItemBuilder
Parameter | Type | Description |
---|---|---|
Parameter maxDamage | Type int | Description The maximum stack size |
withMaxStackSize
Allows you to set the maximum stack size for this item.
Be warned that this cannot be used in combination with mods.contenttweaker.item.ItemBuilder#withMaxDamage!
Returns: This builder, used for method chaining
Return type: mods.contenttweaker.item.ItemBuilder
Parameter | Type | Description |
---|---|---|
Parameter maxStackSize | Type int | Description The maximum stack size |
withNoRepair
Sets that this item may not be repaired in an anvil
Returns: This builder, used for method chaining
Return type: mods.contenttweaker.item.ItemBuilder
withRarity
Allows you to set the item’s rarity
Returns: This builder, used for method chaining
Return type: mods.contenttweaker.item.ItemBuilder
Parameter | Type | Description |
---|---|---|
Parameter rarity | Type String | Description The rarity |
withType
Sets the specific type of this item.
After this method is called the builder’s context will switch to the more provided type builder.
That means that the methods of this builder will no longer be available, so any properties you wish to set should be set before you call this method.
Returns: A builder with the given item.
Return type: T
ParameterName | Bounds |
---|---|
ParameterName T | Bounds mods.contenttweaker.item.ItemTypeBuilder |