mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 23:06:05 +00:00
remove unused random parameter from populators
This commit is contained in:
@@ -30,9 +30,7 @@ public interface ChunkGenerator extends Handle {
|
||||
@Nullable
|
||||
TerraChunkGenerator getTerraGenerator();
|
||||
|
||||
interface ChunkData {
|
||||
Object getHandle();
|
||||
|
||||
interface ChunkData extends Handle {
|
||||
/**
|
||||
* Get the maximum height for the chunk.
|
||||
* <p>
|
||||
|
||||
@@ -3,8 +3,6 @@ package com.dfsek.terra.api.world.generation;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public interface TerraBlockPopulator {
|
||||
void populate(World world, Random random, Chunk chunk);
|
||||
void populate(World world, Chunk chunk);
|
||||
}
|
||||
|
||||
@@ -34,14 +34,14 @@ public class PopulationManager implements TerraBlockPopulator {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
try(ProfileFuture ignored = measure()) {
|
||||
needsPop.add(new ChunkCoordinate(chunk));
|
||||
int x = chunk.getX();
|
||||
int z = chunk.getZ();
|
||||
if(main.isEnabled()) {
|
||||
for(int xi = - 1; xi <= 1; xi++) {
|
||||
for(int zi = - 1; zi <= 1; zi++) {
|
||||
for(int xi = -1; xi <= 1; xi++) {
|
||||
for(int zi = -1; zi <= 1; zi++) {
|
||||
if(xi == 0 && zi == 0) continue;
|
||||
if(world.isChunkGenerated(xi + x, zi + z)) checkNeighbors(xi + x, zi + z, world);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class PopulationManager implements TerraBlockPopulator {
|
||||
random.setSeed((long) x * xRand + (long) z * zRand ^ w.getSeed());
|
||||
Chunk currentChunk = w.getChunkAt(x, z);
|
||||
for(TerraBlockPopulator r : attachedPopulators) {
|
||||
r.populate(w, random, currentChunk);
|
||||
r.populate(w, currentChunk);
|
||||
}
|
||||
needsPop.remove(c);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class CavePopulator implements TerraBlockPopulator {
|
||||
|
||||
@SuppressWarnings("try")
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random r, @NotNull Chunk chunk) {
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
TerraWorld tw = main.getWorld(world);
|
||||
WorldHandle handle = main.getWorldHandle();
|
||||
BlockData AIR = handle.createBlockData("minecraft:air");
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
import com.dfsek.terra.population.items.flora.FloraLayer;
|
||||
import com.dfsek.terra.util.PopulationUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -30,7 +31,7 @@ public class FloraPopulator implements TerraBlockPopulator {
|
||||
|
||||
@SuppressWarnings("try")
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
TerraWorld tw = main.getWorld(world);
|
||||
try(ProfileFuture ignored = tw.getProfiler().measure("FloraTime")) {
|
||||
if(!tw.isSafe()) return;
|
||||
@@ -43,6 +44,9 @@ public class FloraPopulator implements TerraBlockPopulator {
|
||||
layers.put(l, biome.getConfig().getFlora());
|
||||
}
|
||||
}
|
||||
|
||||
Random random = PopulationUtil.getRandom(chunk);
|
||||
|
||||
int iter = 0;
|
||||
boolean finished = false;
|
||||
while(!finished) {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class OrePopulator implements TerraBlockPopulator {
|
||||
|
||||
@SuppressWarnings("try")
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random r, @NotNull Chunk chunk) {
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
TerraWorld tw = main.getWorld(world);
|
||||
try(ProfileFuture ignored = tw.getProfiler().measure("OreTime")) {
|
||||
if(!tw.isSafe()) return;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class StructurePopulator implements TerraBlockPopulator {
|
||||
|
||||
@SuppressWarnings("try")
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random r, @NotNull Chunk chunk) {
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
TerraWorld tw = main.getWorld(world);
|
||||
try(ProfileFuture ignored = tw.getProfiler().measure("StructureTime")) {
|
||||
int cx = (chunk.getX() << 4);
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.biome.grid.master.TerraBiomeGrid;
|
||||
import com.dfsek.terra.population.items.tree.TreeLayer;
|
||||
import com.dfsek.terra.util.PopulationUtil;
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -30,11 +31,12 @@ public class TreePopulator implements TerraBlockPopulator {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
TerraWorld tw = main.getWorld(world);
|
||||
try(ProfileFuture ignored = tw.getProfiler().measure("TreeTime")) {
|
||||
if(!tw.isSafe()) return;
|
||||
TerraBiomeGrid grid = tw.getGrid();
|
||||
Random random = PopulationUtil.getRandom(chunk);
|
||||
for(int x = 0; x < 16; x += 2) {
|
||||
for(int z = 0; z < 16; z += 2) {
|
||||
UserDefinedBiome biome = (UserDefinedBiome) grid.getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z, GenerationPhase.POPULATE);
|
||||
|
||||
@@ -18,6 +18,6 @@ public class BukkitPopulatorWrapper extends BlockPopulator {
|
||||
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk source) {
|
||||
delegate.populate(BukkitAdapter.adapt(world), random, BukkitAdapter.adapt(source));
|
||||
delegate.populate(BukkitAdapter.adapt(world), BukkitAdapter.adapt(source));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ public class PopulatorFeature extends Feature<DefaultFeatureConfig> {
|
||||
FabricChunkGeneratorWrapper gen = (FabricChunkGeneratorWrapper) chunkGenerator;
|
||||
FabricChunkWorldAccess chunk = new FabricChunkWorldAccess(world, pos.getX() >> 4, pos.getZ() >> 4);
|
||||
FabricWorld world1 = new FabricWorld(world.toServerWorld(), new FabricChunkGenerator(chunkGenerator));
|
||||
gen.getCavePopulator().populate(world1, random, chunk);
|
||||
gen.getStructurePopulator().populate(new FabricSeededWorldAccess(world, world.getSeed(), chunkGenerator), random, chunk);
|
||||
gen.getOrePopulator().populate(world1, random, chunk);
|
||||
gen.getTreePopulator().populate(world1, random, chunk);
|
||||
gen.getFloraPopulator().populate(world1, random, chunk);
|
||||
gen.getCavePopulator().populate(world1, chunk);
|
||||
gen.getStructurePopulator().populate(new FabricSeededWorldAccess(world, world.getSeed(), chunkGenerator), chunk);
|
||||
gen.getOrePopulator().populate(world1, chunk);
|
||||
gen.getTreePopulator().populate(world1, chunk);
|
||||
gen.getFloraPopulator().populate(world1, chunk);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.dfsek.terra.region;
|
||||
|
||||
import com.dfsek.terra.StandalonePlugin;
|
||||
import com.dfsek.terra.api.math.MathUtil;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.generation.MasterChunkGenerator;
|
||||
import com.dfsek.terra.generation.math.SamplerCache;
|
||||
import com.dfsek.terra.platform.DirectChunkData;
|
||||
@@ -57,11 +55,11 @@ public class Generator {
|
||||
DirectChunkData chunkData = (DirectChunkData) world.getChunkAt(cx, cz);
|
||||
generator.generateChunkData(world, null, cx, cz, chunkData);
|
||||
|
||||
cavePopulator.populate(world, new FastRandom(MathUtil.getCarverChunkSeed(cx, cz, world.getSeed())), chunkData);
|
||||
structurePopulator.populate(world, new FastRandom(MathUtil.getCarverChunkSeed(cx, cz, world.getSeed())), chunkData);
|
||||
orePopulator.populate(world, new FastRandom(MathUtil.getCarverChunkSeed(cx, cz, world.getSeed())), chunkData);
|
||||
floraPopulator.populate(world, new FastRandom(MathUtil.getCarverChunkSeed(cx, cz, world.getSeed())), chunkData);
|
||||
treePopulator.populate(world, new FastRandom(MathUtil.getCarverChunkSeed(cx, cz, world.getSeed())), chunkData);
|
||||
cavePopulator.populate(world, chunkData);
|
||||
structurePopulator.populate(world, chunkData);
|
||||
orePopulator.populate(world, chunkData);
|
||||
floraPopulator.populate(world, chunkData);
|
||||
treePopulator.populate(world, chunkData);
|
||||
count++;
|
||||
|
||||
if(count % 200 == 0) {
|
||||
|
||||
Reference in New Issue
Block a user