Interface IMultipartBlock

All Known Implementing Classes:
AbstractFacingMultipartBlock, AbstractMultipartBlock, ExampleFacingMultipartBlock, ExampleMultipartBlock

public interface IMultipartBlock
Unimplemented version of AbstractMultipartBlock. You will have to introduce
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    canSurvive(@NotNull net.minecraft.world.level.block.state.BlockState state, @NotNull net.minecraft.world.level.LevelReader level, @NotNull net.minecraft.core.BlockPos pos)
    Boilerplate method to override BlockBehaviour.canSurvive(BlockState, LevelReader, BlockPos)
    default void
    createBlockStateDefinition$multipart(net.minecraft.world.level.block.state.StateDefinition.Builder<net.minecraft.world.level.block.Block,net.minecraft.world.level.block.state.BlockState> builder)
    Boilerplate method to create the blockstate definition.
    void
    Abstract method to define the relative positions of the block parts.
    default void
    destroy(@NotNull net.minecraft.world.level.LevelAccessor level, @NotNull net.minecraft.core.BlockPos pos, @NotNull net.minecraft.world.level.block.state.BlockState state)
    Boilerplate method to override Block.destroy(LevelAccessor, BlockPos, BlockState)
    default void
    forEachElement(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, Consumer<net.minecraft.core.BlockPos> consumer)
    Performs an operation on every part of the multipart block.
    default net.minecraft.core.Direction
    getDirection(net.minecraft.world.level.block.state.BlockState state)
    Returns the direction of the block.
    default net.minecraft.core.BlockPos
    getOrigin(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos statePos, net.minecraft.core.Direction direction)
    Calculates the origin position of the multipart given a position and direction.
    net.minecraft.world.level.block.state.properties.IntegerProperty
    Gives you the IntegerProperty of this precise multipart block
    List<net.minecraft.core.BlockPos>
    It should not be used anywhere, only overwritten; If you're trying to access the size use size()
    default net.minecraft.core.BlockPos
    getRelative(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos statePos, net.minecraft.core.Direction direction)
    Calculates the relative position of a part from the origin.
    void
    setPartsProperty(net.minecraft.world.level.block.state.properties.IntegerProperty property)
    Sets the property.
    default void
    setPlacedBy(@NotNull net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, @NotNull net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.entity.LivingEntity placer, @NotNull net.minecraft.world.item.ItemStack stack)
    Boilerplate method to override Block.setPlacedBy(Level, BlockPos, BlockState, LivingEntity, ItemStack)
    void
    setPositions(List<net.minecraft.core.BlockPos> positions)
    Internally sets the position list to your implemented code.
    default int
    Returns the total number of parts composing the multipart block.
  • Method Details

    • defineParts

      void defineParts(AbstractMultipartBlock.Builder builder)
      Abstract method to define the relative positions of the block parts.
      Parameters:
      builder - the builder used to define positions.
    • getDirection

      default net.minecraft.core.Direction getDirection(net.minecraft.world.level.block.state.BlockState state)
      Returns the direction of the block.
      Parameters:
      state - the block state.
      Returns:
      the block direction (default NORTH).
    • getPositions

      @OverrideOnly List<net.minecraft.core.BlockPos> getPositions()
      It should not be used anywhere, only overwritten; If you're trying to access the size use size()
      Returns:
      the positions you internally stored. See AbstractMultipartBlock.positions
    • setPositions

      @OverrideOnly void setPositions(List<net.minecraft.core.BlockPos> positions)
      Internally sets the position list to your implemented code. It should not be used anywhere, only overwritten
      Parameters:
      positions - positions the API is trying to set, which your code stored internally. See AbstractMultipartBlock.positions
    • getPartsProperty

      net.minecraft.world.level.block.state.properties.IntegerProperty getPartsProperty()
      Gives you the IntegerProperty of this precise multipart block
      Returns:
      the IntegerProperty associated with the parts.
    • setPartsProperty

      @OverrideOnly void setPartsProperty(net.minecraft.world.level.block.state.properties.IntegerProperty property)
      Sets the property. You should not use this, only override it, to set a variable internally like AbstractMultipartBlock.property
      Parameters:
      property - the properties to be set
    • setPlacedBy

      default void setPlacedBy(@NotNull @NotNull net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, @NotNull @NotNull net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.entity.LivingEntity placer, @NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Boilerplate method to override Block.setPlacedBy(Level, BlockPos, BlockState, LivingEntity, ItemStack)
      Parameters:
      level - the level
      pos - the block position
      state - the block state
      placer - the block placer
      stack - the item stack used by the placer
    • getOrigin

      default net.minecraft.core.BlockPos getOrigin(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos statePos, net.minecraft.core.Direction direction)
      Calculates the origin position of the multipart given a position and direction.
      Parameters:
      pos - the reference position.
      statePos - the relative part position.
      direction - the block direction.
      Returns:
      the origin position in the world.
    • getRelative

      default net.minecraft.core.BlockPos getRelative(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos statePos, net.minecraft.core.Direction direction)
      Calculates the relative position of a part from the origin.
      Parameters:
      pos - the origin position.
      statePos - the relative part position.
      direction - the block direction.
      Returns:
      the relative position in the world.
    • forEachElement

      default void forEachElement(net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, Consumer<net.minecraft.core.BlockPos> consumer)
      Performs an operation on every part of the multipart block.
      Parameters:
      pos - the block position.
      state - the block state.
      consumer - the operation to perform on each part position.
    • createBlockStateDefinition$multipart

      default void createBlockStateDefinition$multipart(net.minecraft.world.level.block.state.StateDefinition.Builder<net.minecraft.world.level.block.Block,net.minecraft.world.level.block.state.BlockState> builder)
      Boilerplate method to create the blockstate definition.
      Parameters:
      builder - the block state builder
    • canSurvive

      default boolean canSurvive(@NotNull @NotNull net.minecraft.world.level.block.state.BlockState state, @NotNull @NotNull net.minecraft.world.level.LevelReader level, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Boilerplate method to override BlockBehaviour.canSurvive(BlockState, LevelReader, BlockPos)
      Parameters:
      state - the blockstate
      level - the level
      pos - the block pos
      Returns:
      whether the block can survive or not at that position. Will check for all other blocks of the multipart
    • destroy

      default void destroy(@NotNull @NotNull net.minecraft.world.level.LevelAccessor level, @NotNull @NotNull net.minecraft.core.BlockPos pos, @NotNull @NotNull net.minecraft.world.level.block.state.BlockState state)
      Boilerplate method to override Block.destroy(LevelAccessor, BlockPos, BlockState)
      Parameters:
      level - the level
      pos - the block position
      state - the block state
    • size

      default int size()
      Returns the total number of parts composing the multipart block.
      Returns:
      the number of parts.