猫史档案馆


紧急求助!!!

用户:是小芊a是小芊a查看:1 回复:2 评论:1 创建时间:2022-12-07T14:41:11


家人们

最近不是有那个创作节

就是说,谁有

把地变成雪地,碰到雪地会存档点的代码

栓q拉


回复

上一页1 页 / 共 1下一页
名探酱名探酱

直接给链接

点赞0


评论


名探酱名探酱

qwq那好吧

for(let x=0; x<127; x++){
for(let z=0; z<127; z++){
    voxels.setVoxel(x, 8, z, 'snow')
}}
for (const e of world.querySelectorAll('*')) {//遍历所有实体
    if (e.id.startsWith('存档点')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
        e.collides = true //开启碰撞
        e.fixed = true //固定实体不被推移
        e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
            if (other.isPlayer) { //另一个实体是玩家
                if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存
                    other.player.directMessage('到达新的存档点') // 给玩家发消息
                    other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
                }
            }
        }
        )
    }
}
world.onVoxelContact(({ entity, voxel, }) => {
    if (!entity.isPlayer) return;                 // 如果碰到方块的不是玩家,则跳过
    const voxelName1 = voxels.name(voxel);         // 将方块id转换名称
    if (voxelName1 === 'snow') {
        entity.player.position = entity.player.spawnPoint
        entity.poistion.y += 3
    }
})

点赞0


评论