Class BlockBehaviour
java.lang.Object
net.minecraft.world.level.block.state.BlockBehaviour
- All Implemented Interfaces:
FeatureElement
- Direct Known Subclasses:
Block
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfacestatic enumstatic classstatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ResourceKey<LootTable> protected final booleanprotected final floatprotected final floatDetermines how much velocity is maintained while moving on top of this blockprotected final booleanprotected final booleanWhether this blocks receives random ticksprotected final floatprivate final Supplier<ResourceKey<LootTable>> protected final BlockBehaviour.Propertiesprotected final FeatureFlagSetprotected final SoundTypeprotected final floatprotected static final Direction[]Fields inherited from interface net.minecraft.world.flag.FeatureElement
FILTERED_REGISTRIES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract BlockasBlock()abstract ItemasItem()protected voidattack(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer) protected booleancanBeReplaced(BlockState pState, BlockPlaceContext pUseContext) protected booleancanBeReplaced(BlockState pState, Fluid pFluid) protected booleancanSurvive(BlockState pState, LevelReader pLevel, BlockPos pPos) protected abstract com.mojang.serialization.MapCodec<? extends Block> codec()floatprotected voidentityInside(BlockState pState, Level pLevel, BlockPos pPos, Entity pEntity) protected intgetAnalogOutputSignal(BlockState pState, Level pLevel, BlockPos pPos) Returns the analog signal this block emits.protected VoxelShapegetBlockSupportShape(BlockState pState, BlockGetter pLevel, BlockPos pPos) protected VoxelShapegetCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) protected floatgetDestroyProgress(BlockState pState, Player pPlayer, BlockGetter pLevel, BlockPos pPos) Get the hardness of this Block relative to the ability of the given playerprotected intgetDirectSignal(BlockState pState, BlockGetter pLevel, BlockPos pPos, Direction pDirection) Returns the direct signal this block emits in the given direction.getDrops(BlockState pState, LootParams.Builder pParams) protected FluidStategetFluidState(BlockState pState) protected VoxelShapegetInteractionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos) protected intgetLightBlock(BlockState pState, BlockGetter pLevel, BlockPos pPos) final ResourceKey<LootTable> protected floatprotected floatprotected MenuProvidergetMenuProvider(BlockState pState, Level pLevel, BlockPos pPos) protected VoxelShapegetOcclusionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos) protected RenderShapegetRenderShape(BlockState pState) The type of render function called.protected longgetSeed(BlockState pState, BlockPos pPos) Return a random long to be passed toBakedModel.getQuads(net.minecraft.world.level.block.state.BlockState, net.minecraft.core.Direction, net.minecraft.util.RandomSource), used for random model rotationsprotected floatgetShadeBrightness(BlockState pState, BlockGetter pLevel, BlockPos pPos) protected VoxelShapegetShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) protected intgetSignal(BlockState pState, BlockGetter pLevel, BlockPos pPos, Direction pDirection) Returns the signal this block emits in the given direction.protected SoundTypegetSoundType(BlockState pState) Deprecated.protected VoxelShapegetVisualShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) protected booleanhasAnalogOutputSignal(BlockState pState) protected booleanisAir(BlockState state) protected booleanisCollisionShapeFullBlock(BlockState pState, BlockGetter pLevel, BlockPos pPos) protected booleanisOcclusionShapeFullBlock(BlockState pState, BlockGetter pLevel, BlockPos pPos) protected booleanisPathfindable(BlockState pState, PathComputationType pPathComputationType) protected booleanisRandomlyTicking(BlockState pState) protected booleanisSignalSource(BlockState pState) Returns whether this block is capable of emitting redstone signals.protected BlockStatemirror(BlockState pState, Mirror pMirror) Returns the blockstate with the given mirror of the passed blockstate.protected voidneighborChanged(BlockState pState, Level pLevel, BlockPos pPos, Block pNeighborBlock, BlockPos pNeighborPos, boolean pMovedByPiston) protected voidonExplosionHit(BlockState pState, Level pLevel, BlockPos pPos, Explosion pExplosion, BiConsumer<ItemStack, BlockPos> pDropConsumer) protected voidonPlace(BlockState pState, Level pLevel, BlockPos pPos, BlockState pOldState, boolean pMovedByPiston) protected voidonProjectileHit(Level pLevel, BlockState pState, BlockHitResult pHit, Projectile pProjectile) protected voidonRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pMovedByPiston) protected booleanpropagatesSkylightDown(BlockState pState, BlockGetter pLevel, BlockPos pPos) static <B extends Block>
com.mojang.serialization.codecs.RecordCodecBuilder<B, BlockBehaviour.Properties> protected voidrandomTick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSource pRandom) Performs a random tick on a block.protected BlockStaterotate(BlockState pState, Rotation pRotation) Returns the blockstate with the given rotation from the passed blockstate.static <B extends Block>
com.mojang.serialization.MapCodec<B> simpleCodec(Function<BlockBehaviour.Properties, B> pFactory) protected booleanskipRendering(BlockState pState, BlockState pAdjacentState, Direction pDirection) protected voidspawnAfterBreak(BlockState pState, ServerLevel pLevel, BlockPos pPos, ItemStack pStack, boolean pDropExperience) Perform side-effects from block dropping, such as creating silverfishprotected voidtick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSource pRandom) protected booleantriggerEvent(BlockState pState, Level pLevel, BlockPos pPos, int pId, int pParam) Called on server whenLevel.blockEvent(net.minecraft.core.BlockPos, net.minecraft.world.level.block.Block, int, int)is called.protected voidupdateIndirectNeighbourShapes(BlockState pState, LevelAccessor pLevel, BlockPos pPos, int pFlags, int pRecursionLeft) Updates the shapes of indirect neighbors of this block.protected BlockStateupdateShape(BlockState pState, Direction pDirection, BlockState pNeighborState, LevelAccessor pLevel, BlockPos pPos, BlockPos pNeighborPos) Update the provided state given the provided neighbor direction and neighbor state, returning a new state.protected ItemInteractionResultuseItemOn(ItemStack pStack, BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHitResult) protected booleanuseShapeForLightOcclusion(BlockState pState) protected InteractionResultuseWithoutItem(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, BlockHitResult pHitResult) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.world.flag.FeatureElement
isEnabled
-
Field Details
-
UPDATE_SHAPE_ORDER
-
hasCollision
protected final boolean hasCollision -
explosionResistance
protected final float explosionResistance -
isRandomlyTicking
protected final boolean isRandomlyTickingWhether this blocks receives random ticks -
soundType
-
friction
protected final float frictionDetermines how much velocity is maintained while moving on top of this block -
speedFactor
protected final float speedFactor -
jumpFactor
protected final float jumpFactor -
dynamicShape
protected final boolean dynamicShape -
requiredFeatures
-
properties
-
drops
-
lootTableSupplier
-
-
Constructor Details
-
BlockBehaviour
-
-
Method Details
-
properties
-
codec
-
propertiesCodec
public static <B extends Block> com.mojang.serialization.codecs.RecordCodecBuilder<B,BlockBehaviour.Properties> propertiesCodec() -
simpleCodec
public static <B extends Block> com.mojang.serialization.MapCodec<B> simpleCodec(Function<BlockBehaviour.Properties, B> pFactory) -
updateIndirectNeighbourShapes
protected void updateIndirectNeighbourShapes(BlockState pState, LevelAccessor pLevel, BlockPos pPos, int pFlags, int pRecursionLeft) Updates the shapes of indirect neighbors of this block. This method is analogous tobut where that method affects the 6 direct neighbors of this block, this method affects the indirect neighbors, if any.invalid reference
net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase#updateNeighbourShapesCurrently the only implementation of this method is
RedStoneWireBlock.updateIndirectNeighbourShapes(net.minecraft.world.level.block.state.BlockState, net.minecraft.world.level.LevelAccessor, net.minecraft.core.BlockPos, int, int)where it is used to validate diagonal connections of redstone wire blocks. -
isPathfindable
-
updateShape
protected BlockState updateShape(BlockState pState, Direction pDirection, BlockState pNeighborState, LevelAccessor pLevel, BlockPos pPos, BlockPos pNeighborPos) Update the provided state given the provided neighbor direction and neighbor state, returning a new state. For example, fences make their connections to the passed in state if possible, and wet concrete powder immediately returns its solidified counterpart. Note that this method should ideally consider only the specific direction passed in. -
skipRendering
-
neighborChanged
protected void neighborChanged(BlockState pState, Level pLevel, BlockPos pPos, Block pNeighborBlock, BlockPos pNeighborPos, boolean pMovedByPiston) -
onPlace
protected void onPlace(BlockState pState, Level pLevel, BlockPos pPos, BlockState pOldState, boolean pMovedByPiston) -
onRemove
protected void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pMovedByPiston) -
onExplosionHit
protected void onExplosionHit(BlockState pState, Level pLevel, BlockPos pPos, Explosion pExplosion, BiConsumer<ItemStack, BlockPos> pDropConsumer) -
useWithoutItem
protected InteractionResult useWithoutItem(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, BlockHitResult pHitResult) -
useItemOn
protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHitResult) -
triggerEvent
Called on server whenLevel.blockEvent(net.minecraft.core.BlockPos, net.minecraft.world.level.block.Block, int, int)is called. If server returns true, then also called on the client. On the Server, this may perform additional changes to the world, like pistons replacing the block with an extended base. On the client, the update may involve replacing block entities or effects such as sounds or particles -
getRenderShape
The type of render function called. MODEL for mixed tesr and static model, MODELBLOCK_ANIMATED for TESR-only, LIQUID for vanilla liquids, INVISIBLE to skip all rendering -
useShapeForLightOcclusion
-
isSignalSource
Returns whether this block is capable of emitting redstone signals. -
getFluidState
-
hasAnalogOutputSignal
-
getMaxHorizontalOffset
protected float getMaxHorizontalOffset() -
getMaxVerticalOffset
protected float getMaxVerticalOffset() -
requiredFeatures
- Specified by:
requiredFeaturesin interfaceFeatureElement
-
rotate
Returns the blockstate with the given rotation from the passed blockstate. If inapplicable, returns the passed blockstate. -
mirror
Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed blockstate. -
canBeReplaced
-
canBeReplaced
-
getDrops
-
getSeed
Return a random long to be passed toBakedModel.getQuads(net.minecraft.world.level.block.state.BlockState, net.minecraft.core.Direction, net.minecraft.util.RandomSource), used for random model rotations -
getOcclusionShape
-
getBlockSupportShape
-
getInteractionShape
-
getLightBlock
-
getMenuProvider
-
canSurvive
-
getShadeBrightness
-
getAnalogOutputSignal
Returns the analog signal this block emits. This is the signal a comparator can read from it. -
getShape
protected VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) -
getCollisionShape
protected VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) -
isCollisionShapeFullBlock
-
isOcclusionShapeFullBlock
-
getVisualShape
protected VoxelShape getVisualShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) -
randomTick
protected void randomTick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSource pRandom) Performs a random tick on a block. -
tick
-
getDestroyProgress
protected float getDestroyProgress(BlockState pState, Player pPlayer, BlockGetter pLevel, BlockPos pPos) Get the hardness of this Block relative to the ability of the given player -
spawnAfterBreak
protected void spawnAfterBreak(BlockState pState, ServerLevel pLevel, BlockPos pPos, ItemStack pStack, boolean pDropExperience) Perform side-effects from block dropping, such as creating silverfish -
attack
-
getSignal
Returns the signal this block emits in the given direction.NOTE: directions in redstone signal related methods are backwards, so this method checks for the signal emitted in the opposite direction of the one given.
-
entityInside
-
getDirectSignal
protected int getDirectSignal(BlockState pState, BlockGetter pLevel, BlockPos pPos, Direction pDirection) Returns the direct signal this block emits in the given direction.NOTE: directions in redstone signal related methods are backwards, so this method checks for the signal emitted in the opposite direction of the one given.
-
getLootTable
-
onProjectileHit
protected void onProjectileHit(Level pLevel, BlockState pState, BlockHitResult pHit, Projectile pProjectile) -
propagatesSkylightDown
-
isRandomlyTicking
-
getSoundType
Deprecated. -
asItem
-
asBlock
-
defaultMapColor
-
defaultDestroyTime
public float defaultDestroyTime() -
isAir
-