From 168c4f4d81eae2aaf836e60f090a1c28221097ce Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Sat, 13 Jan 2024 11:57:48 +1000 Subject: [PATCH] Experiments --- build.gradle | 2 +- gradle.properties | 6 +++--- src/main/java/me/cortex/voxelmon/Test.java | 1 - .../java/me/cortex/voxelmon/core/DistanceTracker.java | 4 ++++ .../me/cortex/voxelmon/core/TreeDistanceTracker.java | 10 ++++++++++ src/main/java/me/cortex/voxelmon/core/VoxelCore.java | 6 +++--- .../me/cortex/voxelmon/core/world/WorldEngine.java | 6 ++++-- .../me/cortex/voxelmon/core/world/other/Mapper.java | 5 +++-- 8 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 src/main/java/me/cortex/voxelmon/core/TreeDistanceTracker.java diff --git a/build.gradle b/build.gradle index d0373ff8..9d866baf 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ dependencies { modImplementation(fabricApi.module("fabric-command-api-v2", project.fabric_version)) modImplementation("net.fabricmc.fabric-api:fabric-rendering-data-attachment-v1:0.3.38+73761d2e9a") - modImplementation "maven.modrinth:sodium:mc1.20.2-0.5.3" + modImplementation "maven.modrinth:sodium:mc1.20.3-0.5.5" } diff --git a/gradle.properties b/gradle.properties index fe04a8ea..6f5823db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,13 +3,13 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.20.2 -yarn_mappings=1.20.2+build.1 +minecraft_version=1.20.4 +yarn_mappings=1.20.4+build.1 loader_version=0.14.22 # Mod Properties mod_version = 0.0.1 maven_group = me.cortex -archives_base_name = voxelmon +archives_base_name = zenith fabric_version=0.89.0+1.20.2 diff --git a/src/main/java/me/cortex/voxelmon/Test.java b/src/main/java/me/cortex/voxelmon/Test.java index 14223fa3..eb47a669 100644 --- a/src/main/java/me/cortex/voxelmon/Test.java +++ b/src/main/java/me/cortex/voxelmon/Test.java @@ -57,6 +57,5 @@ public class Test { //WorldEngine engine = new WorldEngine(new File("storagefile2.db"), 5); WorldImporter importer = new WorldImporter(null, null); //importer.importWorld(new File("run/saves/Drehmal 2.2 Apotheosis Beta - 1.0.0/region/")); - importer.importWorldAsyncStart(new File("D:\\PrismLauncher-Windows-MSVC-Portable-7.1\\instances\\1.20.1(3)\\.minecraft\\.bobby\\build.docm77.de\\-8149132374211427218\\minecraft\\overworld\\"), 2,null, null); } } diff --git a/src/main/java/me/cortex/voxelmon/core/DistanceTracker.java b/src/main/java/me/cortex/voxelmon/core/DistanceTracker.java index b4bb6382..4f54872c 100644 --- a/src/main/java/me/cortex/voxelmon/core/DistanceTracker.java +++ b/src/main/java/me/cortex/voxelmon/core/DistanceTracker.java @@ -203,5 +203,9 @@ public class DistanceTracker { }); ops.clear(); } + + public void fill() { + + } } } diff --git a/src/main/java/me/cortex/voxelmon/core/TreeDistanceTracker.java b/src/main/java/me/cortex/voxelmon/core/TreeDistanceTracker.java new file mode 100644 index 00000000..b40559b9 --- /dev/null +++ b/src/main/java/me/cortex/voxelmon/core/TreeDistanceTracker.java @@ -0,0 +1,10 @@ +package me.cortex.voxelmon.core; + +//Tracks the distance with respect to the entire world size +public class TreeDistanceTracker { + private final int scalingFactor; + + public TreeDistanceTracker(int scalingFactor) { + this.scalingFactor = scalingFactor; + } +} diff --git a/src/main/java/me/cortex/voxelmon/core/VoxelCore.java b/src/main/java/me/cortex/voxelmon/core/VoxelCore.java index 52bcc8a6..b6621932 100644 --- a/src/main/java/me/cortex/voxelmon/core/VoxelCore.java +++ b/src/main/java/me/cortex/voxelmon/core/VoxelCore.java @@ -53,7 +53,7 @@ public class VoxelCore { Blocks.SPRUCE_LEAVES, Blocks.BIRCH_LEAVES, Blocks.PINK_PETALS, - Blocks.FERN, Blocks.GRASS, Blocks.POTTED_FERN)); + Blocks.FERN, Blocks.POTTED_FERN)); private static final Set biomeTintableUpFace = new HashSet<>(List.of(Blocks.GRASS_BLOCK)); private static final Set waterTint = new HashSet<>(List.of(Blocks.WATER)); @@ -73,10 +73,10 @@ public class VoxelCore { //Trigger the shared index buffer loading SharedIndexBuffer.INSTANCE.id(); this.renderer = new Gl46FarWorldRenderer(); - this.world = new WorldEngine(new File("storagefile.db"), 20, 5);//"storagefile.db"//"ethoslab.db" + this.world = new WorldEngine(new File("storagefile.db"), 5, 20, 5);//"storagefile.db"//"ethoslab.db" this.renderTracker = new RenderTracker(this.world, this.renderer); - this.renderGen = new RenderGenerationService(this.world,4, this.renderTracker::processBuildResult); + this.renderGen = new RenderGenerationService(this.world,10, this.renderTracker::processBuildResult); this.world.setRenderTracker(this.renderTracker); this.renderTracker.setRenderGen(this.renderGen); diff --git a/src/main/java/me/cortex/voxelmon/core/world/WorldEngine.java b/src/main/java/me/cortex/voxelmon/core/world/WorldEngine.java index 66685415..c4286d1b 100644 --- a/src/main/java/me/cortex/voxelmon/core/world/WorldEngine.java +++ b/src/main/java/me/cortex/voxelmon/core/world/WorldEngine.java @@ -35,14 +35,14 @@ public class WorldEngine { private final int maxMipLevels; - public WorldEngine(File storagePath, int savingServiceWorkers, int maxMipLayers) { + public WorldEngine(File storagePath, int ingestWorkers, int savingServiceWorkers, int maxMipLayers) { this.maxMipLevels = maxMipLayers; this.storage = new StorageBackend(storagePath); this.mapper = new Mapper(this.storage); this.sectionTracker = new ActiveSectionTracker(maxMipLayers, this::unsafeLoadSection); this.savingService = new SectionSavingService(this, savingServiceWorkers); - this.ingestService = new VoxelIngestService(this, 2); + this.ingestService = new VoxelIngestService(this, ingestWorkers); } private int unsafeLoadSection(WorldSection into) { @@ -89,6 +89,8 @@ public class WorldEngine { this.savingService.enqueueSave(section); } + + //TODO: move this to auxilery class so that it can take into account larger than 4 mip levels //Executes an update to the world and automatically updates all the parent mip layers up to level 4 (e.g. where 1 chunk section is 1 block big) public void insertUpdate(VoxelizedSection section) { //The >>1 is cause the world sections size is 32x32x32 vs the 16x16x16 of the voxelized section diff --git a/src/main/java/me/cortex/voxelmon/core/world/other/Mapper.java b/src/main/java/me/cortex/voxelmon/core/world/other/Mapper.java index 3f310bea..e8c32040 100644 --- a/src/main/java/me/cortex/voxelmon/core/world/other/Mapper.java +++ b/src/main/java/me/cortex/voxelmon/core/world/other/Mapper.java @@ -9,6 +9,7 @@ import net.minecraft.block.Blocks; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtIo; import net.minecraft.nbt.NbtOps; +import net.minecraft.nbt.NbtTagSizeTracker; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.stat.Stat; import net.minecraft.world.biome.Biome; @@ -199,7 +200,7 @@ public class Mapper { public static StateEntry deserialize(int id, byte[] data) { try { - var compound = NbtIo.readCompressed(new ByteArrayInputStream(data)); + var compound = NbtIo.readCompressed(new ByteArrayInputStream(data), NbtTagSizeTracker.ofUnlimitedBytes()); if (compound.getInt("id") != id) { throw new IllegalStateException("Encoded id != expected id"); } @@ -235,7 +236,7 @@ public class Mapper { public static BiomeEntry deserialize(int id, byte[] data) { try { - var compound = NbtIo.readCompressed(new ByteArrayInputStream(data)); + var compound = NbtIo.readCompressed(new ByteArrayInputStream(data), NbtTagSizeTracker.ofUnlimitedBytes()); if (compound.getInt("id") != id) { throw new IllegalStateException("Encoded id != expected id"); }