Package refactor into common and client, common cannot interact with client code directly

This commit is contained in:
mcrcortex
2024-01-16 22:27:23 +10:00
parent 79fe1f7e14
commit f73f667687
76 changed files with 206 additions and 295 deletions

View File

@@ -1,7 +0,0 @@
package me.cortex.voxelmon;
import me.cortex.voxelmon.core.VoxelCore;
public interface IGetVoxelCore {
VoxelCore getVoxelCore();
}

View File

@@ -1,18 +0,0 @@
package me.cortex.voxelmon;
import me.cortex.voxelmon.terrain.TestSparseGenCommand;
//import me.cortex.voxelmon.terrain.WorldImportCommand;
import me.cortex.voxelmon.terrain.WorldImportCommand;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
public class Voxelmon implements ClientModInitializer {
@Override
public void onInitializeClient() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
dispatcher.register(WorldImportCommand.register());
});
}
}

View File

@@ -0,0 +1,7 @@
package me.cortex.voxelmon.client;
import me.cortex.voxelmon.client.core.VoxelCore;
public interface IGetVoxelCore {
VoxelCore getVoxelCore();
}

View File

@@ -1,9 +1,8 @@
package me.cortex.voxelmon;
package me.cortex.voxelmon.client;
import me.cortex.voxelmon.core.world.WorldEngine;
import me.cortex.voxelmon.core.world.storage.LMDBInterface;
import me.cortex.voxelmon.core.world.storage.StorageBackend;
import me.cortex.voxelmon.importers.WorldImporter;
import me.cortex.voxelmon.common.world.storage.LMDBInterface;
import me.cortex.voxelmon.common.world.storage.StorageBackend;
import me.cortex.voxelmon.client.importers.WorldImporter;
import org.lwjgl.system.MemoryUtil;
import java.io.File;

View File

@@ -0,0 +1,15 @@
package me.cortex.voxelmon.client;
//import me.cortex.voxelmon.client.terrain.WorldImportCommand;
import me.cortex.voxelmon.client.terrain.WorldImportCommand;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
public class Voxelmon implements ClientModInitializer {
@Override
public void onInitializeClient() {
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
dispatcher.register(WorldImportCommand.register());
});
}
}

View File

