Skip to content
是封面

简单NPC

洛风澜_Sea

洛风澜_Sea

序言

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

功能

支持以下功能:

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

Storage结构

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

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

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

compoundname: 此键名需和name标签一致。
  • string * name:NPC名称。
  • string * zone:NPC生成的区域。
  • compoundconfig: 配置选项。
    • bool * custom_settings:自定义配置( 应该为true )。
    • boollook_player:NPC是否看向玩家。
    • stringdefault_orientation:默认朝向(如果使用look_player此项为必填)。
  • compound * text:悬浮字。
    • compound * pos:坐标。
      • float * x: x坐标。
      • float * y: y坐标。
      • float * z: z坐标。
    • compound * data: 参看文本展示实体的实体数据配置
  • compound * npc:玩家模型配置。
    • compound * pos:坐标。
      • float * x: x坐标。
      • float * y: y坐标。
      • float * z: z坐标。
    • compound * data: 参看玩家模型实体数据配置
  • 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