Shown!
Shown! 是一个基于小部件(Widget)的 Minecraft UI 库,允许简单地为各种用途创建界面!
屏幕(Screens)
与 Minecraft 类似,你需要从 Screen(屏幕)开始。Screen 是你整个界面的创建和处理场所。 最基本的屏幕可以按如下方式创建:
public class ExampleScreen extends ShownScreen {
public ExampleScreen() {
super();
}
@Override
protected void init() {
super.init();
}
}
在创建和添加小部件时,你应该在 init() 中进行。你的 super.init() 调用也应始终放在底部,因为这将运行所有已添加小部件的初始化,并更新每个小部件的尺寸。
小部件(Widgets)
添加小部件及其功能都非常简单。首先,我们应该了解如何定位和缩放它们。
小部件使用一个名为 UIVec 的自定义 Vector 类来处理位置和缩放。UIVec 对每个轴都有两个值:缩放(scale)和偏移(offset)。缩放是相对于父级小部件的轴值,而偏移是一个常数值。以下是其工作原理的一个示例:

如上所示,面板的总宽度为 100px,而盒子的高度仅为 80px。面板中包含的元素如下:
- 一个红色盒子,父级为主面板。其位置为 (0, 0, 0, 0),尺寸为 (0.5, 0.5, 0, 0),因此大小为 50x40px。
- 一个绿色盒子,父级为主面板。其位置为 (0.5, 0.25, 0, 0),尺寸为 (0.25, 0.75, 0, 0),因此大小为 25x60px,同时位于 (50, 20)。
- 一个蓝色盒子,父级为红色盒子。其位置也为 (0, 0, 0, 0),尺寸为 (0.5, 0.5, 0, 0),因此大小为 25x20px。
通过这种方式定位和缩放小部件,可以实现对所有屏幕尺寸的精确相对性,以及特定大小的元素,例如高度为 20px 的标题栏。
利用这一理解,将简单的面板小部件放置在屏幕中心,且其在每个轴上的大小均为原来的一半,可以按如下方式完成:
@Override
protected void init() {
PanelWidget panel = new PanelWidget(
new UIVec(0.25, 0.25, 0, 0),
new UIVec(0.5, 0.5, 0, 0)
);
this.addWidget(panel);
super.init();
}
Shown!
Shown! is a widget-based UI library for Minecraft, allowing simple creation of interfaces for all sorts of purposes!
Screens
Just like Minecraft, you need to start with a Screen. The Screen is where your entire interface is created, and handled. The most basic screen can be created as follows:
public class ExampleScreen extends ShownScreen {
public ExampleScreen() {
super();
}
@Override
protected void init() {
super.init();
}
}
When creating and adding widgets, you should make them in init(). Your call to super.init() should also always be at the bottom, as this runs the initialization for all of the added widgets, as well as updates the dimensions of each widget.
Widgets
Adding widgets is extremely simple, as well as how they function. First, we should go over how to position and scale them.
Widgets use a custom Vector class called UIVec to handle position and scale. UIVec has two values for each axis, scale and offset. Scale is the value of the axis relative to the parent widget, while offset is a constant value. An example of how this works can be shown here:

As seen above, the entire width of the panel is 100px while the height of the box is only 80px. The elements contained within the panel are as follows:
- A red box, parented to the main panel. It has a position of (0, 0, 0, 0) and a size of (0.5, 0.5, 0, 0), therefore being 50x40px large.
- A green box, parented to the main panel. It has a position of (0.5, 0.25, 0, 0) and a size of (0.25, 0.75, 0, 0), therefore being 25x60px large, while also being positioned at (50, 20)
- A blue box, parented to the red box. It also has a position of (0, 0, 0, 0) and a size of (0.5, 05, 0, 0), therefore it is 25x20px large.
Positioning and scaling widgets this way allows for exact relativity for all screen sizes, and also specific sized elements, such as a 20px tall header bar.
Using this understanding, placing a simple panel widget in the center of the screen that is half of the size in each axis can be done as follows:
@Override
protected void init() {
PanelWidget panel = new PanelWidget(
new UIVec(0.25, 0.25, 0, 0),
new UIVec(0.5, 0.5, 0, 0)
);
this.addWidget(panel);
super.init();
}
下载 Shown!
下载 Shown!
下载 Shown!
下载 Shown!
下载 Shown!
下载 Shown!
下载 Shown!
下载 Shown!
未指定更新日志。
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
可定制的鞘翅模组,支持装饰纹饰、旗帜图案等更多功能!
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
原版世界生成优化模组
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
评论 0
登录后参与评分
还没有评论,来抢沙发吧