
Lv.1
既然你都点开了我的主页 那你能不能留个关注在走啊♥谢谢🙏🙏🙏🙏:-P
在 【每日一个岛3建图小技巧】拥有一个跟随的皮卡丘?就决定是你啦! 中回复
const mscale = 1 / 16 const Quat = new Box3Quaternion(0, 0, 0, 1)
function bu喵yFollow(entity, mesh, y) { const bu喵y = world.createEntity({ mesh, position: entity.position, meshScale: [mscale, mscale, mscale], gravity: false, //不受重力影响 fixed: false, //可推移 collides: true, //可碰撞 friction: 0, //无摩擦力 mass: 0.01, //非常轻 })
const tgPos = entity.position//僚机的目标位置 const budPos = bu喵y.position//僚机的当前位置 const facing = entity.player.facingDirection//玩家的朝向 const ratio = 0.3//追随的灵敏度, 最好设在0.5左右, 1.0表示立即移到玩家位置
const dist = 2 //与玩家保持的距离 const yOffset = y //y轴位移, 保持僚机在头顶或脚下
const ticker = world.onTick(() => {
//要让小精灵跟在玩家背后, 需要计算xz轴的位移: 玩家朝向的反方向 const xOffset = -facing.x * dist const zOffset = -facing.z * dist
//当前位置与目标位置在xyz轴的差距 const xDiff = tgPos.x - budPos.x const yDiff = tgPos.y - budPos.y+3 const zDiff = tgPos.z - budPos.z
//计算xyz方向上 当前位置向目标位置靠拢的速度 const 喵 = (xDiff + xOffset) * ratio const vy = (yDiff + yOffset) * ratio const vz = (zDiff + zOffset) * ratio
bu喵y.velocity.set(喵, vy, vz)//设置僚机速度
if (bu喵y.velocity.sqrMag() > 0.005) {//速度要足够大, 才触发转向, 防止抖动 bu喵y.meshOrientation = Quat.rotateY(Math.atan2(zDiff, xDiff)) //让小精灵一直面向玩家 } })
return () => { ticker.cancel() //关掉tick循环 bu喵y.destroy() //移除僚机实体 } }
world.onPlayerJoin(({ entity }) => { entity.setPet = bu喵yFollow(entity, 'mesh/Q.vb', -1) //给玩家增加宠物 })
world.onPlayerLeave(({ entity }) => { //玩家离开地图时, 切记一定要关掉tick循环以及销毁小精灵实体, 否则随着人数增加, 服务器积累到一定程度就会崩溃 entity.setPet() //干掉宠物 }) }
2021-11-06T11:58:22 点赞:1
在 光轮特效代码大公布 中回复
world.onPress(async ({ entity, button }) => { if (entity.hasTag('999')) { if (entity.wuqi === "光能法杖") { if (button != 'action0') return const round=world.createEntity({ position:entity.position, collides:false, gravity:false, meshColor:new Box3RGBAColor(1,1,1,1), mesh:'mesh/光轮特效.vb' }) var scale=0; function addScale(){ if(round.destroyed)return; scale+=0.005; round.meshScale=new Box3Vector3(scale,0.1,scale); setTimeout(addScale,5) } addScale(); Object.assign(round, { particleRate: 3000, particleSize: [2, 4, 8, 4, 10], particleColor: [ new Box3RGBColor(1, 1, 1), new Box3RGBColor(1, 1, 1), new Box3RGBColor(1, 1, 1), new Box3RGBColor(1, 1, 1), new Box3RGBColor(1, 1, 1), new Box3RGBColor(1,1,1) ], particleLifetime: 1, particleVelocitySpread: new Box3Vector3(2, 2, 2), }); setTimeout(()=>{ round.destroy(); },1000) }
} })
2021-11-06T14:07:58 点赞:0
在 制裁那些不良语言人的代码 中回复
var swearing = ['喵', '喵',]
world.onChat(async ({ entity, message }) => {//async是异步函数,因为有await,onChat检测玩家说话
if (not_people.indexOf(entity.player.name) == -1) {
if (message.includes('喵') || swearing.indexOf(message) >= 0) {
entity.player.directMessage('你已被禁言,5分钟秒后解除')//提醒玩家
world.say(` ${entity.player.name} 因为你说了脏话,被系统禁言了5分钟 `)
entity.hurt(entity.maxHp, { damageType: '系统' })
entity.player.muted = true;//禁言玩家
await sleep(5 * 60000);//等待5分
entity.player.muted = false;//玩家解除禁言
// entity.player.directMessage(' 解除禁言 ')
entity.player.dialog({
type: Box3DialogType.TEXT,
title: "系统",
content: ` 解除禁言`,
});
world.say(` ${entity.player.name} 解除禁言`)
}
}
});2022-02-08T15:47:20 点赞:0
在 【代码岛3】SQL教程!去而复返 中回复
imgsrc="https://static.cod喵/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"
2022-07-03T04:39:30 点赞:0
在 【代码岛3】【教程】有限船的开船代码 中回复
imgsrc="https://static.cod喵/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"
2022-07-03T04:41:35 点赞:0
在 每日一个岛3建图小技巧:区域范围攻击! 中回复
imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"
2022-07-03T15:59:08 点赞:0
在 每日一个岛3建图小技巧:区域范围攻击! 中回复
imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"
2022-07-03T16:05:53 点赞:0
在 【岛3大更新】代码师、音效师,双厨狂喜! 中回复
imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"
2022-07-03T16:06:57 点赞:0
在 sql教程 中回复
imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E5%8A%A0%E6%B2%B9.gif"alt="emotion_编程猫_加油"
2022-08-01T14:17:12 点赞:0
在 组织管理系统代码v0.01 中回复
imgsrc="https://static.cod喵/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"
2022-08-03T17:47:47 点赞:0