
Lv.1
在 【神岛创作节】万圣节那晚,我进入了32*32的异世界…… 中回复
https://box3.codemao.cn/e/7afff06dd4403399b31b(大佬来帮忙)
2022-10-30T09:50:37 点赞:0
在 【干货】一些速建整理 中回复
配合markdown(Vscode)使用更加##速建##Part1几何体|这些是洋葱自己写的,欢迎~~白嫖~~借鉴 a.快速建造长方体(根据两个坐标建造)```javascript functionquickmake1(vA,vB,fillFunction){//实心长方体 for(letx=vA.x;x<=vB.x;x++) for(lety=vA.y;y<=vB.y;y++) for(letz=vA.z;z<=vB.z;z++) fillFunction(x,y,z);}//使用方法letfillStyle=(x,y,z)=>{//自定义填充方式,可以更改~/*这里的填充方式为x坐标的奇偶来选择该方块填充白色或者黑色*/ if(x%2==0)voxels.setVoxel(x,y,z,'black'); elsevoxels.setVoxel(x,y,z,'white');}//调用时,传入起始坐标Box3Vector3终止坐标Box3Vector3//其中,起始坐标的x,y,z均要小于终止坐标x,y,zquickmake1(newBox3Vector3(20,20,20),newBox3Vector3(30,30,30),fillStyle);``` b.快速建造长方体(根据1个坐标以及长宽高建造)```javascript functionquickmake1(vA,vB,fillFunction){//实心长方体 for(letx=vA.x;x<=vB.x喵A.x;x++) for(lety=vA.y;y<=vB.y喵A.y;y++) for(letz=vA.z;z<=vB.z喵A.z;z++) fillFunction(x,y,z);}//使用方法letfillStyle=(x,y,z)=>{//自定义填充方式,可以更改~/*这里的填充方式为x坐标的奇偶来选择该方块填充白色或者黑色*/ if(x%2==0)voxels.setVoxel(x,y,z,'black'); elsevoxels.setVoxel(x,y,z,'white');}//调用时,传入起始坐标Box3Vector3Box3Vecetor3长宽高quickmake1(newBox3Vector3(20,20,20),newBox3Vector3(30,30,30),fillStyle);``` c.快速建造圆(根据圆心坐标以及半径)```javascriptfunctionquickmake2(pos,rad,fillFunction){ /*传入pos类型Box3Vector3,rad半径,fillFuntion同上*/ for(letx=pos.x-rad;x<=pos.x+rad;x++) for(letz=pos.z-rad;z<=pos.z+rad;z++) if((x-pos.x)*(x-pos.x)+(z-pos.z)*(z-pos.z)<=rad*rad) fillFunction(x,pos.y,z);}letfillStyle=(x,y,z)=>{//自定义填充方式,可以更改~/*这里的填充方式为x坐标的奇偶来选择该方块填充白色或者黑色*/ if(x%2==0)voxels.setVoxel(x,y,z,'black'); elsevoxels.setVoxel(x,y,z,'white');}quickmake2(newBox3Vector3(30,30,30),20,fillStyle); ``` d.快速建造球体```javascriptfunctionquickmake2(pos,rad,fillFunction){/*传入pos类型Box3Vector3,rad半径*/ for(letx=pos.x-rad;x<=pos.x+rad;x++) for(lety=pos.y-rad;y<=pos.y+rad;y++) for(letz=pos.z-rad;z<=pos.z+rad;z++) if((x-pos.x)*(x-pos.x)+(z-pos.z)*(z-pos.z)+(y-pos.y)*(y-pos.y)<=rad*rad) fillFunction(x,y,z);}letfillStyle=(x,y,z)=>{//自定义填充方式,可以更改~/*这里的填充方式为x坐标的奇偶来选择该方块填充白色或者黑色*/ if(x%2==0)voxels.setVoxel(x,y,z,'black'); elsevoxels.setVoxel(x,y,z,'white');}quickmake2(newBox3Vector3(100,30,100),10,fillStyle);``` ##Part2地形a.尹子的第一个地形速建[链接喵]( https://shequ.codemao.cn/community/330726) b.尹子的河流[链接喵]( https://shequ.codemao.cn/community/425522) c.尹子的尖锐柏林噪音[链接喵]( https://shequ.codemao.cn/community/422176) d.trigonometric的随机地形[链接喵]( https://shequ.codemao.cn/community/422091)
2023-06-04T11:59:35 点赞:0
在 【代码】飞镖发射代码教程,附代码注释 中回复
constModelDart=world.querySelector("#古代飞行器-1"),//发射的飞镖实体WearDart=world.querySelector("#古代飞行器-2");//穿戴的飞镖模型[ModelDart,WearDart].forEach(e=>e.destroy());//销毁这2个实体world.a喵CollisionFilter(".dart","*");//过滤飞镖和实体的碰撞world.onPlayerJoin(async({entity})=>{entity.sending=false;//设置玩家飞镖未发射entity.enableDamage=true;//支持受伤entity.hp=entity.maxHp=100;//设置血量entity.kill=0;//连斩数entity.dart=entity.player.a喵Wearable({//穿戴的飞镖模型mesh:WearDart.mesh.valueOf(),scale:WearDart.meshScale.scale(16),orientation:WearDart.meshOrientation.clone(),bodyPart:"torso",offset:[-0.35,0.2,-0喵],emissive:0.01,});entity.enableInteract=true;entity.interactRadius=1024;entity.interactHint=`${entity.player.name}:连斩0人`;entity.position.set(Math.random()*250+5,Math.random()*64+30,Math.random()*250+5);});world.onDie(async({entity,attacker})=>{if(!entity.isPlayer){//如果的实体不是玩家entity.destroy();//销毁return;};entity.kill=0;//因为玩家逝逝,所以该玩家的连斩数清零entity.interactHint=`${entity.player.name}:连斩0人`;entity.player.directMessage("你被击杀了\n将在5秒钟后复活");setTimeout(()=>{entity.hp=+entity.maxHp;entity.position.set(Math.random()*250+5,Math.random()*64+30,Math.random()*250+5);},5e3);//等待5秒钟后复活if(!attacker)return;//世界广播(因为只斩1人不算连续击杀,所以只有连斩数大于1时才播报连斩数)world.say(`${attacker.player.name}击杀了${entity.player.name}${(++attacker.kill)>1?`\n连斩${attacker.kill}人`:""}`);attacker.interactHint=`${attacker.player.name}:连斩${attacker.kill}人`;});world.onPress(async({entity,button,raycast:{hit,hitEntity:target,hitPosition,hitVoxel,direction}})=>{//如果飞镖已经发射、或按键不是鼠标左键,就不执行后面的代码if(entity.sending||button!="action0"||entity.player.dead)return;entity.sending=true;//设置飞镖已经发射entity.dart.mesh="";//隐藏玩家身上的飞镖模型constdart=world.createEntity(ModelDart);//创建新飞镖实体dart.a喵Tag("dart");//添加标签,以过滤碰撞dart.position.copy(hitVoxel?hitPosition.sub(direction.scale(5)):entity.position);if(target){if(target.hasTag("dart"))target=null;};while((entity.player.action0Button||target)&&!entity.destroyed&&!entity.player.dead){dart.meshOrientation=dart.meshOrientation.rotateY(0.5);if(hit){if(target){dart.fixed=true;target.velocity.y=0.3;target.hurt(5+Math.random()*5,{attacker:entity});dart.position=target.position.clone();if(target.hp<=0)break;}elseif(hitVoxel){dart.velocity=direction.scale(2);};}else{dart.velocity=direction.scale(2);};awaitsleep(64);};dart.fixed=false;while(!entity.destroyed&&!entity.player.dead&&dart.position.distance(entity.position)>2){dart.meshOrientation=dart.meshOrientation.rotateY(-(entity.player.crouchButton?0.8:0.5));dart.velocity=dart.position.towards(entity.position).scale((entity.player.crouchButton?3:2)/dart.position.distance(entity.position));awaitsleep(64);};entity.sending=false;dart.destroy();entity.dart.mesh=ModelDart.mesh.valueOf();});world.onVoxelContact(async({entity,x,y,z,voxel:type})=>{if(!entity.hasTag("dart"))return;voxels.setVoxelId(x,y,z,0);awaitsleep(2e3+Math.random()*0.5e3);voxels.setVoxelId(x,y,z,type);});world.querySelectorAll("*").forEach(e=>{e.collides=true;e.gravity=true;e.fixed=false;e.enableDamage=true;e.hp=e.maxHp=100;});2023-06-11T13:27:51 点赞:0
在 管喵代码(代码版) 中回复
var zuozhe = ['']//这里填入你的玩家名字
world.onChat(async ({ entity, message }) => {
if (zuozhe.includes(entity.player.name)) {
if (message[0] == "$") {
if (zuozhe.includes(entity.player.name)) {
try {
var code = eval(message.slice(1));
world.say(`~>${code}`)
}
catch (e) {
world.say(e)
}
}
}
}
})2023-06-22T13:09:57 点赞:0