Package org.spongepowered.api.block
Interface BlockSnapshot
-
- All Superinterfaces:
CopyableDataHolder,DataHolder,DataHolder.Immutable<BlockSnapshot>,DataSerializable,LocatableSnapshot<BlockSnapshot>,SerializableDataHolder,SerializableDataHolder.Immutable<BlockSnapshot>,ValueContainer
public interface BlockSnapshot extends LocatableSnapshot<BlockSnapshot>
An immutable representation of aBlockStateand any extra data that may be associated with it, includingBlockEntityrelated data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceBlockSnapshot.Builderstatic interfaceBlockSnapshot.Factory-
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
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static BlockSnapshot.Builderbuilder()Creates aBlockSnapshot.Builderto getBlockSnapshots.java.util.Optional<BlockEntityArchetype>createArchetype()Creates a newBlockEntityArchetypefor use withSchematics and placing the archetype in multiple locations.java.util.Optional<java.util.UUID>creator()Gets theUUID, if available, of the user who created thisBlockSnapshot.static BlockSnapshotempty()java.util.Optional<java.util.UUID>notifier()Gets theUUID, if available, of the user who last notified thisBlockSnapshot.booleanrestore(boolean force, BlockChangeFlag flag)Restores theBlockSnapshotto theServerLocationstored within the snapshot.BlockStatestate()Gets theBlockState.BlockSnapshotwithContainer(DataContainer container)Creates a copy of theBlockSnapshotwith the providedDataContainer.BlockSnapshotwithState(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, 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 Detail
-
empty
static BlockSnapshot empty()
-
builder
static BlockSnapshot.Builder builder()
Creates aBlockSnapshot.Builderto getBlockSnapshots.- Returns:
- The new builder
-
state
BlockState state()
Gets theBlockState.- Returns:
- The BlockState
-
withState
BlockSnapshot withState(BlockState blockState)
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
BlockSnapshot withContainer(DataContainer container)
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
boolean restore(boolean force, BlockChangeFlag flag)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
java.util.Optional<java.util.UUID> creator()
Gets theUUID, if available, of the user who created thisBlockSnapshot.- Returns:
- The
UUIDif available
-
notifier
java.util.Optional<java.util.UUID> notifier()
Gets theUUID, if available, of the user who last notified thisBlockSnapshot.- Returns:
- The
UUIDif available
-
createArchetype
java.util.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
-
-