Class ItemSyncedGuiDescription
java.lang.Object
net.minecraft.world.inventory.AbstractContainerMenu
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 SlotAccess, 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 stillValid(Player)).
- Since:
- 7.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface GuiDescription
GuiDescription.FocusChangeListener -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final net.minecraft.world.entity.SlotAccessA reference to the owning item stack of this GUI.protected final net.minecraft.world.item.ItemStackThe initial item stack of this GUI.Fields inherited from class SyncedGuiDescription
blockInventory, darkTitleColor, focus, fullscreen, playerInventory, propertyDelegate, rootPanel, titleAlignment, titleColor, titleVisible, worldFields inherited from class net.minecraft.world.inventory.AbstractContainerMenu
CARRIED_SLOT_SIZE, containerId, QUICKCRAFT_HEADER_CONTINUE, QUICKCRAFT_HEADER_END, QUICKCRAFT_HEADER_START, QUICKCRAFT_TYPE_CHARITABLE, QUICKCRAFT_TYPE_CLONE, QUICKCRAFT_TYPE_GREEDY, SLOT_CLICKED_OUTSIDE, SLOT_SIZE, slots, SLOTS_PER_ROW -
Constructor Summary
ConstructorsConstructorDescriptionItemSyncedGuiDescription(net.minecraft.world.inventory.MenuType<?> type, int syncId, net.minecraft.world.entity.player.Inventory playerInventory, net.minecraft.world.entity.SlotAccess owner) Constructs anItemSyncedGuiDescription. -
Method Summary
Modifier and TypeMethodDescriptionbooleanstillValid(net.minecraft.world.entity.player.Player entity) Methods inherited from class SyncedGuiDescription
addFocusChangeListener, addPainters, addSlotPeer, broadcastChanges, createPlayerInventoryPanel, createPlayerInventoryPanel, createPlayerInventoryPanel, getBlockInventory, getBlockInventory, getBlockPropertyDelegate, getBlockPropertyDelegate, getContainerData, getFocus, getLevel, getNetworking, getNetworkSide, getPacketSender, getRootPanel, getTitleAlignment, getTitleColor, getTitlePos, getUseDefaultRootBackground, getWorld, isFocused, isFullscreen, isTitleVisible, quickMoveStack, registerDataSlot, registerDataSlot, releaseFocus, removed, requestFocus, sendDataSlotUpdates, setContainerData, setFullscreen, setRootPanel, setTitleAlignment, setTitleColor, setTitleColor, setTitlePos, setTitleVisible, setUseDefaultRootBackgroundMethods inherited from class net.minecraft.world.inventory.AbstractContainerMenu
addDataSlot, addDataSlots, addInventoryExtendedSlots, addInventoryHotbarSlots, addSlot, addSlotListener, addStandardInventorySlots, broadcastFullState, canDragTo, canItemQuickReplace, canTakeItemForPickAll, checkContainerDataCount, checkContainerSize, clearContainer, clicked, clickMenuButton, findSlot, getCarried, getItems, getQuickcraftHeader, getQuickcraftMask, getQuickCraftPlaceCount, getQuickcraftType, getRedstoneSignalFromBlockEntity, getRedstoneSignalFromContainer, getSlot, getStateId, getType, incrementStateId, initializeContents, isValidQuickcraftType, isValidSlotIndex, moveItemStackTo, removeSlotListener, resetQuickCraft, resumeRemoteUpdates, sendAllDataToRemote, setCarried, setData, setItem, setRemoteCarried, setRemoteSlot, setRemoteSlotUnsafe, setSelectedBundleItemIndex, setSynchronizer, slotsChanged, stillValid, suppressRemoteUpdates, transferStateMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface GuiDescription
getPropertyDelegate, isDarkMode, setPropertyDelegate
-
Field Details
-
owner
protected final net.minecraft.world.entity.SlotAccess ownerA reference to the owning item stack of this GUI. -
ownerStack
protected final net.minecraft.world.item.ItemStack ownerStackThe initial item stack of this GUI. This stack must not be mutated!
-
-
Constructor Details
-
ItemSyncedGuiDescription
public ItemSyncedGuiDescription(net.minecraft.world.inventory.MenuType<?> type, int syncId, net.minecraft.world.entity.player.Inventory playerInventory, net.minecraft.world.entity.SlotAccess 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
-
stillValid
public boolean stillValid(net.minecraft.world.entity.player.Player entity) The default implementation for
ItemSyncedGuiDescriptionreturnstrueif 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:
stillValidin classSyncedGuiDescription
-