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
-
Constructor Summary
ConstructorDescriptionBlockWorld
(WorldSettings settings) Create a new BlockWorld instance based on the provided settings. -
Method Summary
Modifier and TypeMethodDescriptionint
getBlock
(int x, int y, int z) Get block id for world coordinate x, y, zint
getBlockExtra
(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.int
float
float
getGlobalLighting
(int x, int y, int z) int
float
getLocalLighting
(int x, int y, int z) Get the Node used for rendering the block world.float
lookupLighting
(int lighting) Get the exact float used global lighting.void
void
Reload all chunks.void
setBlock
(int x, int y, int z, int blockId) void
void
setBlocks
(List<BlockEditData> blockList) void
setCaveLight
(ColorRGBA caveLight) void
setDayLight
(ColorRGBA dayLight) void
setGlobalLight
(float globalLight) Set global light value (0-15) for day/night simulation.void
setLightTexture
(Texture lightTexture) void
setNightLight
(ColorRGBA nightLight) void
setTorchLight
(ColorRGBA torchLight) void
Start all processing threads.void
Stop all processing threads, and wait for them to finish.void
traceCollision
(ReadOnlyVector3 curpos, ReadOnlyVector3 raydir, int maxIterations, IntersectionResult result) void
tracePicking
(ReadOnlyVector3 curpos, ReadOnlyVector3 raydir, int maxIterations, IntersectionResult result) void
update
(ReadOnlyTimer timer) Issue world updates based on currently set player position/direction.void
updatePlayer
(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:
postChunk
in 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:BlockProvider
Get block id for world coordinate x, y, z- Specified by:
getBlock
in 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:
setBlock
in interfaceChunkModifier
-
setBlock
- Specified by:
setBlock
in interfaceChunkModifier
-
setBlocks
- Specified by:
setBlocks
in 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:BlockProvider
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 = whatever- Specified by:
getBlockExtra
in 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:
getGlobalLighting
in interfaceLightProvider
-
getLocalLighting
public float getLocalLighting(int x, int y, int z) - Specified by:
getLocalLighting
in interfaceLightProvider
-
getLightTexture
-
setLightTexture
-
getCaveLight
-
setCaveLight
-
getNightLight
-
setNightLight
-
getDayLight
-
setDayLight
-
getTorchLight
-
setTorchLight
-
getCurrentlyLoadedChunksCount
public int getCurrentlyLoadedChunksCount()
-