remove BiomeGrid

This commit is contained in:
dfsek
2021-11-27 08:46:59 -07:00
parent ac50f23090
commit 7a3597a722
6 changed files with 4 additions and 155 deletions

View File

@@ -19,13 +19,9 @@ import com.dfsek.terra.addons.chunkgenerator.generation.math.samplers.Sampler3D;
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteInfo;
import com.dfsek.terra.api.Platform;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.block.state.properties.base.Properties;
import com.dfsek.terra.api.block.state.properties.enums.Direction;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.profiler.ProfileFrame;
import com.dfsek.terra.api.util.math.Sampler;
import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.BiomeGrid;
import com.dfsek.terra.api.world.World;
import com.dfsek.terra.api.world.biome.GenerationSettings;
import com.dfsek.terra.api.world.biome.TerraBiome;
@@ -50,25 +46,6 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
c.getStages().forEach(stage -> generationStages.add(stage.newInstance(c)));
}
@SuppressWarnings("try")
static void biomes(@NotNull World world, int chunkX, int chunkZ, @NotNull BiomeGrid biome, Platform platform) {
try(ProfileFrame ignore = platform.getProfiler().profile("biomes")) {
int xOrig = (chunkX << 4);
int zOrig = (chunkZ << 4);
long seed = world.getSeed();
BiomeProvider grid = world.getBiomeProvider();
for(int x = 0; x < 4; x++) {
for(int z = 0; z < 4; z++) {
int cx = xOrig + (x << 2);
int cz = zOrig + (z << 2);
TerraBiome b = grid.getBiome(cx, cz, seed);
biome.setBiome(cx, cz, b.getVanillaBiomes().get(b.getGenerator().getBiomeNoise(), cx, 0, cz, world.getSeed()));
}
}
}
}
@Override
@SuppressWarnings("try")
public ChunkData generateChunkData(@NotNull World world, Random random, int chunkX, int chunkZ, ChunkData chunk) {
@@ -119,11 +96,6 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
}
}
@Override
public void generateBiomes(@NotNull World world, @NotNull Random random, int chunkX, int chunkZ, @NotNull BiomeGrid biome) {
biomes(world, chunkX, chunkZ, biome, platform);
}
@Override
public Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth) {
return new Sampler3D(chunkX, chunkZ, provider, world, elevationSmooth);

View File

@@ -1,58 +0,0 @@
/*
* Copyright (c) 2020-2021 Polyhedral Development
*
* The Terra API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the common/api directory.
*/
package com.dfsek.terra.api.world;
import org.jetbrains.annotations.NotNull;
import com.dfsek.terra.api.Handle;
import com.dfsek.terra.api.world.biome.Biome;
public interface BiomeGrid extends Handle {
/**
* Set biome at x, z within chunk being generated
*
* @param x - 0-15
* @param z - 0-15
* @param bio - Biome value
*/
void setBiome(int x, int z, @NotNull Biome bio);
/**
* Set biome at x, z within chunk being generated
*
* @param x - 0-15
* @param y - 0-255
* @param z - 0-15
* @param bio - Biome value
*/
void setBiome(int x, int y, int z, @NotNull Biome bio);
/**
* Get biome at x, z within chunk being generated
*
* @param x - 0-15
* @param z - 0-15
*
* @return Biome value
*/
@NotNull
Biome getBiome(int x, int z);
/**
* Get biome at x, z within chunk being generated
*
* @param x - 0-15
* @param y - 0-255
* @param z - 0-15
*
* @return Biome value
*/
@NotNull
Biome getBiome(int x, int y, int z);
}

View File

@@ -17,16 +17,12 @@ import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.util.math.Sampler;
import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.BiomeGrid;
import com.dfsek.terra.api.world.World;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
public interface ChunkGenerator {
ChunkData generateChunkData(@NotNull World world, Random random, int x, int z, ChunkData original);
void generateBiomes(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome);
Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth);
ConfigPack getConfigPack();

View File

@@ -17,6 +17,8 @@
package com.dfsek.terra.world;
import com.dfsek.terra.api.world.generator.SamplerCache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@@ -29,7 +31,7 @@ import com.dfsek.terra.api.util.math.Sampler;
import com.dfsek.terra.api.world.World;
public class SamplerCacheImpl implements com.dfsek.terra.api.world.generator.SamplerCache {
public class SamplerCacheImpl implements SamplerCache {
private final LoadingCache<Long, Sampler> cache;
public SamplerCacheImpl(Platform platform, World world) {

View File

@@ -38,7 +38,6 @@ import com.dfsek.terra.api.world.generator.ChunkGenerator;
import com.dfsek.terra.api.world.generator.GeneratorWrapper;
import com.dfsek.terra.bukkit.population.PopulationManager;
import com.dfsek.terra.bukkit.world.BukkitAdapter;
import com.dfsek.terra.bukkit.world.BukkitBiomeGrid;
public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGenerator implements GeneratorWrapper {
@@ -50,15 +49,13 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
private final ChunkGenerator delegate;
private final Platform platform;
private boolean needsLoad = true;
private WorldConfig worldConfig;
public BukkitChunkGeneratorWrapper(ChunkGenerator delegate) {
this.delegate = delegate;
this.platform = delegate.getPlatform();
Platform platform = delegate.getPlatform();
this.popMan = new PopulationManager(delegate, platform);
}
@@ -96,7 +93,6 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
}
com.dfsek.terra.api.world.World bukkitWorld = BukkitAdapter.adapt(world);
if(needsLoad) load(bukkitWorld); // Load population data for world.
delegate.generateBiomes(bukkitWorld, random, x, z, new BukkitBiomeGrid(biome));
return (ChunkData) delegate.generateChunkData(bukkitWorld, random, x, z, new BukkitChunkData(createChunkData(world))).getHandle();
}

View File

@@ -1,59 +0,0 @@
/*
* This file is part of Terra.
*
* Terra is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Terra is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
*/
package com.dfsek.terra.bukkit.world;
import org.bukkit.generator.ChunkGenerator;
import org.jetbrains.annotations.NotNull;
import com.dfsek.terra.api.world.BiomeGrid;
import com.dfsek.terra.api.world.biome.Biome;
@SuppressWarnings("deprecation")
public class BukkitBiomeGrid implements BiomeGrid {
private final ChunkGenerator.BiomeGrid delegate;
public BukkitBiomeGrid(ChunkGenerator.BiomeGrid biomeGrid) {
this.delegate = biomeGrid;
}
@Override
public ChunkGenerator.BiomeGrid getHandle() {
return delegate;
}
@Override
public void setBiome(int x, int z, @NotNull Biome bio) {
delegate.setBiome(x, z, ((BukkitBiome) bio).getHandle());
}
@Override
public void setBiome(int x, int y, int z, @NotNull Biome bio) {
delegate.setBiome(x, y, z, ((BukkitBiome) bio).getHandle());
}
@Override
public @NotNull Biome getBiome(int x, int z) {
return new BukkitBiome(delegate.getBiome(x, z));
}
@Override
public @NotNull Biome getBiome(int x, int y, int z) {
return new BukkitBiome(delegate.getBiome(x, y, z));
}
}