本文整理汇总了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", "");
}
}
示例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);
}
示例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();
}
}
示例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);
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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();
}