Class SyncedGuiDescription
- All Implemented Interfaces:
GuiDescription
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected net.minecraft.inventory.Inventoryprotected intprotected WWidgetprotected booleanprotected net.minecraft.entity.player.PlayerInventoryprotected net.minecraft.screen.PropertyDelegateprotected WPanelprotected HorizontalAlignmentprotected intprotected booleanprotected net.minecraft.world.WorldFields 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
ConstructorsConstructorDescriptionSyncedGuiDescription(net.minecraft.screen.ScreenHandlerType<?> type, int syncId, net.minecraft.entity.player.PlayerInventory playerInventory) Constructs a new synced GUI description without a block inventory or a property delegate.SyncedGuiDescription(net.minecraft.screen.ScreenHandlerType<?> type, int syncId, net.minecraft.entity.player.PlayerInventory playerInventory, @Nullable net.minecraft.inventory.Inventory blockInventory, @Nullable net.minecraft.screen.PropertyDelegate propertyDelegate) Constructs a new synced GUI description. -
Method Summary
Modifier and TypeMethodDescriptionvoidGuis should use this method to add clientside styles and BackgroundPainters to their controlsvoidaddSlotPeer(ValidatedSlot slot) Typical users won't call this.booleancanUse(net.minecraft.entity.player.PlayerEntity entity) voidclose(net.minecraft.entity.player.PlayerEntity player) 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 net.minecraft.inventory.InventorygetBlockInventory(net.minecraft.screen.ScreenHandlerContext ctx) Gets the block inventory at the context.static net.minecraft.inventory.InventorygetBlockInventory(net.minecraft.screen.ScreenHandlerContext ctx, int size) Gets the block inventory at the context.static net.minecraft.screen.PropertyDelegategetBlockPropertyDelegate(net.minecraft.screen.ScreenHandlerContext ctx) Gets the property delegate at the context.static net.minecraft.screen.PropertyDelegategetBlockPropertyDelegate(net.minecraft.screen.ScreenHandlerContext ctx, int size) Gets the property delegate at the context.getFocus()Gets the currently-focused WWidget.final NetworkSideGets the network side this GUI description runs on.final net.fabricmc.fabric.api.networking.v1.PacketSenderGets the packet sender corresponding to this GUI's network side.@Nullable net.minecraft.screen.PropertyDelegateGets the object which manages the integer properties used by WBars and such.Gets the horizontal alignment of the GUI title.intGets the position of the screen title.booleanTests whether the widget is the currently-focused one.booleanGets whether this GUI is fullscreen.booleanGets whether the title of this GUI should be rendered by the screen.voidonSlotClick(int slotIndex, int button, net.minecraft.screen.slot.SlotActionType actionType, net.minecraft.entity.player.PlayerEntity player) voidreleaseFocus(WWidget widget) Notifies this gui that the widget wants to give up its hold over focus.voidrequestFocus(WWidget widget) Notifies this gui that the widget wants to acquire focus.voidsetFullscreen(boolean fullscreen) Sets whether this GUI is fullscreen.setPropertyDelegate(net.minecraft.screen.PropertyDelegate delegate) Sets the object which manages the integer properties used by WBarssetRootPanel(WPanel panel) voidsetTitleAlignment(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.voidsetTitlePos(Vec2i titlePos) Sets the position of the screen title.voidsetTitleVisible(boolean titleVisible) Sets whether the title of this GUI should be rendered by the screen.net.minecraft.item.ItemStacktransferSlot(net.minecraft.entity.player.PlayerEntity player, int index) 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, packQuickCraftData, removeListener, sendContentUpdates, setCursorStack, setPreviousCursorStack, setPreviousTrackedSlot, setPreviousTrackedSlotMutable, setProperty, setStackInSlot, shouldQuickCraftContinue, syncState, unpackQuickCraftButton, unpackQuickCraftStage, updateSlotStacks, updateSyncHandler, updateToClientMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.cottonmc.cotton.gui.GuiDescription
cycleFocus
-
Field Details
-
blockInventory
protected net.minecraft.inventory.Inventory blockInventory -
playerInventory
protected net.minecraft.entity.player.PlayerInventory playerInventory -
world
protected net.minecraft.world.World world -
propertyDelegate
protected net.minecraft.screen.PropertyDelegate propertyDelegate -
rootPanel
-
titleColor
protected int titleColor -
darkTitleColor
protected int darkTitleColor -
fullscreen
protected boolean fullscreen -
titleVisible
protected boolean titleVisible -
titleAlignment
-
focus
-
-
Constructor Details
-
SyncedGuiDescription
public SyncedGuiDescription(net.minecraft.screen.ScreenHandlerType<?> type, int syncId, net.minecraft.entity.player.PlayerInventory playerInventory) Constructs a new synced GUI description without a block inventory or a property delegate.- Parameters:
type- theScreenHandlerTypeof this GUI descriptionsyncId- the current sync IDplayerInventory- the player inventory of the player viewing this screen
-
SyncedGuiDescription
public SyncedGuiDescription(net.minecraft.screen.ScreenHandlerType<?> type, int syncId, net.minecraft.entity.player.PlayerInventory playerInventory, @Nullable @Nullable net.minecraft.inventory.Inventory blockInventory, @Nullable @Nullable net.minecraft.screen.PropertyDelegate propertyDelegate) Constructs a new synced GUI description.- Parameters:
type- theScreenHandlerTypeof 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:
getRootPanelin interfaceGuiDescription
-
getTitleColor
public int getTitleColor()- Specified by:
getTitleColorin interfaceGuiDescription
-
setRootPanel
- Specified by:
setRootPanelin interfaceGuiDescription
-
setTitleColor
Description copied from interface:GuiDescriptionSets 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:
setTitleColorin interfaceGuiDescription- Parameters:
color- the new title color- Returns:
- this GUI
-
setTitleColor
Description copied from interface:GuiDescriptionSets the light and dark title colors of this GUI.- Specified by:
setTitleColorin interfaceGuiDescription- Parameters:
lightColor- the light-mode colordarkColor- the dark-mode color- Returns:
- this GUI
-
addPainters
@Environment(CLIENT) public void addPainters()Description copied from interface:GuiDescriptionGuis should use this method to add clientside styles and BackgroundPainters to their controls- Specified by:
addPaintersin interfaceGuiDescription
-
addSlotPeer
Description copied from interface:GuiDescriptionTypical users won't call this. This adds a Slot to Container/Controller-based guis, and does nothing on lightweight guis.- Specified by:
addSlotPeerin interfaceGuiDescription
-
transferSlot
public net.minecraft.item.ItemStack transferSlot(net.minecraft.entity.player.PlayerEntity player, int index) - Overrides:
transferSlotin classnet.minecraft.screen.ScreenHandler
-
onSlotClick
public void onSlotClick(int slotIndex, int button, net.minecraft.screen.slot.SlotActionType actionType, net.minecraft.entity.player.PlayerEntity player) - Overrides:
onSlotClickin classnet.minecraft.screen.ScreenHandler
-
getPropertyDelegate
Description copied from interface:GuiDescriptionGets the object which manages the integer properties used by WBars and such.- Specified by:
getPropertyDelegatein interfaceGuiDescription
-
setPropertyDelegate
Description copied from interface:GuiDescriptionSets the object which manages the integer properties used by WBars- Specified by:
setPropertyDelegatein 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
public static net.minecraft.inventory.Inventory getBlockInventory(net.minecraft.screen.ScreenHandlerContext ctx) 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
public static net.minecraft.inventory.Inventory getBlockInventory(net.minecraft.screen.ScreenHandlerContext ctx, int size) 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
public static net.minecraft.screen.PropertyDelegate getBlockPropertyDelegate(net.minecraft.screen.ScreenHandlerContext ctx) 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
public static net.minecraft.screen.PropertyDelegate getBlockPropertyDelegate(net.minecraft.screen.ScreenHandlerContext ctx, int size) 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
public boolean canUse(net.minecraft.entity.player.PlayerEntity entity) - Specified by:
canUsein classnet.minecraft.screen.ScreenHandler
-
close
public void close(net.minecraft.entity.player.PlayerEntity player) - Overrides:
closein classnet.minecraft.screen.ScreenHandler
-
isFocused
Description copied from interface:GuiDescriptionTests whether the widget is the currently-focused one.- Specified by:
isFocusedin interfaceGuiDescription
-
getFocus
Description copied from interface:GuiDescriptionGets the currently-focused WWidget. May be null.- Specified by:
getFocusin interfaceGuiDescription
-
requestFocus
Description copied from interface:GuiDescriptionNotifies this gui that the widget wants to acquire focus.- Specified by:
requestFocusin interfaceGuiDescription
-
releaseFocus
Description copied from interface:GuiDescriptionNotifies this gui that the widget wants to give up its hold over focus.- Specified by:
releaseFocusin interfaceGuiDescription
-
isFullscreen
public boolean isFullscreen()Description copied from interface:GuiDescriptionGets 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:
isFullscreenin interfaceGuiDescription- Returns:
- true if this GUI is fullscreen, false otherwise
-
setFullscreen
public void setFullscreen(boolean fullscreen) Description copied from interface:GuiDescriptionSets whether this GUI is fullscreen.- Specified by:
setFullscreenin interfaceGuiDescription- Parameters:
fullscreen- true if this GUI is fullscreen, false otherwise
-
isTitleVisible
public boolean isTitleVisible()Description copied from interface:GuiDescriptionGets 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:
isTitleVisiblein interfaceGuiDescription- Returns:
- true if the title is visible, false otherwise
-
setTitleVisible
public void setTitleVisible(boolean titleVisible) Description copied from interface:GuiDescriptionSets whether the title of this GUI should be rendered by the screen.- Specified by:
setTitleVisiblein interfaceGuiDescription- Parameters:
titleVisible- true if the title is visible, false otherwise
-
getTitleAlignment
Description copied from interface:GuiDescriptionGets the horizontal alignment of the GUI title.- Specified by:
getTitleAlignmentin interfaceGuiDescription- Returns:
- the alignment
-
setTitleAlignment
Description copied from interface:GuiDescriptionSets the horizontal alignment of the GUI title.- Specified by:
setTitleAlignmentin interfaceGuiDescription- Parameters:
titleAlignment- the new alignment
-
getTitlePos
Description copied from interface:GuiDescriptionGets the position of the screen title.- Specified by:
getTitlePosin interfaceGuiDescription- Returns:
- the title position
-
setTitlePos
Description copied from interface:GuiDescriptionSets the position of the screen title.- Specified by:
setTitlePosin interfaceGuiDescription- Parameters:
titlePos- the new title position
-
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
-