Class Block

java.lang.Object
  extended by Block

public class Block
extends java.lang.Object

Block.java - Provides some way of making/editing blocks


Nested Class Summary
Modifier and Type Class and Description
static class Block.Face
          Face - Used for what face of the block was clicked
static class Block.Type
          Type - Used to identify blocks
 
Field Summary
Modifier and Type Field and Description
 Block.Type blockType
           
 
Constructor Summary
Constructor and Description
Block()
          Create a block with no type, x, y or z.
Block(int type)
          Creates a block of specified type
Block(int type, int x, int y, int z)
          Creates a block of specified type and specified x, y and z
Block(int type, int x, int y, int z, int data)
          Creates a block of specified type and specified x, y and z
 
Method Summary
Modifier and Type Method and Description
 boolean equals(java.lang.Object obj)
          Tests the given object to see if it equals this object
 int getData()
          Returns this block's data
 Block getFace(Block.Face face)
          Returns the block at the given Face
 Block.Face getFaceClicked()
          If this block was clicked, this will return the face that was clicked.
 Block getRelative(int x, int y, int z)
          Finds a Block relative to this Block
 int getStatus()
          Returns the destruction status of this block.
 int getType()
          Type of block
 int getX()
          Gets X location
 int getY()
          Gets Y location
 int getZ()
          Gets Z location
 int hashCode()
          Returns a semi-unique hashcode for this block
 boolean isIndirectlyPowered()
          Checks if this block is being indirectly powered through redstone
 boolean isPowered()
          Checks if this block is being powered through redstone
 void refresh()
          Synchronises this Block with the server, abandoning all local changes and refreshing the data with the current actual values
 void setData(int data)
          Sets this block's data
 void setFaceClicked(Block.Face faceClicked)
          Sets the face that was clicked
 void setStatus(int status)
          Sets the current destruction status of this block.
 void setType(int type)
          Set type of block
 void setX(int x)
          Sets X location
 void setY(int y)
          Sets Y location
 void setZ(int z)
          Sets Z location
 java.lang.String toString()
          Returns a String value representing this Block
 void update()
          Updates this block to the server.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

blockType

public Block.Type blockType
Constructor Detail

Block

public Block()
Create a block with no type, x, y or z.


Block

public Block(int type)
Creates a block of specified type

Parameters:
type -

Block

public Block(int type,
             int x,
             int y,
             int z)
Creates a block of specified type and specified x, y and z

Parameters:
type - Type of block
x -
y -
z -

Block

public Block(int type,
             int x,
             int y,
             int z,
             int data)
Creates a block of specified type and specified x, y and z

Parameters:
type - Type of block
x -
y -
z -
data -
Method Detail

getType

public int getType()
Type of block

Returns:
type

setType

public void setType(int type)
Set type of block

Parameters:
type -

getX

public int getX()
Gets X location

Returns:
x

setX

public void setX(int x)
Sets X location

Parameters:
x -

getY

public int getY()
Gets Y location

Returns:
y

setY

public void setY(int y)
Sets Y location

Parameters:
y -

getZ

public int getZ()
Gets Z location

Returns:
z

setZ

public void setZ(int z)
Sets Z location

Parameters:
z -

getFaceClicked

public Block.Face getFaceClicked()
If this block was clicked, this will return the face that was clicked.

Returns:
face clicked

setFaceClicked

public void setFaceClicked(Block.Face faceClicked)
Sets the face that was clicked

Parameters:
faceClicked - face clicked

getStatus

public int getStatus()
Returns the destruction status of this block.

Returns:
0 = Started Digging, 1 = Digging, 2 = Stopped digging, 3 = Block broken. Note: You have to return true for onBlockDestroy for all of these (except 2) to prevent the block from being destroyed. Returning false just on block broken will not work. Another note is that 0 is called often, far less than 1 but is still called. Good for toggling something.

setStatus

public void setStatus(int status)
Sets the current destruction status of this block.

Parameters:
status -

getData

public int getData()
Returns this block's data

Returns:

setData

public void setData(int data)
Sets this block's data

Parameters:
data -

update

public void update()
Updates this block to the server.


getFace

public Block getFace(Block.Face face)
Returns the block at the given Face

Parameters:
face - the block face of which to return
Returns:
Block at the specified Face

refresh

public void refresh()
Synchronises this Block with the server, abandoning all local changes and refreshing the data with the current actual values


getRelative

public Block getRelative(int x,
                         int y,
                         int z)
Finds a Block relative to this Block

Parameters:
x - amount to shift the x coordinate
y - amount to shift the y coordinate
z - amount to shift the z coordinate
Returns:
Block at the requested location

isPowered

public boolean isPowered()
Checks if this block is being powered through redstone

Returns:
true if the block is being powered

isIndirectlyPowered

public boolean isIndirectlyPowered()
Checks if this block is being indirectly powered through redstone

Returns:
true if the block is being indirectly powered

toString

public java.lang.String toString()
Returns a String value representing this Block

Overrides:
toString in class java.lang.Object
Returns:
String representation of this block

equals

public boolean equals(java.lang.Object obj)
Tests the given object to see if it equals this object

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to test
Returns:
true if the two objects match

hashCode

public int hashCode()
Returns a semi-unique hashcode for this block

Overrides:
hashCode in class java.lang.Object
Returns:
hashcode