Package appeng.api.movable
Class DefaultBlockEntityMoveStrategy
java.lang.Object
appeng.api.movable.DefaultBlockEntityMoveStrategy
- All Implemented Interfaces:
IBlockEntityMoveStrategy
public abstract class DefaultBlockEntityMoveStrategy
extends Object
implements IBlockEntityMoveStrategy
The default strategy for moving block entities in/out of spatial storage. Can be extended to create custom logic that
runs after
completeMove(net.minecraft.world.level.block.entity.BlockEntity, net.minecraft.world.level.block.state.BlockState, net.minecraft.nbt.CompoundTag, net.minecraft.world.level.Level, net.minecraft.core.BlockPos)
or prevents moving specific entities in IBlockEntityMoveStrategy.beginMove(net.minecraft.world.level.block.entity.BlockEntity, net.minecraft.core.HolderLookup.Provider)
by returning null.
The default strategy uses BlockEntity.saveWithId(HolderLookup.Provider)
in
IBlockEntityMoveStrategy.beginMove(net.minecraft.world.level.block.entity.BlockEntity, net.minecraft.core.HolderLookup.Provider)
to persist the block entity data before it is removed, and then creates a
new block entity at the target position using
BlockEntity.loadStatic(BlockPos, BlockState, CompoundTag, HolderLookup.Provider)
in completeMove(net.minecraft.world.level.block.entity.BlockEntity, net.minecraft.world.level.block.state.BlockState, net.minecraft.nbt.CompoundTag, net.minecraft.world.level.Level, net.minecraft.core.BlockPos)
.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@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
completeMove
(net.minecraft.world.level.block.entity.BlockEntity blockEntity, 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 withIBlockEntityMoveStrategy.beginMove(BlockEntity, HolderLookup.Provider)
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface appeng.api.movable.IBlockEntityMoveStrategy
canHandle
-
Constructor Details
-
DefaultBlockEntityMoveStrategy
public DefaultBlockEntityMoveStrategy()
-
-
Method Details
-
beginMove
@Nullable public @Nullable net.minecraft.nbt.CompoundTag beginMove(net.minecraft.world.level.block.entity.BlockEntity blockEntity, net.minecraft.core.HolderLookup.Provider registries) Description copied from interface:IBlockEntityMoveStrategy
Called to begin moving a block entity.- Specified by:
beginMove
in interfaceIBlockEntityMoveStrategy
- 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
public boolean completeMove(net.minecraft.world.level.block.entity.BlockEntity blockEntity, net.minecraft.world.level.block.state.BlockState state, net.minecraft.nbt.CompoundTag savedData, net.minecraft.world.level.Level newLevel, net.minecraft.core.BlockPos newPosition) Description copied from interface:IBlockEntityMoveStrategy
Complete moving a block entity for which a move was initiated successfully withIBlockEntityMoveStrategy.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. usingLevel.setBlockEntity(BlockEntity)
.- Specified by:
completeMove
in interfaceIBlockEntityMoveStrategy
- Parameters:
blockEntity
- 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 inIBlockEntityMoveStrategy.beginMove(BlockEntity, HolderLookup.Provider)
.newLevel
- Level to moved tonewPosition
- Position to move to- Returns:
- True if moving succeeded. If false is returned, AE2 will attempt to recover the original entity.
-