Package org.spongepowered.api.block
Interface BlockSnapshot
- All Superinterfaces:
CopyableDataHolder
,DataHolder
,DataHolder.Immutable<BlockSnapshot>
,DataSerializable
,LocatableSnapshot<BlockSnapshot>
,SerializableDataHolder
,SerializableDataHolder.Immutable<BlockSnapshot>
,ValueContainer
An immutable representation of a
BlockState
and any extra data that
may be associated with it, including BlockEntity
related data.-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
static interface
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.Mutable
Nested classes/interfaces inherited from interface org.spongepowered.api.data.SerializableDataHolder
SerializableDataHolder.Immutable<I extends SerializableDataHolder.Immutable<I>>, SerializableDataHolder.Mutable
-
Method Summary
Modifier and TypeMethodDescriptionstatic BlockSnapshot.Builder
builder()
Creates aBlockSnapshot.Builder
to getBlockSnapshot
s.Creates a newBlockEntityArchetype
for use withSchematic
s and placing the archetype in multiple locations.creator()
Gets theUUID
, if available, of the user who created thisBlockSnapshot
.static BlockSnapshot
empty()
notifier()
Gets theUUID
, if available, of the user who last notified thisBlockSnapshot
.boolean
restore
(boolean force, BlockChangeFlag flag) Restores theBlockSnapshot
to theServerLocation
stored within the snapshot.state()
Gets theBlockState
.withContainer
(DataContainer container) Creates a copy of theBlockSnapshot
with the providedDataContainer
.withState
(BlockState blockState) Creates a copy of theBlockSnapshot
with the providedBlockState
.Methods inherited from interface org.spongepowered.api.data.DataHolder.Immutable
mergeWith, mergeWith, transform, transform, with, with, with, without, without, without
Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
Methods inherited from interface org.spongepowered.api.world.LocatableSnapshot
location, position, withLocation, world
Methods inherited from interface org.spongepowered.api.data.SerializableDataHolder
validateRawData
Methods inherited from interface org.spongepowered.api.data.SerializableDataHolder.Immutable
copy, withRawData
-
Method Details
-
empty
-
builder
Creates aBlockSnapshot.Builder
to getBlockSnapshot
s.- Returns:
- The new builder
-
state
BlockState state()Gets theBlockState
.- Returns:
- The BlockState
-
withState
Creates a copy of theBlockSnapshot
with the providedBlockState
. Any additional data associated with aBlockEntity
or custom data may be lost.Note: all custom data, including implementation detailed data relating to any and all
BlockEntity
instances that was included in this snapshot will NOT copy over to the new snapshot.- Parameters:
blockState
- The block state- Returns:
- The new snapshot
-
withContainer
Creates a copy of theBlockSnapshot
with the providedDataContainer
. Note that this is equal to callingDataBuilder.build(DataView)
. All data is validated and- Parameters:
container
- The data container- Returns:
- The new snapshot
-
restore
Restores theBlockSnapshot
to theServerLocation
stored within the snapshot. If theServerLocation
is not available, the snapshot will not be restored.If forced, the state of the block will change its
BlockType
to match that of the snapshot then set the state. However, if force is set to false and theBlockType
s does not match, false will be returned. If notifyNeighbors is true, neighboring blocks will be notified of changes at the restored block location triggering physic updates.- Parameters:
force
- If true, forces block state to be set even if theBlockType
does not match the snapshot one.flag
- The block change flags to determine whether neighbors are notified, block physics performed, etc.- Returns:
- True if the restore was successful, false otherwise
-
creator
Gets theUUID
, if available, of the user who created thisBlockSnapshot
.- Returns:
- The
UUID
if available
-
notifier
Gets theUUID
, if available, of the user who last notified thisBlockSnapshot
.- Returns:
- The
UUID
if available
-
createArchetype
Optional<BlockEntityArchetype> createArchetype()Creates a newBlockEntityArchetype
for use withSchematic
s and placing the archetype in multiple locations.If this blocksnapshot does not contain a block entity then this will return
Optional.empty()
.- Returns:
- The created archetype for re-creating this block entity
-