Interface IMultiBlock

All Known Subinterfaces:
IPreviewableMultiblock
All Known Implementing Classes:
AbstractMultiBlock, TestBlock

public interface IMultiBlock
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    allBlocksPresent(net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
     
    default boolean
    canPlace(net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos center, net.minecraft.world.level.block.state.BlockState state)
     
    default boolean
    canSurviveHelper(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos)
    Helper for BlockBehaviour.canSurvive(BlockState, LevelReader, BlockPos)
    default void
    destroy(net.minecraft.core.BlockPos center, net.minecraft.world.level.Level level, net.minecraft.world.level.block.state.BlockState state)
     
    default boolean
    extraSurviveRequirements(net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
    Extra requirements for the block to survive or be placed, runs for every single block in the multiblock
    default void
    fixInStructures(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.ServerLevelAccessor level, net.minecraft.core.BlockPos pos)
    Prevents desyncs and ghost blocks when multiblocks are used in structures
    default void
    fixTick(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
    Tries to fix the multiblock, called after fixInStructures(BlockState, ServerLevelAccessor, BlockPos)
    default Stream<net.minecraft.core.BlockPos>
    fullBlockShape(net.minecraft.core.BlockPos center, net.minecraft.world.level.block.state.BlockState state)
     
    Stream<net.minecraft.core.BlockPos>
    fullBlockShape(net.minecraft.core.Direction direction, net.minecraft.core.BlockPos center)
    Returns a BlockPos Stream of every block in this multiblock.
    default net.minecraft.world.level.block.Block
     
    static net.minecraft.core.BlockPos
    getCenter(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos)
    Returns the center BlockPos of the multiblock
    default net.minecraft.core.Direction
    getDirection(net.minecraft.world.level.block.state.BlockState state)
     
    default net.minecraft.world.level.block.state.properties.DirectionProperty
    Returns the multiblocks DirectionProperty.
    static Stream<net.minecraft.core.BlockPos>
    getFullShape(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
     
    default int
    getMaxAge(net.minecraft.world.level.block.state.properties.IntegerProperty ageProperty)
     
    default net.minecraft.world.level.block.state.BlockState
    getStateForPlacementHelper(net.minecraft.world.item.context.BlockPlaceContext context)
     
    default net.minecraft.world.level.block.state.BlockState
    getStateForPlacementHelper(net.minecraft.world.item.context.BlockPlaceContext context, net.minecraft.core.Direction direction)
    Helper for Block.getStateForPlacement(BlockPlaceContext)
    default BiFunction<net.minecraft.world.level.block.state.BlockState,net.minecraft.core.BlockPos,net.minecraft.world.level.block.state.BlockState>
    Changes the BlockState for each Block based on its offset from center
    static int
    getXOffset(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos)
     
    static int
    getYOffset(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos)
     
    static int
    getZOffset(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos)
     
    default void
    growHelper(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.properties.IntegerProperty ageProperty)
    Increases age in each block at the same time
    default boolean
    isBroken(net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
    Checks if the multiblock needs fixing by fixTick(BlockState, Level, BlockPos)
    static boolean
    isCenter(net.minecraft.world.level.block.state.BlockState state)
     
    static boolean
    isCenter(net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos)
     
    static boolean
    isMultiblock(net.minecraft.world.level.block.state.BlockState state)
     
    static boolean
    isMultiblock(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos)
     
    default void
    place(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos posOriginal, net.minecraft.world.level.block.state.BlockState stateOriginal)
    Places the multiblock, sets its BlockStates and BlockEntity center
    default void
    preventCreativeDrops(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
    Should be added into Block.playerDestroy(Level, Player, BlockPos, BlockState, BlockEntity, ItemStack)
    default net.minecraft.world.level.block.state.BlockState
    updateShapeHelper(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos pos)
    Helper for BlockBehaviour.updateShape(BlockState, Direction, BlockState, LevelAccessor, BlockPos, BlockPos)
    default net.minecraft.world.phys.shapes.VoxelShape
    voxelShapeHelper(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.phys.shapes.VoxelShape shape)
     
    default net.minecraft.world.phys.shapes.VoxelShape
    voxelShapeHelper(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.phys.shapes.VoxelShape shape, float xOffset, float yOffset, float zOffset)
     
    default net.minecraft.world.phys.shapes.VoxelShape
    voxelShapeHelper(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.phys.shapes.VoxelShape shape, float xOffset, float yOffset, float zOffset, boolean hasDirectionOffsets)
    Offsets each Blocks VoxelShape to the center, allowing for VoxelShapes larger than 1 block
  • Method Details

    • fullBlockShape

      Stream<net.minecraft.core.BlockPos> fullBlockShape(@Nullable net.minecraft.core.Direction direction, net.minecraft.core.BlockPos center)
      Returns a BlockPos Stream of every block in this multiblock.
    • getDirectionProperty

      @Nullable default net.minecraft.world.level.block.state.properties.DirectionProperty getDirectionProperty()
      Returns the multiblocks DirectionProperty.

      Only used for multiblocks that can be rotated, otherwise returns null

    • getDirection

      @Nullable default net.minecraft.core.Direction getDirection(net.minecraft.world.level.block.state.BlockState state)
    • getBlock

      default net.minecraft.world.level.block.Block getBlock()
    • fullBlockShape

      default Stream<net.minecraft.core.BlockPos> fullBlockShape(net.minecraft.core.BlockPos center, @Nullable net.minecraft.world.level.block.state.BlockState state)
    • getFullShape

      static Stream<net.minecraft.core.BlockPos> getFullShape(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
    • getStateFromOffset

      @Nullable default BiFunction<net.minecraft.world.level.block.state.BlockState,net.minecraft.core.BlockPos,net.minecraft.world.level.block.state.BlockState> getStateFromOffset()
      Changes the BlockState for each Block based on its offset from center

      Code Example:

      ((state, pos) -> state.setValue(yourStateProperty, IBlockPosOffsetEnum.fromOffset(params)))

      See Also:
    • place

      default void place(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos posOriginal, net.minecraft.world.level.block.state.BlockState stateOriginal)
      Places the multiblock, sets its BlockStates and BlockEntity center
    • getStateForPlacementHelper

      default net.minecraft.world.level.block.state.BlockState getStateForPlacementHelper(net.minecraft.world.item.context.BlockPlaceContext context)
    • getStateForPlacementHelper

      default net.minecraft.world.level.block.state.BlockState getStateForPlacementHelper(net.minecraft.world.item.context.BlockPlaceContext context, net.minecraft.core.Direction direction)
      Helper for Block.getStateForPlacement(BlockPlaceContext)
      Parameters:
      direction - The direction the block will have when placed, ignored when getDirectionProperty() is null
    • canPlace

      default boolean canPlace(net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos center, net.minecraft.world.level.block.state.BlockState state)
    • destroy

      default void destroy(net.minecraft.core.BlockPos center, net.minecraft.world.level.Level level, net.minecraft.world.level.block.state.BlockState state)
    • allBlocksPresent

      default boolean allBlocksPresent(net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
    • updateShapeHelper

      default net.minecraft.world.level.block.state.BlockState updateShapeHelper(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.LevelAccessor level, net.minecraft.core.BlockPos pos)
      Helper for BlockBehaviour.updateShape(BlockState, Direction, BlockState, LevelAccessor, BlockPos, BlockPos)

      Destroys the multiblock if canSurvive returns false

    • canSurviveHelper

      default boolean canSurviveHelper(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos)
      Helper for BlockBehaviour.canSurvive(BlockState, LevelReader, BlockPos)
    • extraSurviveRequirements

      default boolean extraSurviveRequirements(net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
      Extra requirements for the block to survive or be placed, runs for every single block in the multiblock
    • preventCreativeDrops

      default void preventCreativeDrops(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
      Should be added into Block.playerDestroy(Level, Player, BlockPos, BlockState, BlockEntity, ItemStack)
    • fixInStructures

      default void fixInStructures(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.ServerLevelAccessor level, net.minecraft.core.BlockPos pos)
      Prevents desyncs and ghost blocks when multiblocks are used in structures
    • fixTick

      default void fixTick(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos)
      Tries to fix the multiblock, called after fixInStructures(BlockState, ServerLevelAccessor, BlockPos)
    • isBroken

      default boolean isBroken(net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
      Checks if the multiblock needs fixing by fixTick(BlockState, Level, BlockPos)
    • getCenter

      static net.minecraft.core.BlockPos getCenter(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos)
      Returns the center BlockPos of the multiblock
    • isCenter

      static boolean isCenter(net.minecraft.world.level.LevelReader level, net.minecraft.core.BlockPos pos)
    • isCenter

      static boolean isCenter(net.minecraft.world.level.block.state.BlockState state)
    • isMultiblock

      static boolean isMultiblock(net.minecraft.world.level.block.state.BlockState state)
    • isMultiblock

      static boolean isMultiblock(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos)
    • getXOffset

      static int getXOffset(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos)
    • getYOffset

      static int getYOffset(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos)
    • getZOffset

      static int getZOffset(net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos)
    • voxelShapeHelper

      default net.minecraft.world.phys.shapes.VoxelShape voxelShapeHelper(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.phys.shapes.VoxelShape shape)
    • voxelShapeHelper

      default net.minecraft.world.phys.shapes.VoxelShape voxelShapeHelper(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.phys.shapes.VoxelShape shape, float xOffset, float yOffset, float zOffset)
    • voxelShapeHelper

      default net.minecraft.world.phys.shapes.VoxelShape voxelShapeHelper(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.BlockGetter level, net.minecraft.core.BlockPos pos, net.minecraft.world.phys.shapes.VoxelShape shape, float xOffset, float yOffset, float zOffset, boolean hasDirectionOffsets)
      Offsets each Blocks VoxelShape to the center, allowing for VoxelShapes larger than 1 block
      Parameters:
      hasDirectionOffsets - Larger directional multiblocks may have their center in a different point for every rotation, this offsets the VoxelShapes accordingly
    • growHelper

      default void growHelper(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.properties.IntegerProperty ageProperty)
      Increases age in each block at the same time

      If used in the randomTick method, don't forget to check isCenter(BlockState) first, otherwise the block will grow significantly faster (each block tick separately)

    • getMaxAge

      default int getMaxAge(net.minecraft.world.level.block.state.properties.IntegerProperty ageProperty)