| name | fxgl-voxel |
| description | Build a voxel or Minecraft-style game in FXGL — store a chunked block grid, generate terrain, place and remove blocks by 3D picking, highlight selected voxels, manage a hotbar of block types, rebuild visible chunk geometry after edits, and save modified chunk data. Use this skill for sandbox voxel worlds, block-building prototypes, or destructible cubic terrain.
|
| triggers | ["voxel","minecraft","chunk","block world","place block","break block","chunk mesh","terrain generation"] |
| compatibility | Java 17+, FXGL 21.x. Requires FXGL 3D mode and builds on fxgl-scene3d.
|
| category | fxgl/3d |
| tags | ["fxgl","java","javafx","3d","game-types","voxel"] |
| metadata | {"author":"fxgl-skills","version":"1.0","fxgl-version":"21.1"} |
| allowed-tools | ["Read","Write","Edit","Bash"] |
FXGL Voxel World
Layering
Use fxgl-scene3d for the basic 3D world and picking behavior. This skill adds:
- chunked world storage
- terrain generation
- place / break interaction
- hotbar block selection
- save/load of modified chunks
Chunk Data
public record ChunkCoord(int x, int z) {}
private static final int CHUNK_SIZE = 16;
private static final int CHUNK_HEIGHT = 64;
private final Map<ChunkCoord, byte[][][]> chunks = new HashMap<>();
Represent air as 0 and solid block IDs as positive values.
Terrain Generation
private byte[][][] generateChunk(ChunkCoord coord) {
byte[][][] data = new byte[CHUNK_SIZE][CHUNK_HEIGHT][CHUNK_SIZE];
for (int x = 0; x < CHUNK_SIZE; x++) {
for (int z = 0; z < CHUNK_SIZE; z++) {
int worldX = coord.x() * CHUNK_SIZE + x;
coord.z() * CHUNK_SIZE + z;
() ( + noise(worldX * , worldZ * ) * );
( ; y <= height; y++) {
data[x][y][z] = () (y == height ? : );
}
}
}
data;
}