net.morbz.minecraft.world
Class World

java.lang.Object
  extended by net.morbz.minecraft.world.World
All Implemented Interfaces:
IBlockContainer

public class World
extends java.lang.Object
implements IBlockContainer

The main class for generating a Minecraft map.

Author:
MorbZ

Field Summary
static byte DEFAULT_SKY_LIGHT
          The default sky light level (maximal light)
static byte DEFAULT_TRANSPARENCY
          The default transparency level (fully transparent)
static int MAX_HEIGHT
          Maximal world height
 
Constructor Summary
World(Level level)
          Creates a new instance.
World(Level level, DefaultLayers layers)
          Creates a new instance.
 
Method Summary
 byte getSkyLight(int x, int y, int z)
          Returns the sky light level of the block at given position.
 byte getSkyLightFromParent(IBlockContainer child, int childX, int childY, int childZ)
          Returns the sky light level of a block that is out of bounds of the child block container.
 java.io.File save()
          Saves the world in a new directory within the /worlds/ directory.
 void setBlock(int x, int y, int z, IBlock block)
          Sets a block at the given world position.
 void spreadSkyLight(byte light)
          Spreads the skylight.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_HEIGHT

public static final int MAX_HEIGHT
Maximal world height

See Also:
Constant Field Values

DEFAULT_TRANSPARENCY

public static final byte DEFAULT_TRANSPARENCY
The default transparency level (fully transparent)

See Also:
Constant Field Values

DEFAULT_SKY_LIGHT

public static final byte DEFAULT_SKY_LIGHT
The default sky light level (maximal light)

See Also:
Constant Field Values
Constructor Detail

World

public World(Level level)
Creates a new instance.

Parameters:
level - The level that is used to define the world settings

World

public World(Level level,
             DefaultLayers layers)
Creates a new instance.

Parameters:
level - The level that is used to define the world settings
layers - The default layers. Can be 'null'
Method Detail

setBlock

public void setBlock(int x,
                     int y,
                     int z,
                     IBlock block)
Sets a block at the given world position.

Parameters:
x - The X-coordinate
y - The Y-coordinate (Height, Must be between 0 and 255)
z - The Z-coordinate
block - The block

getSkyLight

public byte getSkyLight(int x,
                        int y,
                        int z)
Returns the sky light level of the block at given position. If there is no block World.DEFAULT_SKY_LIGHT will be returned.

Specified by:
getSkyLight in interface IBlockContainer
Parameters:
x - The local X-coordinate
y - The local Y-coordinate
z - The local Z-coordinate
Returns:
The sky light level

getSkyLightFromParent

public byte getSkyLightFromParent(IBlockContainer child,
                                  int childX,
                                  int childY,
                                  int childZ)
Returns the sky light level of a block that is out of bounds of the child block container.

Specified by:
getSkyLightFromParent in interface IBlockContainer
Parameters:
child - The child block container
childX - The local X-coordinate
childY - The local Y-coordinate
childZ - The local Z-coordinate
Returns:
The sky light level

spreadSkyLight

public void spreadSkyLight(byte light)
Spreads the skylight. For each block that has the given light level it's adjacent blocks will be lit if their current light level is lower.

Specified by:
spreadSkyLight in interface IBlockContainer
Parameters:
light - The light level

save

public java.io.File save()
                  throws java.io.IOException
Saves the world in a new directory within the /worlds/ directory. The name of the directory is the level name. When there are multiple worlds with the same name they will be numbered.

Returns:
The directory in which the world has been saved
Throws:
java.io.IOException - When file writing fails