@@ -1,17 +1,11 @@
package me.cortex.voxelmon.core;
package me.cortex.voxelmon.client.core;
//Contains the logic to determine what is loaded and at what LoD level, dispatches render changes
// also determines what faces are built etc
import it.unimi.dsi.fastutil.Arrays;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import me.cortex.voxelmon.core.rendering.AbstractFarWorldRenderer;
import me.cortex.voxelmon.core.rendering.RenderTracker;
import me.cortex.voxelmon.core.rendering.building.RenderGenerationService;
import me.cortex.voxelmon.core.util.DebugUtil;
import me.cortex.voxelmon.core.util.RingUtil;
import me.cortex.voxelmon.core.world.WorldEngine;
import me.cortex.voxelmon.client.core.rendering.RenderTracker;
import me.cortex.voxelmon.client.core.util.RingUtil;
import net.minecraft.client.MinecraftClient;
//Can use ring logic

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core;
package me.cortex.voxelmon.client.core;
//Tracks the distance with respect to the entire world size
public class TreeDistanceTracker {

View File

@@ -1,37 +1,26 @@
package me.cortex.voxelmon.core;
package me.cortex.voxelmon.client.core;
import com.mojang.blaze3d.platform.GlStateManager;
import me.cortex.voxelmon.core.rendering.*;
import me.cortex.voxelmon.core.rendering.building.BuiltSectionGeometry;
import me.cortex.voxelmon.core.rendering.building.RenderGenerationService;
import me.cortex.voxelmon.core.util.DebugUtil;
import me.cortex.voxelmon.core.util.MemoryBuffer;
import me.cortex.voxelmon.core.util.RingUtil;
import me.cortex.voxelmon.core.world.WorldEngine;
import me.cortex.voxelmon.core.world.WorldSection;
import me.cortex.voxelmon.core.world.other.BiomeColour;
import me.cortex.voxelmon.core.world.other.BlockStateColour;
import me.cortex.voxelmon.core.world.other.ColourResolver;
import me.cortex.voxelmon.core.world.other.Mapper;
import me.cortex.voxelmon.importers.WorldImporter;
import me.cortex.voxelmon.client.core.rendering.*;
import me.cortex.voxelmon.client.core.rendering.building.RenderGenerationService;
import me.cortex.voxelmon.client.core.util.DebugUtil;
import me.cortex.voxelmon.common.world.WorldEngine;
import me.cortex.voxelmon.client.core.other.BiomeColour;
import me.cortex.voxelmon.client.core.other.BlockStateColour;
import me.cortex.voxelmon.client.core.other.ColourResolver;
import me.cortex.voxelmon.common.world.other.Mapper;
import me.cortex.voxelmon.client.importers.WorldImporter;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.Frustum;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import net.minecraft.world.chunk.WorldChunk;
import org.lwjgl.system.MemoryUtil;
import java.io.File;
import java.util.*;
import static org.lwjgl.opengl.ARBFramebufferObject.GL_FRAMEBUFFER;
import static org.lwjgl.opengl.ARBFramebufferObject.glBindFramebuffer;
//Core class that ingests new data from sources and updates the required systems
//3 primary services:
@@ -80,7 +69,7 @@ public class VoxelCore {
this.renderTracker = new RenderTracker(this.world, this.renderer);
this.renderGen = new RenderGenerationService(this.world,5, this.renderTracker::processBuildResult);
this.world.setRenderTracker(this.renderTracker);
this.world.setDirtyCallback(this.renderTracker::sectionUpdated);
this.renderTracker.setRenderGen(this.renderGen);
System.out.println("Render tracker and generator initialized");

View File

@@ -1,6 +1,6 @@
package me.cortex.voxelmon.core.gl;
package me.cortex.voxelmon.client.core.gl;
import me.cortex.voxelmon.core.util.TrackedObject;
import me.cortex.voxelmon.common.util.TrackedObject;
import static org.lwjgl.opengl.GL15.glDeleteBuffers;
import static org.lwjgl.opengl.GL44C.glBufferStorage;

View File

@@ -1,6 +1,6 @@
package me.cortex.voxelmon.core.gl;
package me.cortex.voxelmon.client.core.gl;
import me.cortex.voxelmon.core.util.TrackedObject;
import me.cortex.voxelmon.common.util.TrackedObject;
import static org.lwjgl.opengl.GL32.*;

View File

@@ -1,7 +1,6 @@
package me.cortex.voxelmon.core.gl;
package me.cortex.voxelmon.client.core.gl;
import me.cortex.voxelmon.core.util.TrackedObject;
import org.lwjgl.opengl.GL30C;
import me.cortex.voxelmon.common.util.TrackedObject;
import static org.lwjgl.opengl.GL45C.*;

View File

@@ -1,9 +1,7 @@
package me.cortex.voxelmon.core.gl;
package me.cortex.voxelmon.client.core.gl;
import me.cortex.voxelmon.core.util.TrackedObject;
import me.cortex.voxelmon.common.util.TrackedObject;
import static org.lwjgl.opengl.ARBMapBufferRange.GL_MAP_FLUSH_EXPLICIT_BIT;
import static org.lwjgl.opengl.ARBMapBufferRange.GL_MAP_UNSYNCHRONIZED_BIT;
import static org.lwjgl.opengl.ARBMapBufferRange.GL_MAP_WRITE_BIT;
import static org.lwjgl.opengl.GL15.glDeleteBuffers;
import static org.lwjgl.opengl.GL45C.*;

View File

@@ -1,6 +1,6 @@
package me.cortex.voxelmon.core.gl;
package me.cortex.voxelmon.client.core.gl;
import me.cortex.voxelmon.core.util.TrackedObject;
import me.cortex.voxelmon.common.util.TrackedObject;
import static org.lwjgl.opengl.ARBFramebufferObject.glDeleteFramebuffers;
import static org.lwjgl.opengl.ARBFramebufferObject.glGenFramebuffers;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.gl.shader;
package me.cortex.voxelmon.client.core.gl.shader;
public interface IShaderProcessor {
String process(ShaderType type, String source);

View File

@@ -1,6 +1,6 @@
package me.cortex.voxelmon.core.gl.shader;
package me.cortex.voxelmon.client.core.gl.shader;
import me.cortex.voxelmon.core.util.TrackedObject;
import me.cortex.voxelmon.common.util.TrackedObject;
import org.lwjgl.opengl.GL20C;
import java.util.HashMap;

View File

@@ -1,8 +1,7 @@
package me.cortex.voxelmon.core.gl.shader;
package me.cortex.voxelmon.client.core.gl.shader;
import me.jellysquid.mods.sodium.client.gl.shader.ShaderConstants;
import me.jellysquid.mods.sodium.client.gl.shader.ShaderParser;
import net.minecraft.util.Identifier;
public class ShaderLoader {
public static String parse(String id) {

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.gl.shader;
package me.cortex.voxelmon.client.core.gl.shader;
import static org.lwjgl.opengl.GL20.GL_FRAGMENT_SHADER;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.world.other;
package me.cortex.voxelmon.client.core.other;
public record BiomeColour(int id, int foliageColour, int waterColour) {
}

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.world.other;
package me.cortex.voxelmon.client.core.other;
public record BlockStateColour(int id, int biomeTintMsk, int[] faceColours) {
}

View File

@@ -1,18 +1,14 @@
package me.cortex.voxelmon.core.world.other;
package me.cortex.voxelmon.client.core.other;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.Sprite;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.LocalRandom;
import net.minecraft.world.biome.BiomeKeys;
import java.util.List;
public class ColourResolver {
//TODO: sample from multiple random values and avg it

View File

@@ -1,13 +1,13 @@
package me.cortex.voxelmon.core.rendering;
package me.cortex.voxelmon.client.core.rendering;
//NOTE: an idea on how to do it is so that any render section, we _keep_ aquired (yes this will be very memory intensive)
// could maybe tosomething else
import me.cortex.voxelmon.core.gl.GlBuffer;
import me.cortex.voxelmon.core.rendering.building.BuiltSectionGeometry;
import me.cortex.voxelmon.core.rendering.util.UploadStream;
import me.cortex.voxelmon.core.world.other.BiomeColour;
import me.cortex.voxelmon.core.world.other.BlockStateColour;
import me.cortex.voxelmon.client.core.gl.GlBuffer;
import me.cortex.voxelmon.client.core.rendering.building.BuiltSectionGeometry;
import me.cortex.voxelmon.client.core.rendering.util.UploadStream;
import me.cortex.voxelmon.client.core.other.BiomeColour;
import me.cortex.voxelmon.client.core.other.BlockStateColour;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.Frustum;

View File

@@ -1,19 +1,14 @@
package me.cortex.voxelmon.core.rendering;
package me.cortex.voxelmon.client.core.rendering;
import it.unimi.dsi.fastutil.ints.Int2LongOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import me.cortex.voxelmon.core.gl.GlBuffer;
import me.cortex.voxelmon.core.rendering.building.BuiltSectionGeometry;
import me.cortex.voxelmon.core.rendering.util.BufferArena;
import me.cortex.voxelmon.core.rendering.util.UploadStream;
import me.cortex.voxelmon.core.util.IndexUtil;
import me.cortex.voxelmon.core.util.MemoryBuffer;
import me.cortex.voxelmon.client.core.gl.GlBuffer;
import me.cortex.voxelmon.client.core.rendering.building.BuiltSectionGeometry;
import me.cortex.voxelmon.client.core.rendering.util.BufferArena;
import me.cortex.voxelmon.client.core.rendering.util.UploadStream;
import org.lwjgl.system.MemoryUtil;
import java.util.Random;
import java.util.concurrent.ConcurrentLinkedDeque;
public class GeometryManager {

View File

@@ -1,12 +1,11 @@
package me.cortex.voxelmon.core.rendering;
package me.cortex.voxelmon.client.core.rendering;
import com.mojang.blaze3d.systems.RenderSystem;
import me.cortex.voxelmon.core.gl.GlBuffer;
import me.cortex.voxelmon.core.gl.shader.Shader;
import me.cortex.voxelmon.core.gl.shader.ShaderType;
import me.cortex.voxelmon.core.rendering.util.UploadStream;
import me.cortex.voxelmon.mixin.joml.AccessFrustumIntersection;
import net.minecraft.client.MinecraftClient;
import me.cortex.voxelmon.client.core.gl.GlBuffer;
import me.cortex.voxelmon.client.core.gl.shader.Shader;
import me.cortex.voxelmon.client.core.gl.shader.ShaderType;
import me.cortex.voxelmon.client.core.rendering.util.UploadStream;
import me.cortex.voxelmon.client.mixin.joml.AccessFrustumIntersection;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.util.math.MatrixStack;
import org.joml.Matrix4f;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.rendering;
package me.cortex.voxelmon.client.core.rendering;
//Manages the storage and updating of model states, textures and colours
public class ModelManager {

View File

@@ -1,19 +1,13 @@
package me.cortex.voxelmon.core.rendering;
package me.cortex.voxelmon.client.core.rendering;
import me.cortex.voxelmon.core.gl.shader.Shader;
import me.cortex.voxelmon.core.gl.shader.ShaderType;
import me.cortex.voxelmon.core.rendering.util.UploadStream;
import me.cortex.voxelmon.client.core.gl.shader.Shader;
import me.cortex.voxelmon.client.core.gl.shader.ShaderType;
import me.cortex.voxelmon.client.core.rendering.util.UploadStream;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.util.math.MatrixStack;
import static org.lwjgl.opengl.ARBMultiDrawIndirect.glMultiDrawElementsIndirect;
import static org.lwjgl.opengl.GL11.GL_TRIANGLES;
import static org.lwjgl.opengl.GL11.GL_UNSIGNED_SHORT;
import static org.lwjgl.opengl.GL30.glBindVertexArray;
import static org.lwjgl.opengl.GL42.*;
import static org.lwjgl.opengl.GL42.GL_FRAMEBUFFER_BARRIER_BIT;
import static org.lwjgl.opengl.GL43.GL_SHADER_STORAGE_BARRIER_BIT;
import static org.lwjgl.opengl.GL43.glDispatchCompute;
import static org.lwjgl.opengl.NVMeshShader.glDrawMeshTasksNV;
//TODO: make this a 2 phase culling system

View File

@@ -1,23 +1,17 @@
package me.cortex.voxelmon.core.rendering;
package me.cortex.voxelmon.client.core.rendering;
import me.cortex.voxelmon.core.gl.GlFramebuffer;
import me.cortex.voxelmon.core.gl.GlTexture;
import me.cortex.voxelmon.core.gl.shader.Shader;
import me.cortex.voxelmon.core.gl.shader.ShaderType;
import me.cortex.voxelmon.client.core.gl.GlFramebuffer;
import me.cortex.voxelmon.client.core.gl.GlTexture;
import me.cortex.voxelmon.client.core.gl.shader.Shader;
import me.cortex.voxelmon.client.core.gl.shader.ShaderType;
import org.lwjgl.opengl.GL11C;
import static org.lwjgl.opengl.ARBFramebufferObject.*;
import static org.lwjgl.opengl.ARBShaderImageLoadStore.glBindImageTexture;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL13.*;
import static org.lwjgl.opengl.GL15C.GL_READ_ONLY;
import static org.lwjgl.opengl.GL15C.GL_READ_WRITE;
import static org.lwjgl.opengl.GL30C.GL_R32F;
import static org.lwjgl.opengl.GL42C.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT;
import static org.lwjgl.opengl.GL42C.glMemoryBarrier;
import static org.lwjgl.opengl.GL43C.glDispatchCompute;
import static org.lwjgl.opengl.GL44C.glBindImageTextures;
import static org.lwjgl.opengl.GL45C.glBlitNamedFramebuffer;
import static org.lwjgl.opengl.GL45C.glTextureBarrier;
public class PostProcessing {

View File

@@ -1,15 +1,13 @@
package me.cortex.voxelmon.core.rendering;
package me.cortex.voxelmon.client.core.rendering;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import me.cortex.voxelmon.core.rendering.building.BuiltSectionGeometry;
import me.cortex.voxelmon.core.rendering.building.RenderGenerationService;
import me.cortex.voxelmon.core.world.WorldEngine;
import me.cortex.voxelmon.core.world.WorldSection;
import me.cortex.voxelmon.client.core.rendering.building.BuiltSectionGeometry;
import me.cortex.voxelmon.client.core.rendering.building.RenderGenerationService;
import me.cortex.voxelmon.common.world.WorldEngine;
import me.cortex.voxelmon.common.world.WorldSection;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.Direction;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
//Tracks active sections, dispatches updates to the build system, everything related to rendering flows through here
public class RenderTracker {

View File

@@ -1,10 +1,9 @@
package me.cortex.voxelmon.core.rendering;
package me.cortex.voxelmon.client.core.rendering;
import me.cortex.voxelmon.core.gl.GlBuffer;
import me.cortex.voxelmon.core.rendering.util.BufferArena;
import me.cortex.voxelmon.core.rendering.util.UploadStream;
import me.cortex.voxelmon.core.util.IndexUtil;
import me.cortex.voxelmon.core.util.MemoryBuffer;
import me.cortex.voxelmon.client.core.gl.GlBuffer;
import me.cortex.voxelmon.client.core.rendering.util.UploadStream;
import me.cortex.voxelmon.client.core.util.IndexUtil;
import me.cortex.voxelmon.common.util.MemoryBuffer;
import org.lwjgl.system.MemoryUtil;

View File

@@ -1,8 +1,7 @@
package me.cortex.voxelmon.core.rendering.building;
package me.cortex.voxelmon.client.core.rendering.building;
import me.cortex.voxelmon.core.util.MemoryBuffer;
import me.cortex.voxelmon.core.util.TrackedObject;
import me.cortex.voxelmon.core.world.WorldEngine;
import me.cortex.voxelmon.common.util.MemoryBuffer;
import me.cortex.voxelmon.common.world.WorldEngine;
public class BuiltSectionGeometry {
public final long position;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.rendering.building;
package me.cortex.voxelmon.client.core.rendering.building;
//Class for generating holding and remapping colours and ids
// used during building and then remapping into the global colour array before insertion into the world

View File

@@ -1,8 +1,8 @@
package me.cortex.voxelmon.core.rendering.building;
package me.cortex.voxelmon.client.core.rendering.building;
import me.cortex.voxelmon.core.util.Mesher2D;
import me.cortex.voxelmon.core.world.other.Mapper;
import me.cortex.voxelmon.client.core.util.Mesher2D;
import me.cortex.voxelmon.common.world.other.Mapper;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.BlockPos;

View File

@@ -1,11 +1,11 @@
package me.cortex.voxelmon.core.rendering.building;
package me.cortex.voxelmon.client.core.rendering.building;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import me.cortex.voxelmon.core.util.MemoryBuffer;
import me.cortex.voxelmon.core.util.Mesher2D;
import me.cortex.voxelmon.core.world.WorldEngine;
import me.cortex.voxelmon.core.world.WorldSection;
import me.cortex.voxelmon.core.world.other.Mapper;
import me.cortex.voxelmon.common.util.MemoryBuffer;
import me.cortex.voxelmon.client.core.util.Mesher2D;
import me.cortex.voxelmon.common.world.WorldEngine;
import me.cortex.voxelmon.common.world.WorldSection;
import me.cortex.voxelmon.common.world.other.Mapper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.Direction;
import org.lwjgl.system.MemoryUtil;

View File

@@ -1,11 +1,11 @@
package me.cortex.voxelmon.core.rendering.building;
package me.cortex.voxelmon.client.core.rendering.building;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import me.cortex.voxelmon.core.util.MemoryBuffer;
import me.cortex.voxelmon.core.util.Mesher2D;
import me.cortex.voxelmon.core.world.WorldEngine;
import me.cortex.voxelmon.core.world.WorldSection;
import me.cortex.voxelmon.core.world.other.Mapper;
import me.cortex.voxelmon.common.util.MemoryBuffer;
import me.cortex.voxelmon.client.core.util.Mesher2D;
import me.cortex.voxelmon.common.world.WorldEngine;
import me.cortex.voxelmon.common.world.WorldSection;
import me.cortex.voxelmon.common.world.other.Mapper;
import net.minecraft.util.math.Direction;
import org.lwjgl.system.MemoryUtil;

View File

@@ -1,19 +1,12 @@
package me.cortex.voxelmon.core.rendering.building;
package me.cortex.voxelmon.client.core.rendering.building;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import me.cortex.voxelmon.core.rendering.AbstractFarWorldRenderer;
import me.cortex.voxelmon.core.rendering.RenderTracker;
import me.cortex.voxelmon.core.world.WorldEngine;
import me.cortex.voxelmon.core.world.WorldSection;
import net.minecraft.util.math.Direction;
import net.minecraft.world.chunk.ChunkNibbleArray;
import net.minecraft.world.chunk.WorldChunk;
import me.cortex.voxelmon.common.world.WorldEngine;
import me.cortex.voxelmon.common.world.WorldSection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.Semaphore;
import java.util.function.Consumer;
import java.util.function.IntFunction;
import java.util.function.Supplier;
import java.util.function.ToIntFunction;

View File

@@ -1,8 +1,8 @@
package me.cortex.voxelmon.core.rendering.util;
package me.cortex.voxelmon.client.core.rendering.util;
import me.cortex.voxelmon.core.gl.GlBuffer;
import me.cortex.voxelmon.core.util.AllocationArena;
import me.cortex.voxelmon.core.util.MemoryBuffer;
import me.cortex.voxelmon.client.core.gl.GlBuffer;
import me.cortex.voxelmon.client.core.util.AllocationArena;
import me.cortex.voxelmon.common.util.MemoryBuffer;
import org.lwjgl.system.MemoryUtil;
public class BufferArena {

View File

@@ -1,16 +1,15 @@
package me.cortex.voxelmon.core.rendering.util;
package me.cortex.voxelmon.client.core.rendering.util;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import me.cortex.voxelmon.core.gl.GlBuffer;
import me.cortex.voxelmon.core.gl.GlFence;
import me.cortex.voxelmon.core.gl.GlPersistentMappedBuffer;
import me.cortex.voxelmon.core.util.AllocationArena;
import org.lwjgl.opengl.GL42;
import me.cortex.voxelmon.client.core.gl.GlBuffer;
import me.cortex.voxelmon.client.core.gl.GlFence;
import me.cortex.voxelmon.client.core.gl.GlPersistentMappedBuffer;
import me.cortex.voxelmon.client.core.util.AllocationArena;
import java.util.ArrayDeque;
import java.util.Deque;
import static me.cortex.voxelmon.core.util.AllocationArena.SIZE_LIMIT;
import static me.cortex.voxelmon.client.core.util.AllocationArena.SIZE_LIMIT;
import static org.lwjgl.opengl.ARBDirectStateAccess.glCopyNamedBufferSubData;
import static org.lwjgl.opengl.ARBDirectStateAccess.glFlushMappedNamedBufferRange;
import static org.lwjgl.opengl.ARBMapBufferRange.*;

View File

@@ -1,11 +1,7 @@
package me.cortex.voxelmon.core.util;
package me.cortex.voxelmon.client.core.util;
import it.unimi.dsi.fastutil.longs.LongArrayList;
import it.unimi.dsi.fastutil.longs.LongList;
import it.unimi.dsi.fastutil.longs.LongRBTreeSet;
import java.util.Random;
//FIXME: NOTE: if there is a free block of size > 2^30 EVERYTHING BREAKS, need to either increase size
// or automatically split and manage multiple blocks which is very painful
//OR instead of addr, defer to a long[] and use indicies

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.util;
package me.cortex.voxelmon.client.core.util;
import java.io.IOException;
import java.io.InputStream;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.util;
package me.cortex.voxelmon.client.core.util;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.render.*;

View File

@@ -1,5 +1,6 @@
package me.cortex.voxelmon.core.util;
package me.cortex.voxelmon.client.core.util;
import me.cortex.voxelmon.common.util.MemoryBuffer;
import org.lwjgl.system.MemoryUtil;
public class IndexUtil {

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.util;
package me.cortex.voxelmon.client.core.util;
import java.util.Arrays;
import java.util.BitSet;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.util;
package me.cortex.voxelmon.client.core.util;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;

View File

@@ -1,10 +1,10 @@
package me.cortex.voxelmon.importers;
package me.cortex.voxelmon.client.importers;
import com.mojang.serialization.Codec;
import me.cortex.voxelmon.core.util.ByteBufferBackedInputStream;
import me.cortex.voxelmon.core.voxelization.VoxelizedSection;
import me.cortex.voxelmon.core.voxelization.WorldConversionFactory;
import me.cortex.voxelmon.core.world.WorldEngine;
import me.cortex.voxelmon.client.core.util.ByteBufferBackedInputStream;
import me.cortex.voxelmon.common.voxelization.VoxelizedSection;
import me.cortex.voxelmon.common.voxelization.WorldConversionFactory;
import me.cortex.voxelmon.common.world.WorldEngine;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@@ -14,7 +14,6 @@ import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.NbtOps;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeKeys;
@@ -28,11 +27,8 @@ import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Function;
public class WorldImporter {

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.mixin.joml;
package me.cortex.voxelmon.client.mixin.joml;
import org.joml.FrustumIntersection;
import org.joml.Vector4f;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.mixin.minecraft;
package me.cortex.voxelmon.client.mixin.minecraft;
import net.minecraft.client.render.BackgroundRenderer;
import org.spongepowered.asm.mixin.Mixin;

View File

@@ -1,6 +1,6 @@
package me.cortex.voxelmon.mixin.minecraft;
package me.cortex.voxelmon.client.mixin.minecraft;
import me.cortex.voxelmon.IGetVoxelCore;
import me.cortex.voxelmon.client.IGetVoxelCore;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientChunkManager;
import net.minecraft.util.math.ChunkPos;

View File

@@ -1,7 +1,6 @@
package me.cortex.voxelmon.mixin.minecraft;
package me.cortex.voxelmon.client.mixin.minecraft;
import me.cortex.voxelmon.IGetVoxelCore;
import me.cortex.voxelmon.core.VoxelCore;
import me.cortex.voxelmon.client.IGetVoxelCore;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.DebugHud;
import org.spongepowered.asm.mixin.Mixin;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.mixin.minecraft;
package me.cortex.voxelmon.client.mixin.minecraft;
import net.minecraft.client.render.GameRenderer;
import org.spongepowered.asm.mixin.Mixin;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.mixin.minecraft;
package me.cortex.voxelmon.client.mixin.minecraft;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.RunArgs;

View File

@@ -1,12 +1,8 @@
package me.cortex.voxelmon.mixin.minecraft;
package me.cortex.voxelmon.client.mixin.minecraft;
import me.cortex.voxelmon.IGetVoxelCore;
import me.cortex.voxelmon.Voxelmon;
import me.cortex.voxelmon.core.VoxelCore;
import net.minecraft.client.MinecraftClient;
import me.cortex.voxelmon.client.IGetVoxelCore;
import me.cortex.voxelmon.client.core.VoxelCore;
import net.minecraft.client.render.*;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld;
import org.jetbrains.annotations.Nullable;

View File

@@ -1,7 +1,6 @@
package me.cortex.voxelmon.terrain;
package me.cortex.voxelmon.client.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;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.terrain;
package me.cortex.voxelmon.client.terrain;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.client.MinecraftClient;

View File

@@ -1,15 +1,13 @@
package me.cortex.voxelmon.terrain;
package me.cortex.voxelmon.client.terrain;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import me.cortex.voxelmon.IGetVoxelCore;
import me.cortex.voxelmon.importers.WorldImporter;
import me.cortex.voxelmon.client.IGetVoxelCore;
import me.cortex.voxelmon.client.importers.WorldImporter;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import org.jetbrains.annotations.NotNull;
import java.io.File;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.util;
package me.cortex.voxelmon.common.util;
import org.lwjgl.system.MemoryUtil;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.util;
package me.cortex.voxelmon.common.util;
import java.lang.ref.Cleaner;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.util;
package me.cortex.voxelmon.common.util;
public class VolatileHolder <T> {
public volatile T obj;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.voxelization;
package me.cortex.voxelmon.common.voxelization;
public interface I3dSupplier <T> {
T supply(int x, int y, int z);

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.voxelization;
package me.cortex.voxelmon.common.voxelization;
import net.minecraft.block.BlockState;

View File

@@ -1,7 +1,7 @@
package me.cortex.voxelmon.core.voxelization;
package me.cortex.voxelmon.common.voxelization;
import me.cortex.voxelmon.core.world.other.Mapper;
import me.cortex.voxelmon.common.world.other.Mapper;
//16x16x16 block section
public class VoxelizedSection {

View File

@@ -1,7 +1,7 @@
package me.cortex.voxelmon.core.voxelization;
package me.cortex.voxelmon.common.voxelization;
import me.cortex.voxelmon.core.world.other.Mipper;
import me.cortex.voxelmon.core.world.other.Mapper;
import me.cortex.voxelmon.common.world.other.Mipper;
import me.cortex.voxelmon.common.world.other.Mapper;
import net.minecraft.block.BlockState;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.world.biome.Biome;

View File

@@ -1,9 +1,7 @@
package me.cortex.voxelmon.core.world;
package me.cortex.voxelmon.common.world;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import me.cortex.voxelmon.core.util.VolatileHolder;
import java.lang.ref.Reference;
import me.cortex.voxelmon.common.util.VolatileHolder;
public class ActiveSectionTracker {
//Deserialize into the supplied section, returns true on success, false on failure

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.world;
package me.cortex.voxelmon.common.world;
import it.unimi.dsi.fastutil.longs.Long2ShortOpenHashMap;
import it.unimi.dsi.fastutil.longs.LongArrayList;

View File

@@ -1,19 +1,15 @@
package me.cortex.voxelmon.core.world;
package me.cortex.voxelmon.common.world;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import me.cortex.voxelmon.core.rendering.RenderTracker;
import me.cortex.voxelmon.core.voxelization.VoxelizedSection;
import me.cortex.voxelmon.core.world.other.Mapper;
import me.cortex.voxelmon.core.world.service.SectionSavingService;
import me.cortex.voxelmon.core.world.service.VoxelIngestService;
import me.cortex.voxelmon.core.world.storage.StorageBackend;
import me.cortex.voxelmon.common.voxelization.VoxelizedSection;
import me.cortex.voxelmon.common.world.other.Mapper;
import me.cortex.voxelmon.common.world.service.SectionSavingService;
import me.cortex.voxelmon.common.world.service.VoxelIngestService;
import me.cortex.voxelmon.common.world.storage.StorageBackend;
import org.lwjgl.system.MemoryUtil;
import java.io.File;
import java.util.Arrays;
import java.util.Deque;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
//Use an LMDB backend to store the world, use a local inmemory cache for lod sections
// automatically manages and invalidates sections of the world as needed
@@ -24,10 +20,10 @@ public class WorldEngine {
private final ActiveSectionTracker sectionTracker;
public final VoxelIngestService ingestService;
public final SectionSavingService savingService;
private RenderTracker renderTracker;
private Consumer<WorldSection> dirtyCallback;
public void setRenderTracker(RenderTracker tracker) {
this.renderTracker = tracker;
public void setDirtyCallback(Consumer<WorldSection> tracker) {
this.dirtyCallback = dirtyCallback;
}
public Mapper getMapper() {return this.mapper;}
@@ -85,7 +81,9 @@ public class WorldEngine {
//Marks a section as dirty, enqueuing it for saving and or render data rebuilding
public void markDirty(WorldSection section) {
this.renderTracker.sectionUpdated(section);
if (this.dirtyCallback != null) {
this.dirtyCallback.accept(section);
}
//TODO: add an option for having synced saving, that is when call enqueueSave, that will instead, instantly
// save to the db, this can be useful for just reducing the amount of thread pools in total
// might have some issues with threading if the same section is saved from multiple threads?

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.world;
package me.cortex.voxelmon.common.world;
import java.util.Arrays;

View File

@@ -1,9 +1,7 @@
package me.cortex.voxelmon.core.world.other;
package me.cortex.voxelmon.common.world.other;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import me.cortex.voxelmon.core.util.MemoryBuffer;
import me.cortex.voxelmon.core.world.storage.StorageBackend;
import me.cortex.voxelmon.common.world.storage.StorageBackend;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@@ -12,7 +10,6 @@ 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.util.Pair;
import net.minecraft.world.biome.Biome;
import org.lwjgl.system.MemoryUtil;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.world.other;
package me.cortex.voxelmon.common.world.other;
//Mipper for data
public class Mipper {

View File

@@ -1,13 +1,10 @@
package me.cortex.voxelmon.core.world.service;
package me.cortex.voxelmon.common.world.service;
import me.cortex.voxelmon.core.world.SaveLoadSystem;
import me.cortex.voxelmon.core.world.WorldEngine;
import me.cortex.voxelmon.core.world.WorldSection;
import net.minecraft.world.chunk.WorldChunk;
import org.lwjgl.system.MemoryStack;
import me.cortex.voxelmon.common.world.SaveLoadSystem;
import me.cortex.voxelmon.common.world.WorldEngine;
import me.cortex.voxelmon.common.world.WorldSection;
import org.lwjgl.system.MemoryUtil;
import java.nio.ByteBuffer;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.Semaphore;

View File

@@ -1,15 +1,12 @@
package me.cortex.voxelmon.core.world.service;
package me.cortex.voxelmon.common.world.service;
import it.unimi.dsi.fastutil.Pair;
import me.cortex.voxelmon.core.voxelization.VoxelizedSection;
import me.cortex.voxelmon.core.voxelization.WorldConversionFactory;
import me.cortex.voxelmon.core.world.WorldEngine;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.ChunkPos;
import me.cortex.voxelmon.common.voxelization.VoxelizedSection;
import me.cortex.voxelmon.common.voxelization.WorldConversionFactory;
import me.cortex.voxelmon.common.world.WorldEngine;
import net.minecraft.util.math.ChunkSectionPos;
import net.minecraft.world.LightType;
import net.minecraft.world.chunk.ChunkNibbleArray;
import net.minecraft.world.chunk.ChunkSection;
import net.minecraft.world.chunk.WorldChunk;
import net.minecraft.world.chunk.light.LightStorage;

View File

@@ -1,8 +1,8 @@
package me.cortex.voxelmon.core.world.storage;
package me.cortex.voxelmon.common.world.storage;
import org.lwjgl.util.lmdb.MDBVal;
import static me.cortex.voxelmon.core.world.storage.LMDBInterface.E;
import static me.cortex.voxelmon.common.world.storage.LMDBInterface.E;
import static org.lwjgl.util.lmdb.LMDB.*;
public class Cursor implements AutoCloseable {

View File

@@ -1,13 +1,10 @@
package me.cortex.voxelmon.core.world.storage;
package me.cortex.voxelmon.common.world.storage;
import org.lwjgl.PointerBuffer;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.util.lmdb.LMDB;
import org.lwjgl.util.lmdb.MDBEnvInfo;
import java.nio.IntBuffer;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import static org.lwjgl.system.MemoryStack.stackPush;
import static org.lwjgl.util.lmdb.LMDB.*;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.world.storage;
package me.cortex.voxelmon.common.world.storage;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import org.lwjgl.system.MemoryUtil;
@@ -8,7 +8,6 @@ import java.io.File;
import java.nio.ByteBuffer;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Supplier;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.world.storage;
package me.cortex.voxelmon.common.world.storage;
import org.lwjgl.system.MemoryStack;

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.world.storage;
package me.cortex.voxelmon.common.world.storage;
public interface TransactionWrappedCallback<T> {
T exec(TransactionWrapper wrapper);

View File

@@ -1,4 +1,4 @@
package me.cortex.voxelmon.core.world.storage;
package me.cortex.voxelmon.common.world.storage;
import org.lwjgl.PointerBuffer;
import org.lwjgl.system.MemoryStack;
@@ -6,7 +6,7 @@ import org.lwjgl.util.lmdb.MDBVal;
import java.nio.ByteBuffer;
import static me.cortex.voxelmon.core.world.storage.LMDBInterface.E;
import static me.cortex.voxelmon.common.world.storage.LMDBInterface.E;
import static org.lwjgl.system.MemoryStack.stackPush;
import static org.lwjgl.util.lmdb.LMDB.*;

View File

@@ -13,7 +13,9 @@
"icon": "assets/voxelmon/icon.png",
"environment": "client",
"entrypoints": {
"client": ["me.cortex.voxelmon.Voxelmon"]
"client": [
"me.cortex.voxelmon.client.Voxelmon"
]
},
"mixins": [
"voxelmon.mixins.json"

View File

@@ -1,6 +1,6 @@
{
"required": true,
"package": "me.cortex.voxelmon.mixin",
"package": "me.cortex.voxelmon.client.mixin",
"compatibilityLevel": "JAVA_17",
"client": [
"minecraft.MixinBackgroundRenderer",