Class ScreenHandler
- Direct Known Subclasses:
AbstractRecipeScreenHandler,BeaconScreenHandler,BrewingStandScreenHandler,CartographyTableScreenHandler,CrafterScreenHandler,CreativeInventoryScreen.CreativeScreenHandler,EnchantmentScreenHandler,ForgingScreenHandler,Generic3x3ContainerScreenHandler,GenericContainerScreenHandler,GrindstoneScreenHandler,HopperScreenHandler,HorseScreenHandler,LecternScreenHandler,LoomScreenHandler,MerchantScreenHandler,ShulkerBoxScreenHandler,StonecutterScreenHandler
On the client, screen handlers are coupled with a HandledScreen. Handled screens have a
reference to a client-sided screen handler that is exposed through the
ScreenHandlerProvider interface.
Models
Screen handlers hold slots, properties, property delegates, and screen handler contexts. This allows easy synchronization of states between the client and the server, and prevents running code on the wrong side.
Slot holds one item stack. The slots are usually controlled by the server,
and the changes to slots on the server are automatically synchronized to the client.
Slots can be backed by an inventory, allowing the changes to be reflected to the
persistent storage (like block entities) on the server. Clients manipulate the
slots by issuing a "slot click" packet. "Clicking" a slot includes actions like
picking up crafting result, shift-clicking stacks, swapping stacks between the
inventory and the hotbar, or dropping stacks.
Screen handlers also contain a list of properties
that are used for syncing integers (e.g. progress bars) from the server to the client.
Properties can also be used to sync an integer from the client to the server, although
it has to be manually performed. If a property relies on other objects, like
a value from a block entity instance, then the property can delegate its operations
using PropertyDelegate. The delegate is passed when creating the screen handler.
On the server, access to the property's value is delegated to the delegate (which in
turn delegates to another object like a block entity instance).
On the client, access to the property's value still uses the synced value.
ScreenHandlerContext allows running code on the server side only. Screen
handlers are designed to be used on both sides; any action modifying the world has
to be wrapped in a call to the context. Like with the property delegate, a context
with the world is passed to the screen handler on creation on the server. On the
server, the context executes the function with the world and the position. On the
client, the context does nothing.
How to use screen handlers
Creation
To create a new screen handler, subclass ScreenHandler, create and register
a new screen handler type, and associate it with
a handled screen.
A subclass should have two constructors. One is for the server, and should take
the syncId and inventories, property delegates, or contexts that are used.
The syncId is shared between the two sides. It is used to verify that a player
has a specific screen (handler) open so that they can move items, for example.
The inventories are used to back a slot so that any changes to a slot is reflected
on the backing inventory, and vice versa. Property delegates and contexts bridge
between the screen handler and other parts of the world; see above for more description.
The constructor should add slots, add properties from delegates, and store the property delegates and screen handler
context in the instance fields.
The other constructor is for the client. There, the only parameters allowed are the
syncId and the player inventory. This is because all other things are
unavailable at creation time and synced later. This constructor should call the
other constructor with a new simple inventory of sufficient size, a new array property delegate, and an empty screen handler context. Synced data then fills the inventory and property
delegate.
The screen handler then has to be registered in a registry. Create a new instance of
ScreenHandlerType with the screen handler type factory (which can be a reference
to the client-side constructor; i.e. MyScreenHandler::MyScreenHandler)
and register it to Registries.SCREEN_HANDLER.
Opening
Most of the screen handlers are associated with a block and opened by using the block.
Screen handlers are opened on the server and synced to the client. To open a
screen handler, use PlayerEntity.openHandledScreen(net.minecraft.screen.NamedScreenHandlerFactory). This takes a
NamedScreenHandlerFactory, which creates a screen handler. In vanilla,
block entity instances implement the interface, allowing them to be passed.
SimpleNamedScreenHandlerFactory is a screen handler factory implementation
for use cases that do not involve a block entity.
The factory should create a new instance of a screen handler with the server-side constructor (one that takes inventories, etc). If the screen handler requires a property delegate or a context, create an instance and pass it here.
As long as the screen handler only uses the slots and properties, there should not be any need for external synchronization.
Interaction
Screen handler interaction mainly involves "slot clicks" and "button clicks".
A slot click is, as mentioned before, an action manipulating
the slots' held item stacks. Slot clicks are implemented in this class and
quickMove(net.minecraft.entity.player.PlayerEntity, int). To manipulate the stacks, get the slot via getSlot(int)
and call methods of it. Screen handlers also provide methods for common operations,
such as insertItem(net.minecraft.item.ItemStack, int, int, boolean) that inserts a stack to the screen handler's available slots.
The "cursor stack" is an item stack held by the cursor. When moving item stacks between slots, the cursor stack can hold the stack temporarily. The cursor stack is not held by any slots. When the screen handler is closed, the stack will be inserted to the player inventory or dropped as an item entity.
Some screen handlers also handle button clicks. This is used to execute an action on the server as a response to clients sending a button click packet. In most cases, this is triggered by a button in the screen rendered by the client, hence the name. Inside screen handlers, buttons are identified with an integer.
Subclasses must implement two methods: canUse(PlayerEntity) and quickMove(net.minecraft.entity.player.PlayerEntity, int). See the documentation of each method for more details.
Closing
Since a screen handler handles the client's screen, the screen must be closed at the
same time. To close the screen handler and the screen, call PlayerEntity.closeHandledScreen() on the server.
Screen handlers should override onClosed(net.minecraft.entity.player.PlayerEntity). In there, it should drop contents of all slots not backed by an inventory and call
Inventory.onClose(net.minecraft.entity.player.PlayerEntity) on the backing inventory. See the documentation of
the method for more details.
- See Also:
- Mappings:
Namespace Name named net/minecraft/screen/ScreenHandlerintermediary net/minecraft/class_1703official cpu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ItemStackprivate booleanstatic final intA special slot index value (-999) indicating that the player has clicked outside the main panel of a screen.static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intprivate final List<ScreenHandlerListener> private static final Loggerprivate ItemStackprivate final DefaultedList<ItemStack> private intprivate intprivate intfinal DefaultedList<Slot> private @Nullable ScreenHandlerSyncHandlerfinal intprivate final IntListprivate final DefaultedList<ItemStack> A list of item stacks that is used for tracking changes insendContentUpdates().private final @Nullable ScreenHandlerType<?> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedScreenHandler(@Nullable ScreenHandlerType<?> type, int syncId) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(ScreenHandlerListener listener) Addslistenerto the screen handler.protected voidaddProperties(PropertyDelegate propertyDelegate) Adds properties ofpropertyDelegateto this screen handler.protected PropertyaddProperty(Property property) Addspropertyto this screen handler.protected SlotAddsslotto this screen handler.static intstatic intcalculateComparatorOutput(@Nullable Inventory inventory) static intcalculateStackSize(Set<Slot> slots, int mode, ItemStack stack) booleancanInsertIntoSlot(ItemStack stack, Slot slot) Returns whetherstackcan be inserted toslot.booleancanInsertIntoSlot(Slot slot) static booleancanInsertItemIntoSlot(@Nullable Slot slot, ItemStack stack, boolean allowOverflow) abstract booleancanUse(PlayerEntity player) Returns whether the screen handler can be used.protected static booleancanUse(ScreenHandlerContext context, PlayerEntity player, Block block) Returns whether the screen handler can be used.private voidprotected static voidcheckDataCount(PropertyDelegate data, int expectedCount) Checks that the size of thedatais at least as large as theexpectedCount.private voidcheckPropertyUpdates(int id, int value) protected static voidChecks that the size of the provided inventory is at least as large as theexpectedSize.private voidcheckSlotUpdates(int slot, ItemStack stack, Supplier<ItemStack> copySupplier) voidcopySharedSlots(ScreenHandler handler) voidprotected voiddropInventory(PlayerEntity player, Inventory inventory) voidprotected voidprivate StackReferenceReturns a reference to the cursor's stack.intgetSlot(int index) Returns the slot with indexindex.getSlotIndex(Inventory inventory, int index) Returns a list of all stacks of the screen handler's slot.getType()Returns the screen handler type.private booleanhandleSlotClick(PlayerEntity player, ClickType clickType, Slot slot, ItemStack stack, ItemStack cursorStack) protected booleaninsertItem(ItemStack stack, int startIndex, int endIndex, boolean fromLast) Tries to consumestackby inserting to slots fromstartIndextoendIndex - 1(both inclusive) until the entire stack is used.private voidinternalOnSlotClick(int slotIndex, int button, SlotActionType actionType, PlayerEntity player) The actual logic that handles a slot click.booleanisValid(int slot) Returns whether the given slot index is valid.intprivate voidnotifyPropertyUpdate(int index, int value) booleanonButtonClick(PlayerEntity player, int id) Called whenplayerclicks a button withid.voidonClosed(PlayerEntity player) Called when this screen handler is closed.voidonContentChanged(Inventory inventory) Called when a slot's content has changed.voidonSlotClick(int slotIndex, int button, SlotActionType actionType, PlayerEntity player) Performs a slot click.static intpackQuickCraftData(int quickCraftStage, int buttonId) abstract ItemStackquickMove(PlayerEntity player, int slot) Quick-moves the stack atslotto other slots of the screen handler that belong to a different inventory or another section of the same inventory.voidremoveListener(ScreenHandlerListener listener) Removeslistenerfrom this screen handler.voidSends updates to listeners if any properties or slot stacks have changed.voidsetCursorStack(ItemStack stack) voidsetPreviousCursorStack(ItemStack stack) voidsetPreviousTrackedSlot(int slot, ItemStack stack) voidsetPreviousTrackedSlotMutable(int slot, ItemStack stack) voidsetProperty(int id, int value) Sets the property with IDidtovalue.voidsetStackInSlot(int slot, int revision, ItemStack stack) static booleanshouldQuickCraftContinue(int stage, PlayerEntity player) voidstatic intunpackQuickCraftButton(int quickCraftData) static intunpackQuickCraftStage(int quickCraftData) voidupdateSlotStacks(int revision, List<ItemStack> stacks, ItemStack cursorStack) voidvoidprivate voidupdateTrackedSlot(int slot, ItemStack stack, Supplier<ItemStack> copySupplier)
-
Field Details
-
LOGGER
- Mappings:
Namespace Name Mixin selector named LOGGERLnet/minecraft/screen/ScreenHandler;LOGGER:Lorg/slf4j/Logger;intermediary field_36534Lnet/minecraft/class_1703;field_36534:Lorg/slf4j/Logger;official kLcpu;k:Lorg/slf4j/Logger;
-
EMPTY_SPACE_SLOT_INDEX
public static final int EMPTY_SPACE_SLOT_INDEXA special slot index value (-999) indicating that the player has clicked outside the main panel of a screen. Used for dropping the cursor stack.- See Also:
- Mappings:
Namespace Name Mixin selector named EMPTY_SPACE_SLOT_INDEXLnet/minecraft/screen/ScreenHandler;EMPTY_SPACE_SLOT_INDEX:Iintermediary field_30730Lnet/minecraft/class_1703;field_30730:Iofficial aLcpu;a:I
-
field_30731
public static final int field_30731- See Also:
- Mappings:
Namespace Name Mixin selector named field_30731Lnet/minecraft/screen/ScreenHandler;field_30731:Iintermediary field_30731Lnet/minecraft/class_1703;field_30731:Iofficial bLcpu;b:I
-
field_30732
public static final int field_30732- See Also:
- Mappings:
Namespace Name Mixin selector named field_30732Lnet/minecraft/screen/ScreenHandler;field_30732:Iintermediary field_30732Lnet/minecraft/class_1703;field_30732:Iofficial cLcpu;c:I
-
field_30733
public static final int field_30733- See Also:
- Mappings:
Namespace Name Mixin selector named field_30733Lnet/minecraft/screen/ScreenHandler;field_30733:Iintermediary field_30733Lnet/minecraft/class_1703;field_30733:Iofficial dLcpu;d:I
-
field_30734
public static final int field_30734- See Also:
- Mappings:
Namespace Name Mixin selector named field_30734Lnet/minecraft/screen/ScreenHandler;field_30734:Iintermediary field_30734Lnet/minecraft/class_1703;field_30734:Iofficial eLcpu;e:I
-
field_30735
public static final int field_30735- See Also:
- Mappings:
Namespace Name Mixin selector named field_30735Lnet/minecraft/screen/ScreenHandler;field_30735:Iintermediary field_30735Lnet/minecraft/class_1703;field_30735:Iofficial fLcpu;f:I
-
field_30736
public static final int field_30736- See Also:
- Mappings:
Namespace Name Mixin selector named field_30736Lnet/minecraft/screen/ScreenHandler;field_30736:Iintermediary field_30736Lnet/minecraft/class_1703;field_30736:Iofficial gLcpu;g:I
-
field_30737
public static final int field_30737- See Also:
- Mappings:
Namespace Name Mixin selector named field_30737Lnet/minecraft/screen/ScreenHandler;field_30737:Iintermediary field_30737Lnet/minecraft/class_1703;field_30737:Iofficial hLcpu;h:I
-
trackedStacks
A list of item stacks that is used for tracking changes insendContentUpdates().- Mappings:
Namespace Name Mixin selector named trackedStacksLnet/minecraft/screen/ScreenHandler;trackedStacks:Lnet/minecraft/util/collection/DefaultedList;intermediary field_7764Lnet/minecraft/class_1703;field_7764:Lnet/minecraft/class_2371;official lLcpu;l:Ljv;
-
slots
- Mappings:
Namespace Name Mixin selector named slotsLnet/minecraft/screen/ScreenHandler;slots:Lnet/minecraft/util/collection/DefaultedList;intermediary field_7761Lnet/minecraft/class_1703;field_7761:Lnet/minecraft/class_2371;official iLcpu;i:Ljv;
-
properties
- Mappings:
Namespace Name Mixin selector named propertiesLnet/minecraft/screen/ScreenHandler;properties:Ljava/util/List;intermediary field_17285Lnet/minecraft/class_1703;field_17285:Ljava/util/List;official mLcpu;m:Ljava/util/List;
-
cursorStack
- Mappings:
Namespace Name Mixin selector named cursorStackLnet/minecraft/screen/ScreenHandler;cursorStack:Lnet/minecraft/item/ItemStack;intermediary field_29205Lnet/minecraft/class_1703;field_29205:Lnet/minecraft/class_1799;official nLcpu;n:Lcuq;
-
previousTrackedStacks
- Mappings:
Namespace Name Mixin selector named previousTrackedStacksLnet/minecraft/screen/ScreenHandler;previousTrackedStacks:Lnet/minecraft/util/collection/DefaultedList;intermediary field_29206Lnet/minecraft/class_1703;field_29206:Lnet/minecraft/class_2371;official oLcpu;o:Ljv;
-
trackedPropertyValues
- Mappings:
Namespace Name Mixin selector named trackedPropertyValuesLnet/minecraft/screen/ScreenHandler;trackedPropertyValues:Lit/unimi/dsi/fastutil/ints/IntList;intermediary field_29559Lnet/minecraft/class_1703;field_29559:Lit/unimi/dsi/fastutil/ints/IntList;official pLcpu;p:Lit/unimi/dsi/fastutil/ints/IntList;
-
previousCursorStack
- Mappings:
Namespace Name Mixin selector named previousCursorStackLnet/minecraft/screen/ScreenHandler;previousCursorStack:Lnet/minecraft/item/ItemStack;intermediary field_29207Lnet/minecraft/class_1703;field_29207:Lnet/minecraft/class_1799;official qLcpu;q:Lcuq;
-
revision
private int revision- Mappings:
Namespace Name Mixin selector named revisionLnet/minecraft/screen/ScreenHandler;revision:Iintermediary field_34024Lnet/minecraft/class_1703;field_34024:Iofficial rLcpu;r:I
-
type
- Mappings:
Namespace Name Mixin selector named typeLnet/minecraft/screen/ScreenHandler;type:Lnet/minecraft/screen/ScreenHandlerType;intermediary field_17493Lnet/minecraft/class_1703;field_17493:Lnet/minecraft/class_3917;official sLcpu;s:Lcrc;
-
syncId
public final int syncId- Mappings:
Namespace Name Mixin selector named syncIdLnet/minecraft/screen/ScreenHandler;syncId:Iintermediary field_7763Lnet/minecraft/class_1703;field_7763:Iofficial jLcpu;j:I
-
quickCraftButton
private int quickCraftButton- Mappings:
Namespace Name Mixin selector named quickCraftButtonLnet/minecraft/screen/ScreenHandler;quickCraftButton:Iintermediary field_7762Lnet/minecraft/class_1703;field_7762:Iofficial tLcpu;t:I
-
quickCraftStage
private int quickCraftStage- Mappings:
Namespace Name Mixin selector named quickCraftStageLnet/minecraft/screen/ScreenHandler;quickCraftStage:Iintermediary field_7759Lnet/minecraft/class_1703;field_7759:Iofficial uLcpu;u:I
-
quickCraftSlots
- Mappings:
Namespace Name Mixin selector named quickCraftSlotsLnet/minecraft/screen/ScreenHandler;quickCraftSlots:Ljava/util/Set;intermediary field_7757Lnet/minecraft/class_1703;field_7757:Ljava/util/Set;official vLcpu;v:Ljava/util/Set;
-
listeners
- Mappings:
Namespace Name Mixin selector named listenersLnet/minecraft/screen/ScreenHandler;listeners:Ljava/util/List;intermediary field_7765Lnet/minecraft/class_1703;field_7765:Ljava/util/List;official wLcpu;w:Ljava/util/List;
-
syncHandler
- Mappings:
Namespace Name Mixin selector named syncHandlerLnet/minecraft/screen/ScreenHandler;syncHandler:Lnet/minecraft/screen/ScreenHandlerSyncHandler;intermediary field_29208Lnet/minecraft/class_1703;field_29208:Lnet/minecraft/class_5916;official xLcpu;x:Lcqi;
-
disableSync
private boolean disableSync- Mappings:
Namespace Name Mixin selector named disableSyncLnet/minecraft/screen/ScreenHandler;disableSync:Zintermediary field_29209Lnet/minecraft/class_1703;field_29209:Zofficial yLcpu;y:Z
-
-
Constructor Details
-
ScreenHandler
- Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/screen/ScreenHandler;<init>(Lnet/minecraft/screen/ScreenHandlerType;I)Vintermediary <init>Lnet/minecraft/class_1703;<init>(Lnet/minecraft/class_3917;I)Vofficial <init>Lcpu;<init>(Lcrc;I)V
-
-
Method Details
-
canUse
Returns whether the screen handler can be used.- Returns:
- whether the screen handler can be used
- See Also:
- API Note:
- This should be called inside
canUse(PlayerEntity). - Implementation Note:
- On the server, this checks that the block at the position is
blockand the player is within 8 blocks from the block's center. - Mappings:
Namespace Name Mixin selector named canUseLnet/minecraft/screen/ScreenHandler;canUse(Lnet/minecraft/screen/ScreenHandlerContext;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/block/Block;)Zintermediary method_17695Lnet/minecraft/class_1703;method_17695(Lnet/minecraft/class_3914;Lnet/minecraft/class_1657;Lnet/minecraft/class_2248;)Zofficial aLcpu;a(Lcqg;Lcmx;Ldfy;)Z
-
getType
Returns the screen handler type.A screen handler must have associated screen handler type to open it.
- Returns:
- the screen handler type
- Throws:
UnsupportedOperationException- if the type is not passed in the constructor- Mappings:
Namespace Name Mixin selector named getTypeLnet/minecraft/screen/ScreenHandler;getType()Lnet/minecraft/screen/ScreenHandlerType;intermediary method_17358Lnet/minecraft/class_1703;method_17358()Lnet/minecraft/class_3917;official aLcpu;a()Lcrc;
-
checkSize
Checks that the size of the provided inventory is at least as large as theexpectedSize.- Throws:
IllegalArgumentException- if the inventory size is smaller thanexpectedSize- Mappings:
Namespace Name Mixin selector named checkSizeLnet/minecraft/screen/ScreenHandler;checkSize(Lnet/minecraft/inventory/Inventory;I)Vintermediary method_17359Lnet/minecraft/class_1703;method_17359(Lnet/minecraft/class_1263;I)Vofficial aLcpu;a(Lbqk;I)V
-
checkDataCount
Checks that the size of thedatais at least as large as theexpectedCount.- Throws:
IllegalArgumentException- if thedatahas a smaller size thanexpectedCount- Mappings:
Namespace Name Mixin selector named checkDataCountLnet/minecraft/screen/ScreenHandler;checkDataCount(Lnet/minecraft/screen/PropertyDelegate;I)Vintermediary method_17361Lnet/minecraft/class_1703;method_17361(Lnet/minecraft/class_3913;I)Vofficial aLcpu;a(Lcqf;I)V
-
isValid
public boolean isValid(int slot) Returns whether the given slot index is valid.This returns
truefor all added slots, -999, and-1.- Returns:
- whether the given slot index is valid
- Mappings:
Namespace Name Mixin selector named isValidLnet/minecraft/screen/ScreenHandler;isValid(I)Zintermediary method_40442Lnet/minecraft/class_1703;method_40442(I)Zofficial aLcpu;a(I)Z
-
addSlot
Addsslotto this screen handler. This must be called inside the subclass's constructor.- Returns:
- the added slot
- Mappings:
Namespace Name Mixin selector named addSlotLnet/minecraft/screen/ScreenHandler;addSlot(Lnet/minecraft/screen/slot/Slot;)Lnet/minecraft/screen/slot/Slot;intermediary method_7621Lnet/minecraft/class_1703;method_7621(Lnet/minecraft/class_1735;)Lnet/minecraft/class_1735;official aLcpu;a(Lcrq;)Lcrq;
-
addProperty
Addspropertyto this screen handler. This must be called inside the subclass's constructor.If the property relies on external objects (such as a block entity instance), it should instead use property delegates and
addProperties(net.minecraft.screen.PropertyDelegate).- Returns:
- the added property
- See Also:
- Mappings:
Namespace Name Mixin selector named addPropertyLnet/minecraft/screen/ScreenHandler;addProperty(Lnet/minecraft/screen/Property;)Lnet/minecraft/screen/Property;intermediary method_17362Lnet/minecraft/class_1703;method_17362(Lnet/minecraft/class_3915;)Lnet/minecraft/class_3915;official aLcpu;a(Lcqn;)Lcqn;
-
addProperties
Adds properties ofpropertyDelegateto this screen handler. This must be called inside the subclass's constructor.- See Also:
- Mappings:
Namespace Name Mixin selector named addPropertiesLnet/minecraft/screen/ScreenHandler;addProperties(Lnet/minecraft/screen/PropertyDelegate;)Vintermediary method_17360Lnet/minecraft/class_1703;method_17360(Lnet/minecraft/class_3913;)Vofficial aLcpu;a(Lcqf;)V
-
addListener
Addslistenerto the screen handler.Listeners are often used to listen to slot or property changes on the client's screen.
- Mappings:
Namespace Name Mixin selector named addListenerLnet/minecraft/screen/ScreenHandler;addListener(Lnet/minecraft/screen/ScreenHandlerListener;)Vintermediary method_7596Lnet/minecraft/class_1703;method_7596(Lnet/minecraft/class_1712;)Vofficial aLcpu;a(Lcqh;)V
-
updateSyncHandler
- Mappings:
Namespace Name Mixin selector named updateSyncHandlerLnet/minecraft/screen/ScreenHandler;updateSyncHandler(Lnet/minecraft/screen/ScreenHandlerSyncHandler;)Vintermediary method_34248Lnet/minecraft/class_1703;method_34248(Lnet/minecraft/class_5916;)Vofficial aLcpu;a(Lcqi;)V
-
syncState
public void syncState()- Mappings:
Namespace Name Mixin selector named syncStateLnet/minecraft/screen/ScreenHandler;syncState()Vintermediary method_34252Lnet/minecraft/class_1703;method_34252()Vofficial bLcpu;b()V
-
removeListener
Removeslistenerfrom this screen handler.- Mappings:
Namespace Name Mixin selector named removeListenerLnet/minecraft/screen/ScreenHandler;removeListener(Lnet/minecraft/screen/ScreenHandlerListener;)Vintermediary method_7603Lnet/minecraft/class_1703;method_7603(Lnet/minecraft/class_1712;)Vofficial bLcpu;b(Lcqh;)V
-
getStacks
Returns a list of all stacks of the screen handler's slot.This should not be used in most cases, and modifying the returned list has no effect to the screen handler.
- Returns:
- a list of all stacks of the screen handler's slot
- Mappings:
Namespace Name Mixin selector named getStacksLnet/minecraft/screen/ScreenHandler;getStacks()Lnet/minecraft/util/collection/DefaultedList;intermediary method_7602Lnet/minecraft/class_1703;method_7602()Lnet/minecraft/class_2371;official cLcpu;c()Ljv;
-
sendContentUpdates
public void sendContentUpdates()Sends updates to listeners if any properties or slot stacks have changed.- Mappings:
Namespace Name Mixin selector named sendContentUpdatesLnet/minecraft/screen/ScreenHandler;sendContentUpdates()Vintermediary method_7623Lnet/minecraft/class_1703;method_7623()Vofficial dLcpu;d()V
-
updateToClient
public void updateToClient()- Mappings:
Namespace Name Mixin selector named updateToClientLnet/minecraft/screen/ScreenHandler;updateToClient()Vintermediary method_37420Lnet/minecraft/class_1703;method_37420()Vofficial eLcpu;e()V
-
notifyPropertyUpdate
private void notifyPropertyUpdate(int index, int value) - Mappings:
Namespace Name Mixin selector named notifyPropertyUpdateLnet/minecraft/screen/ScreenHandler;notifyPropertyUpdate(II)Vintermediary method_37419Lnet/minecraft/class_1703;method_37419(II)Vofficial cLcpu;c(II)V
-
updateTrackedSlot
- Mappings:
Namespace Name Mixin selector named updateTrackedSlotLnet/minecraft/screen/ScreenHandler;updateTrackedSlot(ILnet/minecraft/item/ItemStack;Ljava/util/function/Supplier;)Vintermediary method_34246Lnet/minecraft/class_1703;method_34246(ILnet/minecraft/class_1799;Ljava/util/function/Supplier;)Vofficial aLcpu;a(ILcuq;Ljava/util/function/Supplier;)V
-
checkSlotUpdates
- Mappings:
Namespace Name Mixin selector named checkSlotUpdatesLnet/minecraft/screen/ScreenHandler;checkSlotUpdates(ILnet/minecraft/item/ItemStack;Ljava/util/function/Supplier;)Vintermediary method_34253Lnet/minecraft/class_1703;method_34253(ILnet/minecraft/class_1799;Ljava/util/function/Supplier;)Vofficial bLcpu;b(ILcuq;Ljava/util/function/Supplier;)V
-
checkPropertyUpdates
private void checkPropertyUpdates(int id, int value) - Mappings:
Namespace Name Mixin selector named checkPropertyUpdatesLnet/minecraft/screen/ScreenHandler;checkPropertyUpdates(II)Vintermediary method_34715Lnet/minecraft/class_1703;method_34715(II)Vofficial dLcpu;d(II)V
-
checkCursorStackUpdates
private void checkCursorStackUpdates()- Mappings:
Namespace Name Mixin selector named checkCursorStackUpdatesLnet/minecraft/screen/ScreenHandler;checkCursorStackUpdates()Vintermediary method_34258Lnet/minecraft/class_1703;method_34258()Vofficial lLcpu;l()V
-
setPreviousTrackedSlot
- Mappings:
Namespace Name Mixin selector named setPreviousTrackedSlotLnet/minecraft/screen/ScreenHandler;setPreviousTrackedSlot(ILnet/minecraft/item/ItemStack;)Vintermediary method_34245Lnet/minecraft/class_1703;method_34245(ILnet/minecraft/class_1799;)Vofficial aLcpu;a(ILcuq;)V
-
setPreviousTrackedSlotMutable
- Mappings:
Namespace Name Mixin selector named setPreviousTrackedSlotMutableLnet/minecraft/screen/ScreenHandler;setPreviousTrackedSlotMutable(ILnet/minecraft/item/ItemStack;)Vintermediary method_37449Lnet/minecraft/class_1703;method_37449(ILnet/minecraft/class_1799;)Vofficial bLcpu;b(ILcuq;)V
-
setPreviousCursorStack
- Mappings:
Namespace Name Mixin selector named setPreviousCursorStackLnet/minecraft/screen/ScreenHandler;setPreviousCursorStack(Lnet/minecraft/item/ItemStack;)Vintermediary method_34250Lnet/minecraft/class_1703;method_34250(Lnet/minecraft/class_1799;)Vofficial aLcpu;a(Lcuq;)V
-
onButtonClick
Called whenplayerclicks a button withid."Button click" is an abstract concept; it does not have to be triggered by a button. Examples of button clicks include selecting a recipe for a stonecutter, turning a page of a lectern's book, or selecting an enchantment on an enchanting table. Buttons are identified by an integer.
- Returns:
- whether the button click is handled successfully
- Implementation Note:
- This is normally only called by the server; however, screens that use buttons can call this on the client.
- Mappings:
Namespace Name Mixin selector named onButtonClickLnet/minecraft/screen/ScreenHandler;onButtonClick(Lnet/minecraft/entity/player/PlayerEntity;I)Zintermediary method_7604Lnet/minecraft/class_1703;method_7604(Lnet/minecraft/class_1657;I)Zofficial aLcpu;a(Lcmx;I)Z
-
getSlot
Returns the slot with indexindex.- Returns:
- the slot with index
index - Mappings:
Namespace Name Mixin selector named getSlotLnet/minecraft/screen/ScreenHandler;getSlot(I)Lnet/minecraft/screen/slot/Slot;intermediary method_7611Lnet/minecraft/class_1703;method_7611(I)Lnet/minecraft/class_1735;official bLcpu;b(I)Lcrq;
-
quickMove
Quick-moves the stack atslotto other slots of the screen handler that belong to a different inventory or another section of the same inventory. For example, items can be quick-moved between a chest's slots and the player inventory or between the main player inventory and the hotbar.Subclasses should call
insertItem(net.minecraft.item.ItemStack, int, int, boolean), and if the insertion was successful, clear the slot (if the stack is exhausted) or mark it as dirty. See the vanilla subclasses for basic implementation.Quick-moving is also known as "shift-clicking" since it's usually triggered using Shift+left click.
- Parameters:
slot- the index of the slot to quick-move from- Returns:
ItemStack.EMPTYwhen no stack can be transferred, otherwise the original stack- See Also:
- Mappings:
Namespace Name Mixin selector named quickMoveLnet/minecraft/screen/ScreenHandler;quickMove(Lnet/minecraft/entity/player/PlayerEntity;I)Lnet/minecraft/item/ItemStack;intermediary method_7601Lnet/minecraft/class_1703;method_7601(Lnet/minecraft/class_1657;I)Lnet/minecraft/class_1799;official bLcpu;b(Lcmx;I)Lcuq;
-
onSlotClick
Performs a slot click. This can behave in many different ways depending mainly on the action type.- Parameters:
actionType- the type of slot click, check the docs for eachSlotActionTypevalue for details- Mappings:
Namespace Name Mixin selector named onSlotClickLnet/minecraft/screen/ScreenHandler;onSlotClick(IILnet/minecraft/screen/slot/SlotActionType;Lnet/minecraft/entity/player/PlayerEntity;)Vintermediary method_7593Lnet/minecraft/class_1703;method_7593(IILnet/minecraft/class_1713;Lnet/minecraft/class_1657;)Vofficial aLcpu;a(IILcqe;Lcmx;)V
-
internalOnSlotClick
private void internalOnSlotClick(int slotIndex, int button, SlotActionType actionType, PlayerEntity player) The actual logic that handles a slot click. Called by(int, int, SlotActionType, PlayerEntity)in a try-catch block that wraps exceptions from this method into a crash report.- Mappings:
Namespace Name Mixin selector named internalOnSlotClickLnet/minecraft/screen/ScreenHandler;internalOnSlotClick(IILnet/minecraft/screen/slot/SlotActionType;Lnet/minecraft/entity/player/PlayerEntity;)Vintermediary method_30010Lnet/minecraft/class_1703;method_30010(IILnet/minecraft/class_1713;Lnet/minecraft/class_1657;)Vofficial bLcpu;b(IILcqe;Lcmx;)V
-
handleSlotClick
private boolean handleSlotClick(PlayerEntity player, ClickType clickType, Slot slot, ItemStack stack, ItemStack cursorStack) - Mappings:
Namespace Name Mixin selector named handleSlotClickLnet/minecraft/screen/ScreenHandler;handleSlotClick(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/ClickType;Lnet/minecraft/screen/slot/Slot;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Zintermediary method_45409Lnet/minecraft/class_1703;method_45409(Lnet/minecraft/class_1657;Lnet/minecraft/class_5536;Lnet/minecraft/class_1735;Lnet/minecraft/class_1799;Lnet/minecraft/class_1799;)Zofficial aLcpu;a(Lcmx;Lcqd;Lcrq;Lcuq;Lcuq;)Z
-
getCursorStackReference
Returns a reference to the cursor's stack.- Returns:
- a reference to the cursor's stack
- Mappings:
Namespace Name Mixin selector named getCursorStackReferenceLnet/minecraft/screen/ScreenHandler;getCursorStackReference()Lnet/minecraft/inventory/StackReference;intermediary method_34259Lnet/minecraft/class_1703;method_34259()Lnet/minecraft/class_5630;official mLcpu;m()Lbug;
-
canInsertIntoSlot
Returns whetherstackcan be inserted toslot.Subclasses should override this to return
falseif the slot is used for output.- Returns:
- whether
stackcan be inserted toslot - Mappings:
Namespace Name Mixin selector named canInsertIntoSlotLnet/minecraft/screen/ScreenHandler;canInsertIntoSlot(Lnet/minecraft/item/ItemStack;Lnet/minecraft/screen/slot/Slot;)Zintermediary method_7613Lnet/minecraft/class_1703;method_7613(Lnet/minecraft/class_1799;Lnet/minecraft/class_1735;)Zofficial aLcpu;a(Lcuq;Lcrq;)Z
-
onClosed
Called when this screen handler is closed.To close a screen handler, call
PlayerEntity.closeHandledScreen()on the server instead of this method.This drops the cursor stack by default. Subclasses that have slots not backed by a persistent inventory should call
dropInventory(net.minecraft.entity.player.PlayerEntity, net.minecraft.inventory.Inventory)to drop the stacks.- Mappings:
Namespace Name Mixin selector named onClosedLnet/minecraft/screen/ScreenHandler;onClosed(Lnet/minecraft/entity/player/PlayerEntity;)Vintermediary method_7595Lnet/minecraft/class_1703;method_7595(Lnet/minecraft/class_1657;)Vofficial aLcpu;a(Lcmx;)V
-
dropInventory
- Mappings:
Namespace Name Mixin selector named dropInventoryLnet/minecraft/screen/ScreenHandler;dropInventory(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/inventory/Inventory;)Vintermediary method_7607Lnet/minecraft/class_1703;method_7607(Lnet/minecraft/class_1657;Lnet/minecraft/class_1263;)Vofficial aLcpu;a(Lcmx;Lbqk;)V
-
onContentChanged
Called when a slot's content has changed.This is not called by default; subclasses that override this method should also use a custom
InventorywhosemarkDirtymethod is overridden to call this method as a backing inventory of the slot.This can be used to update the output slot when input changes.
- Mappings:
Namespace Name Mixin selector named onContentChangedLnet/minecraft/screen/ScreenHandler;onContentChanged(Lnet/minecraft/inventory/Inventory;)Vintermediary method_7609Lnet/minecraft/class_1703;method_7609(Lnet/minecraft/class_1263;)Vofficial aLcpu;a(Lbqk;)V
-
setStackInSlot
- Mappings:
Namespace Name Mixin selector named setStackInSlotLnet/minecraft/screen/ScreenHandler;setStackInSlot(IILnet/minecraft/item/ItemStack;)Vintermediary method_7619Lnet/minecraft/class_1703;method_7619(IILnet/minecraft/class_1799;)Vofficial aLcpu;a(IILcuq;)V
-
updateSlotStacks
- Mappings:
Namespace Name Mixin selector named updateSlotStacksLnet/minecraft/screen/ScreenHandler;updateSlotStacks(ILjava/util/List;Lnet/minecraft/item/ItemStack;)Vintermediary method_7610Lnet/minecraft/class_1703;method_7610(ILjava/util/List;Lnet/minecraft/class_1799;)Vofficial aLcpu;a(ILjava/util/List;Lcuq;)V
-
setProperty
public void setProperty(int id, int value) Sets the property with IDidtovalue.Subclasses can call
sendContentUpdates()to manually sync the change to the client.- Mappings:
Namespace Name Mixin selector named setPropertyLnet/minecraft/screen/ScreenHandler;setProperty(II)Vintermediary method_7606Lnet/minecraft/class_1703;method_7606(II)Vofficial aLcpu;a(II)V
-
canUse
Returns whether the screen handler can be used.Subclasses should call #canUse(ScreenHandlerContext, PlayerEntity, Block)} or implement the check itself. The implementation should check that the player is near the screen handler's source position (e.g. block position) and that the source (e.g. block) is not destroyed.
- Returns:
- whether the screen handler can be used
- Mappings:
Namespace Name Mixin selector named canUseLnet/minecraft/screen/ScreenHandler;canUse(Lnet/minecraft/entity/player/PlayerEntity;)Zintermediary method_7597Lnet/minecraft/class_1703;method_7597(Lnet/minecraft/class_1657;)Zofficial bLcpu;b(Lcmx;)Z
-
insertItem
Tries to consumestackby inserting to slots fromstartIndextoendIndex - 1(both inclusive) until the entire stack is used.If
fromLastistrue, this attempts the insertion in reverse order; i.e.endIndex - 1tostartIndex(both inclusive).- Returns:
- whether
stackwas decremented - Mappings:
Namespace Name Mixin selector named insertItemLnet/minecraft/screen/ScreenHandler;insertItem(Lnet/minecraft/item/ItemStack;IIZ)Zintermediary method_7616Lnet/minecraft/class_1703;method_7616(Lnet/minecraft/class_1799;IIZ)Zofficial aLcpu;a(Lcuq;IIZ)Z
-
unpackQuickCraftButton
public static int unpackQuickCraftButton(int quickCraftData) - Mappings:
Namespace Name Mixin selector named unpackQuickCraftButtonLnet/minecraft/screen/ScreenHandler;unpackQuickCraftButton(I)Iintermediary method_7620Lnet/minecraft/class_1703;method_7620(I)Iofficial cLcpu;c(I)I
-
unpackQuickCraftStage
public static int unpackQuickCraftStage(int quickCraftData) - Mappings:
Namespace Name Mixin selector named unpackQuickCraftStageLnet/minecraft/screen/ScreenHandler;unpackQuickCraftStage(I)Iintermediary method_7594Lnet/minecraft/class_1703;method_7594(I)Iofficial dLcpu;d(I)I
-
packQuickCraftData
public static int packQuickCraftData(int quickCraftStage, int buttonId) - Mappings:
Namespace Name Mixin selector named packQuickCraftDataLnet/minecraft/screen/ScreenHandler;packQuickCraftData(II)Iintermediary method_7591Lnet/minecraft/class_1703;method_7591(II)Iofficial bLcpu;b(II)I
-
shouldQuickCraftContinue
- Mappings:
Namespace Name Mixin selector named shouldQuickCraftContinueLnet/minecraft/screen/ScreenHandler;shouldQuickCraftContinue(ILnet/minecraft/entity/player/PlayerEntity;)Zintermediary method_7600Lnet/minecraft/class_1703;method_7600(ILnet/minecraft/class_1657;)Zofficial aLcpu;a(ILcmx;)Z
-
endQuickCraft
protected void endQuickCraft()- Mappings:
Namespace Name Mixin selector named endQuickCraftLnet/minecraft/screen/ScreenHandler;endQuickCraft()Vintermediary method_7605Lnet/minecraft/class_1703;method_7605()Vofficial fLcpu;f()V
-
canInsertItemIntoSlot
public static boolean canInsertItemIntoSlot(@Nullable @Nullable Slot slot, ItemStack stack, boolean allowOverflow) - Mappings:
Namespace Name Mixin selector named canInsertItemIntoSlotLnet/minecraft/screen/ScreenHandler;canInsertItemIntoSlot(Lnet/minecraft/screen/slot/Slot;Lnet/minecraft/item/ItemStack;Z)Zintermediary method_7592Lnet/minecraft/class_1703;method_7592(Lnet/minecraft/class_1735;Lnet/minecraft/class_1799;Z)Zofficial aLcpu;a(Lcrq;Lcuq;Z)Z
-
calculateStackSize
- Mappings:
Namespace Name Mixin selector named calculateStackSizeLnet/minecraft/screen/ScreenHandler;calculateStackSize(Ljava/util/Set;ILnet/minecraft/item/ItemStack;)Iintermediary method_7617Lnet/minecraft/class_1703;method_7617(Ljava/util/Set;ILnet/minecraft/class_1799;)Iofficial aLcpu;a(Ljava/util/Set;ILcuq;)I
-
canInsertIntoSlot
- Mappings:
Namespace Name Mixin selector named canInsertIntoSlotLnet/minecraft/screen/ScreenHandler;canInsertIntoSlot(Lnet/minecraft/screen/slot/Slot;)Zintermediary method_7615Lnet/minecraft/class_1703;method_7615(Lnet/minecraft/class_1735;)Zofficial bLcpu;b(Lcrq;)Z
-
calculateComparatorOutput
- Mappings:
Namespace Name Mixin selector named calculateComparatorOutputLnet/minecraft/screen/ScreenHandler;calculateComparatorOutput(Lnet/minecraft/block/entity/BlockEntity;)Iintermediary method_7608Lnet/minecraft/class_1703;method_7608(Lnet/minecraft/class_2586;)Iofficial aLcpu;a(Ldqh;)I
-
calculateComparatorOutput
- Mappings:
Namespace Name Mixin selector named calculateComparatorOutputLnet/minecraft/screen/ScreenHandler;calculateComparatorOutput(Lnet/minecraft/inventory/Inventory;)Iintermediary method_7618Lnet/minecraft/class_1703;method_7618(Lnet/minecraft/class_1263;)Iofficial bLcpu;b(Lbqk;)I
-
setCursorStack
- Mappings:
Namespace Name Mixin selector named setCursorStackLnet/minecraft/screen/ScreenHandler;setCursorStack(Lnet/minecraft/item/ItemStack;)Vintermediary method_34254Lnet/minecraft/class_1703;method_34254(Lnet/minecraft/class_1799;)Vofficial bLcpu;b(Lcuq;)V
-
getCursorStack
- Mappings:
Namespace Name Mixin selector named getCursorStackLnet/minecraft/screen/ScreenHandler;getCursorStack()Lnet/minecraft/item/ItemStack;intermediary method_34255Lnet/minecraft/class_1703;method_34255()Lnet/minecraft/class_1799;official gLcpu;g()Lcuq;
-
disableSyncing
public void disableSyncing()- Mappings:
Namespace Name Mixin selector named disableSyncingLnet/minecraft/screen/ScreenHandler;disableSyncing()Vintermediary method_34256Lnet/minecraft/class_1703;method_34256()Vofficial hLcpu;h()V
-
enableSyncing
public void enableSyncing()- Mappings:
Namespace Name Mixin selector named enableSyncingLnet/minecraft/screen/ScreenHandler;enableSyncing()Vintermediary method_34257Lnet/minecraft/class_1703;method_34257()Vofficial iLcpu;i()V
-
getSlotIndex
- Mappings:
Namespace Name Mixin selector named getSlotIndexLnet/minecraft/screen/ScreenHandler;getSlotIndex(Lnet/minecraft/inventory/Inventory;I)Ljava/util/OptionalInt;intermediary method_37418Lnet/minecraft/class_1703;method_37418(Lnet/minecraft/class_1263;I)Ljava/util/OptionalInt;official bLcpu;b(Lbqk;I)Ljava/util/OptionalInt;
-
getRevision
public int getRevision()- Mappings:
Namespace Name Mixin selector named getRevisionLnet/minecraft/screen/ScreenHandler;getRevision()Iintermediary method_37421Lnet/minecraft/class_1703;method_37421()Iofficial jLcpu;j()I
-
nextRevision
public int nextRevision()- Mappings:
Namespace Name Mixin selector named nextRevisionLnet/minecraft/screen/ScreenHandler;nextRevision()Iintermediary method_37422Lnet/minecraft/class_1703;method_37422()Iofficial kLcpu;k()I
-