当前位置: 首页>>代码示例>>Java>>正文


Java Generator类代码示例

本文整理汇总了Java中cn.nukkit.level.generator.Generator的典型用法代码示例。如果您正苦于以下问题:Java Generator类的具体用法?Java Generator怎么用?Java Generator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Generator类属于cn.nukkit.level.generator包,在下文中一共展示了Generator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: BaseLevelProvider

import cn.nukkit.level.generator.Generator; //导入依赖的package包/类
public BaseLevelProvider(Level level, String path) throws IOException {
    this.level = level;
    this.path = path;
    File file_path = new File(this.path);
    if (!file_path.exists()) {
        file_path.mkdirs();
    }
    CompoundTag levelData = NBTIO.readCompressed(new FileInputStream(new File(this.getPath() + "level.dat")), ByteOrder.BIG_ENDIAN);
    if (levelData.get("Data") instanceof CompoundTag) {
        this.levelData = levelData.getCompound("Data");
    } else {
        throw new LevelException("Invalid level.dat");
    }

    if (!this.levelData.contains("generatorName")) {
        this.levelData.putString("generatorName", Generator.getGenerator("DEFAULT").getSimpleName().toLowerCase());
    }

    if (!this.levelData.contains("generatorOptions")) {
        this.levelData.putString("generatorOptions", "");
    }

}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:24,代码来源:BaseLevelProvider.java

示例2: registerGenerator

import cn.nukkit.level.generator.Generator; //导入依赖的package包/类
public void registerGenerator() {
    new SavannaBiome().initBiome();
    new JungleBiome().initBiome();
    new RoofedForestMBiome().initBiome();
    new RoofedForestBiome().initBiome();
    new MushroomIsland().initBiome();
    new SwamplandBiome().initBiome();
    
    new BeachBiome().initBiome();
    new DesertBiome().initBiome();
    new IcePlainsBiome().initBiome();
    new OceanBiome().initBiome();
    new PlainBiome().initBiome();
    new RiverBiome().initBiome();
    new TaigaBiome().initBiome();
    new ForestBiome().initBiome();
    new BirchForestBiome().initBiome();

    Generator.addGenerator(NormalGenerator.class, "BiomeMaster", Generator.TYPE_INFINITE);
}
 
开发者ID:NycuRO,项目名称:BiomeMaster,代码行数:21,代码来源:BiomeMaster.java

示例3: onEnable

