public class BaseBlock extends java.lang.Object implements BlockStateHolder<BaseBlock>, 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.
Modifier | Constructor and Description |
---|---|
protected |
BaseBlock(BlockState blockState)
Construct a block with a state.
|
protected |
BaseBlock(BlockState state,
CompoundTag nbtData)
Construct a block with the given ID, data value and NBT data structure.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o)
Checks whether the type ID and data value are equal.
|
boolean |
equalsFuzzy(BlockStateHolder<?> o)
Checks if the type is the same, and if the matched states are the same.
|
BlockType |
getBlockType()
Get the block type.
|
CompoundTag |
getNbtData()
Get the object's NBT data (tile entity data).
|
java.lang.String |
getNbtId()
Return the name of the title entity ID.
|
<V> V |
getState(Property<V> property)
Gets the State for this Block.
|
java.util.Map<Property<?>,java.lang.Object> |
getStates()
Gets a map of state to state values.
|
int |
hashCode() |
boolean |
hasNbtData()
Returns whether the block contains NBT data.
|
void |
setNbtData(CompoundTag nbtData)
Set the object's NBT data (tile entity data).
|
BaseBlock |
toBaseBlock()
Gets a
BaseBlock from this BlockStateHolder. |
BaseBlock |
toBaseBlock(CompoundTag compoundTag)
Gets a
BaseBlock from this BlockStateHolder. |
BlockState |
toImmutableState()
Returns an immutable
BlockState from this BlockStateHolder. |
java.lang.String |
toString() |
<V> BaseBlock |
with(Property<V> property,
V value)
Returns a BlockState with the given state and value applied.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
applyBlock, getAsString
protected BaseBlock(BlockState blockState)
blockState
- The blockstateprotected BaseBlock(BlockState state, CompoundTag nbtData)
state
- The block statenbtData
- NBT data, which must be providedpublic java.util.Map<Property<?>,java.lang.Object> getStates()
getStates
in interface BlockStateHolder<BaseBlock>
public BlockType getBlockType()
BlockStateHolder
getBlockType
in interface BlockStateHolder<BaseBlock>
public <V> BaseBlock with(Property<V> property, V value)
BlockStateHolder
with
in interface BlockStateHolder<BaseBlock>
property
- The statevalue
- The valuepublic <V> V getState(Property<V> property)
getState
in interface BlockStateHolder<BaseBlock>
property
- The state to get the value forpublic 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 boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public boolean equalsFuzzy(BlockStateHolder<?> o)
equalsFuzzy
in interface BlockStateHolder<BaseBlock>
o
- other blockpublic BlockState toImmutableState()
BlockStateHolder
BlockState
from this BlockStateHolder.toImmutableState
in interface BlockStateHolder<BaseBlock>
public BaseBlock toBaseBlock()
BlockStateHolder
BaseBlock
from this BlockStateHolder.toBaseBlock
in interface BlockStateHolder<BaseBlock>
public BaseBlock toBaseBlock(CompoundTag compoundTag)
BlockStateHolder
BaseBlock
from this BlockStateHolder.toBaseBlock
in interface BlockStateHolder<BaseBlock>
compoundTag
- The NBT Data to applypublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object