Creating a Usable Item
In this guide, you will learn how to create a usable item that performs an action when right-clicked. Throughout this guide, you will create a party popper item that, when used, will spawn confetti at the player’s location. 🎉🎉🎉
Adding Assets
Section titled “Adding Assets”If you want to completely customise the look and feel of your item, you can add assets to kanoho’s resource pack. This step can be skipped if you are happy using a vanilla item.
Here is the party popper model we created for this example:

Once you have created your model and sound, you can add them to the resourcepack.
- Create a fork of the kanoho resource pack and clone it to your local machine.
- Add your model to the
pack/assets/kanoho/models/itemdirectory, and any textures to thepack/assets/kanoho/textures/itemdirectory. Make sure to follow our naming conventions. - Open the
pack/assets/minecraft/models/item/clay_ball.jsonfile and add an override for your model. For more information, check out the Minecraft Wiki model definition page. - Add your sound files to the
pack/assets/kanoho/sounds/itemdirectory, and configure them in thepack/assets/kanoho/sounds.jsonfile. For more information on how you can configure your sounds, check out the Minecraft Wiki sounds.json page. - Finally, create a pull request to merge your changes into the main resource pack. Once merged, your assets will be available to all users of kanoho!
Creating the Item
Section titled “Creating the Item”Now that you have your assets ready, you can create the item itself. This involves adding the right data components to your give command to achieve the functionality you desire.
You start with a regular give command, but add square brackets to the end:
give @p minecraft:clay_ball[]Inside of these square brackets, you can add the components that define your item:
-
Mark the item as consumable by adding the
minecraft:consumablecomponent.minecraft:consumable={consume_seconds:0,has_consume_particles:false}consume_secondsis the time it takes to consume the item, andhas_consume_particlesdetermines whether particles are shown during that time. -
Add a cooldown to the item by adding the
minecraft:use_cooldowncomponent.minecraft:use_cooldown={seconds:1,cooldown_group:"kanoho:doc_party_popper"},secondsis the duration of the cooldown in seconds, andcooldown_groupis a unique identifier for the cooldown. Make sure to follow our naming conventions for the cooldown group. -
Add the
minecraft:custom_model_datacomponent to use the model you created earlier.minecraft:custom_model_data={strings:["doc_party_popper"]} -
And finally, add the
minecraft:custom_namecomponent to give change the item’s name.minecraft:custom_name='{"color":"yellow","italic":false,"text":"Party Popper"}'By including
"italic":false, you ensure that the item name is not italicised, which is the default for items with a custom name.
The final give command will like this:
give @p minecraft:clay_ball[ minecraft:consumable={consume_seconds:0,has_consume_particles:false}, minecraft:use_cooldown={seconds:1,cooldown_group:"kanoho:doc_party_popper"}, minecraft:custom_model_data={strings:["doc_party_popper"]}, minecraft:custom_name='{"color":"yellow","italic":false,"text":"Party Popper"}']For help creating items, we recommend using mcstacker, which is a web-based command generator that can help you create complex commands with ease.
Adding the Action
Section titled “Adding the Action”Now that you have created the item, you can add the action that it performs when used.
To begin with, you need to create the function that will be called when the item is used. This function will spawn confetti at the player’s location and play the sound you added earlier.
Open mcfunction-server using the /editor command and create a new function. Make sure to follow our naming conventions for the function name, such as doc/party_popper/used.
Now you can add commands to the function:
- Spawn “confetti” at the player’s location.
particle minecraft:totem_of_undying ~ ~1.5 ~ 0 0 0 0.75 100
- Play the sound you added earlier.
playsound kanoho:doc.party_popper player
And finally, you need to tell your item to call this function when used. To do this, add the Kanoho on_used component to your item:
minecraft:custom_data={kanoho:{on_used:"editor:doc/party_popper/used"}}Notice that Kanoho components are added inside the minecraft:custom_data component. This is because Kanoho components are not part of the standard Minecraft data component format.
Happy Party Popping! 🎉
Section titled “Happy Party Popping! 🎉”Your party popper is now ready to use! You can give it to yourself using the command we created earlier:
give @p minecraft:clay_ball[ minecraft:consumable={consume_seconds:0,has_consume_particles:false}, minecraft:use_cooldown={seconds:1,cooldown_group:"kanoho:doc_party_popper"}, minecraft:custom_model_data={strings:["doc_party_popper"]}, minecraft:custom_name='{"color":"yellow","italic":false,"text":"Party Popper"}', minecraft:custom_data={kanoho:{on_used:"editor:doc/party_popper/used"}}]Tada! 🎉🎉🎉
Section titled “Tada! 🎉🎉🎉”