public interface Multiblock
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.world.level.block.state.properties.BooleanProperty
     
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    afterFormBlock(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos blockPos, net.minecraft.core.BlockPos controllerPos, int layerIndex, int layoutIndex, MultiblockData multiblockData, @Nullable net.minecraft.world.entity.player.Player player)
    This method is called after the block is formed.
    default void
    afterUnformBlock(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos blockPos, net.minecraft.core.BlockPos controllerPos, int layerIndex, int layoutIndex, HorizontalDirection direction, @Nullable net.minecraft.world.entity.player.Player player)
    This method is called after the block is unformed.
    default boolean
    form(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos controllerPos)
     
    default boolean
    form(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos controllerPos, @Nullable net.minecraft.world.entity.player.Player player)
     
    @Nullable net.minecraft.world.level.block.state.BlockState
    formBlock(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos blockPos, net.minecraft.core.BlockPos controllerPos, int layerIndex, int layoutIndex, MultiblockData multiblockData, @Nullable net.minecraft.world.entity.player.Player player)
    This method is used to form a block.
    This method provides a definition map that can be used to look up an integer key in getLayout() and will return a block.
    default @Nullable HorizontalDirection
    This method can make the direction of this multiblock fixed.
    net.minecraft.world.level.block.Block
    This method provides the controller block of your formed multiblock.
    This method provides the layout of your unformed multiblock.
    default int
    This method provides the maximum possible size for this multiblock.
    net.minecraft.world.level.block.entity.BlockEntityType<? extends MultiblockEntity>
    This method provides the block entity resource for the controller of your multiblock.
    net.minecraft.world.level.block.Block
    This method provides the controller block of your unformed multiblock.
    default List<it.unimi.dsi.fastutil.ints.IntIntPair>
    This method provides a list of widths for every layer of your multiblock.
    boolean
    isFormed(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos blockPos)
    This method determines whether the block at the specified position is a formed part of this multiblock.
    layer(int... layer)
    Create a new layer for your multiblock
    default boolean
    unform(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos controllerPos)
     
    default boolean
    unform(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos controllerPos, @Nullable net.minecraft.world.entity.player.Player player)
     
    default net.minecraft.world.level.block.state.BlockState
    unformBlock(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos blockPos, net.minecraft.core.BlockPos controllerPos, int layerIndex, int layoutIndex, MultiblockData multiblockData, @Nullable net.minecraft.world.entity.player.Player player)
     
  • Field Details

    • FORMED

      static final net.minecraft.world.level.block.state.properties.BooleanProperty FORMED
  • Method Details

    • getUnformedController

      net.minecraft.world.level.block.Block getUnformedController()
      This method provides the controller block of your unformed multiblock. Your multiblock needs at least one of these in its structure.

      Returns:
      The controller block of your unformed multiblock
    • getFormedController

      net.minecraft.world.level.block.Block getFormedController()
      This method provides the controller block of your formed multiblock. Your multiblock needs at least one of these in its structure.

      Returns:
      The controller block of your formed multiblock
    • getLayout

      MultiblockLayer[] getLayout()
      This method provides the layout of your unformed multiblock.
      It consists of an array of multiblock layers. Each layer is constructed with a method call.
      For this, you can use layer(int...)
      Each of these methods ask you to provide you a list of integers. These integers represent the actual blocks used. Nonetheless, you still need to provide the actual blocks using the getDefinition() method. This provides the minimum and maximum height for this multiblock.
      Example: IntegerRange.of(1, 3)

      Note: The first layer in this array also represents the bottom layer of the multiblock
      Returns:
      An array of multiblock layers that describes the layout of the multiblock
    • getDefinition

      MultiblockDefinition getDefinition()
      This method provides a definition map that can be used to look up an integer key in getLayout() and will return a block.

      The keyset of this map needs to include every key that is used in getLayout().

      The values of this map need to contain the block for each integer key. If you do not care about a block you can use null instead of a value.
      Returns:
      The integer to block map that provides the integer keys and their block values
    • getMultiBlockEntityType

      net.minecraft.world.level.block.entity.BlockEntityType<? extends MultiblockEntity> getMultiBlockEntityType()
      This method provides the block entity resource for the controller of your multiblock.
      Returns:
      the blockentity resource of your controllers blockentity
    • getWidths

      default List<it.unimi.dsi.fastutil.ints.IntIntPair> getWidths()
      This method provides a list of widths for every layer of your multiblock.

      This method has a default implementation meaning that you do not have to override it, unless one of your multiblock layers is not quadratic. (And it's width can therefore not be determined by getting the square root of the integer arrays length)

      The size of this list needs to be getMaxSize() and needs to contain the widths for every possible layer, this also includes dynamic layers.
      Returns:
      a list of integer pairs where left is the x- and right is the z-width
    • formBlock

      @Nullable @Nullable net.minecraft.world.level.block.state.BlockState formBlock(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos blockPos, net.minecraft.core.BlockPos controllerPos, int layerIndex, int layoutIndex, MultiblockData multiblockData, @Nullable @Nullable net.minecraft.world.entity.player.Player player)
      This method is used to form a block. It is called for that block and also when unforming the multi. This is why this should only return the blockState, not perform any interactions on the level/player.... For interactions with the world/player..., use afterFormBlock(Level, BlockPos, BlockPos, int, int, MultiblockData, Player)
      Parameters:
      level - Level of the multiblock, should only be used for reading things, not setting new things.
      blockPos - BlockPos of the block that is being formed
      controllerPos - BlockPos of this multiblocks controller
      layerIndex - index of the current layers block (array of integer)
      layoutIndex - index of the current multiblock layer (array of multiblock layer)
      multiblockData - Information about the unformed multiblock, like the layers of the concrete multiblock and the direction it is formed in.
      player - Player that is trying to form this multiblock. Note that there does not necessarily have to be a player that is responsible for forming the multiblock
      Returns:
      Formed BlockState. This will replace the unformed block in the multiblock. Return null if you do not want to change the block.
    • unformBlock

      default net.minecraft.world.level.block.state.BlockState unformBlock(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos blockPos, net.minecraft.core.BlockPos controllerPos, int layerIndex, int layoutIndex, MultiblockData multiblockData, @Nullable @Nullable net.minecraft.world.entity.player.Player player)
    • afterFormBlock

      default void afterFormBlock(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos blockPos, net.minecraft.core.BlockPos controllerPos, int layerIndex, int layoutIndex, MultiblockData multiblockData, @Nullable @Nullable net.minecraft.world.entity.player.Player player)
      This method is called after the block is formed. It can be used to interact with the level/player... as it is only called, when the multiblock is formed.
      Parameters:
      level - Level of the multiblock
      blockPos - BlockPos of the block that is being formed
      controllerPos - BlockPos of this multiblocks controller
      layerIndex - index of the current layers block (array of integer)
      layoutIndex - index of the current multiblock layer (array of multiblock layer)
      multiblockData - Information about the unformed multiblock, like the layers of the concrete multiblock and the direction it is formed in.
      player - Player that is trying to form this multiblock. Note that there does not necessarily have to be a player that is responsible for forming the multiblock
    • afterUnformBlock

      default void afterUnformBlock(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos blockPos, net.minecraft.core.BlockPos controllerPos, int layerIndex, int layoutIndex, HorizontalDirection direction, @Nullable @Nullable net.minecraft.world.entity.player.Player player)
      This method is called after the block is unformed. It can be used to interact with the level/player... as it is only called, when the multiblock is unformed.
      Parameters:
      level - Level of the multiblock
      blockPos - BlockPos of the block that is being unformed
      controllerPos - BlockPos of this multiblocks controller
      layerIndex - index of the current layers block (array of integer)
      layoutIndex - index of the current multiblock layer (array of multiblock layer)
      direction - Direction of the multiblock
      player - Player that is trying to unform this multiblock. Note that there does not necessarily have to be a player that is responsible for unforming the multiblock
    • isFormed

      boolean isFormed(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos blockPos)
      This method determines whether the block at the specified position is a formed part of this multiblock.
      Parameters:
      level - Level of the multiblock
      blockPos - BlockPos that needs to be checked if it is formed.
      Returns:
      Whether the block at this position is formed
    • getFixedDirection

      @Nullable default @Nullable HorizontalDirection getFixedDirection()
      This method can make the direction of this multiblock fixed. This only works, if the multiblock cannot be rotated, like the crucible or firebox. Providing a fixed direction can improve performance while forming the multiblock by a bit.
      Returns:
      a horizontal direction, if the direction can be fixed.
    • getMaxSize

      default int getMaxSize()
      This method provides the maximum possible size for this multiblock.
      Returns:
      the maximum possible size
    • layer

      default MultiblockLayer layer(int... layer)
      Create a new layer for your multiblock
      Parameters:
      layer - The block indices for your multiblock layer
      Returns:
      the newly created layer
    • unform

      default boolean unform(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos controllerPos)
    • unform

      default boolean unform(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos controllerPos, @Nullable @Nullable net.minecraft.world.entity.player.Player player)
    • form

      default boolean form(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos controllerPos)
    • form

      default boolean form(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos controllerPos, @Nullable @Nullable net.minecraft.world.entity.player.Player player)