Enum EmptyFixedItemInv
- All Implemented Interfaces:
Convertible
,AbstractItemInvView
,FixedItemInv
,FixedItemInv.ModifiableFixedItemInv
,FixedItemInvView
,NullVariant
,java.io.Serializable
,java.lang.Comparable<EmptyFixedItemInv>
,java.lang.constant.Constable
public enum EmptyFixedItemInv extends java.lang.Enum<EmptyFixedItemInv> implements FixedItemInv.ModifiableFixedItemInv, NullVariant
FixedItemInv
with no slots. Because this inventory is unmodifiable this also doubles as the empty
implementation for FixedItemInvView
.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
java.lang.Enum.EnumDesc<E extends java.lang.Enum<E>>
Nested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.AbstractItemInvView
AbstractItemInvView.DefaultChangeTracker
Nested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.FixedItemInv
FixedItemInv.CopyingFixedItemInv, FixedItemInv.ModifiableFixedItemInv
-
Enum Constant Summary
Enum Constants Enum Constant Description INSTANCE
-
Method Summary
Modifier and Type Method Description ListenerToken
addListener(InvMarkDirtyListener listener, ListenerRemovalToken removalToken)
Adds the given listener to this inventory, such thatInvMarkDirtyListener.onMarkDirty(AbstractItemInvView)
will be called every time that any stored stack is changed (either fromFixedItemInv.setInvStack(int, ItemStack, Simulation)
orFixedItemInv.ModifiableFixedItemInv.markDirty()
).int
getChangeValue()
ItemExtractable
getExtractable()
ItemFilter
getFilterForSlot(int slot)
Note that this filter should only compare theItem
contained inItemStack
's, because callers can always modify any other properties (like count or NBT) themselves.FixedItemInvView
getFixedView()
GroupedItemInv
getGroupedInv()
ItemInsertable
getInsertable()
net.minecraft.item.ItemStack
getInvStack(int slot)
int
getMaxAmount(int slot, net.minecraft.item.ItemStack stack)
int
getSlotCount()
ItemTransferable
getTransferable()
boolean
isItemValidForSlot(int slot, net.minecraft.item.ItemStack item)
Checks to see if the given stack is valid for a given slot.void
markDirty()
Informs this inventory that theItemStack
returned byFixedItemInv.ModifiableFixedItemInv.getInvStack(int)
has been changed.boolean
setInvStack(int slot, net.minecraft.item.ItemStack to, Simulation simulation)
Sets the stack in the given slot to the given stack.java.lang.String
toString()
static EmptyFixedItemInv
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static EmptyFixedItemInv[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
Methods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInv
createLimitedFixedInv, extractStack, forceSetInvStack, getMappedInv, getSlot, getSubInv, insertStack, modifySlot, slotIterable
Methods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInvView
convertTo, offerSelfAsAttribute, stackIterable
-
Enum Constant Details
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
getSlotCount
public int getSlotCount()- Specified by:
getSlotCount
in interfaceFixedItemInvView
- Returns:
- The number of slots in this inventory.
-
getInvStack
public net.minecraft.item.ItemStack getInvStack(int slot)- Specified by:
getInvStack
in interfaceFixedItemInv
- Specified by:
getInvStack
in interfaceFixedItemInv.ModifiableFixedItemInv
- Specified by:
getInvStack
in interfaceFixedItemInvView
- Parameters:
slot
- The slot index. Must be a value between 0 (inclusive) andFixedItemInvView.getSlotCount()
(exclusive) to be valid. (Like in arrays, lists, etc).- Returns:
- The
ItemStack
that is stored in thisFixedItemInv
. Changing this will always change this inventory. As such you must always callFixedItemInv.ModifiableFixedItemInv.markDirty()
orFixedItemInv.ModifiableFixedItemInv.setInvStack(int, ItemStack, Simulation)
after you have finished modifying it.
-
isItemValidForSlot
public boolean isItemValidForSlot(int slot, net.minecraft.item.ItemStack item)Description copied from interface:FixedItemInv.ModifiableFixedItemInv
Checks to see if the given stack is valid for a given slot. This ignores any current stacks in the slot. Note that this should only compare theItem
contained inItemStack
's, because callers can always modify any other properties (like count or NBT) themselves- Specified by:
isItemValidForSlot
in interfaceFixedItemInv
- Specified by:
isItemValidForSlot
in interfaceFixedItemInv.ModifiableFixedItemInv
- Specified by:
isItemValidForSlot
in interfaceFixedItemInvView
- Parameters:
slot
- The slot index. Must be a value between 0 (inclusive) andFixedItemInvView.getSlotCount()
(exclusive) to be valid. (Like in arrays, lists, etc).item
- TheItemStack
to check. It's undefined what is returned if anempty
stack is passed in, but it is not generally expected to be useful.
-
getFilterForSlot
Description copied from interface:FixedItemInv.ModifiableFixedItemInv
Note that this filter should only compare theItem
contained inItemStack
's, because callers can always modify any other properties (like count or NBT) themselves.- Specified by:
getFilterForSlot
in interfaceFixedItemInv.ModifiableFixedItemInv
- Specified by:
getFilterForSlot
in interfaceFixedItemInvView
- Parameters:
slot
- The slot index. Must be a value between 0 (inclusive) andFixedItemInvView.getSlotCount()
(exclusive) to be valid. (Like in arrays, lists, etc).- Returns:
- An
ItemFilter
for what may be present in this slot. If this slot is filtered by anItemFilter
internally then it is highly recommended that this be overridden to return that filter rather than the default opaque wrapper aroundFixedItemInvView.isItemValidForSlot(int, ItemStack)
.
-
getMaxAmount
public int getMaxAmount(int slot, net.minecraft.item.ItemStack stack)- Specified by:
getMaxAmount
in interfaceFixedItemInvView
- Parameters:
slot
- The slot index. Must be a value between 0 (inclusive) andFixedItemInvView.getSlotCount()
(exclusive) to be valid. (Like in arrays, lists, etc).stack
- The stack to check for. May be anempty
stack to get the maximum amount that this can hold of any stack.- Returns:
- The maximum amount that the given slot can hold of the given stack. This method will ignore the current
stack in
FixedItemInvView.getInvStack(int)
. The default implementation just delegates toItemStack.getMaxCount()
. Note that any setters that this object implements (likeFixedItemInv.setInvStack(int, ItemStack, Simulation)
should reject stacks that are greater than this value. (and callers should only call this if they need to check the amounts separately. Note that it is meaningless to return values greater than the maximum amount an item can be stacked to here, and callers are free to throw an exception if this is violated. (Basically huge single-slot inventories shouldn't implement this interface).
-
getChangeValue
public int getChangeValue()- Specified by:
getChangeValue
in interfaceAbstractItemInvView
- Returns:
- A value that indicates whether an inventory might have changed if it differs from the last value
returned. This number doesn't have to start at 0, but it must change every time that the inventory is
changed, although it can change even without any observable changes to this inventory.
Inventories that don't support this might increment the change number every time that this is called - so you should never write a loop that depends on the returned value settling down on a particular value.
Inventories that support
listeners
highly encouraged to support this - by definition if an inventory knows when it changed then it should be able to count the number of changes. It is also implied that any changes to this value will also invoke every registeredInvMarkDirtyListener
.The default implementation returns an ever-increasing value.
-
markDirty
public void markDirty()Description copied from interface:FixedItemInv.ModifiableFixedItemInv
Informs this inventory that theItemStack
returned byFixedItemInv.ModifiableFixedItemInv.getInvStack(int)
has been changed.- Specified by:
markDirty
in interfaceFixedItemInv.ModifiableFixedItemInv
-
addListener
Description copied from interface:AbstractItemInvView
Adds the given listener to this inventory, such thatInvMarkDirtyListener.onMarkDirty(AbstractItemInvView)
will be called every time that any stored stack is changed (either fromFixedItemInv.setInvStack(int, ItemStack, Simulation)
orFixedItemInv.ModifiableFixedItemInv.markDirty()
).If the listener is registered (and thus this returns null) then it implies that
AbstractItemInvView.getChangeValue()
will change every time that the given listener is invoked, always just-before it is invoked.The default implementation refuses to accept any listeners, but implementations are highly encouraged to override this if they are able to!
- Specified by:
addListener
in interfaceAbstractItemInvView
removalToken
- A token that will be called whenever the given listener is removed from this inventory (or if this inventory itself is unloaded or otherwise invalidated).- Returns:
- A token that represents the listener, or null if the listener could not be added.
-
setInvStack
Description copied from interface:FixedItemInv
Sets the stack in the given slot to the given stack.- Specified by:
setInvStack
in interfaceFixedItemInv
- Specified by:
setInvStack
in interfaceFixedItemInv.ModifiableFixedItemInv
to
- The new stack to set this to. If this is identically equal (with ==) to the stack held in this inventory (so it was returned byFixedItemInv.ModifiableFixedItemInv.getInvStack(int)
) then this will return true.- Returns:
- True if the modification was allowed, false otherwise. (For example if the given stack doesn't pass the
FixedItemInvView.isItemValidForSlot(int, ItemStack)
test).
-
getFixedView
- Specified by:
getFixedView
in interfaceFixedItemInvView
- Returns:
- An object that only implements
FixedItemInvView
, and does not expose the modification methods thatFixedItemInv
does. Implementations that don't expose any modification methods themselves should override this method to just return themselves.
-
getGroupedInv
- Specified by:
getGroupedInv
in interfaceFixedItemInv
- Specified by:
getGroupedInv
in interfaceFixedItemInvView
- Returns:
- A
GroupedItemInv
for this inventory. The returned value must always be valid for the lifetime of thisFixedItemInv
object. (In other words it must always be valid to cache this returned value and use it alongside a cached instance of this object).
-
getTransferable
- Specified by:
getTransferable
in interfaceFixedItemInv
- Returns:
- An
ItemTransferable
for this inventory. The default implementation delegates toFixedItemInv.getGroupedInv()
.
-
getInsertable
- Specified by:
getInsertable
in interfaceFixedItemInv
- Returns:
- An
ItemInsertable
for this inventory that will attempt to insert into any of the slots in this inventory. The default implementation delegates toFixedItemInv.getGroupedInv()
.
-
getExtractable
- Specified by:
getExtractable
in interfaceFixedItemInv
- Returns:
- An
ItemExtractable
for this inventory that will attempt to extract from any of the slots in this inventory. The default implementation delegates toFixedItemInv.getGroupedInv()
.
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Enum<EmptyFixedItemInv>
-