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 class
static interface
static enum
static class
static interface
static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ResourceKey
<LootTable> protected final boolean
protected final float
protected final float
Determines how much velocity is maintained while moving on top of this blockprotected final boolean
protected final boolean
Whether this blocks receives random ticksprotected final float
private final Supplier
<ResourceKey<LootTable>> protected final BlockBehaviour.Properties
protected final FeatureFlagSet
protected final SoundType
protected final float
protected static final Direction[]
Fields inherited from interface net.minecraft.world.flag.FeatureElement
FILTERED_REGISTRIES
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Block
asBlock()
abstract Item
asItem()
protected void
attack
(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer) protected boolean
canBeReplaced
(BlockState pState, BlockPlaceContext pUseContext) protected boolean
canBeReplaced
(BlockState pState, Fluid pFluid) protected boolean
canSurvive
(BlockState pState, LevelReader pLevel, BlockPos pPos) protected abstract com.mojang.serialization.MapCodec
<? extends Block> codec()
float
protected void
entityInside
(BlockState pState, Level pLevel, BlockPos pPos, Entity pEntity) protected int
getAnalogOutputSignal
(BlockState pState, Level pLevel, BlockPos pPos) Returns the analog signal this block emits.protected VoxelShape
getBlockSupportShape
(BlockState pState, BlockGetter pLevel, BlockPos pPos) protected VoxelShape
getCollisionShape
(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) protected float
getDestroyProgress
(BlockState pState, Player pPlayer, BlockGetter pLevel, BlockPos pPos) Get the hardness of this Block relative to the ability of the given playerprotected int
getDirectSignal
(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 FluidState
getFluidState
(BlockState pState) protected VoxelShape
getInteractionShape
(BlockState pState, BlockGetter pLevel, BlockPos pPos) protected int
getLightBlock
(BlockState pState, BlockGetter pLevel, BlockPos pPos) final ResourceKey
<LootTable> protected float
protected float
protected MenuProvider
getMenuProvider
(BlockState pState, Level pLevel, BlockPos pPos) protected VoxelShape
getOcclusionShape
(BlockState pState, BlockGetter pLevel, BlockPos pPos) protected RenderShape
getRenderShape
(BlockState pState) The type of render function called.protected long
getSeed
(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 float
getShadeBrightness
(BlockState pState, BlockGetter pLevel, BlockPos pPos) protected VoxelShape
getShape
(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) protected int
getSignal
(BlockState pState, BlockGetter pLevel, BlockPos pPos, Direction pDirection) Returns the signal this block emits in the given direction.protected SoundType
getSoundType
(BlockState pState) Deprecated.protected VoxelShape
getVisualShape
(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) protected boolean
hasAnalogOutputSignal
(BlockState pState) protected boolean
isAir
(BlockState state) protected boolean
isCollisionShapeFullBlock
(BlockState pState, BlockGetter pLevel, BlockPos pPos) protected boolean
isOcclusionShapeFullBlock
(BlockState pState, BlockGetter pLevel, BlockPos pPos) protected boolean
isPathfindable
(BlockState pState, PathComputationType pPathComputationType) protected boolean
isRandomlyTicking
(BlockState pState) protected boolean
isSignalSource
(BlockState pState) Returns whether this block is capable of emitting redstone signals.protected BlockState
mirror
(BlockState pState, Mirror pMirror) Returns the blockstate with the given mirror of the passed blockstate.protected void
neighborChanged
(BlockState pState, Level pLevel, BlockPos pPos, Block pNeighborBlock, BlockPos pNeighborPos, boolean pMovedByPiston) protected void
onExplosionHit
(BlockState pState, Level pLevel, BlockPos pPos, Explosion pExplosion, BiConsumer<ItemStack, BlockPos> pDropConsumer) protected void
onPlace
(BlockState pState, Level pLevel, BlockPos pPos, BlockState pOldState, boolean pMovedByPiston) protected void
onProjectileHit
(Level pLevel, BlockState pState, BlockHitResult pHit, Projectile pProjectile) protected void
onRemove
(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pMovedByPiston) protected boolean
propagatesSkylightDown
(BlockState pState, BlockGetter pLevel, BlockPos pPos) static <B extends Block>
com.mojang.serialization.codecs.RecordCodecBuilder<B, BlockBehaviour.Properties> protected void
randomTick
(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSource pRandom) Performs a random tick on a block.protected BlockState
rotate
(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> p_304394_) protected boolean
skipRendering
(BlockState pState, BlockState pAdjacentState, Direction pDirection) protected void
spawnAfterBreak
(BlockState pState, ServerLevel pLevel, BlockPos pPos, ItemStack pStack, boolean pDropExperience) Perform side-effects from block dropping, such as creating silverfishprotected void
tick
(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSource pRandom) protected boolean
triggerEvent
(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 void
updateIndirectNeighbourShapes
(BlockState pState, LevelAccessor pLevel, BlockPos pPos, int pFlags, int pRecursionLeft) Updates the shapes of indirect neighbors of this block.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.protected ItemInteractionResult
useItemOn
(ItemStack pStack, BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHitResult) protected boolean
useShapeForLightOcclusion
(BlockState pState) protected InteractionResult
useWithoutItem
(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, wait
Methods 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> p_304394_) -
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 toinvalid reference
net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase#updateNeighbourShapes
Currently 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:
requiredFeatures
in 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
-