Skip to main content
Version: Minecraft 26.2

dev.polymodloader.api.content.item

Generated

This page is generated from the source's Javadoc by ./gradlew apiReference. Do not edit it; fix the source comment and generate it again.

TypeKindDescription
ComponentTypeclassThe value type of an ItemComponentKey.
FoodDefinitionrecordMakes an item edible.
ItemBehaviorinterfaceCode that runs when a mod item is used.
ItemComponentKeyrecordA data component that mods attach to item stacks, such as a charge level or an owner's name.
ItemDefinitionrecordProperties of a mod item or block item.
ItemDefinition.BuilderclassBuilds an ItemDefinition.
ItemHandleinterfaceA declared item.
ItemRarityenumName colour of an item.
ItemUserecordA player using (right-clicking) a mod item in the air.

ComponentType​

class · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public final class ComponentType<T>

The value type of an ItemComponentKey.

Constant or fieldTypeDescription
INTEGERComponentType<Integer>A whole number.
BOOLEANComponentType<Boolean>true or false.
STRINGComponentType<String>Text.
TREEComponentType<DataTree>A DataTree; stored and returned as copies.

valueClass()​

public Class<T> valueClass()

Since 0.1.0-alpha.4 or earlier

Java type of the value.

Returns Class<T>

FoodDefinition​

record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public record FoodDefinition(int nutrition, float saturation, boolean alwaysEdible)

Makes an item edible.

ComponentTypeDescription
nutritioninthunger points restored (bread: 5)
saturationfloatsaturation modifier (bread: 0.6)
alwaysEdiblebooleanwhether it can be eaten with a full hunger bar

ItemBehavior​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface ItemBehavior

Code that runs when a mod item is used. Same thread and failure rules as BlockBehavior.

onUse(ItemUse)​

default InteractionResult onUse(ItemUse use)

Since 0.1.0-alpha.4 or earlier

The item was used in the air. Returning InteractionResult.PASS keeps the game's default (for example eating, for food items).

ParameterTypeDescription
useItemUse—

Returns InteractionResult

ItemComponentKey​

record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public record ItemComponentKey<T>(ResourceId id, ComponentType<T> type)

A data component that mods attach to item stacks, such as a charge level or an owner's name. The value is saved with the stack, copied with it, shown in /give syntax as <id>=<value>, and synchronised to clients. Stacks with different values do not stack. Obtain keys from ContentRegistrar.itemComponent.

ComponentTypeDescription
idResourceIdcomponent ID, <mod id>:<path>
typeComponentType<T>value type

ItemDefinition​

record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public record ItemDefinition(int maxStackSize, int durability, boolean fireResistant, ItemRarity rarity, Optional<FoodDefinition> food, Optional<CreativeTab> creativeTab, ItemBehavior behavior)

Properties of a mod item or block item. Created with builder(); immutable.

ComponentTypeDescription
maxStackSizeint1–99; items with durability always stack to 1
durabilityintuses before breaking, 0 for none
fireResistantbooleanwhether the dropped item survives fire and lava
rarityItemRarityname colour
foodOptional<FoodDefinition>what eating it does, or empty when it is not food
creativeTabOptional<CreativeTab>creative inventory tab to list it in, or empty
behaviorItemBehavioruse callbacks; ignored for block items

builder()​

public static ItemDefinition.Builder builder()

Since 0.1.0-alpha.4 or earlier

A builder for a common item stacking to 64, listed in no tab.

Returns ItemDefinition.Builder

ItemDefinition.Builder​

class · Since 0.1.0-alpha.4 or earlier

public static final class Builder

Builds an ItemDefinition.

maxStackSize(int)​

public ItemDefinition.Builder maxStackSize(int maxStackSize)

Since 0.1.0-alpha.4 or earlier

Sets the maximum stack size, 1–99.

ParameterTypeDescription
maxStackSizeint—

Returns ItemDefinition.Builder

durability(int)​

public ItemDefinition.Builder durability(int durability)

Since 0.1.0-alpha.4 or earlier

Gives the item durability; also sets the stack size to 1.

ParameterTypeDescription
durabilityint—

Returns ItemDefinition.Builder

fireResistant()​

public ItemDefinition.Builder fireResistant()

Since 0.1.0-alpha.4 or earlier

The dropped item survives fire and lava.

Returns ItemDefinition.Builder

rarity(ItemRarity)​

public ItemDefinition.Builder rarity(ItemRarity rarity)

Since 0.1.0-alpha.4 or earlier

Sets the name colour.

ParameterTypeDescription
rarityItemRarity—

Returns ItemDefinition.Builder

food(FoodDefinition)​

public ItemDefinition.Builder food(FoodDefinition food)

Since 0.1.0-alpha.4 or earlier

Makes the item edible.

ParameterTypeDescription
foodFoodDefinition—

Returns ItemDefinition.Builder

creativeTab(CreativeTab)​

public ItemDefinition.Builder creativeTab(CreativeTab tab)

Since 0.1.0-alpha.4 or earlier

Lists the item at the end of a creative inventory tab.

ParameterTypeDescription
tabCreativeTab—

Returns ItemDefinition.Builder

behavior(ItemBehavior)​

public ItemDefinition.Builder behavior(ItemBehavior behavior)

Since 0.1.0-alpha.4 or earlier

Sets the use callbacks.

ParameterTypeDescription
behaviorItemBehavior—

Returns ItemDefinition.Builder

build()​

public ItemDefinition build()

Since 0.1.0-alpha.4 or earlier

Creates the definition; invalid values throw IllegalArgumentException.

Returns ItemDefinition

ItemHandle​

interface · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public interface ItemHandle extends ContentHandle

A declared item.

Supertypes: ContentHandle

ItemRarity​

enum · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public enum ItemRarity

Name colour of an item.

ConstantDescription
COMMON—
UNCOMMON—
RARE—
EPIC—

ItemUse​

record · Stability PREVIEW · Since 0.1.0-alpha.4 or earlier

public record ItemUse(WorldView world, PlayerView player, ItemStackRef stack)

A player using (right-clicking) a mod item in the air.

ComponentTypeDescription
worldWorldViewthe world, client or server copy
playerPlayerViewthe player holding the item
stackItemStackRefthe used stack, live
Buy me a coffee