Class DirectFixedItemInv
- All Implemented Interfaces:
- Convertible,- AbstractItemInvView,- FixedItemInv,- FixedItemInv.ModifiableFixedItemInv,- FixedItemInvView,- GroupedItemInv,- GroupedItemInvView,- ItemExtractable,- ItemInsertable,- ItemTransferable,- LimitedConsumer<net.minecraft.item.ItemStack>,- Saveable
FixedItemInv.ModifiableFixedItemInv that supports all of the features that the interface
 exposes. For simplicities sake this also implements GroupedItemInv, however none of the grouped methods run
 in O(1).- 
Nested Class SummaryNested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.AbstractItemInvViewAbstractItemInvView.DefaultChangeTrackerNested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.FixedItemInvFixedItemInv.CopyingFixedItemInv, FixedItemInv.ModifiableFixedItemInvNested classes/interfaces inherited from interface alexiil.mc.lib.attributes.item.GroupedItemInvViewGroupedItemInvView.ItemInvStatistic
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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()).addListener(ItemInvAmountChangeListener listener, ListenerRemovalToken removalToken)Adds the given listener to this inventory, such that theItemInvAmountChangeListener.onChange(GroupedItemInvView, ItemStack, int, int)will be called every time that this inventory changes.net.minecraft.item.ItemStackattemptExtraction(ItemFilter filter, int maxAmount, Simulation simulation)net.minecraft.item.ItemStackattemptInsertion(net.minecraft.item.ItemStack stack, Simulation simulation)Inserts the given stack into this insertable, and returns the excess.net.minecraft.item.ItemStackextract(int slot, int count)Splits off the given amount from theItemStackin the given slot.voidfromTag(net.minecraft.nbt.NbtCompound tag)net.minecraft.item.ItemStackget(int slot)Deprecated, for removal: This API element is subject to removal in a future version.intnet.minecraft.item.ItemStackgetInvStack(int slot)intgetStatistics(ItemFilter filter)Set<net.minecraft.item.ItemStack>intnet.minecraft.item.ItemStackinsert(int slot, net.minecraft.item.ItemStack stack)Tries to insert the given stack into the given slot.voidRemoves every listener currently registered to this inventory.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 byFixedItemInv.ModifiableFixedItemInv.getInvStack(int)has been changed.voidset(int slot, net.minecraft.item.ItemStack stack)Deprecated, for removal: This API element is subject to removal in a future version.This used to be necessary in 0.4.x, but since 0.5.0 this is unnecessary.booleansetInvStack(int slot, net.minecraft.item.ItemStack to, Simulation simulation)Sets the stack in the given slot to the given stack.voidsetOwnerListener(InvMarkDirtyListener ownerListener)Sets the owner listener callback, which is never removed from the listener list wheninvalidateListeners()is called.net.minecraft.nbt.NbtCompoundtoTag()net.minecraft.nbt.NbtCompoundtoTag(net.minecraft.nbt.NbtCompound tag)voidvalidateSlotIndex(int slot)Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInvcreateLimitedFixedInv, extractStack, forceSetInvStack, getExtractable, getGroupedInv, getInsertable, getMappedInv, getSlot, getSubInv, getTransferable, insertStack, modifySlot, slotIterableMethods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInv.ModifiableFixedItemInvgetFilterForSlotMethods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInvViewconvertTo, getFixedView, getMaxAmount, offerSelfAsAttribute, stackIterableMethods inherited from interface alexiil.mc.lib.attributes.item.GroupedItemInvcreateLimitedGroupedInv, filteredMethods inherited from interface alexiil.mc.lib.attributes.item.GroupedItemInvViewgetAmount, getAmount, getCapacity, getGroupedView, getSpace, getStatistics, isEmptyMethods inherited from interface alexiil.mc.lib.attributes.item.ItemExtractableattemptAnyExtraction, couldExtractAnything, extract, extract, extract, getPureExtractableMethods inherited from interface alexiil.mc.lib.attributes.item.ItemInsertablegetInsertionFilter, getPureInsertable, insert, offer, offer, wouldAccept, wouldPartiallyAccept
- 
Constructor Details- 
DirectFixedItemInvpublic DirectFixedItemInv(int slotCount)
 
- 
- 
Method Details- 
get@Deprecated(since="0.5.0", forRemoval=true) public final net.minecraft.item.ItemStack get(int slot)Deprecated, for removal: This API element is subject to removal in a future version.This used to be necessary in 0.4.x, but since 0.5.0getInvStack(int)just returns the itemstack in the slot index.
- 
set@Deprecated(since="0.5.0", forRemoval=true) public final void set(int slot, net.minecraft.item.ItemStack stack)Deprecated, for removal: This API element is subject to removal in a future version.This used to be necessary in 0.4.x, but since 0.5.0 this is unnecessary.
- 
markDirtypublic final void markDirty()Description copied from interface:FixedItemInv.ModifiableFixedItemInvInforms this inventory that theItemStackreturned byFixedItemInv.ModifiableFixedItemInv.getInvStack(int)has been changed.- Specified by:
- markDirtyin interface- FixedItemInv.ModifiableFixedItemInv
 
