自定义实体生物状态HUD
什么是实体 生物状态HUD?
实体生物状态HUD 用来在一系列设置,通过添加额外的HUD,来更加直观的展示实体生物的名字、生命等等的状态
自定义实体生物状态HUD-Dos版演示教程
点击查看完整的示例配置文件
entity_state:
options:
startX: "0"
startY: "0"
openDos:
- "refreshPlaceholder`<->`cursorEntity_exist"
- "refreshPlaceholder`<->`cursorEntity_name"
- "refreshPlaceholder`<->`cursorEntity_health"
- "refreshPlaceholder`<->`cursorEntity_max_health"
- "update`<->`health@width@w*0.172*%cursorEntity_health%/%cursorEntity_max_health%"
- "update`<->`health@endU@108*%cursorEntity_health%/%cursorEntity_max_health%"
- "delay`<->`100"
- "goto`<->`1"
background:
enable: exist(%cursorEntity_exist%,true)
type: texture
path: 'local`<->`textures/gui/custom_entity_state.png'
locationX: "0"
locationY: "0"
locationZ: "0"
width: "w*0.258"
height: "h*0.153"
health:
enable: exist(%cursorEntity_exist%,true)
type: texture
path: 'local`<->`textures/gui/entity_health.png'
locationX: "w*0.080"
locationY: "h*0.083"
locationZ: "1"
width: "w*0.172"
height: "h*0.049"
startU: "0"
startV: "0"
endU: "0"
endV: "16"
cursor_entity:
enable: exist(%cursorEntity_exist%,true)
type: entity
model: 'cursor'
followCursor: false
lookAtX: "w*0.039"
lookAtY: "h*0.092"
size: "28"
locationX: "w*0.04"
locationY: "h*0.126"
locationZ: "1"
cursor_entity_name:
enable: exist(%cursorEntity_exist%,true)
type: label
align: "center"
scale: '2'
font: "default"
texts:
- "%cursorEntity_name%"
locationX: "w*0.165"
locationY: "h*0.028"
locationZ: "1"
第一步,配置实体生物状态HUD的背景图片
首先,制作好合适的背景图片,这里以custom_entity_state.png为例
我们在plugins/GermPlugin/gui文件夹内创建一个yml文件,这里以entity_state.yml为例
entity_state:
options:
startX: "0"
startY: "0"
background:
enable: true
type: texture
path: 'local`<->`textures/gui/custom_entity_state.png'
locationX: "0"
locationY: "0"
locationZ: "0"
width: "w*0.258"
height: "h*0.153"
接下来,我们在Config.yml里进行如下配置,然后再次进入游戏即可
#在玩家加入服务器时,赋予玩家这些HUD
PermanentHud:
- "entity_state"

第二步,配置自右向左切割的实体生物状态HUD
这里我们以实体生物血量条为例,配置一个自右向左切割的状态条,首先准备好图片,这里以entity_health.png为例
我们在entity_state.yml里创建如下配置
entity_state:
options:
startX: "0"
startY: "0"
background:
enable: true
type: texture
path: 'local`<->`textures/gui/custom_entity_state.png'
locationX: "0"
locationY: "0"
locationZ: "0"
width: "w*0.258"
height: "h*0.153"
health:
enable: true
type: texture
path: 'local`<->`textures/gui/entity_health.png'
locationX: "w*0.080"
locationY: "h*0.083"
locationZ: "1"
width: "w*0.172"
height: "h*0.049"
startU: "0"
startV: "0"
endU: "108"
endV: "16"

那我们如何使它从右向左动起来呢,我们在entity_state.yml的options里添加如下的openDos
openDos:
#刷新变量%cursorEntity_health%(十字准星目标血量变量)
- "refreshPlaceholder`<->`cursorEntity_health"
#刷新变量%cursorEntity_health%(十字准星目标最大血量变量)
- "refreshPlaceholder`<->`cursorEntity_max_health"
#更新entity_state.yml内,名为health的组件的width为w*0.172*%player_food_level%/20
#即更新名为health的组件的图片宽度为【满状态图片宽度*当前状态变量/满状态变量】
- "update`<->`health@width@w*0.172*%cursorEntity_health%/%cursorEntity_max_health%"
#更新entity_state.yml内,名为health的组件的endU为84*%player_food_level%/20
#即更新名为health的组件的图片的右侧截取界限为【图片的真实像素宽度*当前状态变量/满状态变量】
- "update`<->`health@endU@108*%cursorEntity_health%/%cursorEntity_max_health%"
#延迟100ms再向下执行
- "delay`<->`100"
#返回openDos的第一行
- "goto`<->`1"
现在再进入游戏,实体生物血量条已经开始随着你的十字准星所瞄准的目标的血量的变化而从右向左变化了!!
