Package net.minecraft.world.level.block
Class Block
java.lang.Object
net.minecraft.world.level.block.state.BlockBehaviour
net.minecraft.world.level.block.Block
- All Implemented Interfaces:
FeatureElement,ItemLike,IBlockExtension
- Direct Known Subclasses:
AbstractCandleBlock,AbstractCauldronBlock,AirBlock,AmethystBlock,BambooSaplingBlock,BambooStalkBlock,BarrierBlock,BaseCoralPlantTypeBlock,BaseEntityBlock,BaseFireBlock,BasePressurePlateBlock,BaseRailBlock,BaseTorchBlock,BubbleColumnBlock,BushBlock,CactusBlock,CakeBlock,CarpetBlock,CartographyTableBlock,ChorusFlowerBlock,ComposterBlock,CopperBulbBlock,CoralBlock,CraftingTableBlock,CrossCollisionBlock,CryingObsidianBlock,DirectionalBlock,DirtPathBlock,DoorBlock,DropExperienceBlock,EndPortalFrameBlock,FallingBlock,FarmBlock,FlowerPotBlock,FrogspawnBlock,GrowingPlantBlock,HalfTransparentBlock,HangingRootsBlock,HeavyCoreBlock,HorizontalDirectionalBlock,HugeMushroomBlock,InfestedBlock,JigsawBlock,LadderBlock,LanternBlock,LeavesBlock,LightBlock,LiquidBlock,MagmaBlock,MangroveRootsBlock,MossBlock,MudBlock,MultifaceBlock,NetherPortalBlock,NetherrackBlock,NoteBlock,NyliumBlock,PipeBlock,PointedDripstoneBlock,PowderSnowBlock,PoweredBlock,PumpkinBlock,RedstoneLampBlock,RedStoneOreBlock,RedStoneWireBlock,RespawnAnchorBlock,RootedDirtBlock,RotatedPillarBlock,ScaffoldingBlock,SlabBlock,SnifferEggBlock,SnowLayerBlock,SnowyDirtBlock,SoulSandBlock,SpongeBlock,SporeBlossomBlock,StairBlock,StonecutterBlock,StructureVoidBlock,SugarCaneBlock,TargetBlock,TntBlock,TripWireBlock,TripWireHookBlock,TurtleEggBlock,VineBlock,WallBlock,WeatheringCopperFullBlock,WebBlock,WetSpongeBlock
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class net.minecraft.world.level.block.state.BlockBehaviour
BlockBehaviour.BlockStateBase, BlockBehaviour.OffsetFunction, BlockBehaviour.OffsetType, BlockBehaviour.Properties, BlockBehaviour.StateArgumentPredicate<A>, BlockBehaviour.StatePredicate -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IdMapper<BlockState> private final Holder.Reference<Block> private static final intprivate static List<ItemEntity> Neo: Short-lived holder of dropped item entities.static final com.mojang.serialization.MapCodec<Block> private BlockStateprivate Stringstatic final floatstatic final floatprivate Itemprivate static final org.slf4j.Loggerprivate static final ThreadLocal<it.unimi.dsi.fastutil.objects.Object2ByteLinkedOpenHashMap<Block.BlockStatePairKey>> private static final com.google.common.cache.LoadingCache<VoxelShape, Boolean> protected final StateDefinition<Block, BlockState> static final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidanimateTick(BlockState state, Level level, BlockPos pos, RandomSource random) Called periodically clientside on blocks near the player to show effects (like furnace fire particles).voidappendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) protected BlockasBlock()asItem()private static voidInitializescapturedDrops, starting the drop capture process.static VoxelShapebox(double x1, double y1, double z1, double x2, double y2, double z2) Deprecated.static Blockstatic booleancanSupportCenter(LevelReader level, BlockPos pos, Direction direction) static booleancanSupportRigidBlock(BlockGetter level, BlockPos pos) protected com.mojang.serialization.MapCodec<? extends Block> codec()private static <T extends Comparable<T>>
BlockStatecopyProperty(BlockState sourceState, BlockState targetState, Property<T> property) protected voidfinal BlockStatevoiddestroy(LevelAccessor level, BlockPos pos, BlockState state) Called after this block has been removed by a player.booleandropFromExplosion(Explosion explosion) Deprecated.static voiddropResources(BlockState state, LevelAccessor level, BlockPos pos, BlockEntity blockEntity) static voiddropResources(BlockState state, Level level, BlockPos pos) static voiddropResources(BlockState state, Level level, BlockPos pos, BlockEntity blockEntity, Entity entity, ItemStack tool) voidfallOn(Level level, BlockState state, BlockPos pos, Entity entity, float fallDistance) getCloneItemStack(LevelReader level, BlockPos pos, BlockState state) Deprecated.getDrops(BlockState state, ServerLevel level, BlockPos pos, BlockEntity blockEntity) getDrops(BlockState state, ServerLevel level, BlockPos pos, BlockEntity blockEntity, Entity entity, ItemStack tool) floatDeprecated.floatstatic intgetId(BlockState state) floatgetName()protected com.google.common.collect.ImmutableMap<BlockState, VoxelShape> getShapeForEachState(Function<BlockState, VoxelShape> shapeGetter) floatgetStateForPlacement(BlockPlaceContext context) voidhandlePrecipitation(BlockState state, Level level, BlockPos pos, Biome.Precipitation precipitation) booleanvoidinitializeClient(Consumer<IClientBlockExtensions> consumer) Deprecated, for removal: This API element is subject to removal in a future version.static booleanstatic booleanisFaceFull(VoxelShape shape, Direction face) booleanstatic booleanisShapeFullBlock(VoxelShape shape) voidplayerDestroy(Level level, Player player, BlockPos pos, BlockState state, BlockEntity blockEntity, ItemStack tool) Called after a player has successfully harvested this block.playerWillDestroy(Level level, BlockPos pos, BlockState state, Player player) voidpopExperience(ServerLevel level, BlockPos pos, int amount) Spawns the given amount of experience into the Level as experience orb entities.private static voidpopResource(Level level, Supplier<ItemEntity> itemEntitySupplier, ItemStack stack) static voidpopResource(Level level, BlockPos pos, ItemStack stack) Spawns the given stack into the Level at the given position, respecting the doTileDrops gamerulestatic voidpopResourceFromFace(Level level, BlockPos pos, Direction direction, ItemStack stack) static BlockStatepushEntitiesUp(BlockState oldState, BlockState newState, LevelAccessor level, BlockPos pos) protected final voidregisterDefaultState(BlockState state) voidsetPlacedBy(Level level, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) Called by BlockItem after this block has been placed.static booleanshouldRenderFace(BlockState state, BlockGetter level, BlockPos offset, Direction face, BlockPos pos) protected voidspawnDestroyParticles(Level level, Player player, BlockPos pos, BlockState state) static BlockStatestateById(int id) voidstepOn(Level level, BlockPos pos, BlockState state, Entity entity) private static List<ItemEntity> Ends the drop capture process by settingcapturedDropsto null and returning the old list.toString()protected voidtryDropExperience(ServerLevel level, BlockPos pos, ItemStack heldItem, IntProvider amount) voidupdateEntityAfterFallOn(BlockGetter level, Entity entity) Called when an Entity lands on this Block.static BlockStateupdateFromNeighbourShapes(BlockState currentState, LevelAccessor level, BlockPos pos) With the provided block state, performs neighbor checks for all neighboring blocks to get an "adjusted" blockstate for placement in the world, if the current state is not valid.static voidupdateOrDestroy(BlockState oldState, BlockState newState, LevelAccessor level, BlockPos pos, int flags) Replaces oldState with newState, possibly playing effects and creating drops.static voidupdateOrDestroy(BlockState oldState, BlockState newState, LevelAccessor level, BlockPos pos, int flags, int recursionLeft) voidwasExploded(Level level, BlockPos pos, Explosion explosion) Called when this Block is destroyed by an Explosionfinal BlockStatewithPropertiesOf(BlockState state) Methods inherited from class net.minecraft.world.level.block.state.BlockBehaviour
attack, canBeReplaced, canBeReplaced, canSurvive, 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
-
Field Details
-
CODEC
-
LOGGER
private static final org.slf4j.Logger LOGGER -
builtInRegistryHolder
-
BLOCK_STATE_REGISTRY
-
SHAPE_FULL_BLOCK_CACHE
private static final com.google.common.cache.LoadingCache<VoxelShape,Boolean> SHAPE_FULL_BLOCK_CACHE -
UPDATE_NEIGHBORS
public static final int UPDATE_NEIGHBORS- See Also:
-
UPDATE_CLIENTS
public static final int UPDATE_CLIENTS- See Also:
-
UPDATE_INVISIBLE
public static final int UPDATE_INVISIBLE- See Also:
-
UPDATE_IMMEDIATE
public static final int UPDATE_IMMEDIATE- See Also:
-
UPDATE_KNOWN_SHAPE
public static final int UPDATE_KNOWN_SHAPE- See Also:
-
UPDATE_SUPPRESS_DROPS
public static final int UPDATE_SUPPRESS_DROPS- See Also:
-
UPDATE_MOVE_BY_PISTON
public static final int UPDATE_MOVE_BY_PISTON- See Also:
-
UPDATE_NONE
public static final int UPDATE_NONE- See Also:
-
UPDATE_ALL
public static final int UPDATE_ALL- See Also:
-
UPDATE_ALL_IMMEDIATE
public static final int UPDATE_ALL_IMMEDIATE- See Also:
-
INDESTRUCTIBLE
public static final float INDESTRUCTIBLE- See Also:
-
INSTANT
public static final float INSTANT- See Also:
-
UPDATE_LIMIT
public static final int UPDATE_LIMIT- See Also:
-
stateDefinition
-
defaultBlockState
-
descriptionId
-
item
-
CACHE_SIZE
private static final int CACHE_SIZE- See Also:
-
OCCLUSION_CACHE
private static final ThreadLocal<it.unimi.dsi.fastutil.objects.Object2ByteLinkedOpenHashMap<Block.BlockStatePairKey>> OCCLUSION_CACHE -
capturedDrops
Neo: Short-lived holder of dropped item entities. Used mainly for Neo hooks and event logic.When not null, records all item entities from
popResource(Level, Supplier, ItemStack)instead of adding them to the world.
-
-
Constructor Details
-
Block
-
-
Method Details
-
codec
- Specified by:
codecin classBlockBehaviour
-
getId
-
stateById
-
byItem
-
pushEntitiesUp
public static BlockState pushEntitiesUp(BlockState oldState, BlockState newState, LevelAccessor level, BlockPos pos) -
box
-
updateFromNeighbourShapes
public static BlockState updateFromNeighbourShapes(BlockState currentState, LevelAccessor level, BlockPos pos) With the provided block state, performs neighbor checks for all neighboring blocks to get an "adjusted" blockstate for placement in the world, if the current state is not valid. -
updateOrDestroy
public static void updateOrDestroy(BlockState oldState, BlockState newState, LevelAccessor level, BlockPos pos, int flags) Replaces oldState with newState, possibly playing effects and creating drops. Flags are as inLevel.setBlock(net.minecraft.core.BlockPos, net.minecraft.world.level.block.state.BlockState, int). -
updateOrDestroy
public static void updateOrDestroy(BlockState oldState, BlockState newState, LevelAccessor level, BlockPos pos, int flags, int recursionLeft) -
isExceptionForConnection
-
shouldRenderFace
public static boolean shouldRenderFace(BlockState state, BlockGetter level, BlockPos offset, Direction face, BlockPos pos) -
canSupportRigidBlock
- Returns:
- whether the given position has a rigid top face
-
canSupportCenter
- Returns:
- whether the given position has a solid center in the given direction
-
isFaceFull
-
isShapeFullBlock
- Returns:
- whether the provided
VoxelShapeis a full block (1x1x1)
-
animateTick
Called periodically clientside on blocks near the player to show effects (like furnace fire particles). -
destroy
Called after this block has been removed by a player. -
getDrops
public static List<ItemStack> getDrops(BlockState state, ServerLevel level, BlockPos pos, @Nullable BlockEntity blockEntity) -
getDrops
public static List<ItemStack> getDrops(BlockState state, ServerLevel level, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) -
dropResources
-
dropResources
public static void dropResources(BlockState state, LevelAccessor level, BlockPos pos, @Nullable BlockEntity blockEntity) -
dropResources
public static void dropResources(BlockState state, Level level, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) -
popResource
Spawns the given stack into the Level at the given position, respecting the doTileDrops gamerule -
popResourceFromFace
-
popResource
private static void popResource(Level level, Supplier<ItemEntity> itemEntitySupplier, ItemStack stack) -
popExperience
Spawns the given amount of experience into the Level as experience orb entities. -
getExplosionResistance
Deprecated. -
wasExploded
Called when this Block is destroyed by an Explosion -
stepOn
-
getStateForPlacement
-
playerDestroy
public void playerDestroy(Level level, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool) Called after a player has successfully harvested this block. This method will only be called if the player has used the correct tool and drops should be spawned. -
setPlacedBy
public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) Called by BlockItem after this block has been placed. -
isPossibleToRespawnInThis
-
getName
-
getDescriptionId
-
fallOn
-
updateEntityAfterFallOn
Called when an Entity lands on this Block. This method is responsible for doing any modification on the motion of the entity that should result from the landing. -
getCloneItemStack
Deprecated. -
getFriction
public float getFriction() -
getSpeedFactor
public float getSpeedFactor() -
getJumpFactor
public float getJumpFactor() -
spawnDestroyParticles
-
playerWillDestroy
-
handlePrecipitation
public void handlePrecipitation(BlockState state, Level level, BlockPos pos, Biome.Precipitation precipitation) -
dropFromExplosion
Deprecated.- Returns:
- whether this block should drop its drops when destroyed by the given explosion
-
createBlockStateDefinition
-
getStateDefinition
-
registerDefaultState
-
defaultBlockState
-
withPropertiesOf
-
copyProperty
private static <T extends Comparable<T>> BlockState copyProperty(BlockState sourceState, BlockState targetState, Property<T> property) -
asItem
- Specified by:
asItemin interfaceItemLike- Specified by:
asItemin classBlockBehaviour
-
hasDynamicShape
public boolean hasDynamicShape() -
toString
-
appendHoverText
public void appendHoverText(ItemStack stack, Item.TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) -
asBlock
- Specified by:
asBlockin classBlockBehaviour
-
getShapeForEachState
protected com.google.common.collect.ImmutableMap<BlockState,VoxelShape> getShapeForEachState(Function<BlockState, VoxelShape> shapeGetter) -
beginCapturingDrops
private static void beginCapturingDrops()InitializescapturedDrops, starting the drop capture process.Must only be called on the server thread.
-
stopCapturingDrops
Ends the drop capture process by settingcapturedDropsto null and returning the old list.Must only be called on the server thread.
-
initializeClient
@Deprecated(forRemoval=true, since="1.21") public void initializeClient(Consumer<IClientBlockExtensions> consumer) Deprecated, for removal: This API element is subject to removal in a future version.UseRegisterClientExtensionsEventinsteadNeo: Allowing mods to define client behavior for their Blocks -
builtInRegistryHolder
Deprecated. -
tryDropExperience
protected void tryDropExperience(ServerLevel level, BlockPos pos, ItemStack heldItem, IntProvider amount)
-
RegisterClientExtensionsEventinstead