- 原创/转载
- 原创
- 作者
- 向南小仙女
大家似乎好像还是搓不来ui的样子.
这里我写一例背包ui作为示范。
只有一张贴图,展示了多种写法。
甚至还有动画噶!
贴图来自群内一位鹿关哥。
(如有侵权,联系我删除帖子)
如果你不想下载贴图也可以直接在帖子内看配置>>>>
这里我写一例背包ui作为示范。
只有一张贴图,展示了多种写法。
甚至还有动画噶!
贴图来自群内一位鹿关哥。
(如有侵权,联系我删除帖子)
如果你不想下载贴图也可以直接在帖子内看配置>>>>
Java:
# 本背包由 “向南” 编写。
# 为群内一位热爱生活和鹿关的大哥所编辑。
# 进确认他同意我发布这个ui作为示例给大家学习.
# 礼赞! 鹿关哥!!!
# 适用 挨插 插件版本为: 1.0.15 beta
#你可以在这里设置唯一的一个背景图片路径。
背包背景图: &背景路径 "~鹿关哥的背包/bg1.png"
menu:
# 覆盖原版UI 这个原版UI的名字可以在客户端日志输出中看到
match:
# - InventoryScreen
# 该UI打开的时候隐藏那些HUD
hide: []
# 点击或者键盘输入事件是否需要传递给HUD
transfer: "false"
# 物品悬浮时的尺寸
itemSize: "16"
# 是否点击穿透
through: "false"
# 按下esc是否关闭UI
escClose: "true"
# 死亡关闭UI 如非重生页面请勿打开
closeDied: "true"
# 是否显示
show: "true"
# 是否在这个UI中启用JEI
jei: "false"
# 背景选项 注意 背景颜色和某些模组可能会冲突,如果冲突该选项会失效
background:
enable: "false"
top: "~255,255,255"
bottom: "~0,0,0"
alpha: "0.5"
# 背景模糊
blur:
enable: "true"
radius: "1"
value: "0.33"
# 动作触发器
action:
# 打开界面时 设置窗口大小 不想要可以删掉
open: |-
Message.chat("§6" + Player.getName() + "打开了背包!")
Message.chat("§6强行设置" + Player.getName() + "的窗口改为720P!")
Display.resize(1280, 720)
# 组件列表 按顺序填写 会按顺序渲染 越靠下渲染层数越靠前
controls:
# 组件名 自适应组件
自适应:
type: "adaptive"
attribute:
point: "~middle_center"
width: var.anmiationW #var.anmiationW ~= Expo(0,1920,1,1000)
height: var.anmiationH
action:
# 动画预建立,其实在哪儿建都一样 直接写上面
var.anmiationW = Expo(0,1920,1,1000)
var.anmiationH = Expo(0,1080,1,1000)
children:
背景:
type: "Texture"
attribute:
point: "~middle_center"
width: "847"
height: "481"
tip: "~按下鼠标拖动"
#设置拖动范围
minDragY: -300
maxDragY: 300
minDragX: -300
maxDragX: 300
normal: *背景路径
children:
#点券
points:
type: "text"
attribute:
x: 410
y: 458
width: "100"
center: "true"
height: "20"
fontSize: 24
tip: "~§b点券§r"
texts:
- "~§b{server.playerpoints_points}§r"
#金币
coins:
type: "text"
attribute:
x: 758
y: 458
width: "100"
center: "true"
height: "20"
tip: "~§6金币§r"
fontSize: 24
texts:
- "~§6{server.vault_eco_balance}§r"
#玩家实体
player:
type: "Entity"
attribute:
x: "210"
y: "200"
scale: "3"
followMouse: "true"
uuid: "~self"
tip: "~§c{Player.getName()} §a>> §e{Player.getLevel()}§a级§r"
second_hand:
type: "slot"
attribute:
x: 242
y: 78
id: 45
width: "54"
tip: "~§c副手§r"
height: "54"
slotType: "~Backpack"
itemScale: "0.8"
#垂直堆方式创建一堆原版装备槽
原版装备槽:
type: "VStack"
attribute:
spaceBetween: "21"
x: 46
y: 144
action:
create: |-
for(i in range(1,3)){
slot = self['装备槽'].copy('装备槽' + i.round())
slot.id = i+5
}
children:
装备槽:
type: "slot"
attribute:
width: "54"
height: "54"
tip: "~§c装备槽"
itemScale: "0.8"
id: 5
slotType: "~Backpack"
自定义装备:
type: "VStack"
attribute:
spaceBetween: "21"
x: 122
y: 68
action:
create: |-
for(i in range(1,4)){
tmp.customID = ['项链','戒指','腰带','披风']
slot = self['自定义装备槽'].copy('自定义装备槽' + i.round())
slot.id = tmp.customID.get(i-1)
slot.tip = "§c{tmp.customID.get(i-1)}"
}
children:
自定义装备槽:
type: "slot"
attribute:
width: "54"
height: "54"
slotType: "~Extra"
tip:
- "~§c头冠"
itemScale: "0.8"
id: 头冠
合成输出:
type: "slot"
attribute:
x: 642
y: 76
width: "54"
tip: "~§e合成出口§r"
height: "54"
id: 0
#网格容器2x2
随身合成台:
type: Grid
attribute:
x: "392"
y: "42"
# 网格容器的行间距和列间距
spaceBetweenY: "24"
spaceBetweenX: "24"
column: 2
action:
create: |-
for(i in range(1,3)){
slot = self['slot0'].copy('slot' + i)
slot.id = 1 + i
}
children:
slot0:
type: "slot"
attribute:
width: "54"
hover: "~255,255,255"
tip: "~§e小型合成台§r"
height: "54"
slotType: "~Backpack"
itemScale: "0.8"
id: 1
#以网格容器创建背包栏
slots:
type: "Grid"
attribute:
x: "345"
y: "222"
spaceBetweenY: "12"
spaceBetweenX: "12"
column: "9"
action:
create: |-
for(i in range(1,26)){
slot = self['slot0'].copy('slot' + i)
slot.id = 9 + i
}
children:
slot0:
type: "slot"
attribute:
width: "42"
height: "42"
tip: "~§c背包{self.id.round()}"
slotType: "~Backpack"
itemScale: "0.8"
id: 9
#以横向堆方式创建背包栏(快捷栏)
hot_slots:
type: "HStack"
attribute:
x: "345"
y: "396"
spaceBetween: "12"
column: "9"
action:
create: |-
for(i in range(1,8)){
slot = self['slot0'].copy('slot' + i)
slot.id = 36 + i
}
children:
slot0:
type: "slot"
attribute:
width: "42"
height: "42"
tip: "~§c快捷栏{self.id.round()}"
slotType: "~Backpack"
itemScale: "0.8"
id: 36