Enum Class EmptyFixedItemInv
- All Implemented Interfaces:
Convertible,AbstractItemInvView,FixedItemInv,FixedItemInv.ModifiableFixedItemInv,FixedItemInvView,NullVariant,Serializable,Comparable<EmptyFixedItemInv>,Constable
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
Enum.EnumDesc<E extends Enum<E>>Nested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.AbstractItemInvView
AbstractItemInvView.DefaultChangeTrackerNested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.FixedItemInv
FixedItemInv.CopyingFixedItemInv, FixedItemInv.ModifiableFixedItemInv -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionaddListener(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()).intgetFilterForSlot(int slot) Note that this filter should only compare theItemcontained inItemStack's, because callers can always modify any other properties (like count or NBT) themselves.net.minecraft.item.ItemStackgetInvStack(int slot) intgetMaxAmount(int slot, net.minecraft.item.ItemStack stack) intbooleanisItemValidForSlot(int slot, net.minecraft.item.ItemStack item) Checks to see if the given stack is valid for a given slot.voidInforms this inventory that theItemStackreturned byFixedItemInv.ModifiableFixedItemInv.getInvStack(int)has been changed.booleansetInvStack(int slot, net.minecraft.item.ItemStack to, Simulation simulation) Sets the stack in the given slot to the given stack.toString()static EmptyFixedItemInvReturns the enum constant of this class with the specified name.static EmptyFixedItemInv[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOfMethods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInv
createLimitedFixedInv, extractStack, forceSetInvStack, getMappedInv, getSlot, getSubInv, insertStack, modifySlot, slotIterableMethods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInvView
convertTo, offerSelfAsAttribute, stackIterable
-
Enum Constant Details
-
INSTANCE
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getSlotCount
public int getSlotCount()- Specified by:
getSlotCountin interfaceFixedItemInvView- Returns:
- The number of slots in this inventory.
-
getInvStack
public net.minecraft.item.ItemStack getInvStack(int slot) - Specified by:
getInvStackin interfaceFixedItemInv- Specified by:
getInvStackin interfaceFixedItemInv.ModifiableFixedItemInv- Specified by:
getInvStackin 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
ItemStackthat 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.ModifiableFixedItemInvChecks 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 theItemcontained inItemStack's, because callers can always modify any other properties (like count or NBT) themselves- Specified by:
isItemValidForSlotin interfaceFixedItemInv- Specified by:
isItemValidForSlotin interfaceFixedItemInv.ModifiableFixedItemInv- Specified by:
isItemValidForSlotin 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- TheItemStackto check. It's undefined what is returned if anemptystack is passed in, but it is not generally expected to be useful.
-
getFilterForSlot
Description copied from interface:FixedItemInv.ModifiableFixedItemInvNote that this filter should only compare theItemcontained inItemStack's, because callers can always modify any other properties (like count or NBT) themselves.- Specified by:
getFilterForSlotin interfaceFixedItemInv.ModifiableFixedItemInv- Specified by:
getFilterForSlotin 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
ItemFilterfor what may be present in this slot. If this slot is filtered by anItemFilterinternally 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:
getMaxAmountin 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 anemptystack 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:
getChangeValuein 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
listenershighly 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.ModifiableFixedItemInvInforms this inventory that theItemStackreturned byFixedItemInv.ModifiableFixedItemInv.getInvStack(int)has been changed.- Specified by:
markDirtyin interfaceFixedItemInv.ModifiableFixedItemInv
-
addListener
Description copied from interface:AbstractItemInvViewAdds 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:
addListenerin interfaceAbstractItemInvViewremovalToken- 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:FixedItemInvSets the stack in the given slot to the given stack.- Specified by:
setInvStackin interfaceFixedItemInv- Specified by:
setInvStackin interfaceFixedItemInv.ModifiableFixedItemInvto- 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:
getFixedViewin interfaceFixedItemInvView- Returns:
- An object that only implements
FixedItemInvView, and does not expose the modification methods thatFixedItemInvdoes. Implementations that don't expose any modification methods themselves should override this method to just return themselves.
-
getGroupedInv
- Specified by:
getGroupedInvin interfaceFixedItemInv- Specified by:
getGroupedInvin interfaceFixedItemInvView- Returns:
- A
GroupedItemInvfor this inventory. The returned value must always be valid for the lifetime of thisFixedItemInvobject. (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:
getTransferablein interfaceFixedItemInv- Returns:
- An
ItemTransferablefor this inventory. The default implementation delegates toFixedItemInv.getGroupedInv().
-
getInsertable
- Specified by:
getInsertablein interfaceFixedItemInv- Returns:
- An
ItemInsertablefor this inventory that will attempt to insert into any of the slots in this inventory. The default implementation delegates toFixedItemInv.getGroupedInv().
-
getExtractable
- Specified by:
getExtractablein interfaceFixedItemInv- Returns:
- An
ItemExtractablefor this inventory that will attempt to extract from any of the slots in this inventory. The default implementation delegates toFixedItemInv.getGroupedInv().
-
toString
- Overrides:
toStringin classEnum<EmptyFixedItemInv>
-