2 Star 1 Fork 1

GermMC / WikiGermEngine

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

自定义玩家背包


第一步,在服务端中新建GermPlugin/gui/player_inventory.yml,并填入对应基础配置

player_inventory: #这里是自定义背包配置文件的名字 不可修改 游戏内默认E键即可打开
  #options标识符表示设置这个GUI的参数(该标识符可全部删除)
  options:
    #设置起始坐标轴,你可以根据你的习惯来设置这个界面的原点。(如果删除此行,默认为MC界面的最上边)
    startX: "w*0"
    #设置起始坐标轴,你可以根据你的习惯来设置这个界面的原点。(如果删除此行,默认为MC界面的最左边)
    startY: "h*0"
    #此界面的优先级 优先级越大 越不会被遮住 (物品模型的默认优先级都很大,要想把物品模型遮住,Z轴就要很大) 不懂不要管 直接删去就可以 默认为 0
    startZ: "10"
    #打开一次后就在客户端删除该界面的缓存(就是打开并关闭后,需要重载才能再打开,给写插件时用的,写配置直接删去)可删除 默认false
    consume: false
    #是否开启坐标指南,开启后将会绘制鼠标的坐标位置(可删除,默认为false)
    guide: false
    #是否取消ESC关闭界面 (可删除默认为 false)
    escCancel: false
    #如果该界面在最顶层 开启下面选项后 按下ESC只会关闭这个界面 (关闭escCancel才有效,可删除默认为false)
    escCloseOnly: false
    #当玩家在此界面按下按键时触发
    keyDos:
      keyDown_22:
        - "message<->按下了 U 键"
      keyUp_22:
        - "message<->松开了 U 键"
    #这里设置窗口拖动的参数 删掉代表无法拖动
    drag:
      #可拖动区域的坐标
      locationX: "0"
      locationY: "0"
      #可拖动区域的宽度
      width: "100"
      #可拖动区域的高度
      height: "100"
    #打开界面时的声音,删除此行默认无声
    openSound: "minecraft:block.anvil.use"
    #打开GUI时执行一些关于GUI的特殊操作 以下称为dos(可删除)
    #dos都是以 标记<->参数 的形式书写 不同的标记拥有不同的功能
    openDos:
      - "openChild<->default3" #打开一个子窗口(default3也是一个gui目录下的yml文件)
    #该动画选项会使得整个背包界面按照预设动画做出移动(可删除)
    animations:
      - "default_move"
  private:
    #背包背景纹理地址 这个默认的是内置的
    background:  
      #图片的本地材质路径地址格式为 local<->本地路径 或者直接输入 本地路径
      #图片的网络材质链接地址格式为 url<->网络链接 例如:url<->https://s1.ax1x.com/2020/06/19/NnqzVK.png
      #背包背景纹理地址 这个默认的是内置的 (不可为空)
      path: 'local<->textures/gui/player_backpack.png'
      #图片位置的起始坐标(图片的左上角为起始点)
      locationX: "w*0.355"
      locationY: "h*0.208"
      #图片宽度width和高度height也同样支持运算符和 w h 变量 w代表整个MC的宽度
      width: "w*0.281"
      height: "h*0.526"
    #玩家模型
    player:
      show: true
      locationX: 'w*0.442'
      locationY: 'h*0.412'
      locationZ: '1'
    #知识之书(背包内绿色书本按钮)
    book:
      #是否开启
      show: false
      #位置
      locationX: '-10'
      locationY: '30'
    #其他设置
    other:
      #是否关闭默认的背景(一个半黑色的透明背景) 默认为false
      disableDefaultBackground: true
      #点击到哪些组件会将鼠标上的物品丢出 (默认为点击没有组件的地方为丢出物品,但是用到全屏GUI时就需要此方法了)
      #填组件名字
      clickPartsDropCursorItem:
        - "background"
        - "drop_item_on_cursor"
    SlotSettings:
      #槽位的ID 格式为 slot_ID 每个槽位的ID请对应下图
      #槽位如果有的位置不想调的话就不写就可以了
      Slot_0:
        #槽位是否开启 默认为开启 可删除
        show: true
        #槽位的大小
        size: '16'
        #槽位的位置
        locationX: 'w*0.101'
        locationY: 'h*0.322'
      Slot_1:
        #槽位是否开启 默认为开启 可删除
        show: true
        #槽位的大小
        size: '16'
        #槽位的位置
        locationX: 'w*0.033'
        locationY: 'h*0.3'
      Slot_2:
        #槽位是否开启 默认为开启 可删除
        show: true
        #槽位的大小
        size: '16'
        #槽位的位置
        locationX: 'w*0.054'
        locationY: 'h*0.3'
      Slot_3:
        #槽位是否开启 默认为开启 可删除
        show: true
        #槽位的大小
        size: '16'
        #槽位的位置
        locationX: 'w*0.033'
        locationY: 'h*0.34'
      Slot_4:
        #槽位是否开启 默认为开启 可删除
        show: true
        #槽位的大小
        size: '16'
        #槽位的位置
        locationX: 'w*0.054'
        locationY: 'h*0.34'
      Slot_5:
        show: false
        size: '16'
        locationX: '22'
        locationY: '7'
      Slot_6:
        show: false
        size: '16'
        locationX: '22'
        locationY: '35'
      Slot_7:
        show: false
        size: '16'
        locationX: '22'
        locationY: '62'
      Slot_8:
        show: false
        size: '16'
        locationX: '119'
        locationY: '62'
      Slot_9:
        show: true
        size: '16'
        locationX: 'w*0.166'
        locationY: 'h*0.016'
      Slot_10:
        show: true
        size: '16'
        locationX: 'w*0.1875'
        locationY: 'h*0.016'
      Slot_11:
        show: true
        size: '16'
        locationX: 'w*0.208'
        locationY: 'h*0.016'
      Slot_12:
        show: true
        size: '16'
        locationX: 'w*0.23'
        locationY: 'h*0.016'
      Slot_13:
        show: true
        size: '16'
        locationX: 'w*0.166'
        locationY: 'h*0.058'
      Slot_14:
        show: true
        size: '16'
        locationX: 'w*0.1875'
        locationY: 'h*0.058'
      Slot_15:
        show: true
        size: '16'
        locationX: 'w*0.208'
        locationY: 'h*0.058'
      Slot_16:
        show: true
        size: '16'
        locationX: 'w*0.23'
        locationY: 'h*0.058'
      Slot_17:
        show: true
        size: '16'
        locationX: 'w*0.166'
        locationY: 'h*0.1'
      Slot_18:
        show: true
        size: '16'
        locationX: 'w*0.1875'
        locationY: 'h*0.1'
      Slot_19:
        show: true
        size: '16'
        locationX: 'w*0.208'
        locationY: 'h*0.1'
      Slot_20:
        show: true
        size: '16'
        locationX: 'w*0.23'
        locationY: 'h*0.1'
      Slot_21:
        show: true
        size: '16'
        locationX: 'w*0.166'
        locationY: 'h*0.142'
      Slot_22:
        show: true
        size: '16'
        locationX: 'w*0.1875'
        locationY: 'h*0.142'
      Slot_23:
        show: true
        size: '16'
        locationX: 'w*0.208'
        locationY: 'h*0.142'
      Slot_24:
        show: true
        size: '16'
        locationX: 'w*0.23'
        locationY: 'h*0.142'
      Slot_25:
        show: true
        size: '16'
        locationX: 'w*0.166'
        locationY: 'h*0.182'
      Slot_26:
        show: true
        size: '16'
        locationX: 'w*0.1875'
        locationY: 'h*0.182'
      Slot_27:
        show: true
        size: '16'
        locationX: 'w*0.208'
        locationY: 'h*0.182'
      Slot_28:
        show: true
        size: '16'
        locationX: 'w*0.23'
        locationY: 'h*0.182'
      Slot_29:
        show: true
        size: '16'
        locationX: 'w*0.166'
        locationY: 'h*0.226'
      Slot_30:
        show: true
        size: '16'
        locationX: 'w*0.1875'
        locationY: 'h*0.226'
      Slot_31:
        show: true
        size: '16'
        locationX: 'w*0.208'
        locationY: 'h*0.226'
      Slot_32:
        show: true
        size: '16'
        locationX: 'w*0.23'
        locationY: 'h*0.226'
      Slot_33:
        show: true
        size: '16'
        locationX: 'w*0.166'
        locationY: 'h*0.266'
      Slot_34:
        show: true
        size: '16'
        locationX: 'w*0.1875'
        locationY: 'h*0.266'
      Slot_35:
        show: true
        size: '16'
        locationX: 'w*0.208'
        locationY: 'h*0.266'
      Slot_36:
        show: false
        size: '16'
        locationX: '33'
        locationY: 'h*0.44'
      Slot_37:
        show: true
        size: '16'
        locationX: 'w*0.055'
        locationY: 'h*0.44'
      Slot_38:
        show: true
        size: '16'
        locationX: 'w*0.077'
        locationY: 'h*0.44'
      Slot_39:
        show: true
        size: '16'
        locationX: 'w*0.098'
        locationY: 'h*0.44'
      Slot_40:
        show: true
        size: '16'
        locationX: 'w*0.1198'
        locationY: 'h*0.44'
      Slot_41:
        show: true
        size: '16'
        locationX: 'w*0.1416'
        locationY: 'h*0.44'
      Slot_42:
        show: true
        size: '16'
        locationX: 'w*0.1635'
        locationY: 'h*0.44'
      Slot_43:
        show: true
        size: '16'
        locationX: 'w*0.1854'
        locationY: 'h*0.44'
      Slot_44:
        show: true
        size: '16'
        locationX: 'w*0.206'
        locationY: 'h*0.44'
      Slot_45:
        show: false
        size: '16'
        locationX: '90'
        locationY: '91'

