dev.polymodloader.api.inventory
This page is generated from the source's Javadoc by ./gradlew apiReference. Do not edit it; fix the source comment and generate it again.
| Type | Kind | Description |
|---|---|---|
InventoryView | interface | Slots of an inventory, such as a mod block entity's. |
ItemStackRef | interface | A live item stack in a slot or a hand: changes apply to the game's stack directly. |
ItemStackView | record | An 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.
| Parameter | Type | Description |
|---|---|---|
slot | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
slot | int | — |
item | ResourceId | — |
count | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
item | ResourceId | — |
count | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
item | ResourceId | — |
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.
| Parameter | Type | Description |
|---|---|---|
slot | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
tag | TagKey | — |
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.
| Parameter | Type | Description |
|---|---|---|
count | int | — |
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.
| Parameter | Type | Description |
|---|---|---|
key | ItemComponentKey<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.
| Parameter | Type | Description |
|---|---|---|
key | ItemComponentKey<T> | — |
value | T | — |
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.
| Parameter | Type | Description |
|---|---|---|
key | ItemComponentKey<?> | — |
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.
| Parameter | Type | Description |
|---|---|---|
name | String | — |
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].
| Parameter | Type | Description |
|---|---|---|
damage | int | — |
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.
| Component | Type | Description |
|---|---|---|
item | ResourceId | the item, minecraft:air for an empty slot |
count | int | how many, 0 for an empty slot |
| Constant or field | Type | Description |
|---|---|---|
EMPTY | ItemStackView | An empty slot. |
isEmpty()
public boolean isEmpty()
Since 0.1.0-alpha.4 or earlier
Whether the slot is empty.
Returns boolean