diff --git a/src/main/java/dev/hilligans/ourcraft/world/newworldsystem/BufferedSubChunk.java b/src/main/java/dev/hilligans/ourcraft/world/newworldsystem/BufferedSubChunk.java new file mode 100644 index 0000000..ed563dd --- /dev/null +++ b/src/main/java/dev/hilligans/ourcraft/world/newworldsystem/BufferedSubChunk.java @@ -0,0 +1,54 @@ +package dev.hilligans.ourcraft.world.newworldsystem; + +import dev.hilligans.ourcraft.block.blockstate.IBlockState; + +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.util.ArrayList; + +public class BufferedSubChunk implements ISubChunk { + + public MemorySegment memorySegment; + public ArrayList blockStatePalette; + + public BufferedSubChunk(MemorySegment memorySegment, ArrayList blockStatePalette) { + this.memorySegment = memorySegment; + this.blockStatePalette = blockStatePalette; + } + + @Override + public int getWidth() { + return 16; + } + + @Override + public int getHeight() { + return 16; + } + + @Override + public IBlockState getBlockState(IWorld world, int x, int y, int z) { + return blockStatePalette.get(memorySegment.get(ValueLayout.JAVA_SHORT, getIndex(x, y, z))); + } + + @Override + public IBlockState setBlockState(IWorld world, int x, int y, int z, IBlockState blockState) { + IBlockState old = getBlockState(world, x, y, z); + memorySegment.set(ValueLayout.JAVA_SHORT, getIndex(x,y,z), (short)blockState.getBlockStateID()); + return old; + } + + @Override + public boolean isEmpty() { + return false; + } + + public static int getIndex(int x, int y, int z) { + return ((x * 16) + y) * 16 + z; + } + + @Override + public ISubChunk canInsertOrGetNext(IBlockState blockState) { + return null; + } +} diff --git a/src/main/java/dev/hilligans/ourcraft/world/newworldsystem/MMapContainer.java b/src/main/java/dev/hilligans/ourcraft/world/newworldsystem/MMapContainer.java new file mode 100644 index 0000000..34b19f2 --- /dev/null +++ b/src/main/java/dev/hilligans/ourcraft/world/newworldsystem/MMapContainer.java @@ -0,0 +1,30 @@ +package dev.hilligans.ourcraft.world.newworldsystem; + +import java.lang.foreign.MemorySegment; + +public class MMapContainer { + + MemorySegment masterSegment; + + public IWorld world; + + public int x; + public int y; + public int z; + + public int width; + public int height; + + public MMapContainer(IWorld world, int x, int y, int z, int width, int height) { + this.world = world; + this.x = x; + this.y = y; + this.z = z; + this.width = width; + this.height = height; + } + + public CubicChunk createChunk(int chunkX, int chunkY, int chunkZ) { + + } +} diff --git a/src/main/java/dev/hilligans/ourcraft/world/newworldsystem/MMappedSubChunk.java b/src/main/java/dev/hilligans/ourcraft/world/newworldsystem/MMappedSubChunk.java new file mode 100644 index 0000000..f08194a --- /dev/null +++ b/src/main/java/dev/hilligans/ourcraft/world/newworldsystem/MMappedSubChunk.java @@ -0,0 +1,7 @@ +package dev.hilligans.ourcraft.world.newworldsystem; + +public class MMappedSubChunk { + + + +}