Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MobLocator

一个用于查询服务器中实体/生物数量和定位实体/生物位置的 LeviLamina 插件。

功能特性

  • 查询实体数量: 统计当前加载区块中所有实体或指定类型实体的数量
  • 定位实体位置: 获取指定类型实体的坐标位置
  • 坐标合并: 自动合并相邻坐标(±5格范围内)的相同实体,显示群落数量
  • GUI面板: 提供友好的图形界面查询

命令

命令 描述
/mobcount 查询实体总数与生物总数
/mobcount <type> 查询指定类型实体数量
/moblocate <type> 定位指定类型实体的位置
/mobmenu 打开GUI查询面板

参数说明

  • <type>: 实体类型标识符,如 minecraft:zombieminecraft:creeperminecraft:item

配置文件

配置文件位于 plugins/MobLocator/config.json

{
    "version": 1,
    "language": "zh_CN",
    "maxDisplayCount": 50,
    "mergeRadius": 5
}
  • maxDisplayCount: 最大显示数量,防止刷屏
  • mergeRadius: 坐标合并半径,范围内相同生物会被合并显示

使用示例

/mobcount                    # 显示实体总数与生物总数
/mobcount minecraft:zombie   # 查询僵尸数量
/moblocate minecraft:creeper # 定位爬行者
/moblocate minecraft:item    # 定位掉落物
/mobmenu                     # 打开GUI面板

输出示例

实体总数:1234
生物总数:890
=== minecraft:zombie 位置 ===
总计: 256 个
-------------------
[主世界] (100.5, 64.0, -200.3) x5
[主世界] (150.2, 32.0, -180.7) x3
[下界] (-50.0, 45.0, 100.5) x2
...

插件 API

其他插件可查询当前 上一 tick 发生 tick 的已加载实体(与命令一致,非全图未加载实体)。

语义约定

接口 是否排除玩家 匹配方式
getTotalEntityCount / getLivingMobCount / getAllCounts / listTypes
countByType / locate 否(按类型精确匹配) getTypeName() 全等,如 minecraft:zombie

locate:同维度、合并半径内的同类型位置会合并;count 为群落数量;maxCount 限制返回的群落条数。

LL3 原生插件(Service)

接口头:src/api/IMobLocatorApi.hsrc/api/Types.h

#include "api/IMobLocatorApi.h"
#include "ll/api/service/ServiceManager.h"

auto api = ll::service::ServiceManager::getInstance().getService<MobLocator::IMobLocatorApi>();
if (api) {
    int n = (*api)->countByType("minecraft:zombie");
    auto locs = (*api)->locate("minecraft:zombie", 5, 50);
}

也可 subscribeService<IMobLocatorApi> 等待晚加载。

LSE 脚本(LegacyRemoteCall)

需安装 LegacyRemoteCall(LSE 依赖)。命名空间:MobLocator

导出名 参数 返回
getTotalEntityCount number
getLivingMobCount number
countByType typeName: string number
getAllCounts object(类型 → 数量)
listTypes string[]
locate typeName, mergeRadius, maxCount {x,y,z,dim,count}[]
mc.listen("onServerStarted", () => {
    if (!ll.hasExported("MobLocator", "countByType")) {
        logger.error("MobLocator API 不可用");
        return;
    }
    const countByType = ll.imports("MobLocator", "countByType");
    const locate = ll.imports("MobLocator", "locate");
    logger.info(countByType("minecraft:zombie"));
    logger.info(JSON.stringify(locate("minecraft:zombie", 5, 50)));
});

脚本侧无默认参数,locate 请显式传入 mergeRadius(如 5)和 maxCount(如 50)。

依赖

  • LeviLamina 26.10.14+(对应 BDS 26.10.4)
  • Minecraft Bedrock Dedicated Server 26.10.4
  • (可选)LegacyRemoteCall — 供 LSE / RemoteCall 调用

安装

  1. 将编译产物的 MobLocator.dll 放入 plugins/MobLocator/ 目录
  2. manifest.json 放入同一目录
  3. 重启服务器

构建

xmake f -c
xmake f --target_type=server
xmake
xmake install

许可证

MIT License

About

LeviLamina 实体查询与定位插件,支持统计生物数量及 GUI 面板

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages