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 state, Level level, BlockPos pos, Player player) protected boolean
canBeReplaced
(BlockState state, BlockPlaceContext useContext) protected boolean
canBeReplaced
(BlockState state, Fluid fluid) protected boolean
canSurvive
(BlockState state, LevelReader level, BlockPos pos) protected abstract com.mojang.serialization.MapCodec
<? extends Block> codec()
float
protected void
entityInside
(BlockState state, Level level, BlockPos pos, Entity entity) protected int
getAnalogOutputSignal
(BlockState state, Level level, BlockPos pos) Returns the analog signal this block emits.protected VoxelShape
getBlockSupportShape
(BlockState state, BlockGetter level, BlockPos pos) protected VoxelShape
getCollisionShape
(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) protected float
getDestroyProgress
(BlockState state, Player player, BlockGetter level, BlockPos pos) Get the hardness of this Block relative to the ability of the given playerprotected int
getDirectSignal
(BlockState state, BlockGetter level, BlockPos pos, Direction direction) Returns the direct signal this block emits in the given direction.getDrops
(BlockState state, LootParams.Builder params) protected FluidState
getFluidState
(BlockState state) protected VoxelShape
getInteractionShape
(BlockState state, BlockGetter level, BlockPos pos) protected int
getLightBlock
(BlockState state, BlockGetter level, BlockPos pos) final ResourceKey
<LootTable> protected float
protected float
protected MenuProvider
getMenuProvider
(BlockState state, Level level, BlockPos pos) protected VoxelShape
getOcclusionShape
(BlockState state, BlockGetter level, BlockPos pos) protected RenderShape
getRenderShape
(BlockState state) The type of render function called.protected long
getSeed
(BlockState state, BlockPos pos) 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 state, BlockGetter level, BlockPos pos) protected VoxelShape
getShape
(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) protected int
getSignal
(BlockState state, BlockGetter level, BlockPos pos, Direction direction) Returns the signal this block emits in the given direction.protected SoundType
getSoundType
(BlockState state) Deprecated.protected VoxelShape
getVisualShape
(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) protected boolean
hasAnalogOutputSignal
(BlockState state) protected boolean
isAir
(BlockState state) protected boolean
isCollisionShapeFullBlock
(BlockState state, BlockGetter level, BlockPos pos) protected boolean
isOcclusionShapeFullBlock
(BlockState state, BlockGetter level, BlockPos pos) protected boolean
isPathfindable
(BlockState state, PathComputationType pathComputationType) protected boolean
isRandomlyTicking
(BlockState state) protected boolean
isSignalSource
(BlockState state) Returns whether this block is capable of emitting redstone signals.protected BlockState
mirror
(BlockState state, Mirror mirror) Returns the blockstate with the given mirror of the passed blockstate.protected void
neighborChanged
(BlockState state, Level level, BlockPos pos, Block neighborBlock, BlockPos neighborPos, boolean movedByPiston) protected void
onExplosionHit
(BlockState state, Level level, BlockPos pos, Explosion explosion, BiConsumer<ItemStack, BlockPos> dropConsumer) protected void
onPlace
(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) protected void
onProjectileHit
(Level level, BlockState state, BlockHitResult hit, Projectile projectile) protected void
onRemove
(BlockState state, Level level, BlockPos pos, BlockState newState, boolean movedByPiston) protected boolean
propagatesSkylightDown
(BlockState state, BlockGetter level, BlockPos pos) static <B extends Block>
com.mojang.serialization.codecs.RecordCodecBuilder<B, BlockBehaviour.Properties> protected void
randomTick
(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) Performs a random tick on a block.protected BlockState
rotate
(BlockState state, Rotation rotation) 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> factory) protected boolean
skipRendering
(BlockState state, BlockState adjacentState, Direction direction) protected void
spawnAfterBreak
(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) Perform side-effects from block dropping, such as creating silverfishprotected void
tick
(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) protected boolean
triggerEvent
(BlockState state, Level level, BlockPos pos, int id, int param) Called on server whenLevel.blockEvent(net.minecraft.core.BlockPos, net.minecraft.world.level.block.Block, int, int)
is called.protected void
updateIndirectNeighbourShapes
(BlockState state, LevelAccessor level, BlockPos pos, int flags, int recursionLeft) Updates the shapes of indirect neighbors of this block.protected BlockState
updateShape
(BlockState state, Direction direction, BlockState neighborState, LevelAccessor level, BlockPos pos, BlockPos neighborPos) Update the provided state given the provided neighbor direction and neighbor state, returning a new state.protected ItemInteractionResult
useItemOn
(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) protected boolean
protected InteractionResult
useWithoutItem
(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) 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> factory) -
updateIndirectNeighbourShapes
protected void updateIndirectNeighbourShapes(BlockState state, LevelAccessor level, BlockPos pos, int flags, int recursionLeft) 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 state, Direction direction, BlockState neighborState, LevelAccessor level, BlockPos pos, BlockPos neighborPos) 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 state, Level level, BlockPos pos, Block neighborBlock, BlockPos neighborPos, boolean movedByPiston) -
onPlace
protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) -
onRemove
protected void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean movedByPiston) -
onExplosionHit
protected void onExplosionHit(BlockState state, Level level, BlockPos pos, Explosion explosion, BiConsumer<ItemStack, BlockPos> dropConsumer) -
useWithoutItem
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) -
useItemOn
protected ItemInteractionResult useItemOn(ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult) -
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 state, BlockGetter level, BlockPos pos, CollisionContext context) -
getCollisionShape
protected VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) -
isCollisionShapeFullBlock
-
isOcclusionShapeFullBlock
-
getVisualShape
protected VoxelShape getVisualShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) -
randomTick
Performs a random tick on a block. -
tick
-
getDestroyProgress
protected float getDestroyProgress(BlockState state, Player player, BlockGetter level, BlockPos pos) Get the hardness of this Block relative to the ability of the given player -
spawnAfterBreak
protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) 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 state, BlockGetter level, BlockPos pos, Direction direction) 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 level, BlockState state, BlockHitResult hit, Projectile projectile) -
propagatesSkylightDown
-
isRandomlyTicking
-
getSoundType
Deprecated. -
asItem
-
asBlock
-
defaultMapColor
-
defaultDestroyTime
public float defaultDestroyTime() -
isAir
-