Files
GeyserWebsite/wiki/geyser/custom-items-old.mdx
T
9918f4a047 Feature: Custom item v2 docs (#115)
* Start documenting custom item mappings: V2

* Document json definition types

* Continue documenting Bedrock item options

* Start on component docs

* Document removing components, start documenting predicates

* Sync all example types

* Rough draft should now be sort of there

* Resolve suggestions

* Split v1 and v2 docs

* Document & add examples to range predicates

* Component examples

* Minor fixes

* Remove warning on Hydraulic

* oops

* more tiny changes

* Add javadoc links

* Update the build number mentioned in docs

---------

Co-authored-by: rtm516 <ryantmilner@hotmail.co.uk>
Co-authored-by: Aurora <auroranova8756@gmail.com>
2026-02-07 19:36:25 +01:00

138 lines
5.2 KiB
Plaintext

---
title: Custom Items (v1)
description: Legacy documentation for the first version of the custom item API
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
### Format version 1 (legacy)
:::warning
`format_version: 1` is no longer receiving updates. New features will only be added to format version 2.
:::
## JSON mappings (v1)
1. Start your server, and you should have a folder called `custom_mappings` that is created. That would be with the folder of `Geyser.jar` file for standalone and inside your Geyser data folder for a plugin.
2. Create a `.json` file, it can be any name you like and as many files as you like. You don't need to make one file per item. Here is the structure of the file:
```json
{
"format_version": 1,
"items": {
}
}
```
3. Inside the `items` entry, you can add your java item to extend:
```json
"minecraft:JAVA_ITEM": [
]
```
4. Inside this java item, goes an array of all your custom items.
```json
{
"name": "my_item"
}
```
5. Then, you need to set one or more item options or registrations, they can be stacked, so that all of the specified types need to match.
* Custom model data: `custom_model_data` (int)
* Damage predicate: `damage_predicate` (int) This is a fractional value of damage/max damage and not a number between 0 and 1.
* Unbreakable: `unbreakable` (boolean)
6. You also have some extra modifiers that you can set to further customise your item. **Note that the following modifiers are NOT required.**
* `display_name` (string) default: item name
* `icon` (string) default: item name
* `allow_offhand` (boolean) default: false
* `texture_size` (int) default: 16
* `creative_category` (int) default: not set. This can take values between 1-5, and defines the creative category the item appears in. Note: Adding your item to a creative category is needed if you want recipes that output this custom item to show up in the recipe book! However, including it does NOT mean you can get the custom item from the creative inventory.
* `creative_group` (string) default: not set. Requires a creative category to also be set - allows you to group the custom item in a sub-group. See [here](https://wiki.bedrock.dev/documentation/menu-categories.html#list-of-categories) for all categories.
* `render_offsets` (object) It works as follows. Note that all the sub-objects are optional, except x, y and z. You can have for example only a main hand with a position, and noting else. default: no render offset
* `tags` (array) default: no tags. Allows defining tags that can be used in Molang queries. Example value: ["test:tag_one", "test:tag_two"].
```json
"render_offsets": {
"main_hand": {
"first_person": {
"position": {
"x": 0,
"y": 0,
"z": 0
},
"rotation": {
"x": 0,
"y": 0,
"z": 0
},
"scale": {
"x": 0,
"y": 0,
"z": 0
}
},
"third_person": {
}
},
"off_hand": {
}
}
```
## Geyser extensions (v1)
### Extending a vanilla item (v1)
1. Create your custom item options or registrations, to which you can add any of the following. They can be stacked, so that all of the specified types need to match, but you **do NOT need all of them.**
```java
CustomItemOptions itemOptions = CustomItemOptions.builder()
.customModelData(1)
.damagePredicate(1) //This is a fractional value of damage/max damage and not a number between 0 and 1.
.unbreakable(true)
.build();
```
2. Create your custom item, and store it somewhere:
```java
CustomItemData data = CustomItemData.builder()
.name("my_item")
.customItemOptions(itemOptions)
.build();
```
3. You have some modifiers that you can set to further customise your item. **Note that the following modifiers are NOT required.**
```java
.displayName("displayName"); //Default: item name
.icon("my_icon"); //Default: item name
.allowOffhand(false); //Default: false
.textureSize(16); //Default: 16
.renderOffsets(new CustomRenderOffsets(...)); //Default: no render offset
```
4. Then, in your pre init event, you can register your item:
```java
@Subscribe
public void onGeyserPreInitializeEvent(GeyserDefineCustomItemsEvent event) {
event.registerCustomItem("minecraft:JAVA_ITEM", data);
}
```
### Non vanilla (modded) items with Geyser extensions (for example to use with Fabric) (v1)
1. Create your item data:
```java
NonVanillaCustomItemData data = NonVanillaCustomItemData.builder()
.name("my_item")
.identifier("my_mod:my_item")
.javaId(1)
```
2. There are many other options you can set to match the behavior that you require for your item. You can see them [here](https://github.com/GeyserMC/Geyser/blob/master/api/src/main/java/org/geysermc/geyser/api/item/custom/NonVanillaCustomItemData.java)
3. Register your item in the GeyserDefineCustomItems event:
```java
@Subscribe
public void onGeyserDefineCustomItemsEvent(GeyserDefineCustomItemsEvent event) {
event.register(data);
}
```