當前位置: 首頁>>代碼示例>>Java>>正文


Java BiomeSource類代碼示例

本文整理匯總了Java中net.minecraft.world.level.biome.BiomeSource的典型用法代碼示例。如果您正苦於以下問題:Java BiomeSource類的具體用法?Java BiomeSource怎麽用?Java BiomeSource使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BiomeSource類屬於net.minecraft.world.level.biome包,在下文中一共展示了BiomeSource類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertRegions

import net.minecraft.world.level.biome.BiomeSource; //導入依賴的package包/類
private void convertRegions(File baseFolder, ArrayList<File> regionFiles, BiomeSource biomeSource, int currentCount, int totalCount, ProgressListener progress) {

        for (File regionFile : regionFiles) {
            convertRegion(baseFolder, regionFile, biomeSource, currentCount, totalCount, progress);

            currentCount++;
            int percent = (int) Math.round(100.0d * (double) currentCount / (double) totalCount);
            progress.progressStagePercentage(percent);
        }

    }
 
開發者ID:CoreNetwork,項目名稱:CoreNetwork-Tools,代碼行數:12,代碼來源:AnvilLevelStorageSource.java

示例2: convertRegion

import net.minecraft.world.level.biome.BiomeSource; //導入依賴的package包/類
private void convertRegion(File baseFolder, File regionFile, BiomeSource biomeSource, int currentCount, int totalCount, ProgressListener progress) {

        try {
            String name = regionFile.getName();

            RegionFile regionSource = new RegionFile(regionFile);
            RegionFile regionDest = new RegionFile(new File(baseFolder, name.substring(0, name.length() - RegionFile.MCREGION_EXTENSION.length()) + RegionFile.ANVIL_EXTENSION));

            for (int x = 0; x < 32; x++) {
                for (int z = 0; z < 32; z++) {
                    if (regionSource.hasChunk(x, z) && !regionDest.hasChunk(x, z)) {
                        DataInputStream regionChunkInputStream = regionSource.getChunkDataInputStream(x, z);
                        if (regionChunkInputStream == null) {
                            System.out.println("Failed to fetch input stream");
                            continue;
                        }
                        CompoundTag chunkData = NbtIo.read(regionChunkInputStream);
                        regionChunkInputStream.close();

                        CompoundTag compound = chunkData.getCompound("Level");
                        {
                            OldLevelChunk oldChunk = OldChunkStorage.load(compound);

                            CompoundTag tag = new CompoundTag();
                            CompoundTag levelData = new CompoundTag();
                            tag.put("Level", levelData);
                            OldChunkStorage.convertToAnvilFormat(oldChunk, levelData, biomeSource);

                            DataOutputStream chunkDataOutputStream = regionDest.getChunkDataOutputStream(x, z);
                            NbtIo.write(tag, chunkDataOutputStream);
                            chunkDataOutputStream.close();
                        }
                    }
                }
                int basePercent = (int) Math.round(100.0d * (double) (currentCount * 1024) / (double) (totalCount * 1024));
                int newPercent = (int) Math.round(100.0d * (double) ((x + 1) * 32 + currentCount * 1024) / (double) (totalCount * 1024));
                if (newPercent > basePercent) {
                    progress.progressStagePercentage(newPercent);
                }
            }

            regionSource.close();
            regionDest.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
開發者ID:CoreNetwork,項目名稱:CoreNetwork-Tools,代碼行數:48,代碼來源:AnvilLevelStorageSource.java


注:本文中的net.minecraft.world.level.biome.BiomeSource類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。