2 Star 1 Fork 1

GermMC / WikiGermEngine

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
custom_entity_state.md 7.43 KB
一键复制 编辑 原始数据 按行查看 历史
GermMC 提交于 2022-01-03 20:32 . first commit

自定义实体生物状态HUD


什么是实体生物状态HUD?

实体生物状态HUD 用来在一系列设置,通过添加额外的HUD,来更加直观的展示实体生物的名字、生命等等的状态


示例配置文件

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: 0
    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: 0
    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"
  cursor_entity:
    enable: exist(%cursorEntity_exist%,true)
    type: 6
    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: 4
    align: "center"
    scale: '2'
    font: "default"
    texts:
      - "%cursorEntity_name%"
    locationX: "w*0.165"
    locationY: "h*0.028"
    locationZ: "1"    

自定义实体生物状态HUD演示教程


第一步,配置实体生物状态HUD的背景图片

首先,制作好合适的背景图片,这里以custom_entity_state.png为例

我们在plugins/GermPlugin/gui文件夹内创建一个yml文件,这里以entity_state.yml为例

entity_state:
  options:
    startX: "0"
    startY: "0"
  background:
    enable: true
    type: 0
    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: 0
    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: 0
    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.ymloptions里添加如下的**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"

现在再进入游戏,实体生物血量条已经开始随着你的十字准星所瞄准的目标的血量的变化而从右向左变化了!!

第三步,配置实体生物名称与模型

我们先在entity_state.ymlopenDos里写上

    openDos:
      #刷新变量%cursorEntity_name%(十字准星目标名称变量)
      - "refreshPlaceholder<->cursorEntity_name"

我们继续在entity_state.yml里创建如下配置

entity_state:
  options:
    startX: "0"
    startY: "0"
    openDos:
      - "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: true
    type: 0
    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: 0
    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"
  cursor_entity:
    enable: true
    type: 6
    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: true
    type: 4
    align: "center"
    scale: '2'
    font: "default"
    texts:
      - "%cursorEntity_name%"
    locationX: "w*0.165"
    locationY: "h*0.028"
    locationZ: "1" 

第四步,配置实体生物状态HUD的自动开关

当我们面前没有实体生物时,这样一个东西挡在左上角可能会显得很突兀,这时候我们可以对它进行配置,使其自动开关

我们先在entity_state.ymlopenDos里写上

    openDos:
      #刷新变量%cursorEntity_exist%(十字准星目标是否存在变量)
      - "refreshPlaceholder<->cursorEntity_exist"

然后,我们对在entity_state.yml里的每个组件的enable属性进行修改,改为如下样式

    enable: exist(%cursorEntity_exist%,true)

此时,再进入游戏,实体生物状态条的自动开关就已经完成了!

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/germmc/wiki-germ-engine.git
git@gitee.com:germmc/wiki-germ-engine.git
germmc
wiki-germ-engine
WikiGermEngine
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891