Package alexiil.mc.lib.attributes.item
Interface FixedItemInv.ModifiableFixedItemInv
- All Superinterfaces:
AbstractItemInvView
,Convertible
,FixedItemInv
,FixedItemInvView
- All Known Implementing Classes:
CombinedFixedItemInv.OfModifiable
,DelegatingFixedItemInv.OfModifiable
,DirectFixedItemInv
,EmptyFixedItemInv
,FixedInventoryVanillaWrapper
,FixedSidedInventoryVanillaWrapper
,MappedFixedItemInv.OfModifiable
,SimpleLimitedFixedItemInv.OfModifiable
,SubFixedItemInv.OfModifiable
- Enclosing interface:
- FixedItemInv
The "simpler" variant of
FixedItemInv
which allows callers to freely modify the current
ItemStack
contained in it's inventory.-
Nested Class Summary
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
-
Method Summary
Modifier and TypeMethodDescriptiondefault 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.net.minecraft.item.ItemStack
getInvStack(int slot)
boolean
isItemValidForSlot(int slot, net.minecraft.item.ItemStack stack)
Checks to see if the given stack is valid for a given slot.void
Informs this inventory that theItemStack
returned bygetInvStack(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.Methods inherited from interface alexiil.mc.lib.attributes.item.AbstractItemInvView
addListener, getChangeValue
Methods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInv
createLimitedFixedInv, extractStack, forceSetInvStack, getExtractable, getGroupedInv, getInsertable, getMappedInv, getSlot, getSubInv, getTransferable, insertStack, modifySlot, slotIterable
Methods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInvView
convertTo, getFixedView, getMaxAmount, getSlotCount, offerSelfAsAttribute, stackIterable
-
Method Details
-
getInvStack
net.minecraft.item.ItemStack getInvStack(int slot)- Specified by:
getInvStack
in interfaceFixedItemInv
- 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 callmarkDirty()
orsetInvStack(int, ItemStack, Simulation)
after you have finished modifying it.
-
isItemValidForSlot
boolean isItemValidForSlot(int slot, net.minecraft.item.ItemStack stack)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 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
- 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
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 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)
.
-
setInvStack
Description copied from interface:FixedItemInv
Sets the stack in the given slot to the given stack.- Specified by:
setInvStack
in interfaceFixedItemInv
- Parameters:
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 bygetInvStack(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).
-
markDirty
void markDirty()Informs this inventory that theItemStack
returned bygetInvStack(int)
has been changed.
-