net.morbz.minecraft.world
Class Section

java.lang.Object
  extended by net.morbz.minecraft.world.Section
All Implemented Interfaces:
ITagProvider, IBlockContainer

public class Section
extends java.lang.Object
implements ITagProvider, IBlockContainer

Defines a section. It consist of 16 blocks in each dimension.

Author:
MorbZ

Field Summary
static int BLOCKS_PER_SECTION
          The total number of blocks in a section
static int SECTION_HEIGHT
          The height in blocks of a section
 
Constructor Summary
Section(IBlockContainer parent, int y)
          Creates a new instance.
 
Method Summary
 int getBlockCount()
          Returns the number of blocks that are not air.
 int getHighestBlock(int x, int z)
          Returns the Y-coordinate of the highest block that is not air or -1 is there are no blocks in this column.
 byte getSkyLight(int x, int y, int z)
          Returns the sky light level of the block at given position.
 byte getSkyLightFromParent(IBlockContainer child, int x, int y, int z)
          Returns the sky light level of a block that is out of bounds of the child block container.
 org.jnbt.Tag getTag()
          Returns an instance of a subclass of the NBT-Tag class.
 int getY()
           
 void setBlock(int x, int y, int z, IBlock block)
          Sets a block at the given position.
 void setSkyLight(int x, int y, int z, byte light)
          Sets the sky light level of the block at given 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

SECTION_HEIGHT

public static final int SECTION_HEIGHT
The height in blocks of a section

See Also:
Constant Field Values

BLOCKS_PER_SECTION

public static final int BLOCKS_PER_SECTION
The total number of blocks in a section

See Also:
Constant Field Values
Constructor Detail

Section

public Section(IBlockContainer parent,
               int y)
Creates a new instance.

Parameters:
parent - The parent block container
y - The Y-position within the chunk
Method Detail

getY

public int getY()
Returns:
The Y-position within the chunk

setBlock

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

Parameters:
x - The X-coordinate within the section
y - The Y-coordinate within the section
z - The Z-coordinate within the section
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

setSkyLight

public void setSkyLight(int x,
                        int y,
                        int z,
                        byte light)
Sets the sky light level of the block at given position.

Parameters:
x - The X-coordinate
y - The Y-coordinate
z - The Z-coordinate
light - The sky light level

getSkyLightFromParent

public byte getSkyLightFromParent(IBlockContainer child,
                                  int x,
                                  int y,
                                  int z)
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
x - The local X-coordinate
y - The local Y-coordinate
z - 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

getBlockCount

public int getBlockCount()
Returns the number of blocks that are not air.

Returns:
Number of blocks

getHighestBlock

public int getHighestBlock(int x,
                           int z)
Returns the Y-coordinate of the highest block that is not air or -1 is there are no blocks in this column.

Parameters:
x - The X-coordinate
z - The Z-coordinate
Returns:
The Y-coordinate of the highest block or -1

getTag

public org.jnbt.Tag getTag()
Returns an instance of a subclass of the NBT-Tag class.

Specified by:
getTag in interface ITagProvider
Returns:
The Tag representation of this class