Record Class SlotRef
- Record Components:
container- the container the slot reads and writescontainerSlot- the slot's index withincontainerslot- the live slot on the menu, ornulloff-menu- the open menu, ornulloff-menuplayer- who is acting, ornullfor automationcategory- the slot's category onmenu, ornullwhen off-menu or in no categoryaddress- the slot's window address, ornullwhen the seam cannot identify the container
SlotOperations.Veto sees.
Every seam has the backing Container and the container-relative
index, which is how a locking mod already keys its locks (the player inventory
by index, an ender chest by index, a placed container by identity). A menu seam
also has the live Slot and its menu, and from those the slot's
SlotGroupCategory on that menu. A click seam has the acting
Player; a per-player lock needs to know whose click this is, so a LAN
guest is not checked against the host's locks. The slot's Address is
here too, minted once by the installed rule, so a veto that keys on it never
derives it itself. Anything the seam does not have is null: an inventory
insert (Inventory.getFreeSlot) has no menu and no slot, only the
inventory, its index and its owner, and an address only where the container has
an identity.
-
Constructor Summary
ConstructorsConstructorDescriptionSlotRef(net.minecraft.world.Container container, int containerSlot, @Nullable net.minecraft.world.inventory.Slot slot, @Nullable net.minecraft.world.inventory.AbstractContainerMenu menu, @Nullable net.minecraft.world.entity.player.Player player, @Nullable SlotGroupCategory category, @Nullable Address address) Creates an instance of aSlotRefrecord class. -
Method Summary
Modifier and TypeMethodDescription@Nullable Addressaddress()Returns the value of theaddressrecord component.static AddressaddressOf(net.minecraft.world.inventory.AbstractContainerMenu menu, net.minecraft.world.inventory.Slot slot) @Nullable SlotGroupCategorycategory()Returns the value of thecategoryrecord component.net.minecraft.world.ContainerReturns the value of thecontainerrecord component.intReturns the value of thecontainerSlotrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static SlotRefinventory(net.minecraft.world.inventory.AbstractContainerMenu menu, net.minecraft.world.entity.player.Player player, int index) The player-inventory slot atindexas it sits onmenu, so it resolves with its menu category; the bare container form when the menu does not show it (vanilla swaps against the inventory directly, so the swap works on such a menu too).@Nullable net.minecraft.world.inventory.AbstractContainerMenumenu()Returns the value of themenurecord component.static SlotRefof(net.minecraft.world.Container container, int containerSlot, @Nullable net.minecraft.world.entity.player.Player player) A slot reached with no menu open: an inventory insert.static SlotRefof(net.minecraft.world.inventory.AbstractContainerMenu menu, net.minecraft.world.inventory.Slot slot, @Nullable net.minecraft.world.entity.player.Player player) A slot reached through an open menu: the click and shift-click seams.@Nullable net.minecraft.world.entity.player.Playerplayer()Returns the value of theplayerrecord component.@Nullable net.minecraft.world.inventory.Slotslot()Returns the value of theslotrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SlotRef
public SlotRef(net.minecraft.world.Container container, int containerSlot, @Nullable net.minecraft.world.inventory.Slot slot, @Nullable net.minecraft.world.inventory.AbstractContainerMenu menu, @Nullable net.minecraft.world.entity.player.Player player, @Nullable SlotGroupCategory category, @Nullable Address address) Creates an instance of aSlotRefrecord class.- Parameters:
container- the value for thecontainerrecord componentcontainerSlot- the value for thecontainerSlotrecord componentslot- the value for theslotrecord componentmenu- the value for themenurecord componentplayer- the value for theplayerrecord componentcategory- the value for thecategoryrecord componentaddress- the value for theaddressrecord component
-
-
Method Details
-
of
public static SlotRef of(net.minecraft.world.inventory.AbstractContainerMenu menu, net.minecraft.world.inventory.Slot slot, @Nullable net.minecraft.world.entity.player.Player player) A slot reached through an open menu: the click and shift-click seams. -
inventory
public static SlotRef inventory(net.minecraft.world.inventory.AbstractContainerMenu menu, net.minecraft.world.entity.player.Player player, int index) The player-inventory slot atindexas it sits onmenu, so it resolves with its menu category; the bare container form when the menu does not show it (vanilla swaps against the inventory directly, so the swap works on such a menu too). -
of
public static SlotRef of(net.minecraft.world.Container container, int containerSlot, @Nullable net.minecraft.world.entity.player.Player player) A slot reached with no menu open: an inventory insert. -
addressOf
@Internal public static Address addressOf(net.minecraft.world.inventory.AbstractContainerMenu menu, net.minecraft.world.inventory.Slot slot) -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
container
-
containerSlot
public int containerSlot()Returns the value of thecontainerSlotrecord component.- Returns:
- the value of the
containerSlotrecord component
-
slot
-
player
-
category
-
address
-