Skip to content
是封面

简单NPC

洛风澜_Sea

洛风澜_Sea

序言 ​

此数据包使原版配置NPC更加简单,只需要写storage并执行生成函数即可配置一个属于你的NPC

功能 ​

支持以下功能:

  • 自定义NPC上方的悬浮字。
  • 自定义NPC皮肤。
  • 右键NPC运行指令或函数。

Storage结构 ​

默认结构(不开启自定义配置) ​

compoundname: 此键名需和name标签一致。
  • stringname * :NPC名称。
  • stringzone * :NPC生成的区域。
  • compoundconfig: 配置选项。
    • boolcustom_settings * :自定义配置。
    • boollook_player:NPC是否看向玩家。
    • stringdefault_orientation:默认朝向( 如果使用look_player此项为必填)。
  • compoundtext * :悬浮字。
    • compoundpos * :坐标。
      • floatx * : x坐标。
      • floaty * : y坐标。
      • floatz * : z坐标。
    • listtext * : 内含文本组件。
  • compoundnpc * :玩家模型配置。
    • compoundpos * :坐标。
      • floatx * : x坐标。
      • floaty * : y坐标。
      • floatz * : z坐标。
    • stringmodel * : 玩家模型类型。
    • stringtexture * : 玩家皮肤<命名空间>:textures/<路径>.png或皮肤链接。
  • compoundright_click:右键NPC执行。
    • stringcommand:右键执行的指令( 与function任选其一配置)。
    • stringfunction:右键执行的函数( 与command任选其一配置)。

自定义配置结构(开启自定义配置) ​

compoundname: 此键名需和name标签一致。
  • stringname * :NPC名称。
  • stringzone * :NPC生成的区域。
  • compoundconfig: 配置选项。
    • boolcustom_settings * :自定义配置( 应该为true )。
    • boollook_player:NPC是否看向玩家。
    • stringdefault_orientation:默认朝向(如果使用look_player此项为必填)。
  • compoundtext * :悬浮字。
    • compoundpos * :坐标。
      • floatx * : x坐标。
      • floaty * : y坐标。
      • floatz * : z坐标。
    • compounddata * : 参看文本展示实体的实体数据配置
  • compoundnpc * :玩家模型配置。
    • compoundpos * :坐标。
      • floatx * : x坐标。
      • floaty * : y坐标。
      • floatz * : z坐标。
    • compounddata * : 参看玩家模型实体数据配置
  • compoundright_click:右键NPC执行。
    • stringcommand:右键执行的指令(与function任选其一配置)。
    • stringfunction:右键执行的函数(与command任选其一配置)。

示例storage ​

默认配置

mcfunction
data modify storage windwaves_sea:npc root.npc_setting merge value {\
    test:{\
        name:"test",\
        zone:"test",\
        config:{\
            custom_settings:false,\
            look_player:true\
        },\
        text:{\
            pos:{x:1,y:1,z:1},\
            text:[{text:"1"}]\
        },\
        npc:{\
            pos:{x:1,y:1,z:1},\
            model:"wide",\
            texture:"lobby:npc/start_game",\
            rotation:[180,0]\
        },\
        right_click:{\
            command:"",\(function:""\)
        }\
    }\
}

自定义配置

mcfunction
data modify storage windwaves_sea:npc root.npc_setting merge value {\
    test_custom:{\
        name:"test_custom",\
        zone:"test",\
        config:{\
            custom_settings:true,\
            look_player:true,\
            default_orientation:"north" \
        },\
        text:{\
            pos:{x:1,y:1,z:1},\
            data:{}\
        },\
        npc:{\
            pos:{x:1,y:1,z:1},\
            data:{}\
        },\
        right_click:{\
            function:""\(command:""\)
        }\
    }\
}

指令解析 ​

生成NPC ​

mcfunction
function npc:summon {name:"name"}

生成NPC,需先写入配置,不可重复生成,name为上方配置中的NPC名称(下文相同)。

清除NPC ​

mcfunction
function npc:remove/npc {name:"name"}

删除配置( 同时清除NPC ) ​

mcfunction
function npc:remove/setting {name:"name"}

下载 ​

QQ群:117464315

Github:https://github.com/WindWavesSea/Simple-NPC/

Modrinth: https://modrinth.com/datapack/simple-npc/

鸣谢 ​

感谢NOX OBSCURA提供的交互实体大小, 使其可以贴合NPC碰撞箱

感谢轩宇1725提供的storage检测思路,使字符串可以检测

Powered by Vitepress and Github Pages