mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-18 23:01:03 +00:00
clean up ChunkGenerator
This commit is contained in:
+2
-3
@@ -26,7 +26,7 @@ import com.dfsek.terra.api.world.World;
|
|||||||
import com.dfsek.terra.api.world.biome.GenerationSettings;
|
import com.dfsek.terra.api.world.biome.GenerationSettings;
|
||||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
import com.dfsek.terra.api.world.generator.ProtoChunk;
|
||||||
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
||||||
import com.dfsek.terra.api.world.generator.GenerationStage;
|
import com.dfsek.terra.api.world.generator.GenerationStage;
|
||||||
import com.dfsek.terra.api.world.generator.Palette;
|
import com.dfsek.terra.api.world.generator.Palette;
|
||||||
@@ -48,7 +48,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
public ChunkData generateChunkData(@NotNull World world, Random random, int chunkX, int chunkZ, ChunkData chunk) {
|
public void generateChunkData(@NotNull World world, Random random, int chunkX, int chunkZ, ProtoChunk chunk) {
|
||||||
try(ProfileFrame ignore = platform.getProfiler().profile("chunk_base_3d")) {
|
try(ProfileFrame ignore = platform.getProfiler().profile("chunk_base_3d")) {
|
||||||
BiomeProvider grid = world.getBiomeProvider();
|
BiomeProvider grid = world.getBiomeProvider();
|
||||||
|
|
||||||
@@ -92,7 +92,6 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return chunk;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.api.world.generator;
|
package com.dfsek.terra.api.world.generator;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.util.vector.integer.Vector3Int;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -22,7 +24,7 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
|||||||
|
|
||||||
|
|
||||||
public interface ChunkGenerator {
|
public interface ChunkGenerator {
|
||||||
ChunkData generateChunkData(@NotNull World world, Random random, int x, int z, ChunkData original);
|
void generateChunkData(@NotNull World world, Random random, int x, int z, ProtoChunk original);
|
||||||
Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth);
|
Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth);
|
||||||
|
|
||||||
ConfigPack getConfigPack();
|
ConfigPack getConfigPack();
|
||||||
@@ -36,4 +38,8 @@ public interface ChunkGenerator {
|
|||||||
default BlockState getBlock(World world, Vector3 vector3) {
|
default BlockState getBlock(World world, Vector3 vector3) {
|
||||||
return getBlock(world, vector3.getBlockX(), vector3.getBlockY(), vector3.getBlockZ());
|
return getBlock(world, vector3.getBlockX(), vector3.getBlockY(), vector3.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default BlockState getBlock(World world, Vector3Int vector3) {
|
||||||
|
return getBlock(world, vector3.getX(), vector3.getY(), vector3.getZ());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ package com.dfsek.terra.api.world.generator;
|
|||||||
import com.dfsek.terra.api.world.ChunkAccess;
|
import com.dfsek.terra.api.world.ChunkAccess;
|
||||||
|
|
||||||
|
|
||||||
public interface ChunkData extends ChunkAccess {
|
public interface ProtoChunk extends ChunkAccess {
|
||||||
/**
|
/**
|
||||||
* Get the maximum height for the chunk.
|
* Get the maximum height for the chunk.
|
||||||
* <p>
|
* <p>
|
||||||
+3
-1
@@ -93,7 +93,9 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
|
|||||||
}
|
}
|
||||||
com.dfsek.terra.api.world.World bukkitWorld = BukkitAdapter.adapt(world);
|
com.dfsek.terra.api.world.World bukkitWorld = BukkitAdapter.adapt(world);
|
||||||
if(needsLoad) load(bukkitWorld); // Load population data for world.
|
if(needsLoad) load(bukkitWorld); // Load population data for world.
|
||||||
return (ChunkData) delegate.generateChunkData(bukkitWorld, random, x, z, new BukkitChunkData(createChunkData(world))).getHandle();
|
ChunkData data = createChunkData(world);
|
||||||
|
delegate.generateChunkData(bukkitWorld, random, x, z, new BukkitProtoChunk(data));
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+3
-3
@@ -21,15 +21,15 @@ import org.bukkit.generator.ChunkGenerator;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
import com.dfsek.terra.api.world.generator.ProtoChunk;
|
||||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockState;
|
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockState;
|
||||||
|
|
||||||
|
|
||||||
public class BukkitChunkData implements ChunkData {
|
public class BukkitProtoChunk implements ProtoChunk {
|
||||||
|
|
||||||
private final ChunkGenerator.ChunkData delegate;
|
private final ChunkGenerator.ChunkData delegate;
|
||||||
|
|
||||||
public BukkitChunkData(ChunkGenerator.ChunkData delegate) {
|
public BukkitProtoChunk(ChunkGenerator.ChunkData delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
+2
-2
@@ -55,7 +55,7 @@ import java.util.concurrent.Executor;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.config.ConfigPack;
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
import com.dfsek.terra.api.world.World;
|
import com.dfsek.terra.api.world.World;
|
||||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
import com.dfsek.terra.api.world.generator.ProtoChunk;
|
||||||
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
import com.dfsek.terra.api.world.generator.ChunkGenerator;
|
||||||
import com.dfsek.terra.api.world.generator.Chunkified;
|
import com.dfsek.terra.api.world.generator.Chunkified;
|
||||||
import com.dfsek.terra.api.world.generator.GeneratorWrapper;
|
import com.dfsek.terra.api.world.generator.GeneratorWrapper;
|
||||||
@@ -193,7 +193,7 @@ public class FabricChunkGeneratorWrapper extends net.minecraft.world.gen.chunk.C
|
|||||||
public CompletableFuture<Chunk> populateNoise(Executor executor, Blender arg, StructureAccessor structureAccessor, Chunk chunk) {
|
public CompletableFuture<Chunk> populateNoise(Executor executor, Blender arg, StructureAccessor structureAccessor, Chunk chunk) {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
World world = (World) ((StructureAccessorAccessor) structureAccessor).getWorld();
|
World world = (World) ((StructureAccessorAccessor) structureAccessor).getWorld();
|
||||||
delegate.generateChunkData(world, new FastRandom(), chunk.getPos().x, chunk.getPos().z, (ChunkData) chunk);
|
delegate.generateChunkData(world, new FastRandom(), chunk.getPos().x, chunk.getPos().z, (ProtoChunk) chunk);
|
||||||
delegate.getGenerationStages().forEach(populator -> {
|
delegate.getGenerationStages().forEach(populator -> {
|
||||||
if(populator instanceof Chunkified) {
|
if(populator instanceof Chunkified) {
|
||||||
populator.populate(world, (com.dfsek.terra.api.world.Chunk) world);
|
populator.populate(world, (com.dfsek.terra.api.world.Chunk) world);
|
||||||
|
|||||||
+3
-4
@@ -18,7 +18,6 @@
|
|||||||
package com.dfsek.terra.fabric.mixin.implementations.chunk.data;
|
package com.dfsek.terra.fabric.mixin.implementations.chunk.data;
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.chunk.ProtoChunk;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spongepowered.asm.mixin.Implements;
|
import org.spongepowered.asm.mixin.Implements;
|
||||||
import org.spongepowered.asm.mixin.Interface;
|
import org.spongepowered.asm.mixin.Interface;
|
||||||
@@ -27,12 +26,12 @@ import org.spongepowered.asm.mixin.Mixin;
|
|||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.world.generator.ChunkData;
|
import com.dfsek.terra.api.world.generator.ProtoChunk;
|
||||||
import com.dfsek.terra.fabric.block.FabricBlockState;
|
import com.dfsek.terra.fabric.block.FabricBlockState;
|
||||||
|
|
||||||
|
|
||||||
@Mixin(ProtoChunk.class)
|
@Mixin(net.minecraft.world.chunk.ProtoChunk.class)
|
||||||
@Implements(@Interface(iface = ChunkData.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
@Implements(@Interface(iface = ProtoChunk.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||||
public abstract class ProtoChunkMixin {
|
public abstract class ProtoChunkMixin {
|
||||||
@Shadow
|
@Shadow
|
||||||
public abstract net.minecraft.block.BlockState getBlockState(BlockPos pos);
|
public abstract net.minecraft.block.BlockState getBlockState(BlockPos pos);
|
||||||
|
|||||||
Reference in New Issue
Block a user