Class AbstractMultipartBlock

java.lang.Object
net.minecraft.world.level.block.state.BlockBehaviour
net.minecraft.world.level.block.Block
net.liukrast.multipart.block.AbstractMultipartBlock
All Implemented Interfaces:
IMultipartBlock, net.minecraft.world.flag.FeatureElement, net.minecraft.world.level.ItemLike, net.neoforged.neoforge.common.extensions.IBlockExtension
Direct Known Subclasses:
AbstractFacingMultipartBlock, ExampleMultipartBlock

public abstract class AbstractMultipartBlock extends net.minecraft.world.level.block.Block implements IMultipartBlock
Implementation of IMultipartBlock Most cases do not need you to implement the interface, but to use this abstract class instead If you want to see an example implementation, check ExampleMultipartBlock
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Builder to define relative positions of multipart block parts.

    Nested classes/interfaces inherited from class net.minecraft.world.level.block.Block

    net.minecraft.world.level.block.Block.BlockStatePairKey

    Nested classes/interfaces inherited from class net.minecraft.world.level.block.state.BlockBehaviour

    net.minecraft.world.level.block.state.BlockBehaviour.BlockStateBase, net.minecraft.world.level.block.state.BlockBehaviour.OffsetFunction, net.minecraft.world.level.block.state.BlockBehaviour.OffsetType, net.minecraft.world.level.block.state.BlockBehaviour.Properties, net.minecraft.world.level.block.state.BlockBehaviour.StateArgumentPredicate<A>, net.minecraft.world.level.block.state.BlockBehaviour.StatePredicate
  • Field Summary

    Fields inherited from class net.minecraft.world.level.block.Block

    BLOCK_STATE_REGISTRY, CODEC, INDESTRUCTIBLE, INSTANT, stateDefinition, UPDATE_ALL, UPDATE_ALL_IMMEDIATE, UPDATE_CLIENTS, UPDATE_IMMEDIATE, UPDATE_INVISIBLE, UPDATE_KNOWN_SHAPE, UPDATE_LIMIT, UPDATE_MOVE_BY_PISTON, UPDATE_NEIGHBORS, UPDATE_NONE, UPDATE_SUPPRESS_DROPS

    Fields inherited from class net.minecraft.world.level.block.state.BlockBehaviour

    drops, dynamicShape, explosionResistance, friction, hasCollision, isRandomlyTicking, jumpFactor, properties, requiredFeatures, soundType, speedFactor, UPDATE_SHAPE_ORDER

    Fields inherited from interface net.minecraft.world.flag.FeatureElement

    FILTERED_REGISTRIES
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractMultipartBlock(net.minecraft.world.level.block.state.BlockBehaviour.Properties properties)
    Constructor for the block.
  • Method Summary

    Modifier and Type
    Method
    Description
    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)
    protected void
    createBlockStateDefinition(@NotNull net.minecraft.world.level.block.state.StateDefinition.Builder<net.minecraft.world.level.block.Block,net.minecraft.world.level.block.state.BlockState> builder)
     
    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)
    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 IMultipartBlock.size()
    void
    setPartsProperty(net.minecraft.world.level.block.state.properties.IntegerProperty property)
    Sets the property.
    void
    setPlacedBy(@NotNull net.minecraft.world.level.Level level, @NotNull 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.

    Methods inherited from class net.minecraft.world.level.block.Block

    animateTick, appendHoverText, asBlock, asItem, box, builtInRegistryHolder, byItem, canSupportCenter, canSupportRigidBlock, codec, defaultBlockState, dropFromExplosion, dropResources, dropResources, dropResources, fallOn, getCloneItemStack, getDescriptionId, getDrops, getDrops, getExplosionResistance, getFriction, getId, getJumpFactor, getName, getShapeForEachState, getSpeedFactor, getStateDefinition, getStateForPlacement, handlePrecipitation, hasDynamicShape, initializeClient, isExceptionForConnection, isFaceFull, isPossibleToRespawnInThis, isShapeFullBlock, playerDestroy, playerWillDestroy, popExperience, popResource, popResourceFromFace, pushEntitiesUp, registerDefaultState, shouldRenderFace, spawnDestroyParticles, stateById, stepOn, toString, tryDropExperience, updateEntityAfterFallOn, updateFromNeighbourShapes, updateOrDestroy, updateOrDestroy, wasExploded, withPropertiesOf

    Methods inherited from class net.minecraft.world.level.block.state.BlockBehaviour

    attack, canBeReplaced, canBeReplaced, defaultDestroyTime, defaultMapColor, entityInside, getAnalogOutputSignal, getBlockSupportShape, getCollisionShape, getDestroyProgress, getDirectSignal, getDrops, getFluidState, getInteractionShape, getLightBlock, getLootTable, getMaxHorizontalOffset, getMaxVerticalOffset, getMenuProvider, getOcclusionShape, getRenderShape, getSeed, getShadeBrightness, getShape, getSignal, getSoundType, getVisualShape, hasAnalogOutputSignal, isAir, isCollisionShapeFullBlock, isOcclusionShapeFullBlock, isPathfindable, isRandomlyTicking, isSignalSource, mirror, neighborChanged, onExplosionHit, onPlace, onProjectileHit, onRemove, propagatesSkylightDown, properties, propertiesCodec, randomTick, requiredFeatures, rotate, simpleCodec, skipRendering, spawnAfterBreak, tick, triggerEvent, updateIndirectNeighbourShapes, updateShape, useItemOn, useShapeForLightOcclusion, useWithoutItem

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface net.minecraft.world.flag.FeatureElement

    isEnabled

    Methods inherited from interface net.neoforged.neoforge.common.extensions.IBlockExtension

    addLandingEffects, addRunningEffects, canBeHydrated, canConnectRedstone, canDropFromExplosion, canEntityDestroy, canHarvestBlock, canStickTo, canSustainPlant, collisionExtendsVertically, getAdjacentBlockPathType, getAppearance, getBeaconColorMultiplier, getBedDirection, getBlockPathType, getBubbleColumnDirection, getCloneItemStack, getEnchantPowerBonus, getExpDrop, getExplosionResistance, getFireSpreadSpeed, getFlammability, getFriction, getLightEmission, getMapColor, getPistonPushReaction, getRespawnPosition, getSoundType, getStateAtViewpoint, getToolModifiedState, getWeakChanges, hasDynamicLightEmission, hidesNeighborFace, isBed, isBurning, isConduitFrame, isEmpty, isFertile, isFireSource, isFlammable, isLadder, isPortalFrame, isScaffolding, isSlimeBlock, isStickyBlock, makesOpenTrapdoorAboveClimbable, onBlockExploded, onBlockStateChange, onCaughtFire, onDestroyedByPlayer, onDestroyedByPushReaction, onNeighborChange, onTreeGrow, rotate, setBedOccupied, shouldCheckWeakPower, shouldDisplayFluidOverlay, shouldHideAdjacentFluidFace, supportsExternalFaceHiding

    Methods inherited from interface net.liukrast.multipart.block.IMultipartBlock

    createBlockStateDefinition$multipart, defineParts, forEachElement, getDirection, getOrigin, getRelative, size
  • Constructor Details

    • AbstractMultipartBlock

      public AbstractMultipartBlock(net.minecraft.world.level.block.state.BlockBehaviour.Properties properties)
      Constructor for the block.
      Parameters:
      properties - the block properties.
  • Method Details

    • getPositions

      public List<net.minecraft.core.BlockPos> getPositions()
      Description copied from interface: IMultipartBlock
      It should not be used anywhere, only overwritten; If you're trying to access the size use IMultipartBlock.size()
      Specified by:
      getPositions in interface IMultipartBlock
      Returns:
      the positions you internally stored. See positions
    • setPositions

      public void setPositions(List<net.minecraft.core.BlockPos> positions)
      Description copied from interface: IMultipartBlock
      Internally sets the position list to your implemented code. It should not be used anywhere, only overwritten
      Specified by:
      setPositions in interface IMultipartBlock
      Parameters:
      positions - positions the API is trying to set, which your code stored internally. See positions
    • getPartsProperty

      public net.minecraft.world.level.block.state.properties.IntegerProperty getPartsProperty()
      Description copied from interface: IMultipartBlock
      Gives you the IntegerProperty of this precise multipart block
      Specified by:
      getPartsProperty in interface IMultipartBlock
      Returns:
      the IntegerProperty associated with the parts.
    • setPartsProperty

      public void setPartsProperty(net.minecraft.world.level.block.state.properties.IntegerProperty property)
      Description copied from interface: IMultipartBlock
      Sets the property. You should not use this, only override it, to set a variable internally like property
      Specified by:
      setPartsProperty in interface IMultipartBlock
      Parameters:
      property - the properties to be set
    • setPlacedBy

      public void setPlacedBy(@NotNull @NotNull net.minecraft.world.level.Level level, @NotNull @NotNull 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)
      Description copied from interface: IMultipartBlock
      Boilerplate method to override Block.setPlacedBy(Level, BlockPos, BlockState, LivingEntity, ItemStack)
      Specified by:
      setPlacedBy in interface IMultipartBlock
      Overrides:
      setPlacedBy in class net.minecraft.world.level.block.Block
      Parameters:
      level - the level
      pos - the block position
      state - the block state
      placer - the block placer
      stack - the item stack used by the placer
    • createBlockStateDefinition

      protected void createBlockStateDefinition(@NotNull net.minecraft.world.level.block.state.StateDefinition.Builder<net.minecraft.world.level.block.Block,net.minecraft.world.level.block.state.BlockState> builder)
      Overrides:
      createBlockStateDefinition in class net.minecraft.world.level.block.Block
    • canSurvive

      public 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)
      Description copied from interface: IMultipartBlock
      Boilerplate method to override BlockBehaviour.canSurvive(BlockState, LevelReader, BlockPos)
      Specified by:
      canSurvive in interface IMultipartBlock
      Overrides:
      canSurvive in class net.minecraft.world.level.block.state.BlockBehaviour
      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

      public 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)
      Description copied from interface: IMultipartBlock
      Boilerplate method to override Block.destroy(LevelAccessor, BlockPos, BlockState)
      Specified by:
      destroy in interface IMultipartBlock
      Overrides:
      destroy in class net.minecraft.world.level.block.Block
      Parameters:
      level - the level
      pos - the block position
      state - the block state