Skip to main content
Version: Minecraft 26.2

dev.polymodloader.api.inventory

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
InventoryViewinterfaceSlots of an inventory, such as a mod block entity's.
ItemStackRefinterfaceA live item stack in a slot or a hand: changes apply to the game's stack directly.
ItemStackViewrecordAn item and a count; a snapshot, so changing the inventory does not change it.

InventoryView​

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

public interface InventoryView

Slots of an inventory, such as a mod block entity's. Changes are saved with the world. Same thread rules as WorldView.

size()​

int size()

Since 0.1.0-alpha.4 or earlier

Number of slots.

Returns int

get(int)​

ItemStackView get(int slot)

Since 0.1.0-alpha.4 or earlier

The stack in slot; IndexOutOfBoundsException for a bad slot.

ParameterTypeDescription
slotint—

Returns ItemStackView

set(int, ResourceId, int)​

void set(int slot, ResourceId item, int count)

Since 0.1.0-alpha.4 or earlier

Replaces the stack in slot; a count of 0 empties it.

ParameterTypeDescription
slotint—
itemResourceId—
countint—

Throws IllegalArgumentException — for an unknown item or a count above the item's stack size

add(ResourceId, int)​

int add(ResourceId item, int count)

Since 0.1.0-alpha.4 or earlier

Adds items to existing stacks first, then to empty slots.

ParameterTypeDescription
itemResourceId—
countint—

Returns int — how many did not fit

count(ResourceId)​

int count(ResourceId item)

Since 0.1.0-alpha.4 or earlier

How many of item the inventory holds.

ParameterTypeDescription
itemResourceId—

Returns int

stackAt(int)​

ItemStackRef stackAt(int slot)

Since 0.1.0-alpha.4 or earlier

The live stack in slot, to read or change its components.

ParameterTypeDescription
slotint—

Returns ItemStackRef

clear()​

void clear()

Since 0.1.0-alpha.4 or earlier

Empties every slot.

ItemStackRef​

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

public interface ItemStackRef

A live item stack in a slot or a hand: changes apply to the game's stack directly. Valid during the callback that handed it out; same thread rules as WorldView. Change stacks on the server; client changes are overwritten by the server's copy.

item()​

ResourceId item()

Since 0.1.0-alpha.4 or earlier

The item, minecraft:air when empty.

Returns ResourceId

count()​

int count()

Since 0.1.0-alpha.4 or earlier

How many, 0 when empty.

Returns int

isEmpty()​

default boolean isEmpty()

Since 0.1.0-alpha.4 or earlier

Whether the stack is empty.

Returns boolean

isIn(TagKey)​

boolean isIn(TagKey tag)

Since 0.1.0-alpha.4 or earlier

Whether the stack's item is in an item tag, for example #minecraft:logs; false for an empty stack.

ParameterTypeDescription
tagTagKey—

Returns boolean

Throws IllegalArgumentException — when tag is not an item tag

setCount(int)​

void setCount(int count)

Since 0.1.0-alpha.4 or earlier

Changes the count; 0 empties the stack.

ParameterTypeDescription
countint—

Throws IllegalArgumentException — for a negative count or one above the stack size

get(ItemComponentKey<T>)​

<T> Optional<T> get(ItemComponentKey<T> key)

Since 0.1.0-alpha.4 or earlier

The component's value, or empty when the stack does not have it.

ParameterTypeDescription
keyItemComponentKey<T>—

Returns Optional<T>

set(ItemComponentKey<T>, T)​

<T> void set(ItemComponentKey<T> key, T value)

Since 0.1.0-alpha.4 or earlier

Sets the component's value.

ParameterTypeDescription
keyItemComponentKey<T>—
valueT—

Throws IllegalArgumentException — for a key that is not registered

Throws IllegalStateException — on an empty stack

remove(ItemComponentKey<?>)​

void remove(ItemComponentKey<?> key)

Since 0.1.0-alpha.4 or earlier

Removes the component.

ParameterTypeDescription
keyItemComponentKey<?>—

customName()​

Optional<String> customName()

Since 0.1.0-alpha.4 or earlier

The name given with an anvil or setCustomName, if any.

Returns Optional<String>

setCustomName(String)​

void setCustomName(String name)

Since 0.1.0-alpha.4 or earlier

Gives the stack a name, or removes it with null.

ParameterTypeDescription
nameString—

damage()​

int damage()

Since 0.1.0-alpha.4 or earlier

Durability used up, 0 for undamaged or undamageable items.

Returns int

maxDamage()​

int maxDamage()

Since 0.1.0-alpha.4 or earlier

Durability, 0 for undamageable items.

Returns int

setDamage(int)​

void setDamage(int damage)

Since 0.1.0-alpha.4 or earlier

Sets the used durability, clamped to [0, maxDamage].

ParameterTypeDescription
damageint—

snapshot()​

ItemStackView snapshot()

Since 0.1.0-alpha.4 or earlier

A snapshot of item and count.

Returns ItemStackView

ItemStackView​

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

public record ItemStackView(ResourceId item, int count)

An item and a count; a snapshot, so changing the inventory does not change it.

ComponentTypeDescription
itemResourceIdthe item, minecraft:air for an empty slot
countinthow many, 0 for an empty slot
Constant or fieldTypeDescription
EMPTYItemStackViewAn empty slot.

isEmpty()​

public boolean isEmpty()

Since 0.1.0-alpha.4 or earlier

Whether the slot is empty.

Returns boolean

Buy me a coffee