본문으로 건너뛰기
버전: Minecraft 26.2

dev.polymodloader.api.content.item

자동 생성

이 페이지는 소스의 Javadoc에서 ./gradlew apiReference로 만든 것입니다. 설명은 코드에 적힌 영어 그대로입니다. 직접 고치지 말고 소스의 주석을 고친 뒤 다시 만드세요.

형식종류설명
ComponentType클래스The value type of an ItemComponentKey.
FoodDefinition레코드Makes an item edible.
ItemBehavior인터페이스Code that runs when a mod item is used.
ItemComponentKey레코드A data component that mods attach to item stacks, such as a charge level or an owner's name.
ItemDefinition레코드Properties of a mod item or block item.
ItemDefinition.Builder클래스Builds an ItemDefinition.
ItemHandle인터페이스A declared item.
ItemRarity열거형Name colour of an item.
ItemUse레코드A player using (right-clicking) a mod item in the air.

ComponentType​

클래스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

public final class ComponentType<T>

The value type of an ItemComponentKey.

상수·필드타입설명
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()

추가된 버전 0.1.0-alpha.4 또는 그 이전

Java type of the value.

반환 Class<T>

FoodDefinition​

레코드 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

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

Makes an item edible.

구성 요소타입설명
nutritioninthunger points restored (bread: 5)
saturationfloatsaturation modifier (bread: 0.6)
alwaysEdiblebooleanwhether it can be eaten with a full hunger bar

ItemBehavior​

인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

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)

추가된 버전 0.1.0-alpha.4 또는 그 이전

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

인자타입설명
useItemUse—

반환 InteractionResult

ItemComponentKey​

레코드 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

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.

구성 요소타입설명
idResourceIdcomponent ID, <mod id>:<path>
typeComponentType<T>value type

ItemDefinition​

레코드 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

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.

구성 요소타입설명
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()

추가된 버전 0.1.0-alpha.4 또는 그 이전

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

반환 ItemDefinition.Builder

ItemDefinition.Builder​

클래스 · 추가된 버전 0.1.0-alpha.4 또는 그 이전

public static final class Builder

Builds an ItemDefinition.

maxStackSize(int)​

public ItemDefinition.Builder maxStackSize(int maxStackSize)

추가된 버전 0.1.0-alpha.4 또는 그 이전

Sets the maximum stack size, 1–99.

인자타입설명
maxStackSizeint—

반환 ItemDefinition.Builder

durability(int)​

public ItemDefinition.Builder durability(int durability)

추가된 버전 0.1.0-alpha.4 또는 그 이전

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

인자타입설명
durabilityint—

반환 ItemDefinition.Builder

fireResistant()​

public ItemDefinition.Builder fireResistant()

추가된 버전 0.1.0-alpha.4 또는 그 이전

The dropped item survives fire and lava.

반환 ItemDefinition.Builder

rarity(ItemRarity)​

public ItemDefinition.Builder rarity(ItemRarity rarity)

추가된 버전 0.1.0-alpha.4 또는 그 이전

Sets the name colour.

인자타입설명
rarityItemRarity—

반환 ItemDefinition.Builder

food(FoodDefinition)​

public ItemDefinition.Builder food(FoodDefinition food)

추가된 버전 0.1.0-alpha.4 또는 그 이전

Makes the item edible.

인자타입설명
foodFoodDefinition—

반환 ItemDefinition.Builder

creativeTab(CreativeTab)​

public ItemDefinition.Builder creativeTab(CreativeTab tab)

추가된 버전 0.1.0-alpha.4 또는 그 이전

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

인자타입설명
tabCreativeTab—

반환 ItemDefinition.Builder

behavior(ItemBehavior)​

public ItemDefinition.Builder behavior(ItemBehavior behavior)

추가된 버전 0.1.0-alpha.4 또는 그 이전

Sets the use callbacks.

인자타입설명
behaviorItemBehavior—

반환 ItemDefinition.Builder

build()​

public ItemDefinition build()

추가된 버전 0.1.0-alpha.4 또는 그 이전

Creates the definition; invalid values throw IllegalArgumentException.

반환 ItemDefinition

ItemHandle​

인터페이스 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

public interface ItemHandle extends ContentHandle

A declared item.

상위 형식: ContentHandle

ItemRarity​

열거형 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

public enum ItemRarity

Name colour of an item.

상수설명
COMMON—
UNCOMMON—
RARE—
EPIC—

ItemUse​

레코드 · 안정성 PREVIEW · 추가된 버전 0.1.0-alpha.4 또는 그 이전

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

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

구성 요소타입설명
worldWorldViewthe world, client or server copy
playerPlayerViewthe player holding the item
stackItemStackRefthe used stack, live
Buy me a coffee