bean
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
package me.cortex.voxelmon;
|
||||
|
||||
public class Voxelmon {
|
||||
import me.cortex.voxelmon.terrain.TestSparseGenCommand;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
|
||||
public class Voxelmon implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> TestSparseGenCommand.register(dispatcher));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class VoxelCore {
|
||||
//Trigger the shared index buffer loading
|
||||
SharedIndexBuffer.INSTANCE.id();
|
||||
this.renderer = new Gl46FarWorldRenderer();
|
||||
this.world = new WorldEngine(new File("ethoslab.db"), 16, 5);//"hc9.db"//"storagefile.db"
|
||||
this.world = new WorldEngine(new File("storagefile.db"), 16, 5);//"hc9.db"//"storagefile.db"
|
||||
|
||||
this.renderTracker = new RenderTracker(this.world, this.renderer);
|
||||
this.renderGen = new RenderGenerationService(this.world, this.renderTracker,4);
|
||||
@@ -90,7 +90,7 @@ public class VoxelCore {
|
||||
|
||||
|
||||
//WorldImporter importer = new WorldImporter(this.world, MinecraftClient.getInstance().world);
|
||||
//importer.importWorldAsyncStart(new File("saves/Etho's LP Ep550/region"));
|
||||
//importer.importWorldAsyncStart(new File("saves/New World/region"));
|
||||
|
||||
Set<Block> biomeTintableAllFaces = new HashSet<>(List.of(Blocks.OAK_LEAVES, Blocks.JUNGLE_LEAVES, Blocks.ACACIA_LEAVES, Blocks.DARK_OAK_LEAVES, Blocks.VINE, Blocks.MANGROVE_LEAVES,
|
||||
Blocks.TALL_GRASS, Blocks.LARGE_FERN));
|
||||
|
||||
@@ -78,11 +78,13 @@ public class WorldEngine {
|
||||
public void tryUnload(WorldSection section) {
|
||||
synchronized (this.loadedSectionCache[section.lvl]) {
|
||||
if (section.getRefCount() != 0) {
|
||||
section.assertNotFree();
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO: make a thing where it checks if the section is dirty, if it is, enqueue it for a save first and return
|
||||
|
||||
section.setFreed();
|
||||
section.setFreed();//TODO: FIXME THIS IS SOMEHOW FAILING
|
||||
var removedSection = this.loadedSectionCache[section.lvl].remove(section.getKey());
|
||||
if (removedSection != section) {
|
||||
throw new IllegalStateException("Removed section not the same as attempted to remove");
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package me.cortex.voxelmon.terrain;
|
||||
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.util.math.ColumnPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.biome.source.util.MultiNoiseUtil;
|
||||
import net.minecraft.world.gen.densityfunction.DensityFunction;
|
||||
import net.minecraft.world.gen.noise.NoiseConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SparseTerrainGenerator {
|
||||
|
||||
private final DensityFunction initialDensity;
|
||||
private final DensityFunction finalDensity;
|
||||
private final BiomeSource biomeSource;
|
||||
private final MultiNoiseUtil.MultiNoiseSampler biomeSampler;
|
||||
public SparseTerrainGenerator(NoiseConfig config, BiomeSource biomeSource) {
|
||||
this.biomeSource = biomeSource;
|
||||
|
||||
var router = config.getNoiseRouter();
|
||||
this.initialDensity = router.initialDensityWithoutJaggedness();
|
||||
this.finalDensity = router.finalDensity();
|
||||
|
||||
this.biomeSampler = new MultiNoiseUtil.MultiNoiseSampler(router.temperature(), router.vegetation(), router.continents(), router.erosion(), router.depth(), router.ridges(), List.of());
|
||||
}
|
||||
|
||||
public int getInitialHeight(int x, int z) {
|
||||
int minHeight = -64;
|
||||
int verticalCellBlockCount = 8;
|
||||
int worldHeight = 384;
|
||||
for(int y = minHeight + worldHeight; y >= minHeight; y -= verticalCellBlockCount) {
|
||||
if (this.initialDensity.sample(new DensityFunction.UnblendedNoisePos(x, y, z)) > 0.390625) {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public RegistryEntry<Biome> getBiome(int bx, int by, int bz) {
|
||||
return this.biomeSource.getBiome(bx, by, bz, this.biomeSampler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private final class NoisePos implements DensityFunction.NoisePos {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int z;
|
||||
|
||||
private NoisePos(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int blockX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int blockY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int blockZ() {
|
||||
return this.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package me.cortex.voxelmon.terrain;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
|
||||
import static net.minecraft.server.command.CommandManager.literal;
|
||||
|
||||
public class TestSparseGenCommand {
|
||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||
dispatcher.register(literal("testsparsegen")
|
||||
.executes(ctx -> test()));
|
||||
}
|
||||
|
||||
private static int test() {
|
||||
var world = MinecraftClient.getInstance().getServer().getWorld(MinecraftClient.getInstance().world.getRegistryKey());
|
||||
var gen = new SparseTerrainGenerator(world.getChunkManager().getNoiseConfig(), world.getChunkManager().getChunkGenerator().getBiomeSource());
|
||||
long s = System.currentTimeMillis();
|
||||
int c = 0;
|
||||
for (int x = -50; x <= 50; x++) {
|
||||
for (int z = -50; z <= 50; z++) {
|
||||
var biome = gen.getBiome((x*16)>>2, 64>>2, (z*16)>>2);
|
||||
int minHeight = gen.getInitialHeight(x*16, z*16);
|
||||
c += minHeight;
|
||||
}
|
||||
}
|
||||
System.err.println((System.currentTimeMillis()-s) + " e " + c);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
"icon": "assets/voxelmon/icon.png",
|
||||
"environment": "client",
|
||||
"entrypoints": {
|
||||
"client": ["me.cortex.voxelmon.Voxelmon"]
|
||||
},
|
||||
"mixins": [
|
||||
"voxelmon.mixins.json"
|
||||
|
||||
Reference in New Issue
Block a user