Class SyncedGuiDescription
- All Implemented Interfaces:
GuiDescription
- Direct Known Subclasses:
ItemSyncedGuiDescription
-
Field Summary
Modifier and TypeFieldDescriptionprotected Inventory
protected int
protected WWidget
protected boolean
protected PlayerInventory
protected PropertyDelegate
protected WPanel
protected HorizontalAlignment
protected int
protected boolean
protected 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
ConstructorDescriptionSyncedGuiDescription
(ScreenHandlerType<?> type, int syncId, PlayerInventory playerInventory) Constructs a new synced GUI description without a block inventory or a property delegate.SyncedGuiDescription
(ScreenHandlerType<?> type, int syncId, PlayerInventory playerInventory, @Nullable Inventory blockInventory, @Nullable PropertyDelegate propertyDelegate) Constructs a new synced GUI description. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Guis should use this method to add clientside styles and BackgroundPainters to their controlsvoid
addSlotPeer
(ValidatedSlot slot) Typical users won't call this.boolean
canUse
(PlayerEntity entity) Creates a player inventory widget from this panel's player inventory.createPlayerInventoryPanel
(boolean hasLabel) Creates a player inventory widget from this panel's player inventory.Creates a player inventory widget from this panel's player inventory.static Inventory
Gets the block inventory at the context.static Inventory
getBlockInventory
(ScreenHandlerContext ctx, int size) Gets the block inventory at the context.static PropertyDelegate
Gets the property delegate at the context.static PropertyDelegate
getBlockPropertyDelegate
(ScreenHandlerContext ctx, int size) Gets the property delegate at the context.getFocus()
Gets the currently-focused WWidget.final NetworkSide
Gets the network side this GUI description runs on.final net.fabricmc.fabric.api.networking.v1.PacketSender
Gets the packet sender corresponding to this GUI's network side.Gets the object which manages the integer properties used by WBars and such.Gets the horizontal alignment of the GUI title.int
Gets the position of the screen title.getWorld()
Returns the world of this GUI description's player.boolean
Tests whether the widget is the currently-focused one.boolean
Gets whether this GUI is fullscreen.boolean
Gets whether the title of this GUI should be rendered by the screen.void
onClosed
(PlayerEntity player) quickMove
(PlayerEntity player, int index) void
releaseFocus
(WWidget widget) Notifies this gui that the widget wants to give up its hold over focus.void
requestFocus
(WWidget widget) Notifies this gui that the widget wants to acquire focus.void
setFullscreen
(boolean fullscreen) Sets whether this GUI is fullscreen.setPropertyDelegate
(PropertyDelegate delegate) Sets the object which manages the integer properties used by WBarssetRootPanel
(WPanel panel) void
setTitleAlignment
(HorizontalAlignment titleAlignment) Sets the horizontal alignment of the GUI title.setTitleColor
(int color) Sets the title color of this GUI.setTitleColor
(int lightColor, int darkColor) Sets the light and dark title colors of this GUI.void
setTitlePos
(Vec2i titlePos) Sets the position of the screen title.void
setTitleVisible
(boolean titleVisible) Sets whether the title of this GUI should be rendered by the screen.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
-
blockInventory
-
playerInventory
-
world
-
propertyDelegate
-
rootPanel
-
titleColor
protected int titleColor -
darkTitleColor
protected int darkTitleColor -
fullscreen
protected boolean fullscreen -
titleVisible
protected boolean titleVisible -
titleAlignment
-
focus
-
-
Constructor Details
-
SyncedGuiDescription
Constructs a new synced GUI description without a block inventory or a property delegate.- Parameters:
type
- theScreenHandlerType
of this GUI descriptionsyncId
- the current sync IDplayerInventory
- the player inventory of the player viewing this screen
-
SyncedGuiDescription
public SyncedGuiDescription(ScreenHandlerType<?> type, int syncId, PlayerInventory playerInventory, @Nullable @Nullable Inventory blockInventory, @Nullable @Nullable PropertyDelegate propertyDelegate) Constructs a new synced GUI description.- Parameters:
type
- theScreenHandlerType
of this GUI descriptionsyncId
- the current sync IDplayerInventory
- the player inventory of the player viewing this screenblockInventory
- the block inventory of a corresponding container block, or null if not found or applicablepropertyDelegate
- a property delegate whose properties, if any, will automatically be added
-
-
Method Details
-
getRootPanel
- Specified by:
getRootPanel
in interfaceGuiDescription
-
getTitleColor
public int getTitleColor()- Specified by:
getTitleColor
in interfaceGuiDescription
-
setRootPanel
- Specified by:
setRootPanel
in interfaceGuiDescription
-
setTitleColor
Description copied from interface:GuiDescription
Sets the title color of this GUI.The dark-mode title color will also be set by this method. If the specified color is
WLabel.DEFAULT_TEXT_COLOR
, the dark-mode color will beWLabel.DEFAULT_DARKMODE_TEXT_COLOR
; otherwise it will be the specified color.- Specified by:
setTitleColor
in interfaceGuiDescription
- Parameters:
color
- the new title color- Returns:
- this GUI
-
setTitleColor
Description copied from interface:GuiDescription
Sets the light and dark title colors of this GUI.- Specified by:
setTitleColor
in interfaceGuiDescription
- Parameters:
lightColor
- the light-mode colordarkColor
- the dark-mode color- Returns:
- this GUI
-
addPainters
@Environment(CLIENT) public void addPainters()Description copied from interface:GuiDescription
Guis should use this method to add clientside styles and BackgroundPainters to their controls- Specified by:
addPainters
in interfaceGuiDescription
-
addSlotPeer
Description copied from interface:GuiDescription
Typical users won't call this. This adds a Slot to Container/Controller-based guis, and does nothing on lightweight guis.- Specified by:
addSlotPeer
in interfaceGuiDescription
-
quickMove
- Specified by:
quickMove
in classScreenHandler
-
getPropertyDelegate
Description copied from interface:GuiDescription
Gets the object which manages the integer properties used by WBars and such.- Specified by:
getPropertyDelegate
in interfaceGuiDescription
-
setPropertyDelegate
Description copied from interface:GuiDescription
Sets the object which manages the integer properties used by WBars- Specified by:
setPropertyDelegate
in interfaceGuiDescription
-
createPlayerInventoryPanel
Creates a player inventory widget from this panel's player inventory.- Returns:
- the created inventory widget
-
createPlayerInventoryPanel
Creates a player inventory widget from this panel's player inventory.- Parameters:
hasLabel
- whether the "Inventory" label should be displayed- Returns:
- the created inventory widget
- Since:
- 2.0.0
-
createPlayerInventoryPanel
Creates a player inventory widget from this panel's player inventory.- Parameters:
label
- the inventory label widget- Returns:
- the created inventory widget
- Since:
- 2.0.0
-
getBlockInventory
Gets the block inventory at the context.If no inventory is found, returns
EmptyInventory.INSTANCE
.Searches for these implementations in the following order:
- Blocks implementing
InventoryProvider
- Block entities implementing
InventoryProvider
- Block entities implementing
Inventory
- Parameters:
ctx
- the context- Returns:
- the found inventory
- Blocks implementing
-
getBlockInventory
Gets the block inventory at the context.If no inventory is found, returns a simple mutable inventory with the specified number of slots.
Searches for these implementations in the following order:
- Blocks implementing
InventoryProvider
- Block entities implementing
InventoryProvider
- Block entities implementing
Inventory
- Parameters:
ctx
- the contextsize
- the fallback inventory size- Returns:
- the found inventory
- Since:
- 2.0.0
- Blocks implementing
-
getBlockPropertyDelegate
Gets the property delegate at the context.If no property delegate is found, returns an empty property delegate with no properties.
Searches for block entities implementing
PropertyDelegateHolder
.- Parameters:
ctx
- the context- Returns:
- the found property delegate
-
getBlockPropertyDelegate
Gets the property delegate at the context.If no property delegate is found, returns an array property delegate with the specified number of properties.
Searches for block entities implementing
PropertyDelegateHolder
.- Parameters:
ctx
- the contextsize
- the number of properties- Returns:
- the found property delegate
- Since:
- 2.0.0
-
canUse
- Specified by:
canUse
in classScreenHandler
-
onClosed
- Overrides:
onClosed
in classScreenHandler
-
isFocused
Description copied from interface:GuiDescription
Tests whether the widget is the currently-focused one.- Specified by:
isFocused
in interfaceGuiDescription
-
getFocus
Description copied from interface:GuiDescription
Gets the currently-focused WWidget. May be null.- Specified by:
getFocus
in interfaceGuiDescription
-
requestFocus
Description copied from interface:GuiDescription
Notifies this gui that the widget wants to acquire focus.- Specified by:
requestFocus
in interfaceGuiDescription
-
releaseFocus
Description copied from interface:GuiDescription
Notifies this gui that the widget wants to give up its hold over focus.- Specified by:
releaseFocus
in interfaceGuiDescription
-
isFullscreen
public boolean isFullscreen()Description copied from interface:GuiDescription
Gets whether this GUI is fullscreen.Fullscreen GUIs have no default background painter and have the root panel stretched to fit the entire screen on the client.
- Specified by:
isFullscreen
in interfaceGuiDescription
- Returns:
- true if this GUI is fullscreen, false otherwise
-
setFullscreen
public void setFullscreen(boolean fullscreen) Description copied from interface:GuiDescription
Sets whether this GUI is fullscreen.- Specified by:
setFullscreen
in interfaceGuiDescription
- Parameters:
fullscreen
- true if this GUI is fullscreen, false otherwise
-
isTitleVisible
public boolean isTitleVisible()Description copied from interface:GuiDescription
Gets whether the title of this GUI should be rendered by the screen.Modders can disable this to render the title themselves with a widget.
- Specified by:
isTitleVisible
in interfaceGuiDescription
- Returns:
- true if the title is visible, false otherwise
-
setTitleVisible
public void setTitleVisible(boolean titleVisible) Description copied from interface:GuiDescription
Sets whether the title of this GUI should be rendered by the screen.- Specified by:
setTitleVisible
in interfaceGuiDescription
- Parameters:
titleVisible
- true if the title is visible, false otherwise
-
getTitleAlignment
Description copied from interface:GuiDescription
Gets the horizontal alignment of the GUI title.- Specified by:
getTitleAlignment
in interfaceGuiDescription
- Returns:
- the alignment
-
setTitleAlignment
Description copied from interface:GuiDescription
Sets the horizontal alignment of the GUI title.- Specified by:
setTitleAlignment
in interfaceGuiDescription
- Parameters:
titleAlignment
- the new alignment
-
getTitlePos
Description copied from interface:GuiDescription
Gets the position of the screen title.- Specified by:
getTitlePos
in interfaceGuiDescription
- Returns:
- the title position
-
setTitlePos
Description copied from interface:GuiDescription
Sets the position of the screen title.- Specified by:
setTitlePos
in interfaceGuiDescription
- Parameters:
titlePos
- the new title position
-
getWorld
Returns the world of this GUI description's player.- Returns:
- the world of this GUI description's player
- Since:
- 10.0.0
-
getNetworkSide
Gets the network side this GUI description runs on.- Returns:
- this GUI's network side
- Since:
- 3.3.0
-
getPacketSender
public final net.fabricmc.fabric.api.networking.v1.PacketSender getPacketSender()Gets the packet sender corresponding to this GUI's network side.- Returns:
- the packet sender
- Since:
- 3.3.0
-