- 
invalidateListenerspublic final void invalidateListeners()Removes every listener currently registered to this inventory.
- 
validateSlotIndexpublic void validateSlotIndex(int slot)
- 
toTagpublic final net.minecraft.nbt.NbtCompound toTag()
- 
toTagpublic net.minecraft.nbt.NbtCompound toTag(net.minecraft.nbt.NbtCompound tag)
- 
fromTagpublic void fromTag(net.minecraft.nbt.NbtCompound tag)
- 
getSlotCountpublic int getSlotCount()- Specified by:
- getSlotCountin interface- FixedItemInvView
- Returns:
- The number of slots in this inventory.
 
- 
getInvStackpublic net.minecraft.item.ItemStack getInvStack(int slot)- Specified by:
- getInvStackin interface- FixedItemInv
- Specified by:
- getInvStackin interface- FixedItemInv.ModifiableFixedItemInv
- Specified by:
- getInvStackin interface- FixedItemInvView
- Parameters:
- slot- The slot index. Must be a value between 0 (inclusive) and- FixedItemInvView.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.
 
- 
isItemValidForSlotpublic boolean isItemValidForSlot(int slot, net.minecraft.item.ItemStack stack)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 interface- FixedItemInv
- Specified by:
- isItemValidForSlotin interface- FixedItemInv.ModifiableFixedItemInv
- Specified by:
- isItemValidForSlotin interface- FixedItemInvView
- Parameters:
- slot- The slot index. Must be a value between 0 (inclusive) and- FixedItemInvView.getSlotCount()(exclusive) to be valid. (Like in arrays, lists, etc).
- stack- The- ItemStackto check. It's undefined what is returned if an- emptystack is passed in, but it is not generally expected to be useful.
 
- 
addListenerpublic final ListenerToken addListener(InvMarkDirtyListener listener, ListenerRemovalToken removalToken)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 interface- AbstractItemInvView
- Specified by:
- addListenerin interface- GroupedItemInvView
- 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.
 
- 
setOwnerListenerSets the owner listener callback, which is never removed from the listener list wheninvalidateListeners()is called.
- 
setInvStackDescription copied from interface:FixedItemInvSets the stack in the given slot to the given stack.- Specified by:
- setInvStackin interface- FixedItemInv
- Specified by:
- setInvStackin interface- FixedItemInv.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 by- FixedItemInv.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).
 
- 
getChangeValuepublic int getChangeValue()- Specified by:
- getChangeValuein interface- AbstractItemInvView
- 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. 
 
- 
getStoredStacks- Specified by:
- getStoredStacksin interface- GroupedItemInvView
- Returns:
- a set containing all of the ItemStack's that are stored in the inventory. NOTE: This must return a set using one of theHash.Strategy's inItemStackCollectionsotherwise comparison methods won't work correctly!
 
- 
getTotalCapacitypublic int getTotalCapacity()- Specified by:
- getTotalCapacityin interface- GroupedItemInvView
- Returns:
- The total capacity for every ItemStackthat can be stored in this inventory.NOTE: This value might not be equal to the sum of GroupedItemInvView.getCapacity(ItemStack)overGroupedItemInvView.getStoredStacks()!
 
- 
getStatistics- Specified by:
- getStatisticsin interface- GroupedItemInvView
- Parameters:
- filter- The filter to check on.
- Returns:
- Statistics about the currently stored amount, capacity, and space for everything that matches the given filter.
 
- 
addListenerpublic ListenerToken addListener(ItemInvAmountChangeListener listener, ListenerRemovalToken removalToken)Description copied from interface:GroupedItemInvViewAdds the given listener to this inventory, such that theItemInvAmountChangeListener.onChange(GroupedItemInvView, ItemStack, int, int)will be called every time that this inventory changes. However if this inventory doesn't support listeners then this will return a nulltoken.The default implementation refuses to accept any listeners, but implementations are highly encouraged to override this if they are able to! - Specified by:
- addListenerin interface- GroupedItemInvView
- 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.
 
- 
attemptInsertionpublic net.minecraft.item.ItemStack attemptInsertion(net.minecraft.item.ItemStack stack, Simulation simulation)Description copied from interface:ItemInsertableInserts the given stack into this insertable, and returns the excess.- Specified by:
- attemptInsertionin interface- ItemInsertable
- Parameters:
- stack- The incoming stack. Must not be modified by this call.
- simulation- If- Simulation.SIMULATEthen this shouldn't modify anything.
- Returns:
- the excess ItemStackthat wasn't accepted. This will be independent of this insertable, however it might be the given stack instead of a completely new object.
 
- 
attemptExtractionpublic net.minecraft.item.ItemStack attemptExtraction(ItemFilter filter, int maxAmount, Simulation simulation)Description copied from interface:ItemExtractable- Specified by:
- attemptExtractionin interface- ItemExtractable
- maxAmount- The maximum number of items that can be extracted. Negative numbers throw an exception.
- simulation- If- Simulation.SIMULATEthen this should return the same result that a call with- Simulation.ACTIONwould do, but without modifying anything else.
- Returns:
- A new, independent ItemStackthat was extracted.
 
- 
extractpublic net.minecraft.item.ItemStack extract(int slot, int count)Splits off the given amount from theItemStackin the given slot.
- 
insertpublic net.minecraft.item.ItemStack insert(int slot, net.minecraft.item.ItemStack stack)Tries to insert the given stack into the given slot.- Returns:
- The result that couldn't be inserted.
 
 
- 
getInvStack(int)just returns the itemstack in the slot index.