超神的冰凉
如题,现在在开发插件过程中遇到一个问题,请问怎样才能使用server.generateLevel函数生成一个虚空世界(一个方块都没有的那种),感激不尽!
好心人贴一下实例代码呗

Kenneth_z

  1. import cn.nukkit.level.ChunkManager;
  2. import cn.nukkit.level.biome.Biome;
  3. import cn.nukkit.level.format.generic.BaseFullChunk;
  4. import cn.nukkit.level.generator.Generator;
  5. import cn.nukkit.math.NukkitRandom;
  6. import cn.nukkit.math.Vector3;

  7. import java.util.HashMap;
  8. import java.util.Map;

  9. public class VoidGenerator extends Generator {
  10.     private ChunkManager level;
  11.     private NukkitRandom random;
  12.     private Map<String, Object> options;

  13.     public VoidGenerator() {
  14.         this(new HashMap<>());
  15.     }

  16.     public VoidGenerator(Map<String, Object> options) {
  17.         this.options = options;
  18.     }

  19.     public int getId() {
  20.         return 4;
  21.     }

  22.     public void init(ChunkManager chunkManager, NukkitRandom nukkitRandom) {
  23.         this.level = chunkManager;
  24.         this.random = nukkitRandom;
  25.     }

  26.     public void generateChunk(int chunkX, int chunkZ) {
  27.     }

  28.     public void populateChunk(int chunkX, int chunkZ) {
  29.         for (int x = 0; x < 16; x++) {
  30.             for (int z = 0; z < 16; z++) {
  31.                 this.level.getChunk(chunkX, chunkZ).setBiomeId(x, z, Biome.AIR);
  32.             }
  33.         }
  34.     }

  35.     public Map<String, Object> getSettings() {
  36.         return this.options;
  37.     }

  38.     public String getName() {
  39.         return "void";
  40.     }

  41.     public Vector3 getSpawn() {
  42.         return new Vector3(128.0D, 68.0D, 128.0D);
  43.     }

  44.     public ChunkManager getChunkManager() {
  45.         return this.level;
  46.     }
  47. }
复制代码

第一页 上一页 下一页 最后一页