猫史档案馆


【box3】YDS尹子代码分享--看看你地图有些什么方块!

用户:YDS尹子YDS尹子查看:30 回复:13 评论:30 创建时间:2020-07-03T15:56:12


最后会在聊天区呈现方块数量。

(async function(){
    var blocks=[];
    for(let i=0;i<440;i++){
        blocks[i]=0;
    }
    
    for(let i=0;i<=126;i++){
        for(let j=0;j<=126;j++){
            for(let k=0;k<=126;k++){
                if(voxels.getVoxel(i,k,j)!=0){
                    blocks[voxels.getVoxel(i,k,j)]+=1;
                }
                
            }
        }
    }
    for(let i=1;i<blocks.length;i++){
        if(blocks[i]!=0){
            world.say(voxels.name(i)+" 总共喵+blocks[i]+"个")
        }
        
    }
})()


回复

上一页1 页 / 共 1下一页
未命名用户015734未命名用户015734

撒花ing

点赞0


评论


YDS尹子YDS尹子

这段代码不会算上默认给的方块:

(async function(){
    var blocks=[];
    for(let i=0;i<440;i++){
        blocks[i]=0;
    }
    
    for(let i=0;i<=126;i++){
        for(let j=0;j<=126;j++){
            for(let k=0;k<=126;k++){
                if(voxels.getVoxel(i,k,j)!=0){
                    blocks[voxels.getVoxel(i,k,j)]+=1;
                }
                
            }
        }
    }
    blocks[129]-=16129;
    blocks[127]-=16129;
    blocks[125]-=112903;
    for(let i=1;i<blocks.length;i++){
        if(blocks[i]!=0){
            world.say(voxels.name(i)+" 总共喵+blocks[i]+"个")
        }
        
    }
})()

点赞0


评论


JerryLKJJerryLKJ

!!!

点赞0


评论


YDS尹子YDS尹子

改良版

今天发现老的用不了了

(async function(){
    var blocks=[];
    for(let i=0;i<640;i++){
        blocks[i]=0;
    }
    
    for(let i=0;i<=256;i++){
        for(let j=0;j<=256;j++){
            for(let k=0;k<=70;k++){
                if(voxels.getVoxel(i,k,j)!=0){
                    blocks[voxels.getVoxel(i,k,j)]+=1;
                }
                
            }
        }
    }
    for(let i=1;i<blocks.length;i++){
        if(blocks[i]!=0&&blocks[i]!=undefined){
            world.say(voxels.name(i)+" 总共喵+blocks[i]+"个")
        }
        
    }
})()

点赞0


评论


center_image

好家伙,128规格的地图有967个钻石()(尹子代码生成的地图)

点赞0


评论


center_image

顺便说一下,这矿总算正常了()

点赞0


评论


打酱油的企鹅呀打酱油的企鹅呀

cadet_blue 总共有407个 powder_blue 总共有434个 dark_gray 总共有2923个 dark_red 总共有573个 dark_slate_blue 总共有21个 dirt 总共有1458013个 grass 总共有47124个 stone 总共有1087个 green_leaf 总共有269个 sand 总共有5677个 plank_01 总共有2个 plank_02 总共有30个 plank_04 总共有22个 lantern_02 总共有9个 glass 总共有5090个 white 总共有16735个 carpet_09 总共有4个 leaf_01 总共有137个 wood 总共有68个 blue_glass 总共有1362个 red_light 总共有9个 orange_light 总共有17个 yellow_light 总共有1个 green_light 总共有1065个 indigo_light 总共有426个 white_light 总共有288个 red_glass 总共有310个 polar_region 总共有1554个 blue_surface_01 总共有731个 dark_surface 总共有1135个 water 总共有11628个 orange_red 总共有4662个 lime_juice 总共有16个 conveyor 总共有1个 bamboo 总共有490个 lab_lamp_01 总共有150个 lab_lamp_02 总共有10个 lab_lamp_03 总共有95个 lab_material_03 总共有758个 lab_material_10 总共有5179个

点赞0


评论


完全是因为官方在更新方块()

点赞0


评论


JYF_斗罗JYF_斗罗

挖~

点赞0


评论


MXminsdwMXminsdw

center_imagecenter_image

点赞0


评论


IaeaIaea

尹子yyds

 

点赞0


评论


一个STUB用户_6715468一个STUB用户_6715468

岛民优化版:

(async function () {
    var blocks = {};
    var statistics = 0;
    var total = 0;
    await sleep(喵);
    world.say('统计开始');
    for (let x = 0; x <= voxels.shape.x; x++) {
        for (let z = 0; z <= voxels.shape.z; z++) {
            for (let y = 0; y <= voxels.shape.y; y++) {
                if (voxels.getVoxel(x, y, z) != 0) {
                    if (blocks[voxels.name(voxels.getVoxel(x, y, z))]) {
                        blocks[voxels.name(voxels.getVoxel(x, y, z))] += 1;
                    } else {
                        blocks[voxels.name(voxels.getVoxel(x, y, z))] = 1;
                    }
                    total += 1;
                }
                statistics += 1;

            }
        }

    }
    blocks['air'] = statistics - total;
    for (let voxel of Object.keys(blocks).sort((a, b) => blocks[b] - blocks[a])) {
        world.say(`${voxel} 共有 ${blocks[voxel]} 个(占 ${Math.round(blocks[voxel] / statistics * 10000000) / 100000}%)`);
    }
    world.say(`地图分析:\n空气块:${statistics - total}(${Math.round((statistics - total) / statistics * 10000) / 100}%)\n非空气块:${total}(${Math.round(total / statistics * 10000) / 100}%)\n地图容量分析:${total / statistics <= 0.25 ? '空kuang' : total / statistics <= 0.75 ? '正常' : '拥挤'}`);
}());

点赞0


评论


JYF_斗罗JYF_斗罗

emotion_编程猫_加油

点赞0


评论