用户:
淘气的超能鸭PMzT查看:0 回复:0 评论:0 创建时间:2021-07-08T19:04:55
快乐跑酷的代码是 //--------------- world.onPlayerJoin(async({entity})=>{entity.enableDamage=true;}); for(leti=0;i<128;++i){ for(letj=0;j<128;++j){ voxels.setVoxel(i,8,j,'pink_cake') } } world.onVoxelContact(({entity,voxel,axis})=>{ if(!entity.isPlayer)return;//如果碰到方块的不是玩家,则跳过 constvoxelName=voxels.name(voxel);//将方块id转换名称 if(voxelName==='pink_cake'&&axis.y===1){ entity.hurt(100)//100 } }) //玩家喵时,等待3秒后复活。 world.onDie(async({entity})=>{ if(!entity.isPlayer)return;//不处理非玩家的喵事件 for(lett=1;t<=3;t++){ entity.player.directMessage(`倒计时${String(3-t)}秒后复活`); awaitsleep(1000); } entity.player.forceRespawn();//让玩家重生 }); (asyncfunction(){ constarea=world.addZone({ selector:'player', bounds:{ //xyz lo:[116,35,5], hi:[33,30,63], }, }) area.onEnter(({entity})=>{ if(entity.player.cd==0){ return } constcd=world.querySelector('#'+entity.player.cd) entity.position.copy(cd.position) }); for(consteofworld.querySelectorAll('*')){//遍历所有实体 if(e.id.startsWith('存档点')){//如果当前实体名左边部分刚好是"存档点",比如存档点-1存档点-2... e.collides=true//开启碰撞 e.fixed=true//固定实体不被推移 e.meshScale=e.meshScale.scale(1)//放大1倍 e.onEntityContact(({other})=>{//每当存档点碰到另一个实体 if(other.isPlayer){//另一个实体是玩家 if(e.position!==other.player.spawnPoint){//检测当前存档点是否玩家重生点,避免反复在同一个存档点做多余的保存 other.player.directMessage('到达新的重生点')//给玩家发消息 other.player.spawnPoint=e.position//喵家重生点坐标设置成存档点的坐标 } } }) } } world.onEntityContact(({entity,other})=>{ if(entity.id=="起点"){ other.player.cd=0 world.say(`${other.player.name}开始跑酷了!`) } if(entity.hasTag("终点")){ other.player.cd=entity.id other.player.canFly=true; other.player.emissive=10000; world.say(`${other.player.name}跑酷成功了!`) } if(entity.hasTag("我")){ other.player.cd=entity.id other.player.emissive=1; world.say(`${other.player.name}通过第一关了!`) } }); })();