Package com.ardorcraft.world
Class BlockWorld
java.lang.Object
com.ardorcraft.world.BlockWorld
- All Implemented Interfaces:
BlockProvider,ChunkModifier,LightProvider
BlockWorld is the main class when it comes to building and rendering the block world. It handles asynchronous
updating and rebuilding of the chunks after receiving chunk or block updates. It also handles light calculations.
In the simplest setup, the blockworld is just initialized with a WorldSettings object. Then the main node for
rendering the world is extracted and added to your scenegraph. Finally when you have everything else setup, all the
threads are kicked off to start processing.
blockWorld = new BlockWorld(settings);
root.attachChild(blockWorld.getWorldNode());
...
blockWorld.startThreads();
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBlockWorld(WorldSettings settings) Create a new BlockWorld instance based on the provided settings. -
Method Summary
Modifier and TypeMethodDescriptionintgetBlock(int x, int y, int z) Get block id for world coordinate x, y, zintgetBlockExtra(int x, int y, int z) Get block extra data for world coordinate x, y, z.
bits 0,1,2 = orientation
bits 3,4,5,6 = age (or something else)
bit 7 = whatevergetBlockOrientation(int x, int y, int z) Get block orientation at coordinate x, y, z.intfloatfloatgetGlobalLighting(int x, int y, int z) intfloatgetLocalLighting(int x, int y, int z) Get the Node used for rendering the block world.floatlookupLighting(int lighting) Get the exact float used global lighting.voidvoidReload all chunks.voidsetBlock(int x, int y, int z, int blockId) voidvoidsetBlocks(List<BlockEditData> blockList) voidsetCaveLight(ColorRGBA caveLight) voidsetDayLight(ColorRGBA dayLight) voidsetGlobalLight(float globalLight) Set global light value (0-15) for day/night simulation.voidsetLightTexture(Texture lightTexture) voidsetNightLight(ColorRGBA nightLight) voidsetTorchLight(ColorRGBA torchLight) voidStart all processing threads.voidStop all processing threads, and wait for them to finish.voidtraceCollision(ReadOnlyVector3 curpos, ReadOnlyVector3 raydir, int maxIterations, IntersectionResult result) voidtracePicking(ReadOnlyVector3 curpos, ReadOnlyVector3 raydir, int maxIterations, IntersectionResult result) voidupdate(ReadOnlyTimer timer) Issue world updates based on currently set player position/direction.voidupdatePlayer(ReadOnlyVector3 location, ReadOnlyVector3 direction) Let the block world know the current player position and direction.
-
Field Details
-
WATER
public static int WATER
-
-
Constructor Details
-
BlockWorld
Create a new BlockWorld instance based on the provided settings.- Parameters:
settings- the world settings
-
-
Method Details
-
startThreads
public void startThreads()Start all processing threads. Currently a chunk updater and a light updater. -
getWorldNode
Get the Node used for rendering the block world.- Returns:
- Node with block world
-
update
Issue world updates based on currently set player position/direction.- Parameters:
timer- the timer
-
postChunk
- Specified by:
postChunkin interfaceChunkModifier
-
updatePlayer
Let the block world know the current player position and direction.- Parameters:
location- the locationdirection- the direction
-
reloadAll
public void reloadAll()Reload all chunks. -
lookupLighting
public float lookupLighting(int lighting) Get the exact float used global lighting.- Parameters:
lighting- the lighting- Returns:
- the exact float used global lighting
-
getBlock
public int getBlock(int x, int y, int z) Description copied from interface:BlockProviderGet block id for world coordinate x, y, z- Specified by:
getBlockin interfaceBlockProvider- Parameters:
x- X coordinatey- Y coordinatez- Z coordinate- Returns:
- Block id at position
-
setBlock
public void setBlock(int x, int y, int z, int blockId) - Specified by:
setBlockin interfaceChunkModifier
-
setBlock
- Specified by:
setBlockin interfaceChunkModifier
-
setBlocks
- Specified by:
setBlocksin interfaceChunkModifier
-
getBlockOrientation
Get block orientation at coordinate x, y, z.- Parameters:
x- the x valuey- the y valuez- the z value- Returns:
- Orientation
-
getBlockExtra
public int getBlockExtra(int x, int y, int z) Description copied from interface:BlockProviderGet block extra data for world coordinate x, y, z.
bits 0,1,2 = orientation
bits 3,4,5,6 = age (or something else)
bit 7 = whatever- Specified by:
getBlockExtrain interfaceBlockProvider- Parameters:
x- X coordinatey- Y coordinatez- Z coordinate- Returns:
- Block id at position
-
getHeight
public int getHeight() -
tracePicking
public void tracePicking(ReadOnlyVector3 curpos, ReadOnlyVector3 raydir, int maxIterations, IntersectionResult result) -
traceCollision
public void traceCollision(ReadOnlyVector3 curpos, ReadOnlyVector3 raydir, int maxIterations, IntersectionResult result) -
stopThreads
public void stopThreads()Stop all processing threads, and wait for them to finish. -
getGlobalLight
public float getGlobalLight() -
setGlobalLight
public void setGlobalLight(float globalLight) Set global light value (0-15) for day/night simulation.- Parameters:
globalLight- the global light value (0-15) for day/night simulation
-
getSettings
-
getBlockUtil
-
getGlobalLighting
public float getGlobalLighting(int x, int y, int z) - Specified by:
getGlobalLightingin interfaceLightProvider
-
getLocalLighting
public float getLocalLighting(int x, int y, int z) - Specified by:
getLocalLightingin interfaceLightProvider
-
getLightTexture
-
setLightTexture
-
getCaveLight
-
setCaveLight
-
getNightLight
-
setNightLight
-
getDayLight
-
setDayLight
-
getTorchLight
-
setTorchLight
-
getCurrentlyLoadedChunksCount
public int getCurrentlyLoadedChunksCount()
-