public class BaseBlock extends Block implements TileEntityBlock
An instance of this block contains all the information needed to accurately reproduce the block, provided that the instance was made correctly. In some implementations, it may not be possible to get a snapshot of blocks correctly, so, for example, the NBT data for a block may be missing.
This class identifies blocks using an integer ID. However, IDs for
a given block may differ between worlds so it is important that users of
this class convert the ID from one "world space" to another "world space,"
a task that that is assisted with by working with the source and
destination WorldData
instances. Numeric IDs are utilized because
they are more space efficient to store, and it also implies that internal
uses of this class (i.e. history, etc.) do not need to worry about
interning block string IDs.
A peculiar detail of this class is that it accepts -1
as a
valid data value. This is due to legacy reasons: WorldEdit uses -1
as a "wildcard" block value, even though a Mask
would be
more appropriate.
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 |
---|
BaseBlock(BaseBlock other)
Create a clone of another block.
|
BaseBlock(int id)
Construct a block with the given ID and a data value of 0.
|
BaseBlock(int id,
int data)
Construct a block with the given ID and data value.
|
BaseBlock(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 |
---|---|
static boolean |
containsFuzzy(java.util.Collection<BaseBlock> collection,
BaseBlock o)
Deprecated.
|
int |
cycleData(int increment)
Deprecated.
|
boolean |
equals(java.lang.Object o)
Checks whether the type ID and data value are equal.
|
boolean |
equalsFuzzy(BaseBlock o)
Checks if the type is the same, and if data is the same if only data != -1.
|
BaseBlock |
flip()
Deprecated.
|
BaseBlock |
flip(CuboidClipboard.FlipDirection direction)
Deprecated.
Use
BlockData#flip(int, int, FlipDirection) |
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).
|
java.lang.String |
getNbtId()
Return the name of the title entity ID.
|
int |
getType()
Get the type of block.
|
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.
|
boolean |
inIterable(java.lang.Iterable<BaseBlock> iter)
Deprecated.
This method is silly, use
containsFuzzy(java.util.Collection, BaseBlock) instead. |
protected void |
internalSetData(int data)
Set the block's data value.
|
protected void |
internalSetId(int id)
Set the block ID.
|
boolean |
isAir()
Returns true if it's air.
|
int |
rotate90()
Deprecated.
|
int |
rotate90Reverse()
Deprecated.
|
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).
|
void |
setType(int type)
Set the type of block.
|
java.lang.String |
toString() |
public static final int MAX_ID
public static final int MAX_DATA
public BaseBlock(int id)
id
- ID valuesetId(int)
public BaseBlock(int id, int data)
id
- ID valuedata
- data valuesetId(int)
,
setData(int)
public BaseBlock(int id, int data, @Nullable CompoundTag nbtData)
id
- ID valuedata
- data valuenbtData
- NBT data, which may be nullpublic BaseBlock(BaseBlock other)
other
- the other blockpublic int getId()
protected final void internalSetId(int id)
id
- block id (between 0 and MAX_ID
).public void setId(int id)
public int getData()
protected final void internalSetData(int data)
data
- block data value (between 0 and MAX_DATA
).public void setData(int data)
public void setIdAndData(int id, int data)
setIdAndData
in class Block
id
- ID valuedata
- data valuesetId(int)
,
setData(int)
public boolean hasWildcardData()
hasWildcardData
in class Block
public boolean hasNbtData()
NbtValued
NbtValued.getNbtData()
must not return null if this method returns true.hasNbtData
in interface NbtValued
public java.lang.String getNbtId()
TileEntityBlock
getNbtId
in interface TileEntityBlock
@Nullable public CompoundTag getNbtData()
NbtValued
NbtValued.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 NbtValued
public void setNbtData(@Nullable CompoundTag nbtData)
NbtValued
setNbtData
in interface NbtValued
nbtData
- NBT data, or null if no datapublic int getType()
public void setType(int type)
type
- the type to setpublic boolean isAir()
@Deprecated public int rotate90()
BlockData.rotate90(int, int)
@Deprecated public int rotate90Reverse()
BlockData.rotate90Reverse(int, int)
@Deprecated public int cycleData(int increment)
BlockData.cycle(int, int, int)
increment
- 1 for forward, -1 for backward@Deprecated public BaseBlock flip()
BlockData.flip(int, int)
@Deprecated public BaseBlock flip(CuboidClipboard.FlipDirection direction)
BlockData#flip(int, int, FlipDirection)
direction
- direction to flip inpublic boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public boolean equalsFuzzy(BaseBlock o)
o
- other block@Deprecated public boolean inIterable(java.lang.Iterable<BaseBlock> iter)
containsFuzzy(java.util.Collection, BaseBlock)
instead.@Deprecated public static boolean containsFuzzy(java.util.Collection<BaseBlock> collection, BaseBlock o)
Blocks.containsFuzzy(Collection, BaseBlock)
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object