Inventory class
Slots of ItemStacks, the first hotbarSize of them the hotbar. How many of an item fit a slot and how long it lasts are the game's, asked through stackSize and maxDurability.
Constructors
Properties
- capacity → int
-
How many slots.
final
- hasEmptySlot → bool
-
Whether any slot is empty.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hotbarSize → int
-
How many of the first slots are the hotbar.
final
-
listeners
→ List<
void Function()> -
Called after every change.
final
- maxDurability → int Function(String id)
-
Uses item
idsurvives; 0 for one that never wears.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
slots
→ List<
ItemStack?> -
The slots; null is empty.
final
- stackSize → int Function(String id)
-
How many of item
idfit one slot.final
Methods
-
add(
String id, int count) → int -
Adds up to
countofid, topping up stacks before opening slots; returns what did not fit. -
addStack(
ItemStack stack) → bool -
Puts a copy of
stack(bonus and wear kept) in the first empty slot; false when none is. -
bonusAt(
int i) → int -
The bonus of slot
i's stack. -
countAt(
int i) → int -
How many in slot
i. -
countOf(
String id) → int -
How many of
idin every slot. -
durAt(
int i) → int -
Uses left on slot
i's tool or weapon (its maximum when never worn), 0 for an item that never wears or an empty slot. -
emitChanged(
) → void - Tells the listeners a slot changed from outside (a stack edited in place).
-
find(
String id) → int -
The first slot holding
id, or -1. -
fromJson(
List< Object?> data, {bool known(String id)?}) → void -
Reads
databack; a slot naming an itemknownrejects stays empty. -
idAt(
int i) → String -
The item in slot
i,''when empty. -
isEmptySlot(
int i) → bool -
Whether slot
iis empty. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
String id, int count) → bool -
Takes
countofid, from the last slots first; false (and nothing taken) when there are fewer. -
roomFor(
String id, int count) → int -
How many of
countidwould fit right now. -
setSlot(
int i, ItemStack? stack) → void -
Sets slot
ito a copy ofstack(null empties it). -
swap(
int a, int b) → void -
Swaps slots
aandb. -
takeFromSlot(
int i, int count) → ItemStack? -
Takes up to
countfrom slotias a new stack; null when empty. -
toJson(
) → List< Object> - Every slot, an empty map for an empty one.
-
toString(
) → String -
A string representation of this object.
inherited
-
wear(
int i, [int uses = 1]) → bool -
Wears slot
i's item byuses; true when it broke (the slot empties).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited