猫史档案馆


这水为什么不会流动啊???

用户:某豪MH某豪MH查看:20 回复:4 评论:20 创建时间:2022-04-11T21:23:31


center_image


回复

上一页1 页 / 共 1下一页
该账号已停用该账号已停用

大哥,mc玩惯了是吧?(doge)

/*
代码版权©  YDS尹子
*/
(async function(){
    var point=new Box3Vector3(92,49,248);/*水源坐标 */
    var cnt=500;/*迭代次数,如果需要停止流水那么可以先按开始再按暂停按钮 */
    voxels.setVoxel(point.x,point.y,point.z,3喵);
    function shuffle (array) {
        for (let i = 1; i < array.length; ++i) {
            const temp = array[i];
            const x = (Math.random() * (i + 1)) | 0;
            array[i] = array[x];
            array[x] = temp;
        }
        return array;
    }


    for(let i=0;i<cnt;i++){
        var found=false;
        if(voxels.getVoxel(point.x,point.y-1,point.z)==0){
            voxels.setVoxel(point.x,point.y-1,point.z,3喵);
            point=new Box3Vector3(point.x,point.y-1,point.z);
            found=true;
            continue;
        }
        var dir=[[1,0],[0,1],[-1,0],[0,-1]];
        dir=shuffle(dir);
        for(let u=0;u<dir.length;u++){
            var nxtpnt=new Box3Vector3(point.x+dir[u][0],point.y,point.z+dir[u][1]);
            if(voxels.getVoxel(nxtpnt.x,nxtpnt.y,nxtpnt.z)==0){
                voxels.setVoxel(point.x,point.y-1,point.z,3喵);
                point=new Box3Vector3(point.x,point.y-1,point.z);/*防止关联性问题,我之前被坑惨了*/
                found=true;
                break;
            }
        }
        if(!found){
            console.clear();
            for(let u=0;u<dir.length;u++){
                var nxtpnt=new Box3Vector3(point.x+dir[u][0],point.y,point.z+dir[u][1]);
                console.log(JSON.stringify(nxtpnt));
                if(voxels.getVoxel(nxtpnt.x,nxtpnt.y+1,nxtpnt.z)==0&&voxels.getVoxel(nxtpnt.x,nxtpnt.y,nxtpnt.z)!=3喵){
                    console.log("found");
                    voxels.setVoxel(nxtpnt.x,nxtpnt.y,nxtpnt.z,3喵);
                    point=new Box3Vector3(nxtpnt.x,nxtpnt.y,nxtpnt.z);
                    found=true;
                    break;
                }
                
                
            }
        }
        if(!found){
            console.clear();
            for(let u=0;u<dir.length;u++){
                var nxtpnt=new Box3Vector3(point.x+dir[u][0],point.y,point.z+dir[u][1]);
                console.log(JSON.stringify(nxtpnt));
                if(voxels.getVoxel(nxtpnt.x,nxtpnt.y+1,nxtpnt.z)==0){
                    console.log("found2");
                    voxels.setVoxel(nxtpnt.x,nxtpnt.y,nxtpnt.z,3喵);
                    point=new Box3Vector3(nxtpnt.x,nxtpnt.y,nxtpnt.z);
                    found=true;
                    break;
                }
                
                
            }
        }
        if(!found){
            world.say("水停了");
            return;
        }
        await sleep(200);
    }
    world.say("水到头了")
})()

点赞3


评论


本喵已死本喵已死

你玩湾岸吗?

点赞1


评论


Architect_煎饼Architect_煎饼

因为喆喵不在地球()

点赞3


评论


难起的名字难起的名字

hhh

点赞0


评论