Interface IBlockEntityMoveStrategy

All Known Implementing Classes:
DefaultBlockEntityMoveStrategy

public interface IBlockEntityMoveStrategy
A strategy for moving block entities in and out of spatial storage.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable net.minecraft.nbt.CompoundTag
    beginMove(net.minecraft.world.level.block.entity.BlockEntity blockEntity, net.minecraft.core.HolderLookup.Provider registries)
    Called to begin moving a block entity.
    boolean
    canHandle(net.minecraft.world.level.block.entity.BlockEntityType<?> type)
    Tests if this strategy is capable of moving the given block entity type.
    boolean
    completeMove(net.minecraft.world.level.block.entity.BlockEntity entity, net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag savedData, net.minecraft.world.level.Level newLevel, net.minecraft.core.BlockPos newPosition)
    Complete moving a block entity for which a move was initiated successfully with beginMove(BlockEntity, HolderLookup.Provider).
  • Method Details

    • canHandle

      boolean canHandle(net.minecraft.world.level.block.entity.BlockEntityType<?> type)
      Tests if this strategy is capable of moving the given block entity type.
    • beginMove

      @Nullable @Nullable net.minecraft.nbt.CompoundTag beginMove(net.minecraft.world.level.block.entity.BlockEntity blockEntity, net.minecraft.core.HolderLookup.Provider registries)
      Called to begin moving a block entity.
      Parameters:
      blockEntity - The block entity to move.
      registries -
      Returns:
      The saved representation of the block entity that can be used by this strategy to restore the block entity at the target position. Return null to prevent the block entity from being moved.
    • completeMove

      boolean completeMove(net.minecraft.world.level.block.entity.BlockEntity entity, net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag savedData, net.minecraft.world.level.Level newLevel, net.minecraft.core.BlockPos newPosition)
      Complete moving a block entity for which a move was initiated successfully with beginMove(BlockEntity, HolderLookup.Provider). The block entity has already been invalidated, and the blocks have already been fully moved.

      You are responsible for adding the new block entity to the target level, i.e. using Level.setBlockEntity(BlockEntity).

      Parameters:
      entity - The block entity being moved, which has already been removed from the original chunk and should not be reused.
      state - The original block state of the block entity being moved.
      savedData - Data saved by this strategy in beginMove(BlockEntity, HolderLookup.Provider).
      newLevel - Level to moved to
      newPosition - Position to move to
      Returns:
      True if moving succeeded. If false is returned, AE2 will attempt to recover the original entity.