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 a BlockState and any extra data that may be associated with it, including BlockEntity related data.
  • Method Details

    • empty

      static BlockSnapshot empty()
    • builder

      static BlockSnapshot.Builder builder()
      The new builder
    • state

      BlockState state()
      Gets the BlockState.
      The BlockState
    • withState

      BlockSnapshot withState(BlockState blockState)
      Creates a copy of the BlockSnapshot with the provided BlockState. Any additional data associated with a BlockEntity 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.

      blockState - The block state
      The new snapshot
    • withContainer

      BlockSnapshot withContainer(DataContainer container)
      Creates a copy of the BlockSnapshot with the provided DataContainer. Note that this is equal to calling All data is validated and
      container - The data container
      The new snapshot
    • restore

      boolean restore(boolean force, BlockChangeFlag flag)
      Restores the BlockSnapshot to the ServerLocation stored within the snapshot. If the ServerLocation 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 the BlockTypes 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.

      force - If true, forces block state to be set even if the BlockType does not match the snapshot one.
      flag - The block change flags to determine whether neighbors are notified, block physics performed, etc.
      True if the restore was successful, false otherwise
    • creator

      Optional<UUID> creator()
      Gets the UUID, if available, of the user who created this BlockSnapshot.
      The UUID if available
    • notifier

      Optional<UUID> notifier()
      Gets the UUID, if available, of the user who last notified this BlockSnapshot.
      The UUID if available
    • createArchetype

      Optional<BlockEntityArchetype> createArchetype()
      Creates a new BlockEntityArchetype for use with Schematics and placing the archetype in multiple locations.

      If this blocksnapshot does not contain a block entity then this will return Optional.empty().

      The created archetype for re-creating this block entity