mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-13 19:51:27 +01:00
Annotation for ChunkGenerator
This commit is contained in:
parent
765dfee3f0
commit
8cddf30b9e
@ -10,6 +10,7 @@ import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.network.ConnectionManager;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.world.biomes.Biome;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -51,7 +52,7 @@ public class MainDemo {
|
||||
private static class GeneratorDemo implements ChunkGenerator {
|
||||
|
||||
@Override
|
||||
public void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ) {
|
||||
public void generateChunkData(@NotNull ChunkBatch batch, int chunkX, int chunkZ) {
|
||||
// Set chunk blocks
|
||||
for (byte x = 0; x < Chunk.CHUNK_SIZE_X; x++)
|
||||
for (byte z = 0; z < Chunk.CHUNK_SIZE_Z; z++) {
|
||||
@ -62,7 +63,7 @@ public class MainDemo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillBiomes(Biome[] biomes, int chunkX, int chunkZ) {
|
||||
public void fillBiomes(Biome @NotNull [] biomes, int chunkX, int chunkZ) {
|
||||
Arrays.fill(biomes, MinecraftServer.getBiomeManager().getById(0));
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@ package net.minestom.server.instance;
|
||||
import net.minestom.server.instance.batch.ChunkBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.world.biomes.Biome;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -23,7 +25,7 @@ public interface ChunkGenerator {
|
||||
* @param chunkX the chunk X
|
||||
* @param chunkZ the chunk Z
|
||||
*/
|
||||
void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ);
|
||||
void generateChunkData(@NotNull ChunkBatch batch, int chunkX, int chunkZ);
|
||||
|
||||
/**
|
||||
* Defines all the {@link Biome} in the {@link Chunk}.
|
||||
@ -32,13 +34,14 @@ public interface ChunkGenerator {
|
||||
* @param chunkX the chunk X
|
||||
* @param chunkZ the chunk Z
|
||||
*/
|
||||
void fillBiomes(Biome[] biomes, int chunkX, int chunkZ);
|
||||
void fillBiomes(@NotNull Biome[] biomes, int chunkX, int chunkZ);
|
||||
|
||||
/**
|
||||
* Gets all the {@link ChunkPopulator} of this generator.
|
||||
*
|
||||
* @return a {@link List} of {@link ChunkPopulator}
|
||||
* @return a {@link List} of {@link ChunkPopulator}, can be null or empty
|
||||
*/
|
||||
@Nullable
|
||||
List<ChunkPopulator> getPopulators();
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import net.minestom.server.instance.batch.ChunkBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.utils.Position;
|
||||
import net.minestom.server.world.biomes.Biome;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -42,7 +43,7 @@ public class MainDemo {
|
||||
private static class GeneratorDemo implements ChunkGenerator {
|
||||
|
||||
@Override
|
||||
public void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ) {
|
||||
public void generateChunkData(@NotNull ChunkBatch batch, int chunkX, int chunkZ) {
|
||||
// Set chunk blocks
|
||||
for (byte x = 0; x < Chunk.CHUNK_SIZE_X; x++)
|
||||
for (byte z = 0; z < Chunk.CHUNK_SIZE_Z; z++) {
|
||||
@ -53,7 +54,7 @@ public class MainDemo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillBiomes(Biome[] biomes, int chunkX, int chunkZ) {
|
||||
public void fillBiomes(Biome @NotNull [] biomes, int chunkX, int chunkZ) {
|
||||
Arrays.fill(biomes, Biome.PLAINS);
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import net.minestom.server.instance.ChunkPopulator;
|
||||
import net.minestom.server.instance.batch.ChunkBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.world.biomes.Biome;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -14,7 +15,7 @@ import java.util.List;
|
||||
public class ChunkGeneratorDemo implements ChunkGenerator {
|
||||
|
||||
@Override
|
||||
public void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ) {
|
||||
public void generateChunkData(@NotNull ChunkBatch batch, int chunkX, int chunkZ) {
|
||||
for (byte x = 0; x < Chunk.CHUNK_SIZE_X; x++)
|
||||
for (byte z = 0; z < Chunk.CHUNK_SIZE_Z; z++) {
|
||||
for (byte y = 0; y < 40; y++) {
|
||||
@ -24,7 +25,7 @@ public class ChunkGeneratorDemo implements ChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillBiomes(Biome[] biomes, int chunkX, int chunkZ) {
|
||||
public void fillBiomes(Biome @NotNull [] biomes, int chunkX, int chunkZ) {
|
||||
Arrays.fill(biomes, MinecraftServer.getBiomeManager().getById(0));
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import net.minestom.server.instance.batch.ChunkBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.world.biomes.Biome;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -29,7 +30,7 @@ public class NoiseTestGenerator implements ChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateChunkData(ChunkBatch batch, int chunkX, int chunkZ) {
|
||||
public void generateChunkData(@NotNull ChunkBatch batch, int chunkX, int chunkZ) {
|
||||
for (int x = 0; x < Chunk.CHUNK_SIZE_X; x++) {
|
||||
for (int z = 0; z < Chunk.CHUNK_SIZE_Z; z++) {
|
||||
final int height = getHeight(x + chunkX * 16, z + chunkZ * 16);
|
||||
@ -63,7 +64,7 @@ public class NoiseTestGenerator implements ChunkGenerator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillBiomes(Biome[] biomes, int chunkX, int chunkZ) {
|
||||
public void fillBiomes(Biome @NotNull [] biomes, int chunkX, int chunkZ) {
|
||||
Arrays.fill(biomes, MinecraftServer.getBiomeManager().getById(0));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user