Interface LocationBaseDataHolder.Mutable

All Superinterfaces:
LocationBaseDataHolder
All Known Subinterfaces:
Chunk<P>, ClientWorld, GenerationChunk, GenerationRegion, Schematic, ServerWorld, TrackedVolume, World<W,L>, WorldChunk, WorldLike<P>
Enclosing interface:
LocationBaseDataHolder

public static interface LocationBaseDataHolder.Mutable extends LocationBaseDataHolder
  • Method Details

    • transform

      default <E> DataTransactionResult transform(Vector3i position, Key<? extends Value<E>> key, Function<E,E> function)
      Applies a transformation on the pre-existing value of the data keyed by the provided Key and returns a DataTransactionResult of said transformation.
      Type Parameters:
      E - The type of data
      Parameters:
      position - The position of the block
      key - The key to the data
      function - The function applying the transformation
      Returns:
      The transaction result
    • transform

      default <E> DataTransactionResult transform(Vector3i position, DefaultedRegistryReference<? extends Key<? extends Value<E>>> key, Function<E,E> function)
      Applies a transformation on the pre-existing value of the data keyed by the provided Key and returns a DataTransactionResult of said transformation.
      Type Parameters:
      E - The type of data
      Parameters:
      position - The position of the block
      key - The key to the data
      function - The function applying the transformation
      Returns:
      The transaction result
    • transform

      default <E> DataTransactionResult transform(int x, int y, int z, Key<? extends Value<E>> key, Function<E,E> function)
      Applies a transformation on the pre-existing value of the data keyed by the provided Key and returns a DataTransactionResult of said transformation.
      Type Parameters:
      E - The type of data
      Parameters:
      x - The X position
      y - The Y position
      z - The Z position
      key - The key to the data
      function - The function applying the transformation
      Returns:
      The transaction result
    • transform

      default <E> DataTransactionResult transform(int x, int y, int z, DefaultedRegistryReference<? extends Key<? extends Value<E>>> key, Function<E,E> function)
      Applies a transformation on the pre-existing value of the data keyed by the provided Key and returns a DataTransactionResult of said transformation.
      Type Parameters:
      E - The type of data
      Parameters:
      x - The X position
      y - The Y position
      z - The Z position
      key - The key to the data
      function - The function applying the transformation
      Returns:
      The transaction result
    • offer

      default <E> DataTransactionResult offer(Vector3i position, Key<? extends Value<E>> key, E value)
      Offers the given E value that is keyed by the provided Key to the block at the provided location.

      If any data is rejected or existing data is replaced, the DataTransactionResult will retain the rejected and replaced data.

      Type Parameters:
      E - The type of data being offered
      Parameters:
      position - The position of the block
      key - The key for the data
      value - The value to offer
      Returns:
      The transaction result
    • offer

      default <E> DataTransactionResult offer(Vector3i position, DefaultedRegistryReference<? extends Key<? extends Value<E>>> key, E value)
      Offers the given E value that is keyed by the provided Key to the block at the provided location.

      If any data is rejected or existing data is replaced, the DataTransactionResult will retain the rejected and replaced data.

      Type Parameters:
      E - The type of data being offered
      Parameters:
      position - The position of the block
      key - The key for the data
      value - The value to offer
      Returns:
      The transaction result
    • offer

      <E> DataTransactionResult offer(int x, int y, int z, Key<? extends Value<E>> key, E value)
      Offers the given E value that is keyed by the provided Key to the block at the provided location.

      If any data is rejected or existing data is replaced, the DataTransactionResult will retain the rejected and replaced data.

      Type Parameters:
      E - The type of data being offered
      Parameters:
      x - The X position
      y - The Y position
      z - The Z position
      key - The key for the data
      value - The value to offer
      Returns:
      The transaction result
    • offer

      default <E> DataTransactionResult offer(int x, int y, int z, DefaultedRegistryReference<? extends Key<? extends Value<E>>> key, E value)
      Offers the given E value that is keyed by the provided Key to the block at the provided location.

      If any data is rejected or existing data is replaced, the DataTransactionResult will retain the rejected and replaced data.

      Type Parameters:
      E - The type of data being offered
      Parameters:
      x - The X position
      y - The Y position
      z - The Z position
      key - The key for the data
      value - The value to offer
      Returns:
      The transaction result
    • offer

      default <E> DataTransactionResult offer(Vector3i position, Value<E> value)
      Offers the given Value to the block at the given position.

      If any data is rejected or existing data is replaced, the DataTransactionResult will retain the rejected and replaced data.

      Type Parameters:
      E - The type of the element wrapped by the value
      Parameters:
      position - The position of the block
      value - The value to offer
      Returns:
      The transaction result
    • offer

      default <E> DataTransactionResult offer(int x, int y, int z, Value<E> value)
      Offers the given Value to the block at the given position.

      If any data is rejected or existing data is replaced, the DataTransactionResult will retain the rejected and replaced data.

      Type Parameters:
      E - The type of the element wrapped by the value
      Parameters:
      x - The X position
      y - The Y position
      z - The Z position
      value - The value to offer
      Returns:
      The transaction result
    • remove

      default DataTransactionResult remove(Vector3i position, Key<?> key)
      Attempts to remove the data associated with the provided Key from the block at the provided location.
      Parameters:
      position - The position of the block
      key - The key to the data to remove
      Returns:
      The transaction result
    • remove

      default DataTransactionResult remove(Vector3i position, DefaultedRegistryReference<? extends Key<?>> key)
      Attempts to remove the data associated with the provided Key from the block at the provided location.
      Parameters:
      position - The position of the block
      key - The key to the data to remove
      Returns:
      The transaction result
    • remove

      DataTransactionResult remove(int x, int y, int z, Key<?> key)
      Attempts to remove the data associated with the provided Key from the block at the provided location.
      Parameters:
      x - The X position
      y - The Y position
      z - The Z position
      key - The key of the data to remove
      Returns:
      The transaction result
    • remove

      default DataTransactionResult remove(int x, int y, int z, DefaultedRegistryReference<? extends Key<?>> key)
      Attempts to remove the data associated with the provided Key from the block at the provided location.
      Parameters:
      x - The X position
      y - The Y position
      z - The Z position
      key - The key of the data to remove
      Returns:
      The transaction result
    • undo

      default DataTransactionResult undo(Vector3i position, DataTransactionResult result)
      Attempts to undo a DataTransactionResult. Specifically, all Value.Immutables that were successfully added are removed, and all replaced Value.Immutables are offered.
      Parameters:
      position - The position of the block
      result - The transaction result to undo
      Returns:
      The transaction result
    • undo

      DataTransactionResult undo(int x, int y, int z, DataTransactionResult result)
      Attempts to undo a DataTransactionResult. Specifically, all Value.Immutables that were successfully added are removed, and all replaced Value.Immutables are offered.
      Parameters:
      x - The X position
      y - The Y position
      z - The Z position
      result - The transaction result to undo
      Returns:
      The transaction result
    • copyFrom

      default DataTransactionResult copyFrom(Vector3i to, ValueContainer from)
      Attempts to copy all the relevant data from the provided DataHolder to the block at the provided position.
      Parameters:
      to - The position of the block
      from - The data holder to copy data from
      Returns:
      The transaction result
    • copyFrom

      DataTransactionResult copyFrom(int xTo, int yTo, int zTo, ValueContainer from)
      Attempts to copy all the relevant data from the provided DataHolder to the block at the provided position.
      Parameters:
      xTo - The X pos
      yTo - The Y pos
      zTo - The Z pos
      from - The data holder to copy data from
      Returns:
      The transaction result
    • copyFrom

      default DataTransactionResult copyFrom(Vector3i positionTo, Vector3i positionFrom)
      Attempts to copy all the relevant data from the provided DataHolder to the block at the provided position.
      Parameters:
      positionTo - The position of the block
      positionFrom - The position of the block to copy data from
      Returns:
      The transaction result
    • copyFrom

      default DataTransactionResult copyFrom(int xTo, int yTo, int zTo, int xFrom, int yFrom, int zFrom)
      Attempts to copy all Value.Immutables from the provided block to provided block to the provided block position.
      Parameters:
      xTo - The X position of the block to copy data to
      yTo - The Y position of the block to copy data to
      zTo - The Z position of the block to copy data to
      xFrom - The X position of the block to copy data from
      yFrom - The Y position of the block to copy data from
      zFrom - The Z position of the block to copy data from
      Returns:
      The transaction result
    • copyFrom

      default DataTransactionResult copyFrom(Vector3i to, ValueContainer from, MergeFunction function)
      Attempts to copy all Value.Immutables from the provided block to provided block to the provided block position. Any conflicting data is handled through the provided MergeFunction.
      Parameters:
      to - The block position to copy to
      from - the data holder to copy data from
      function - The merge function to resolve conflicts
      Returns:
      The transaction result
    • copyFrom

      DataTransactionResult copyFrom(int xTo, int yTo, int zTo, ValueContainer from, MergeFunction function)
      Attempts to copy all Value.Immutables from the provided block to provided block to the provided block position. Any conflicting data is handled through the provided MergeFunction.
      Parameters:
      xTo - The X pos of the block to copy data to
      yTo - The Y pos of the block to copy data to
      zTo - The Z pos of the block to copy data to
      from - The data holder to copy data from
      function - The merge function to resolve conflicts
      Returns:
      The transaction result
    • copyFrom

      default DataTransactionResult copyFrom(Vector3i positionTo, Vector3i positionFrom, MergeFunction function)
      Attempts to copy all Value.Immutables from the provided block to provided block to the provided block position. Any conflicting data is handled through the provided MergeFunction.
      Parameters:
      positionTo - The position of the block copying data to
      positionFrom - The position of the block to copy data from
      function - The merge function to resolve conflicts
      Returns:
      The transaction result
    • copyFrom

      DataTransactionResult copyFrom(int xTo, int yTo, int zTo, int xFrom, int yFrom, int zFrom, MergeFunction function)
      Attempts to copy all Value.Immutables from the provided block to provided block to the provided block position. Any conflicting data is handled through the provided MergeFunction.
      Parameters:
      xTo - The X position
      yTo - The Y position
      zTo - The Z position
      xFrom - The X position
      yFrom - The Y position
      zFrom - The Z position
      function - The merge resolving function
      Returns:
      The transaction result
    • validateRawData

      default boolean validateRawData(Vector3i position, DataView container)
      Validates the container with known data required to set the raw data to the block at the given position. If the container is incomplete or contains invalid data, false is returned.

      This validation should be checked prior to calling setRawData(Vector3i, DataView) to avoid exceptions.

      Parameters:
      position - The position of the block
      container - The raw data to validate
      Returns:
      True if the data is valid
    • validateRawData

      boolean validateRawData(int x, int y, int z, DataView container)
      Validates the container with known data required to set the raw data to the block at the given position. If the container is incomplete or contains invalid data, false is returned.

      This validation should be checked prior to calling setRawData(Vector3i, DataView) to avoid exceptions.

      Parameters:
      x - The X position
      y - The Y position
      z - The Z position
      container - The raw data to validate
      Returns:
      True if the data is valid
    • setRawData

      default void setRawData(Vector3i position, DataView container) throws InvalidDataException
      Attempts to set all data of the block at the given position according to the DataContainer's held information. Using this to modify known DataManipulators is unsupported and if the data is invalid, an InvalidDataException is thrown.

      This setter is used to provide setting custom data that is not represented by the Data API, including forge mods and other unknown data. Attempts at validating known DataManipulators contained in the data container are made with the assumption that all necessary data exists.

      Parameters:
      position - The position of the block
      container - A container containing all raw data to set on the block at the given position
      Throws:
      InvalidDataException - If the container is missing or has invalid data that this holder will refuse
    • setRawData

      void setRawData(int x, int y, int z, DataView container) throws InvalidDataException
      Attempts to set all data of the block at the given position according to the DataContainer's held information. Using this to modify known DataManipulators is unsupported and if the data is invalid, an InvalidDataException is thrown.

      This setter is used to provide setting custom data that is not represented by the Data API, including forge mods and other unknown data. Attempts at validating known DataManipulators contained in the data container are made with the assumption that all necessary data exists.

      Parameters:
      x - The X position
      y - The Y position
      z - The Z position
      container - A container containing all raw data to set on the block at the given position
      Throws:
      InvalidDataException - If the container is missing or has invalid data that this holder will refuse