-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/main/java/dev/hilligans/ourcraft/world/newworldsystem/BufferedSubChunk.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<IBlockState> blockStatePalette; | ||
|
||
public BufferedSubChunk(MemorySegment memorySegment, ArrayList<IBlockState> 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; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/dev/hilligans/ourcraft/world/newworldsystem/MMapContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) { | ||
|
||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/dev/hilligans/ourcraft/world/newworldsystem/MMappedSubChunk.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package dev.hilligans.ourcraft.world.newworldsystem; | ||
|
||
public class MMappedSubChunk { | ||
|
||
|
||
|
||
} |