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:
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 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 TypeMethodDescriptionbooleancanSurvive(@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)protected voidcreateBlockStateDefinition(@NotNull net.minecraft.world.level.block.state.StateDefinition.Builder<net.minecraft.world.level.block.Block, net.minecraft.world.level.block.state.BlockState> builder) 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)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 useIMultipartBlock.size()voidsetPartsProperty(net.minecraft.world.level.block.state.properties.IntegerProperty property) Sets the property.voidsetPlacedBy(@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 overrideBlock.setPlacedBy(Level, BlockPos, BlockState, LivingEntity, ItemStack)voidsetPositions(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, 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, supportsExternalFaceHidingMethods 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
Description copied from interface:IMultipartBlockIt should not be used anywhere, only overwritten; If you're trying to access the size useIMultipartBlock.size()- Specified by:
getPositionsin interfaceIMultipartBlock- Returns:
- the positions you internally stored. See
positions
-
setPositions
Description copied from interface:IMultipartBlockInternally sets the position list to your implemented code. It should not be used anywhere, only overwritten- Specified by:
setPositionsin interfaceIMultipartBlock- Parameters:
positions- positions the API is trying to set, which your code stored internally. Seepositions
-
getPartsProperty
public net.minecraft.world.level.block.state.properties.IntegerProperty getPartsProperty()Description copied from interface:IMultipartBlockGives you the IntegerProperty of this precise multipart block- Specified by:
getPartsPropertyin interfaceIMultipartBlock- Returns:
- the IntegerProperty associated with the parts.
-
setPartsProperty
public void setPartsProperty(net.minecraft.world.level.block.state.properties.IntegerProperty property) Description copied from interface:IMultipartBlockSets the property. You should not use this, only override it, to set a variable internally likeproperty- Specified by:
setPartsPropertyin interfaceIMultipartBlock- 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:IMultipartBlockBoilerplate method to overrideBlock.setPlacedBy(Level, BlockPos, BlockState, LivingEntity, ItemStack)- Specified by:
setPlacedByin interfaceIMultipartBlock- Overrides:
setPlacedByin classnet.minecraft.world.level.block.Block- Parameters:
level- the levelpos- the block positionstate- the block stateplacer- the block placerstack- 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:
createBlockStateDefinitionin classnet.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:IMultipartBlockBoilerplate method to overrideBlockBehaviour.canSurvive(BlockState, LevelReader, BlockPos)- Specified by:
canSurvivein interfaceIMultipartBlock- Overrides:
canSurvivein classnet.minecraft.world.level.block.state.BlockBehaviour- 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
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:IMultipartBlockBoilerplate method to overrideBlock.destroy(LevelAccessor, BlockPos, BlockState)- Specified by:
destroyin interfaceIMultipartBlock- Overrides:
destroyin classnet.minecraft.world.level.block.Block- Parameters:
level- the levelpos- the block positionstate- the block state
-