User Tools

Site Tools


editing_voxels

**This is an old revision of the document!**

Programming::Editing Voxel Data

VoxelContexts

To wrap the modifications of the world into usable chunks, the game makes use of VoxelContexts. The base VoxelContext interface exposes two things:

  • A Location, ie a 4-uple (world, x, y, z)
  • The data associated with this location :
    • The voxel type: an instance of the 'Voxel.class' class.
    • Two 4-bit nibbles : sunlight and blocklight, representing the voxel flood-fill lightning values
    • A byte of metadata

It is recommanded to use VoxelContexts rather than directly using 'raw' cell data and unstable voxel ids.

  • VoxelContext: base interface.
    • WorldVoxelContext: Associated with a real World, getWorld() guaranteed not to return null. If corresponding chunks are loaded, getNeighbor functions will work.
      • ChunkVoxelContext: Associated with a real, loaded chunk.
        • FutureVoxelContext: Describes future changes you wish to make to a cell
        • AbstractVoxelContext: Describe a voxel cell outside of any real world (without context if you will)
        • EditableVoxelContext: Additional interface that allows subsequent pokes without going back to world

        Peek types and what they mean

Name Arguments Return Throws Exceptions
world.peek() int x, int y, int z ChunkVoxelContext Yes
world.peek() Vector3dc location ChunkVoxelContext Yes
world.peekSafely() int x, int y, int z WorldVoxelContext No
world.peekSafely() Vector3dc location WorldVoxelContext No
world.peekSimple() int x, int y, int z Voxel No
world.peekRaw() int x, int y, int z int No
chunk.peek() int x, int y, int z ChunkVoxelContext No
chunk.peek() Vector3dc location ChunkVoxelContext No
chunk.peekSimple() int x, int y, int z Voxel No
chunk.peekRaw() int x, int y, int z int No

Poke types and what they mean

Name Arguments Return Triggers Updates Throws Exceptions
world.poke() x, y, z, voxel, sunlight, blocklight, metadata, cause VoxelContext Yes Yes
world.poke() futureVoxelContext, cause VoxelContext Yes Yes
world.pokeSimple() x, y, z, voxel, sunlight, blocklight, metadata void Yes No
world.pokeSimple() futureVoxelContext void Yes No
world.pokeSimpleSilently() x, y, z, voxel, sunlight, blocklight, metadata void No No
world.pokeSimpleSilently() futureVoxelContext void No No
world.pokeRaw() x, y, z, raw_data_bits void Yes No
world.pokeRawSilently() x, y, z, raw_data_bits void No No
chunk.poke() x, y, z, voxel, sunlight, blocklight, metadata, cause VoxelContext Yes Yes
chunk.pokeSimple() x, y, z, voxel, sunlight, blocklight, metadata void Yes No
chunk.pokeSimpleSilently() x, y, z, voxel, sunlight, blocklight, metadata void No No
chunk.pokeRaw() x, y, z, raw_data_bits void Yes No
chunk.pokeRawSilently() x, y, z, raw_data_bits void No No
editing_voxels.1516882179.txt.gz · Last modified: 2018/01/25 13:09 by gobrosse