Package io.github.cottonmc.cotton.gui
Class ItemSyncedGuiDescription
java.lang.Object
net.minecraft.screen.ScreenHandler
io.github.cottonmc.cotton.gui.SyncedGuiDescription
io.github.cottonmc.cotton.gui.ItemSyncedGuiDescription
- All Implemented Interfaces:
GuiDescription
A
SyncedGuiDescription
for an item stack
in an inventory.
The owning item is represented with a StackReference
, which can be
an item in an entity's inventory or a block's container, or any other reference
to an item stack.
If the owning item stack changes in any way, the screen closes by default (see canUse(PlayerEntity)
).
- Since:
- 7.0.0
-
Field Summary
Modifier and TypeFieldDescriptionprotected final StackReference
A reference to the owning item stack of this GUI.protected final ItemStack
The initial item stack of this GUI.Fields inherited from class io.github.cottonmc.cotton.gui.SyncedGuiDescription
blockInventory, darkTitleColor, focus, fullscreen, playerInventory, propertyDelegate, rootPanel, titleAlignment, titleColor, titleVisible, world
Fields inherited from class net.minecraft.screen.ScreenHandler
EMPTY_SPACE_SLOT_INDEX, field_30731, field_30732, field_30733, field_30734, field_30735, field_30736, field_30737, slots, syncId
-
Constructor Summary
ConstructorDescriptionItemSyncedGuiDescription
(ScreenHandlerType<?> type, int syncId, PlayerInventory playerInventory, StackReference owner) Constructs anItemSyncedGuiDescription
. -
Method Summary
Methods inherited from class io.github.cottonmc.cotton.gui.SyncedGuiDescription
addPainters, addSlotPeer, createPlayerInventoryPanel, createPlayerInventoryPanel, createPlayerInventoryPanel, getBlockInventory, getBlockInventory, getBlockPropertyDelegate, getBlockPropertyDelegate, getFocus, getNetworkSide, getPacketSender, getPropertyDelegate, getRootPanel, getTitleAlignment, getTitleColor, getTitlePos, getWorld, isFocused, isFullscreen, isTitleVisible, onClosed, quickMove, releaseFocus, requestFocus, setFullscreen, setPropertyDelegate, setRootPanel, setTitleAlignment, setTitleColor, setTitleColor, setTitlePos, setTitleVisible
Methods inherited from class net.minecraft.screen.ScreenHandler
addListener, addProperties, addProperty, addSlot, calculateComparatorOutput, calculateComparatorOutput, calculateStackSize, canInsertIntoSlot, canInsertIntoSlot, canInsertItemIntoSlot, canUse, checkDataCount, checkSize, copySharedSlots, disableSyncing, dropInventory, enableSyncing, endQuickCraft, getCursorStack, getRevision, getSlot, getSlotIndex, getStacks, getType, insertItem, isValid, nextRevision, onButtonClick, onContentChanged, onSlotClick, packQuickCraftData, removeListener, sendContentUpdates, setCursorStack, setPreviousCursorStack, setPreviousTrackedSlot, setPreviousTrackedSlotMutable, setProperty, setStackInSlot, shouldQuickCraftContinue, syncState, unpackQuickCraftButton, unpackQuickCraftStage, updateSlotStacks, updateSyncHandler, updateToClient
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.github.cottonmc.cotton.gui.GuiDescription
isDarkMode
-
Field Details
-
owner
A reference to the owning item stack of this GUI. -
ownerStack
The initial item stack of this GUI. This stack must not be mutated!
-
-
Constructor Details
-
ItemSyncedGuiDescription
public ItemSyncedGuiDescription(ScreenHandlerType<?> type, int syncId, PlayerInventory playerInventory, StackReference owner) Constructs anItemSyncedGuiDescription
.- Parameters:
type
- the screen handler typesyncId
- the sync IDplayerInventory
- the inventory of the player viewing this GUI descriptionowner
- a reference to the owning item stack of this GUI description
-
-
Method Details
-
canUse
The default implementation for
ItemSyncedGuiDescription
returnstrue
if and only if the current owning item stack is fully equal to the original owner.If the item NBT is intended to change, subclasses should override this method to only check the item and the count. Those subclasses should also take care to respond properly to any NBT changes in the owning item stack.
- Overrides:
canUse
in classSyncedGuiDescription
-