Skip to content

Framework

This page is about some core classes of a Modular GUI.

ModularScreen

This is the core of each GUI on the client side. It keeps track of all panels. This is where the GuiContext is stored.

Useful methods are:

  • getOwner() returns the owner of the screen (usually a mod id)
  • getName() returns the name of the main panel
  • getContext() returns the GuiContext
  • getWindowManager() returns the WindowManager
  • getSyncManager() returns the GuiSyncManager
  • isClientOnly() returns if the screen is only open on client side
  • registerGuiActionListener() register an interaction listener
  • registerFrameUpdateListener() registers a listener which is called approximately 60 times per second
  • getCurrentTheme() returns the active theme for the screen
  • useTheme() tries to set the new theme (does nothing if theme is overridden by resource packs)

GuiContext

This class keeps track of the current GUI state. For example pressed buttons and keys, focused widgets dragging widgets, mouse position, JEI settings, themes and most importantly viewports and transformations.

Useful methods are:

  • isAbove() returns if the mouse is above a widget
  • all methods related to hovering
  • all methods related to focusing
  • hasDraggable() if the mouse is currently dragging an IDraggable (not including item stacks)
  • isMouseItemEmpty() if the mouse is currently not dragging an ItemStack
  • getMouseX() and getMouseY() returns the current mouse position with the current transformations applied to it. That means it is relative to the current widgets position
  • getMouseAbsX() and getMouseAbsY() returns the true (absolute) mouse position
  • unTransformMouseX() and unTransformMouseY() is like getMouseX() and getMouseY(), but the transformations are inverted
  • getMouseButton() returns the last pressed mouse button
  • getMouseWheel() returns the last scroll wheel use
  • getKeyCode() returns the last typed key code
  • getTypedChar() returns the last typed character
  • getPartialTicks() returns the partial ticks for the current frame
  • getTheme() returns the current active theme
  • getJeiSettings() returns the current modifiable JEI settings

ModularPanel

This is the root of each widget tree. Panels are also widgets.

Widget

A widget is an element in the widget tree. It has a size and position and it can be rendered on screen.

This class has a lot of useful methods, too many to list them all. But you can take a look yourself. I did my best to structure it and make it clean.

WindowManager

Keeps track of all panels and the main panels. Handles opening and closing panels

GuiSyncManager

Manages sync values. This is the only class (with ModularContainer) that exists on client and server side.

GuiScreenWrapper

This is the minecraft GuiContainer class which wraps the ModularScreen. This is an internal class.

ModularContainer

This is the minecraft Container class. This is an internal class.

贡献者

© 2024 CleanroomMC. All Rights Reserved.

布局切换

调整 VitePress 的布局样式,以适配不同的阅读习惯和屏幕环境。

全部展开
使侧边栏和内容区域占据整个屏幕的全部宽度。
全部展开,但侧边栏宽度可调
侧边栏宽度可调,但内容区域宽度不变,调整后的侧边栏将可以占据整个屏幕的最大宽度。
全部展开,且侧边栏和内容区域宽度均可调
侧边栏宽度可调,但内容区域宽度不变,调整后的侧边栏将可以占据整个屏幕的最大宽度。
原始宽度
原始的 VitePress 默认布局宽度

页面最大宽度

调整 VitePress 布局中页面的宽度,以适配不同的阅读习惯和屏幕环境。

调整页面最大宽度
一个可调整的滑块,用于选择和自定义页面最大宽度。

内容最大宽度

调整 VitePress 布局中内容区域的宽度,以适配不同的阅读习惯和屏幕环境。

调整内容最大宽度
一个可调整的滑块,用于选择和自定义内容最大宽度。

聚光灯

支持在正文中高亮当前鼠标悬停的行和元素,以优化阅读和专注困难的用户的阅读体验。

ON开启
开启聚光灯。
OFF关闭
关闭聚光灯。

聚光灯样式

调整聚光灯的样式。

置于底部
在当前鼠标悬停的元素下方添加一个纯色背景以突出显示当前鼠标悬停的位置。
置于侧边
在当前鼠标悬停的元素旁边添加一条固定的纯色线以突出显示当前鼠标悬停的位置。