舊寫法,跑完8秒
IntStream.range(0, 16).forEach(x -> { IntStream.range(0, 128).forEach(y -> { IntStream.range(0, 16).forEach(z -> { BlockState b = chunk.getBlock(x, y, z).getState(); if(Fo.isOreMa(b.getType())) { yml.set(chunk.getWorld().getName() + "." + b.getX() + "." + b.getY() + "." + b.getZ(), Fo.getByType(b.getType()).name()); } }); }); }); |
ChunkSection[] cs = ((CraftChunk) chunk).getHandle().getSections(); Arrays.asList(cs).stream().filter(chunkSection -> chunkSection != null).filter(chunkSection -> chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.GOLD_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.IRON_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.COAL_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.DIAMOND_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.LAPIS_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.REDSTONE_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.EMERALD_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.NETHER_QUARTZ_ORE).getBlockData())). collect(Collectors.toList()).forEach(chunkSection -> { IntStream.range(0, 16).forEach(x -> { IntStream.range(0, 16).forEach(y -> { IntStream.range(0, 16).forEach(z -> { Material type = CraftMagicNumbers.getMaterial(chunkSection.getType(x,y,z).getBlock()); if(Fo.isOreMa(type)) { int x0 = chunk.getX()*16; int z0 = chunk.getZ()*16; int y0 = chunkSection.getYPosition(); yml.set(chunk.getWorld().getName() + "." + (x0+x) + "." + (y0+y) + "." + (z0+z), Fo.getByType(type).name()); } }); }); }); }); |
ChunkSection[] cs = ((CraftChunk) chunk).getHandle().getSections(); Arrays.asList(cs).parallelStream().filter(chunkSection -> chunkSection != null).filter(chunkSection -> chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.GOLD_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.IRON_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.COAL_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.DIAMOND_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.LAPIS_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.REDSTONE_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.EMERALD_ORE).getBlockData()) || chunkSection.getBlocks().a(CraftMagicNumbers.getBlock(Material.NETHER_QUARTZ_ORE).getBlockData())). collect(Collectors.toList()).parallelStream().forEach(chunkSection -> { IntStream.range(0, 16).forEach(x -> { IntStream.range(0, 16).forEach(y -> { IntStream.range(0, 16).forEach(z -> { Material type = CraftMagicNumbers.getMaterial(chunkSection.getType(x,y,z).getBlock()); if(Fo.isOreMa(type)) { int x0 = chunk.getX()*16; int z0 = chunk.getZ()*16; int y0 = chunkSection.getYPosition(); yml.set(chunk.getWorld().getName() + "." + (x0+x) + "." + (y0+y) + "." + (z0+z), Fo.getByType(type).name()); } }); }); }); }); |
測試處理器i5-2410M