public class Block extends Object implements TileEntityBlock
getNbtData() and setNbtData(CompoundTag) are called). When
overriding the NBT methods, getNbtId() should be overridden too, otherwise
the default implementation will invoke getNbtData(), a potentially costly
operation when it is not needed. Implementations may want to cache converted NBT data
structures if possible.
Currently, BaseBlock is used throughout WorldEdit and implementations, but
eventually an API-breaking transition will occur to switch to this object instead.
As-is, the definition of this class is complete, but may need changes in MC 1.4
because data values may be eradicated.| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_DATA
Indicates the maximum data value (inclusive) that can be used.
|
static int |
MAX_ID
Indicates the highest possible block ID (inclusive) that can be used.
|
| Constructor and Description |
|---|
Block(int id)
Construct a block with the given ID and a data value of 0.
|
Block(int id,
int data)
Construct a block with the given ID and data value.
|
Block(int id,
int data,
CompoundTag nbtData)
Construct a block with the given ID, data value, and NBT data structure.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getData()
Get the block's data value.
|
int |
getId()
Get the ID of the block.
|
CompoundTag |
getNbtData()
Get the object's NBT data (tile entity data).
|
String |
getNbtId()
Return the name of the title entity ID.
|
int |
hashCode() |
boolean |
hasNbtData()
Returns whether the block contains NBT data.
|
boolean |
hasWildcardData()
Returns whether the data value is -1, indicating that this block is to be
used as a wildcard matching block.
|
void |
setData(int data)
Set the block's data value.
|
void |
setId(int id)
Set the block ID.
|
void |
setIdAndData(int id,
int data)
Set both the block's ID and data value.
|
void |
setNbtData(CompoundTag nbtData)
Set the object's NBT data (tile entity data).
|
String |
toString() |
public static final int MAX_ID
public static final int MAX_DATA
public Block(int id)
id - ID valuesetId(int)public Block(int id,
int data)
id - ID valuedata - data valuesetId(int),
setData(int)public Block(int id,
int data,
CompoundTag nbtData)
throws DataException
id - ID valuedata - data valuenbtData - NBT dataDataException - if possibly the data is invalidsetId(int),
setData(int),
setNbtData(CompoundTag)public int getId()
MAX_ID)public void setId(int id)
id - block id (between 0 and MAX_ID).public int getData()
public void setData(int data)
data - block data value (between 0 and MAX_DATA).public void setIdAndData(int id,
int data)
id - ID valuedata - data valuesetId(int),
setData(int)public boolean hasWildcardData()
public boolean hasNbtData()
NbtValuedNbtValued.getNbtData() must not return
null if this method returns true.hasNbtData in interface NbtValuedpublic String getNbtId()
TileEntityBlockgetNbtId in interface TileEntityBlockpublic CompoundTag getNbtData()
NbtValuedNbtValued.setNbtData(CompoundTag) so that
the instance knows of the changes. Making changes without calling
NbtValued.setNbtData(CompoundTag) could have unintended consequences.
NbtValued.hasNbtData() must return true if and only if method does not return null.getNbtData in interface NbtValuedpublic void setNbtData(CompoundTag nbtData) throws DataException
NbtValuedsetNbtData in interface NbtValuednbtData - NBT data, or null if no dataDataException - if possibly the data is invalidCopyright © 2010-2014. All Rights Reserved.