mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-01 23:47:50 +00:00
implement MinestomBiomeGrid
This commit is contained in:
parent
468bee27ab
commit
952c3cf086
@ -28,6 +28,8 @@ public final class MinestomEntry {
|
||||
|
||||
container.setChunkGenerator(new MinestomChunkGeneratorWrapper(chunkGenerator3D, container));
|
||||
|
||||
MinecraftServer.getBiomeManager().unmodifiableCollection().forEach(biome -> System.out.println(biome.getId() + ": " + biome.toNbt()));
|
||||
|
||||
GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
|
||||
globalEventHandler.addEventCallback(PlayerLoginEvent.class, event -> {
|
||||
Player player = event.getPlayer();
|
||||
|
@ -3,6 +3,7 @@ package com.dfsek.terra.minestom.generator;
|
||||
import com.dfsek.terra.api.platform.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
import com.dfsek.terra.minestom.world.MinestomBiomeGrid;
|
||||
import com.dfsek.terra.minestom.world.MinestomBlockPopulatorWrapper;
|
||||
import com.dfsek.terra.minestom.world.MinestomChunkData;
|
||||
import com.dfsek.terra.minestom.world.MinestomWorld;
|
||||
@ -16,7 +17,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MinestomChunkGeneratorWrapper implements GeneratorWrapper, ChunkGenerator {
|
||||
@ -42,7 +42,7 @@ public class MinestomChunkGeneratorWrapper implements GeneratorWrapper, ChunkGen
|
||||
|
||||
@Override
|
||||
public void fillBiomes(@NotNull Biome[] biomes, int chunkX, int chunkZ) {
|
||||
Arrays.fill(biomes, Biome.PLAINS);
|
||||
chunkGenerator3D.generateBiomes(new MinestomWorld(instance), new FastRandom(), chunkX, chunkZ, new MinestomBiomeGrid(biomes, chunkX, chunkZ));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,7 @@ public class MinestomBiome implements Biome {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getHandle() {
|
||||
public net.minestom.server.world.biomes.Biome getHandle() {
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.dfsek.terra.minestom.world;
|
||||
|
||||
import com.dfsek.terra.api.platform.world.Biome;
|
||||
import com.dfsek.terra.api.platform.world.BiomeGrid;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MinestomBiomeGrid implements BiomeGrid {
|
||||
private final net.minestom.server.world.biomes.Biome[] biomes;
|
||||
private final int chunkX;
|
||||
private final int chunkZ;
|
||||
|
||||
public MinestomBiomeGrid(net.minestom.server.world.biomes.Biome[] biomes, int chunkX, int chunkZ) {
|
||||
this.biomes = biomes;
|
||||
this.chunkX = chunkX;
|
||||
this.chunkZ = chunkZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getHandle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Biome getBiome(int x, int z) {
|
||||
return getBiome(x, 0, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Biome getBiome(int x, int y, int z) {
|
||||
x -= (chunkX << 4);
|
||||
z -= (chunkZ << 4);
|
||||
x >>= 2;
|
||||
y >>= 2;
|
||||
z >>= 2;
|
||||
return new MinestomBiome(biomes[(x << 8) + (y << 2) + z]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, @NotNull Biome bio) {
|
||||
for(int y = 0; y < 64; y++) setBiome(x, y << 2, z, bio);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int y, int z, @NotNull Biome bio) {
|
||||
x -= (chunkX << 4);
|
||||
z -= (chunkZ << 4);
|
||||
x >>= 2;
|
||||
y >>= 2;
|
||||
z >>= 2;
|
||||
biomes[(x << 8) + (y << 2) + z] = ((MinestomBiome) bio).getHandle();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user