Record Class BlockChange

java.lang.Object
java.lang.Record
com.sk89q.worldedit.history.change.BlockChange
Record Components:
position - the position
previous - the previous block
current - the current block
All Implemented Interfaces:
Change

public record BlockChange(BlockVector3 position, BaseBlock previous, BaseBlock current) extends Record implements Change
Represents a block change that may be undone or replayed.

This block change does not have an Extent assigned to it because one will be taken from the passed UndoContext. If the context does not have an extent (it is null), cryptic errors may occur.

  • Constructor Details

    • BlockChange

      public BlockChange(BlockVector3 position, BaseBlock previous, BaseBlock current)
      Create a new block change.
    • BlockChange

      public BlockChange(BlockVector3 position, BP previous, BC current)
      Create a new block change.
      Parameters:
      position - the position
      previous - the previous block
      current - the current block
  • Method Details

    • getPosition

      @Deprecated(forRemoval=true) public BlockVector3 getPosition()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the position.
      Returns:
      the position
    • getPrevious

      @Deprecated(forRemoval=true) public BaseBlock getPrevious()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the previous block.
      Returns:
      the previous block
    • getCurrent

      @Deprecated(forRemoval=true) public BaseBlock getCurrent()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the current block.
      Returns:
      the current block
    • undo

      public void undo(UndoContext context) throws WorldEditException
      Description copied from interface: Change
      Perform an undo. This method may not be available if the object was returned from ChangeSet.forwardIterator().
      Specified by:
      undo in interface Change
      Parameters:
      context - a context for undo
      Throws:
      WorldEditException - on an error
    • redo

      public void redo(UndoContext context) throws WorldEditException
      Description copied from interface: Change
      Perform an redo. This method may not be available if the object was returned from ChangeSet.backwardIterator() ()}.
      Specified by:
      redo in interface Change
      Parameters:
      context - a context for redo
      Throws:
      WorldEditException - on an error
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • position

      public BlockVector3 position()
      Returns the value of the position record component.
      Returns:
      the value of the position record component
    • previous

      public BaseBlock previous()
      Returns the value of the previous record component.
      Returns:
      the value of the previous record component
    • current

      public BaseBlock current()
      Returns the value of the current record component.
      Returns:
      the value of the current record component