Custom Item API

An API to make your own custom blocks and custom items.

1,62k

Custom Item API

</p> <p align="center"> <a href="https://github.com/Senne98/Custom-Item-Api" alt="available on GitHub"> <img src="https://img.shields.io/badge/-available_on_GitHub-gray?logo=github&style=flat" /></a> <a href="https://modrinth.com/plugin/custom-item-api" alt="available on Modrinth"> <img src="https://img.shields.io/badge/-available_on_Modrinth-brightgreen?logo=modrinth&style=flat&logoColor=white" /></a> <a href="https://hangar.papermc.io/Senne/Custom_Item_API" alt="available on Hangar"> <img src="https://img.shields.io/badge/-available_on_Hangar-gray?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC0AAAAtCAMAAAANxBKoAAAACXBIWXMAAAsTAAALEwEAmpwYAAADAFBMVEVHcEw8NzhbOzw9PDxERETr1UNERERFRESpX09ERERPYU08PDw7Ozw7Ozs9PDyX1wL9Slj45UhLOztXPT9LOTpJOjr65kfsTFD440TzTFRsOkT55kj04EaR2wFBjt38UFXw3ET+TllqO0P55khCjuDn0jqAxQpEREQxcLbjXUzCQEZZVzhHRkXlSE/+N3X/TljySlL65UT45kWWvR+hjm1LUTDxSVRBg8H04ERiQDmeoVViPUL9TFnUwDVGhJX3TVV+xwD13j355UaY1gJEkds+ity6giialBXlVkkyc8RTirWV1gXs1jyBzwAyetaItgSYmkv65kg3bYn24kY8gtNDj9w6Ojo8PDw7OzxiXz31S1PpSVFYVT42SWX9RGBBSkf9TlbeRk39TFdERUM2RFVKVUXiUEnkzzp9lnpYaSOBvBjPYD22rkRhOkaW0AGZ1QOb2AZlnjyWzQGN1QBzkYB4thE5g9pQkXvFdDPpU0uZ2wD0SFa2cS2piR+qvhuKxhvXaj5Cjdd5shyWxAGmsgiJmGSNxw+doRF3sibiXEZdmkgyfeDiWkdrk5I8h852simJ1ABEeXg7Ozs7OztQOzxJOjtROTr8TldMSz58dT3/T1fQQkqmrWNQXCbt2kRIgp713j9NkY/FukZoiYdnjmBfi6CT0QXaWEOgjxuboRo8fqmBpweqcCfDZDZsoTywayu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ppPQpYahSxhvEXp+5l7/1THeZ0pnLab0Xur7E/q7wv6mWK/vVLe2SAAAAAElFTkSuQmCC&style=flat&color=5c4747" /></a> <p align="center"> </p>

</p> <p align="center"> <a href="https://discord.gg/DBabnRZAhC" alt="join_Discord"> <img src="https://img.shields.io/badge/-join_Discord-blue?logo=discord&style=flat&logoColor=white" /></a> </p>

</p> </p> <p align="center"> <a href="https://discord.gg/DBabnRZAhC" alt="join_Discord"> <img src="https://cdn.modrinth.com/data/dw1mp4kD/images/0fa5f6a7090dff62370fb5cc3221b07e2af5a0be.png" width="550"/></a> </p>

An API for making custom blocks and items for 1.20+ on paperMC

How to use?

Data driven blocks and items

Create a 'pack'

To create custom items and blocks in this way, you will have to create a 'pack' similar to a datapack or a resource pack. The file structure of which looks like this: ``` - <namespace> - blocks - default_block - transparent_block - items ``` The namespace of your pack will be what shows before the item id in the give command ```namespace:item_id```.

##### Add items To add an item you just need to create a json and put it in the items folder. The name of the file will become the item id.

##### Add blocks To add a block you need to create a json. If you want it to be a transparent block, you need to put it in the transparent_block folder. It is recommended to use a block that is transparent as the placed_block, otherwise it might look weird. If you want a normal block you put the json in the default_block folder. The name of the file will become the block id, for good practice you should make this id the same as the id of its item but it's not required.

Use a 'pack'

To use a 'pack' you need to put it in the packs folder, this can be found by going in the plugins folder and then the custom_item_api folder. ``` - plugins - Custom_Item_Api - packs ```

Add blocks and items with a plugin

Custom items

You can add a custom item by creating a ```new CustomItem(Material material, NamespacedKey key, Class actions)```. This will create the custom item if there isn't a custom item with this NamespacedKey. The actions define what should happen when the item is clicked, it's a class that implements ```CustomItemActions```. You can change the texture,tags,... If you want to place a custom block using this item you can add this with CustomItem#setCustomBlock(NamespacedKey)

example: ````java NamespacedKey itemKey = new NamespacedKey(plugin, "example_item"); CustomItem customItem = new CustomItem(Material.FURNACE, itemKey, Class.forName("org.super_man2006.custom_item_api.utils.items.EmptyCustomItemAction")); customItem.setCustomBlock(blockKey); customItem.setName(Component.text("Example")); ``````

Custom blocks

You can add a custom item by creating a ```new CustomBlock(Material material, NamespacedKey key, Class actions, Material placedBlock)```. This will create the custom item if there isn't a custom item with this NamespacedKey. The actions define what should happen when the block is placed/broken/clicked on, it's a class that implements ```CustomBlockActions```. You can change the texture,tags,... The block uses an item texture, NOT a block texture. This means that if you set custom model data (cmd) you can change the texture. If you want to drop a custom item after breaking this block you made with CustomBlock#setDropItem(NamespacedKey)

example: ````java NamespacedKey blockKey = new NamespacedKey(plugin, "example_block"); CustomBlock customBlock = new CustomBlock(Material.FURNACE, blockKey, Class.forName("org.super_man2006.custom_item_api.utils.blocks.EmptyCustomBlockAction"), Material.STONE); customBlock.setRotation(CustomBlock.Rotation.AROUND_Y); ``````

Features / Bugs

If you find bugs or want a feature to be added, ask in the discord or create an issue on github.

ADS