Package net.liukrast.multipart.block
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:
net.minecraft.world.flag.FeatureElement,net.minecraft.world.level.ItemLike,net.neoforged.neoforge.common.extensions.IBlockExtension
- Direct Known Subclasses:
AbstractFacingMultipartBlock
public abstract class AbstractMultipartBlock
extends net.minecraft.world.level.block.Block
Abstract class for multipart blocks composed of multiple parts
positioned relative to each other.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder 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.BlockStatePairKeyNested 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_DROPSFields inherited from class net.minecraft.world.level.block.state.BlockBehaviour
drops, dynamicShape, explosionResistance, friction, hasCollision, isRandomlyTicking, jumpFactor, properties, requiredFeatures, soundType, speedFactor, UPDATE_SHAPE_ORDERFields inherited from interface net.minecraft.world.flag.FeatureElement
FILTERED_REGISTRIES -
Constructor Summary
ConstructorsConstructorDescriptionAbstractMultipartBlock(net.minecraft.world.level.block.state.BlockBehaviour.Properties properties) Constructor for the block. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanSurvive(@NotNull net.minecraft.world.level.block.state.BlockState state, @NotNull net.minecraft.world.level.LevelReader level, @NotNull net.minecraft.core.BlockPos pos) protected voidcreateBlockStateDefinition(net.minecraft.world.level.block.state.StateDefinition.Builder<net.minecraft.world.level.block.Block, net.minecraft.world.level.block.state.BlockState> builder) abstract voidAbstract method to define the relative positions of the block parts.voiddestroy(@NotNull net.minecraft.world.level.LevelAccessor level, @NotNull net.minecraft.core.BlockPos pos, @NotNull net.minecraft.world.level.block.state.BlockState state) 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.net.minecraft.core.DirectiongetDirection(net.minecraft.world.level.block.state.BlockState state) Returns the direction of the block.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.IntegerPropertyReturns the integer property representing the part of the block.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.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) intsize()Returns the total number of parts composing the multipart block.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, withPropertiesOfMethods 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, useWithoutItemMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.world.flag.FeatureElement
isEnabledMethods 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
-
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
-
defineParts
Abstract method to define the relative positions of the block parts.- Parameters:
builder- the builder used to define positions.
-
getDirection
public 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).
-
getPartsProperty
public net.minecraft.world.level.block.state.properties.IntegerProperty getPartsProperty()Returns the integer property representing the part of the block.- Returns:
- the IntegerProperty associated with the parts.
-
setPlacedBy
public 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) - Overrides:
setPlacedByin classnet.minecraft.world.level.block.Block
-
getOrigin
public 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
public 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
public 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
protected void createBlockStateDefinition(net.minecraft.world.level.block.state.StateDefinition.Builder<net.minecraft.world.level.block.Block, net.minecraft.world.level.block.state.BlockState> builder) - Overrides:
createBlockStateDefinitionin classnet.minecraft.world.level.block.Block
-
canSurvive
protected 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) - Overrides:
canSurvivein classnet.minecraft.world.level.block.state.BlockBehaviour
-
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) - Overrides:
destroyin classnet.minecraft.world.level.block.Block
-
size
public int size()Returns the total number of parts composing the multipart block.- Returns:
- the number of parts.
-