Interface CustomItemDefinition
- All Known Subinterfaces:
NonVanillaCustomItemDefinition
A custom Bedrock item definition will be used when translating any item stack that matches the vanilla Java item this definition is registered for, and the item model this item definition has specified. Additionally, predicates can be added that allow fine-grained control as to when to use this custom item. These predicates are similar to the predicates available in Java item model definitions.
In Geyser, all registered custom item definitions for a Java item model will be checked in a specific order:
- First by checking their priority values, higher priority values going first.
- Then by checking if they both have a similar
ItemRangeDispatchPredicatepredicate, the one with the highest (or lowest, when both are negated) threshold going first. - Lastly by the amount of predicates, from most to least.
Please note! While this system in most cases ensures predicates will be checked in the correct order, the range dispatch predicate sorting only works when 2 definitions only have 1 range dispatch predicate that is similar enough. With more complicated predicate checks, it is recommended to make use of priority values, to ensure the intended order.
- Since:
- 2.9.3
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceThe builder for the custom item definition. -
Method Summary
Modifier and TypeMethodDescription@NonNull IdentifierThe Bedrock identifier for this custom item.@NonNull CustomItemBedrockOptionsstatic CustomItemDefinition.Builderbuilder(@NonNull Identifier bedrockIdentifier, @NonNull Identifier itemModel) Creates a builder for the custom item definition.@NonNull ItemDataComponentMapThe item's data components.@NonNull StringThe display name of the item.@NonNull Stringicon()The icon used for this item.@NonNull Identifiermodel()The item model this definition is for.@NonNull List<MinecraftPredicate<? super ItemPredicateContext>> The predicates that have to match for this item definition to be used.@NonNull PredicateStrategyThe predicate strategy used when evaluating predicates.intpriority()@NonNull List<Identifier> A list of removed default item data components.
-
Method Details
-
bedrockIdentifier
@NonNull Identifier bedrockIdentifier()The Bedrock identifier for this custom item. It cannot be in theminecraftnamespace.- Returns:
- the Bedrock item identifier
- Since:
- 2.9.3
-
displayName
@NonNull String displayName()The display name of the item. If none is set, the display name is taken from the item's Bedrock identifier.- Returns:
- the display name shown to Bedrock clients
- Since:
- 2.9.3
-
model
@NonNull Identifier model()The item model this definition is for. If the model is in theminecraftnamespace, then the definition must have at least one predicate.If multiple item definitions for a model are registered, then only one can have no predicate.
- Returns:
- the identifier of the Java item model used to match this definition
- Since:
- 2.9.3
-
icon
@NonNull String icon()The icon used for this item.If none is set in the item's Bedrock options, then the item's Bedrock identifier is used, the namespace separator (
:) replaced with.and the path separators (/) replaced with_. For example:my_datapack:my_custom_item=>my_datapack.my_custom_itemmy_datapack:cool_items/cool_item_1=>my_datapack.cool_items_cool_item_1- Returns:
- the icon shown to Bedrock players
- Since:
- 2.9.3
-
predicates
@NonNull List<MinecraftPredicate<? super ItemPredicateContext>> predicates()The predicates that have to match for this item definition to be used. These predicates can access properties similar to the Java item model predicates.When adding predicates, avoid chaining many predicates that use an OR expression - instead, set the
PredicateStrategyof the definition toPredicateStrategy.OR.It is recommended to use built-in predicates created from classes such as
MatchPredicate,ItemMatchPredicate,ItemRangeDispatchPredicate, andItemConditionPredicatewhen possible. These predicates have built in conflict detection, value caching, and, in the case of range dispatch predicates, proper predicate sorting. This makes bugs easier to discover, and is generally more performant.- Since:
- 2.9.3
-
predicateStrategy
@NonNull PredicateStrategy predicateStrategy()The predicate strategy used when evaluating predicates. Determines if one of, or all of the predicates have to pass for this item definition to be used. Defaults toPredicateStrategy.AND.- Since:
- 2.9.3
-
priority
int priority()- Returns:
- the priority of this definition. For all definitions for a single Java item model, definitions with a higher priority will be matched first. Defaults to 0.
- Since:
- 2.9.3
-
bedrockOptions
@NonNull CustomItemBedrockOptions bedrockOptions()- Returns:
- the item's Bedrock options. These describe item properties that can't be described in item components, e.g. item texture size and if the item is allowed in the off-hand.
- Since:
- 2.9.3
-
components
@NonNull ItemDataComponentMap components()The item's data components. It is expected that the item always has these components on the server. If the components mismatch, bugs will occur.Currently, the following components are (somewhat) supported:
minecraft:consumable(JavaItemDataComponents.CONSUMABLE)minecraft:equippable(JavaItemDataComponents.EQUIPPABLE)minecraft:food(JavaItemDataComponents.FOOD)minecraft:max_damage(JavaItemDataComponents.MAX_DAMAGE)minecraft:max_stack_size(JavaItemDataComponents.MAX_STACK_SIZE)minecraft:use_cooldown(JavaItemDataComponents.USE_COOLDOWN)minecraft:enchantable(JavaItemDataComponents.ENCHANTABLE)minecraft:tool(JavaItemDataComponents.TOOL)minecraft:repairable(JavaItemDataComponents.REPAIRABLE)minecraft:enchantment_glint_override(JavaItemDataComponents.ENCHANTMENT_GLINT_OVERRIDE)minecraft:attack_range(JavaItemDataComponents.ATTACK_RANGE)minecraft:piercing_weapon(JavaItemDataComponents.PIERCING_WEAPON)minecraft:use_effects(JavaItemDataComponents.USE_EFFECTS)minecraft:kinetic_weapon(JavaItemDataComponents.KINETIC_WEAPON
Note: some components, for example
minecraft:rarityandminecraft:attribute_modifiers, are translated automatically, and do not have to be specified here. Components that are added here cannot be removed inremovedComponents().- Returns:
- the item's data component patch
- Since:
- 2.9.3
- See Also:
-
removedComponents
@NonNull List<Identifier> removedComponents()A list of removed default item data components. These are components that are present on the vanilla base item, but not on the custom item. Like with custom added components, it is expected that this always matches the removed components on the server. Removed components cannot be present in the added components incomponents().- Returns:
- a list of removed default item data components
- Since:
- 2.9.3
- See Also:
-
builder
static CustomItemDefinition.Builder builder(@NonNull Identifier bedrockIdentifier, @NonNull Identifier itemModel) Creates a builder for the custom item definition.- Parameters:
bedrockIdentifier- the Bedrock item identifieritemModel- the Java item model identifier- Returns:
- a new builder
- Since:
- 2.9.3
- See Also:
-