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.DefaultChangeTrackerNested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.FixedItemInv
FixedItemInv.CopyingFixedItemInv, FixedItemInv.ModifiableFixedItemInv -
Method Summary
Modifier and TypeMethodDescriptiondefault ItemFiltergetFilterForSlot(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) booleanisItemValidForSlot(int slot, net.minecraft.item.ItemStack stack) Checks to see if the given stack is valid for a given slot.voidInforms this inventory that theItemStackreturned bygetInvStack(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.Methods inherited from interface alexiil.mc.lib.attributes.item.AbstractItemInvView
addListener, getChangeValueMethods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInv
createLimitedFixedInv, extractStack, forceSetInvStack, getExtractable, getGroupedInv, getInsertable, getMappedInv, getSlot, getSubInv, getTransferable, insertStack, modifySlot, slotIterableMethods 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:
getInvStackin interfaceFixedItemInv- 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 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 theItemcontained inItemStack's, because callers can always modify any other properties (like count or NBT) themselves- Specified by:
isItemValidForSlotin interfaceFixedItemInv- 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).stack- TheItemStackto check. It's undefined what is returned if anemptystack is passed in, but it is not generally expected to be useful.
-
getFilterForSlot
Note 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 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).
-
setInvStack
Description copied from interface:FixedItemInvSets the stack in the given slot to the given stack.- Specified by:
setInvStackin 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 theItemStackreturned bygetInvStack(int)has been changed.
-