Package com.sk89q.worldedit.world.block
Class BaseBlock
java.lang.Object
com.sk89q.worldedit.world.block.BaseBlock
- All Implemented Interfaces:
TileEntityBlock
,Pattern
,BlockStateHolder<BaseBlock>
,NbtValued
- Direct Known Subclasses:
MobSpawnerBlock
,SignBlock
,SkullBlock
Represents a "snapshot" of a block with NBT Data.
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.
-
Constructor Summary
ModifierConstructorDescriptionprotected
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. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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.Get the block type.Get the object's NBT data (tile entity data).getNbtId()
Return the name of the title entity ID.<V> V
Gets the State for this Block.Gets a map of state to state values.int
hashCode()
boolean
Returns whether the block contains NBT data.void
setNbtData
(CompoundTag nbtData) Set the object's NBT data (tile entity data).Gets aBaseBlock
from this BlockStateHolder.toBaseBlock
(CompoundTag compoundTag) Gets aBaseBlock
from this BlockStateHolder.Returns an immutableBlockState
from this BlockStateHolder.toString()
<V> BaseBlock
Returns a BlockState with the given state and value applied.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.sk89q.worldedit.world.block.BlockStateHolder
applyBlock, getAsString
-
Constructor Details
-
BaseBlock
Construct a block with a state.- Parameters:
blockState
- The blockstate
-
BaseBlock
Construct a block with the given ID, data value and NBT data structure.- Parameters:
state
- The block statenbtData
- NBT data, which must be provided
-
-
Method Details
-
getStates
Gets a map of state to state values.- Specified by:
getStates
in interfaceBlockStateHolder<BaseBlock>
- Returns:
- The state map
-
getBlockType
Description copied from interface:BlockStateHolder
Get the block type.- Specified by:
getBlockType
in interfaceBlockStateHolder<BaseBlock>
- Returns:
- The type
-
with
Description copied from interface:BlockStateHolder
Returns a BlockState with the given state and value applied.- Specified by:
with
in interfaceBlockStateHolder<BaseBlock>
- Parameters:
property
- The statevalue
- The value- Returns:
- The modified state, or same if could not be applied
-
getState
Gets the State for this Block.- Specified by:
getState
in interfaceBlockStateHolder<BaseBlock>
- Parameters:
property
- The state to get the value for- Returns:
- The state value
-
hasNbtData
public boolean hasNbtData()Description copied from interface:NbtValued
Returns whether the block contains NBT data.NbtValued.getNbtData()
must not return null if this method returns true.- Specified by:
hasNbtData
in interfaceNbtValued
- Returns:
- true if there is NBT data
-
getNbtId
Description copied from interface:TileEntityBlock
Return the name of the title entity ID.- Specified by:
getNbtId
in interfaceTileEntityBlock
- Returns:
- tile entity ID, non-null string
-
getNbtData
Description copied from interface:NbtValued
Get the object's NBT data (tile entity data). The returned tag, if modified in any way, should be sent toNbtValued.setNbtData(CompoundTag)
so that the instance knows of the changes. Making changes without callingNbtValued.setNbtData(CompoundTag)
could have unintended consequences.NbtValued.hasNbtData()
must return true if and only if method does not return null.- Specified by:
getNbtData
in interfaceNbtValued
- Returns:
- compound tag, or null
-
setNbtData
Description copied from interface:NbtValued
Set the object's NBT data (tile entity data).- Specified by:
setNbtData
in interfaceNbtValued
- Parameters:
nbtData
- NBT data, or null if no data
-
equals
Checks whether the type ID and data value are equal. -
equalsFuzzy
Checks if the type is the same, and if the matched states are the same.- Specified by:
equalsFuzzy
in interfaceBlockStateHolder<BaseBlock>
- Parameters:
o
- other block- Returns:
- true if equal
-
toImmutableState
Description copied from interface:BlockStateHolder
Returns an immutableBlockState
from this BlockStateHolder.- Specified by:
toImmutableState
in interfaceBlockStateHolder<BaseBlock>
- Returns:
- A BlockState
-
toBaseBlock
Description copied from interface:BlockStateHolder
Gets aBaseBlock
from this BlockStateHolder.- Specified by:
toBaseBlock
in interfaceBlockStateHolder<BaseBlock>
- Returns:
- The BaseBlock
-
toBaseBlock
Description copied from interface:BlockStateHolder
Gets aBaseBlock
from this BlockStateHolder.- Specified by:
toBaseBlock
in interfaceBlockStateHolder<BaseBlock>
- Parameters:
compoundTag
- The NBT Data to apply- Returns:
- The BaseBlock
-
hashCode
public int hashCode() -
toString
-