Package net.liukrast.multipart.block
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 TypeMethodDescriptiondefault booleancanSurvive(@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 overrideBlockBehaviour.canSurvive(BlockState, LevelReader, BlockPos)default voidcreateBlockStateDefinition$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.voidAbstract method to define the relative positions of the block parts.default voiddestroy(@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 overrideBlock.destroy(LevelAccessor, BlockPos, BlockState)default voidforEachElement(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.DirectiongetDirection(net.minecraft.world.level.block.state.BlockState state) Returns the direction of the block.default net.minecraft.core.BlockPosgetOrigin(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.IntegerPropertyGives you the IntegerProperty of this precise multipart blockList<net.minecraft.core.BlockPos> It should not be used anywhere, only overwritten; If you're trying to access the size usesize()default net.minecraft.core.BlockPosgetRelative(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.voidsetPartsProperty(net.minecraft.world.level.block.state.properties.IntegerProperty property) Sets the property.default voidsetPlacedBy(@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 overrideBlock.setPlacedBy(Level, BlockPos, BlockState, LivingEntity, ItemStack)voidsetPositions(List<net.minecraft.core.BlockPos> positions) Internally sets the position list to your implemented code.default intsize()Returns the total number of parts composing the multipart block.
-
Method Details
-
defineParts
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
It should not be used anywhere, only overwritten; If you're trying to access the size usesize()- Returns:
- the positions you internally stored. See
AbstractMultipartBlock.positions
-
setPositions
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. SeeAbstractMultipartBlock.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 likeAbstractMultipartBlock.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 overrideBlock.setPlacedBy(Level, BlockPos, BlockState, LivingEntity, ItemStack)- Parameters:
level- the levelpos- the block positionstate- the block stateplacer- the block placerstack- 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 overrideBlockBehaviour.canSurvive(BlockState, LevelReader, BlockPos)- Parameters:
state- the blockstatelevel- the levelpos- 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 overrideBlock.destroy(LevelAccessor, BlockPos, BlockState)- Parameters:
level- the levelpos- the block positionstate- the block state
-
size
default int size()Returns the total number of parts composing the multipart block.- Returns:
- the number of parts.
-