import cn.nukkit.level.generator.Generator; //导入依赖的package包/类
@Override
public void onEnable() {
    try {
        this.name = getDescription().getName();
        getServer().getName();
        new PS(this, "Nukkit");
        if (Settings.Enabled_Components.METRICS) {
            new Metrics(this).start();
            PS.log(C.PREFIX + "&6Metrics enabled.");
        } else {
            PS.log(C.CONSOLE_PLEASE_ENABLE_METRICS.f(getPluginName()));
        }
        Generator.addGenerator(NukkitHybridGen.class, getPluginName(), 1);
        if (Settings.Enabled_Components.WORLDS) {
            TaskManager.IMP.taskRepeat(new Runnable() {
                @Override
                public void run() {
                    unload();
                }
            }, 20);
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:26,代码来源:NukkitMain.java

示例4: getGenerator

import cn.nukkit.level.generator.Generator; //导入依赖的package包/类
@Override
public GeneratorWrapper<?> getGenerator(String world, String name) {
    if (name == null) {
        return null;
    }
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("world", world);
    try {
        Class<? extends Generator> gen = Generator.getGenerator(name);
        if (gen != null) {
            Generator instance = gen.getConstructor(Map.class).newInstance(map);
            if (instance instanceof GeneratorWrapper) {
                return (GeneratorWrapper<?>) instance;
            }
            map.put("generator", instance);
            return new NukkitPlotGenerator(map);
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
    return new NukkitHybridGen(map);
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:23,代码来源:NukkitMain.java

示例5: handle

import cn.nukkit.level.generator.Generator; //导入依赖的package包/类
private void handle(Level level) {
    String name = level.getName();
    try {
        Generator gen = (Generator) instance.get(level);
        if (gen instanceof GeneratorWrapper) {
            PS.get().loadWorld(name, (GeneratorWrapper<?>) gen);
        } else {
            HashMap<String, Object> settings = new HashMap<>();
            settings.put("world", level.getName());
            settings.put("generator", gen);
            PS.get().loadWorld(name, new NukkitPlotGenerator(settings));
            for (PlotArea area : PS.get().getPlotAreas(name)) {
                area.MAX_BUILD_HEIGHT = Math.min(127, area.MAX_BUILD_HEIGHT);
            }
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:20,代码来源:WorldEvents.java

示例6: onRun

import cn.nukkit.level.generator.Generator; //导入依赖的package包/类
@Override
public void onRun() {
    Block.init();
    Biome.init();
    SimpleChunkManager manager = new SimpleChunkManager(this.seed);
    try {
        Generator generator = this.generator.getConstructor(Map.class).newInstance(this.settings);
        generator.init(manager, new NukkitRandom(manager.getSeed()));
        GeneratorPool.put(this.levelId, generator);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:14,代码来源:GeneratorRegisterTask.java

示例7: onRun

import cn.nukkit.level.generator.Generator; //导入依赖的package包/类
@Override
public void onRun() {
    Generator generator = GeneratorPool.get(this.levelId);

    if (generator == null) {
        this.state = false;
        return;
    }

    SimpleChunkManager manager = (SimpleChunkManager) generator.getChunkManager();

    if (manager == null) {
        this.state = false;
        return;
    }

    synchronized (manager) {
        BaseFullChunk chunk = this.chunk.clone();

        if (chunk == null) {
            return;
        }

        manager.setChunk(chunk.getX(), chunk.getZ(), chunk);

        generator.generateChunk(chunk.getX(), chunk.getZ());

        chunk = manager.getChunk(chunk.getX(), chunk.getZ());
        chunk.setGenerated();
        this.chunk = chunk.clone();

        manager.setChunk(chunk.getX(), chunk.getZ(), null);
    }

}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:36,代码来源:GenerationTask.java

示例8: generate

import cn.nukkit.level.generator.Generator; //导入依赖的package包/类
public static void generate(String path, String name, long seed, Class<? extends Generator> generator, Map<String, String> options) throws IOException {
    if (!new File(path + "/region").exists()) {
        new File(path + "/region").mkdirs();
    }

    CompoundTag levelData = new CompoundTag("Data")
            .putCompound("GameRules", new CompoundTag())

            .putLong("DayTime", 0)
            .putInt("GameType", 0)
            .putString("generatorName", Generator.getGeneratorName(generator))
            .putString("generatorOptions", options.containsKey("preset") ? options.get("preset") : "")
            .putInt("generatorVersion", 1)
            .putBoolean("hardcore", false)
            .putBoolean("initialized", true)
            .putLong("LastPlayed", System.currentTimeMillis() / 1000)
            .putString("LevelName", name)
            .putBoolean("raining", false)
            .putInt("rainTime", 0)
            .putLong("RandomSeed", seed)
            .putInt("SpawnX", 128)
            .putInt("SpawnY", 70)
            .putInt("SpawnZ", 128)
            .putBoolean("thundering", false)
            .putInt("thunderTime", 0)
            .putInt("version", 19133)
            .putLong("Time", 0)
            .putLong("SizeOnDisk", 0);

    NBTIO.writeGZIPCompressed(new CompoundTag().putCompound("Data", levelData), new FileOutputStream(path + "level.dat"), ByteOrder.BIG_ENDIAN);
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:32,代码来源:McRegion.java

示例9: onLoad

import cn.nukkit.level.generator.Generator; //导入依赖的package包/类
@Override
public void onLoad() {
    if (!(object instanceof ASkyBlock)) {
        object = this;
    }
    // Init this config
    initConfig();
    // Register generator
    Generator.addGenerator(SkyBlockGenerator.class, "island", SkyBlockGenerator.TYPE_SKYBLOCK);
    // Register TaskManager
    TaskManager.IMP = new TaskManager();
}
 
开发者ID:TheSolidCrafter,项目名称:ASkyBlock-Nukkit,代码行数:13,代码来源:ASkyBlock.java


注:本文中的cn.nukkit.level.generator.Generator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。