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 aBlockState
and any extra data that may be associated with it, includingBlockEntity
related data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
BlockSnapshot.Builder
static interface
BlockSnapshot.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.Builder
builder()
Creates aBlockSnapshot.Builder
to getBlockSnapshot
s.java.util.Optional<BlockEntityArchetype>
createArchetype()
Creates a newBlockEntityArchetype
for use withSchematic
s 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 BlockSnapshot
empty()
java.util.Optional<java.util.UUID>
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.BlockState
state()
Gets theBlockState
.BlockSnapshot
withContainer(DataContainer container)
Creates a copy of theBlockSnapshot
with the providedDataContainer
.BlockSnapshot
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 Detail
-
empty
static BlockSnapshot empty()
-
builder
static BlockSnapshot.Builder builder()
Creates aBlockSnapshot.Builder
to getBlockSnapshot
s.- Returns:
- The new builder
-
state
BlockState state()
Gets theBlockState
.- Returns:
- The BlockState
-
withState
BlockSnapshot withState(BlockState blockState)
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
BlockSnapshot withContainer(DataContainer container)
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
boolean restore(boolean force, BlockChangeFlag flag)
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
java.util.Optional<java.util.UUID> creator()
Gets theUUID
, if available, of the user who created thisBlockSnapshot
.- Returns:
- The
UUID
if available
-
notifier
java.util.Optional<java.util.UUID> notifier()
Gets theUUID
, if available, of the user who last notified thisBlockSnapshot
.- Returns:
- The
UUID
if available
-
createArchetype
java.util.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
-
-