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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacestatic interfaceNested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.MutableNested 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.Builderbuilder()Creates aBlockSnapshot.Builderto getBlockSnapshots.Creates a newBlockEntityArchetypefor use withSchematics and placing the archetype in multiple locations.creator()Gets theUUID, if available, of the user who created thisBlockSnapshot.static BlockSnapshotempty()notifier()Gets theUUID, if available, of the user who last notified thisBlockSnapshot.booleanrestore(boolean force, BlockChangeFlag flag) Restores theBlockSnapshotto theServerLocationstored within the snapshot.state()Gets theBlockState.withContainer(DataContainer container) Creates a copy of theBlockSnapshotwith the providedDataContainer.withState(BlockState blockState) Creates a copy of theBlockSnapshotwith the providedBlockState.Methods inherited from interface org.spongepowered.api.data.DataHolder.Immutable
mergeWith, mergeWith, transform, transform, with, with, with, without, without, withoutMethods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainerMethods inherited from interface org.spongepowered.api.world.LocatableSnapshot
location, position, withLocation, worldMethods inherited from interface org.spongepowered.api.data.SerializableDataHolder
validateRawDataMethods inherited from interface org.spongepowered.api.data.SerializableDataHolder.Immutable
copy, withRawData
-
Method Details
-
empty
-
builder
Creates aBlockSnapshot.Builderto getBlockSnapshots.- Returns:
- The new builder
-
state
BlockState state()Gets theBlockState.- Returns:
- The BlockState
-
withState
Creates a copy of theBlockSnapshotwith the providedBlockState. Any additional data associated with aBlockEntityor custom data may be lost.Note: all custom data, including implementation detailed data relating to any and all
BlockEntityinstances 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 theBlockSnapshotwith 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 theBlockSnapshotto theServerLocationstored within the snapshot. If theServerLocationis not available, the snapshot will not be restored.If forced, the state of the block will change its
BlockTypeto match that of the snapshot then set the state. However, if force is set to false and theBlockTypes 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 theBlockTypedoes 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
UUIDif available
-
notifier
Gets theUUID, if available, of the user who last notified thisBlockSnapshot.- Returns:
- The
UUIDif available
-
createArchetype
Optional<BlockEntityArchetype> createArchetype()Creates a newBlockEntityArchetypefor use withSchematics 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
-