• 欢迎加入MineBBS QQ讨论群:点击查看所有的官方讨论群
  • 我们将于近期对服务器进行迁移,服务可能中断至多2日。请各位安排好自己的访问计划,造成不便敬请谅解!
  • MineBBS入站考试已经上线!想要成为【正式会员】解锁更多功能吗?快来参与吧!【点我去看】
资源图标

LSE 大家都能用的矿物探测器 1.0.0

完成注册/登录后下载
版权类型
原创
版权链接
#
语言支持
中文(简体)
前置组件
liteloader https://www.minebbs.com/liteloader/
适配版本(基岩)
  1. 全版本
基于js的矿物探测器
Y_E}VXJ8X77G@~VRBDE3{(N.png

会自动输出玩家丢出物品至控制台
不需要的把42行删掉就可以了

请将下述代码写入文件并修改为js后缀(附件不让传js我真的没办法)
JavaScript:
//LiteLoaderScript Dev Helper
/// <reference path="c:\Users\Administrator\Desktop/dts/llaids/src/index.d.ts"/>

ll.registerPlugin(
  /* name */ "minedetector",
  /* introduction */ "丢出矿物即可开始检测最近的矿物",
  /* version */[1, 0, 0],
  /* otherInformation */ {}
);


function findNearestBlock(
  pos,
  blockTypes,
) {
  const radius = 8
  const { x, y, z, dimid } = pos;
  let lastDistance = 0;
  let lastBlock;

  for (let lx = x - radius; lx <= x + radius; lx += 1) {
    for (let ly = y - radius; ly <= y + radius; ly += 1) {
      for (let lz = z - radius; lz <= z + radius; lz += 1) {
        const block = mc.getBlock(lx, ly, lz, dimid);
        if (blockTypes.includes(block.type)) {
          const distance = Math.sqrt(
            (x - lx) * (x - lx) + (y - ly) * (y - ly) + (z - lz) * (z - lz)
          );
          if (distance < lastDistance || !lastDistance) {
            lastDistance = distance;
            lastBlock = block;
          }
        }
      }
    }
  }

  return lastBlock;
}

mc.listen("onDropItem", (player, item) => {
  const { x, y, z, dimid } = player.blockPos;

  let blockTypes;
  let label;

  switch (item.type) {
    case "minecraft:emerald":
      blockTypes = ["minecraft:emerald_ore", "minecraft:deepslate_emerald_ore"];
      label = "绿宝石";
      break;
    case "minecraft:diamond":
      blockTypes = ["minecraft:diamond_ore", "minecraft:deepslate_diamond_ore"];
      label = "钻石";
      break;
    case "minecraft:ancient_debris":
      blockTypes = ["minecraft:ancient_debris"];
      label = "下界残骸";
      break;
    case "minecraft:lapis_lazuli":
      blockTypes = ["minecraft:lapis_ore", "minecraft:deepslate_lapis_ore"];
      label = "青金石";
      break;
    case "minecraft:iron_ingot":
      blockTypes = ["minecraft:iron_ore", "minecraft:deepslate_iron_ore"];
      label = "铁矿";
      break;
    default:
      return;
  }

  const found = findNearestBlock(mc.newIntPos(x, y, z, dimid), blockTypes);
  const pos = found?.pos;

  player.setTitle(
    pos
      ? `最近的${label}位于§e§l(${pos.x}, ${pos.y}, ${pos.z})`
      : `附近没有${label}`,
    4, 10, 20, 0
  );

  if (pos) {
    let lizi = mc.newParticleSpawner(8, true, true);
    lizi.drawOrientedLine(
      player.blockPos,
      pos,
      2,
      0.5,
      64,
      "minecraft:balloon_gas_particle"
    );
  }
});


const conYellow = '\u001b[0;33m';
logger.info(`${conYellow}插件加载成功,欢迎使用矿物探测器`);
  • 喜欢
反馈: lgc2333
作者
苏达克
下载
528
查看
1,634
首次发布
最后更新

评分

0.00 星 0 次评分
后退
顶部 底部