Class FixedInventoryVanillaWrapper
java.lang.Object
alexiil.mc.lib.attributes.item.compat.FixedInventoryViewVanillaWrapper
alexiil.mc.lib.attributes.item.compat.FixedInventoryVanillaWrapper
- All Implemented Interfaces:
Convertible
,AbstractItemInvView
,FixedItemInv
,FixedItemInv.ModifiableFixedItemInv
,FixedItemInvView
,OpenWrapper
- Direct Known Subclasses:
FixedSidedInventoryVanillaWrapper
public class FixedInventoryVanillaWrapper extends FixedInventoryViewVanillaWrapper implements FixedItemInv.ModifiableFixedItemInv
An
FixedItemInv
that wraps a vanilla 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
-
Field Summary
Fields inherited from class alexiil.mc.lib.attributes.item.compat.FixedInventoryViewVanillaWrapper
inv
-
Constructor Summary
Constructors Constructor Description FixedInventoryVanillaWrapper(net.minecraft.inventory.Inventory inv)
-
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()
).protected boolean
canExtract(int slot, net.minecraft.item.ItemStack extractedStack)
protected boolean
canInsert(int slot, net.minecraft.item.ItemStack newStack)
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.Methods inherited from class alexiil.mc.lib.attributes.item.compat.FixedInventoryViewVanillaWrapper
getInvStack, getMaxAmount, getSlotCount, getWrapped, isItemValidForSlot, wrapInventory
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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.FixedItemInv.ModifiableFixedItemInv
getFilterForSlot, getInvStack, isItemValidForSlot
Methods inherited from interface alexiil.mc.lib.attributes.item.FixedItemInvView
convertTo, getFixedView, getMaxAmount, getSlotCount, offerSelfAsAttribute, stackIterable
-
Constructor Details
-
FixedInventoryVanillaWrapper
public FixedInventoryVanillaWrapper(net.minecraft.inventory.Inventory inv)
-
-
Method Details
-
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).
-
canExtract
protected boolean canExtract(int slot, net.minecraft.item.ItemStack extractedStack) -
canInsert
protected boolean canInsert(int slot, net.minecraft.item.ItemStack newStack) -
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.
-