{c}SlotSettings选项内槽位id对照表


第二步,调节背包内玩家模型大小

根据上面的配置我们很容易发现,在player_inventory.private.player的配置是这样的

    #玩家模型
    player:
      show: true
      locationX: 'w*0.442'
      locationY: 'h*0.412'
      locationZ: '1'

我们会发现原版的玩家模型是没有办法改变大小的,这时我们就需要利用一个实体模型组件来模拟一个自定义度更高的玩家模型。

首先,将原版玩家模型关闭,配置改为show: false

   #玩家模型
   player:
     show: false
     locationX: 'w*0.442'
     locationY: 'h*0.412'
     locationZ: '1'

然后我们在背包内添加一个实体模型组件,配置如下,不需要的配置项自行删去即可

  player_model:
    type: entity
    enable: true
    initDos:
      - "message<->我是背包界面的玩家模型组件"
    tooltip:
      - '&c我是一个玩家模型'
    model: 'self'
    #模型是否看向鼠标 默认为 true
    followCursor: true
    #如果不是看向鼠标的 可以设置模型看向的位置
    lookAtX: "w*0.5"
    lookAtY: "h*0.5"
    #模型的大小
    size: "30"
    #width height这两个是因为每个模型的大小都不同 没办法自适应大小判断悬浮 所以可以重新指定判断悬浮的大小区域 不会对实际渲染造成影响
    width: '10'
    height: '10'
    locationX: 'w*0.442'
    locationY: 'h*0.412'
    locationZ: '1'
    #模型组件整体动画
    animations:
      - "default_rotate"

第三步,自行添加更多你需要的组件吧 😝

1
https://gitee.com/germmc/wiki-germ-engine.git
git@gitee.com:germmc/wiki-germ-engine.git
germmc
wiki-germ-engine
WikiGermEngine
master

搜索帮助