猫史档案馆


跑酷必备代码-guxia666出品(几乎全面)

用户:guxia666guxia666查看:2 回复:8 评论:2 创建时间:2022-02-26T17:26:59


 

//大佬勿喷(萌新专用)
//1(存档)
world.addCollisionFilter('player','player');
for (const e of world.querySelectorAll('*')) {//遍历所有实体
    if (e.id.startsWith('存档点')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
            e.collides = true //开启碰撞
                    e.fixed = true //固定实体不被推移
                            e.meshScale = e.meshScale.scale(2) //放大2倍
                                    e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
                                                if (other.isPlayer) { //另一个实体是玩家
                                                                if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存
                                                                                    other.player.directMessage('到达新的重生点') // 给玩家发消息
                                                                                                        other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
                                                                                                                        }
                                                                                                                                    }
                                                                                                                                            })
                                                                                                                                                }
                                                                                                                                                }
//(其实吉吉喵发过了)
//2(存档)
world.onVoxelContact(({voxel ,entity})=> {//设置碰撞事件
    const block = voxels.id('S');//设置碰撞对象ID为'S'(即spawnpoint), 触发(方块ID可改),给碰撞对象起名为block(方块)
         if (voxel === block) {//假如碰撞了
                  entity.player.directMessage('存档成功');//私信玩家'存档成功'
                           entity.player.spawnPoint = new Box3Vector3 (entity.position.x,entity.position.y,entity.position.z)//玩家重生点为x4z2y111
         
         }
//3(关闭碰撞)
world.addCollisionFilter("player","player")
//4(碰到指定液体方块就返回出生点)
world.onFluidEnter(({entity, voxel}) => {
    if (entity.isPlayer){
        if (voxel === voxels.id('water')) {
            entity.player.forceRespawn(); //返回重生点
        }
    }  
});
//5(碰到所有液体方块就返回出生点)
world.onPlayerJoin(({ entity }) => {
    entity.onFluidEnter(() => {//当玩家掉到水里
        entity.position.copy(entity.player.spawnPoint)
        entity.position.y += 4
    })
})
//6(碰到指定方块掉血)
world.onVoxelContact(async({ voxel, entity }) => {
    if(voxel == voxels.id('lava01')){
        entity.enableDamage = true     //允许伤害
        entity.hurt(30)
 
    }
    if(voxel == voxels.id('lava02')){
        entity.enableDamage = true     //允许伤害
        entity.hurt(30)
    }
})


回复

上一页1 页 / 共 1下一页
guxia666guxia666

给我顶

点赞1


评论


一个STUB用户_14302596一个STUB用户_14302596

建议你看看我的教程https://shequ.cod喵/community/427759

点赞1


评论


guxia666guxia666

挖我自己的坟emotion_doge

点赞3


评论


白奕e白奕e

az,ddd(挖

点赞0


评论


DDguanDDguan

都学会我的头像风格了:)

点赞0


评论


灵清帝王吃爆一切厕所灵清帝王吃爆一切厕所

挖坟

点赞1


评论


悠悠仙姚悠悠仙姚

center_image

点赞0


评论


盗码师盗码师

师傅我换号了(悲

点赞0


评论