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,BonemealableFeaturePlacerBlock,BubbleColumnBlock,CactusBlock,CakeBlock,CarpetBlock,CartographyTableBlock,ChorusFlowerBlock,ComposterBlock,CopperBulbBlock,CoralBlock,CraftingTableBlock,CrossCollisionBlock,CryingObsidianBlock,DirectionalBlock,DirtPathBlock,DoorBlock,DropExperienceBlock,EndPortalFrameBlock,FallingBlock,FarmBlock,FlowerPotBlock,FrogspawnBlock,GrowingPlantBlock,HalfTransparentBlock,HangingMossBlock,HangingRootsBlock,HeavyCoreBlock,HorizontalDirectionalBlock,HugeMushroomBlock,InfestedBlock,JigsawBlock,LadderBlock,LanternBlock,LeavesBlock,LightBlock,LiquidBlock,MagmaBlock,MangroveRootsBlock,MossyCarpetBlock,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,VegetationBlock,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 BlockStatestatic final floatstatic final floatprivate Itemprivate static final org.slf4j.Loggerprivate static final ThreadLocal<it.unimi.dsi.fastutil.objects.Object2ByteLinkedOpenHashMap<Block.ShapePairKey>> private static final 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 intstatic final intstatic final intstatic final intstatic final intFields inherited from class net.minecraft.world.level.block.state.BlockBehaviour
descriptionId, 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 pState, Level pLevel, BlockPos pPos, RandomSource pRandom) Called periodically clientside on blocks near the player to show effects (like furnace fire particles).protected BlockasBlock()asItem()private static voidInitializescapturedDrops, starting the drop capture process.static VoxelShapebox(double pX1, double pY1, double pZ1, double pX2, double pY2, double pZ2) static VoxelShape[]boxes(int pCount, IntFunction<VoxelShape> pBoxCreator) static VoxelShapeboxZ(double pSize, double pZ1, double pZ2) static VoxelShapeboxZ(double pXSize, double pYSize, double pZ1, double pZ2) static VoxelShapeboxZ(double pXSize, double pY1, double pY2, double pZ1, double pZ2) Deprecated.static Blockstatic booleancanSupportCenter(LevelReader pLevel, BlockPos pPos, Direction pDirection) static booleancanSupportRigidBlock(BlockGetter pLevel, BlockPos pPos) protected com.mojang.serialization.MapCodec<? extends Block> codec()static VoxelShapecolumn(double pSize, double pY1, double pY2) static VoxelShapecolumn(double pXSize, double pZSize, double pY1, double pY2) private static <T extends Comparable<T>>
BlockStatecopyProperty(BlockState pSourceState, BlockState pTargetState, Property<T> pProperty) protected voidstatic VoxelShapecube(double pSize) static VoxelShapecube(double pXSize, double pYSize, double pZSize) final BlockStatevoiddestroy(LevelAccessor pLevel, BlockPos pPos, BlockState pState) Called after this block has been removed by a player.protected static booleandropFromBlockInteractLootTable(ServerLevel pLevel, ResourceKey<LootTable> pLootTable, BlockState pState, BlockEntity pBlockEntity, ItemStack pTool, Entity pEntity, BiConsumer<ServerLevel, ItemStack> pDropConsumer) booleandropFromExplosion(Explosion pExplosion) Deprecated.protected static booleandropFromLootTable(ServerLevel pLevel, ResourceKey<LootTable> pLootTable, Function<LootParams.Builder, LootParams> pParams, BiConsumer<ServerLevel, ItemStack> pDropConsumer) static voiddropResources(BlockState pState, LevelAccessor pLevel, BlockPos pPos, BlockEntity pBlockEntity) static voiddropResources(BlockState pState, Level pLevel, BlockPos pPos) static voiddropResources(BlockState pState, Level pLevel, BlockPos pPos, BlockEntity pBlockEntity, Entity pEntity, ItemStack pTool) voidfallOn(Level pLevel, BlockState pState, BlockPos pPos, Entity pEntity, double pFallDistance) getDrops(BlockState pState, ServerLevel pLevel, BlockPos pPos, BlockEntity pBlockEntity) getDrops(BlockState pState, ServerLevel pLevel, BlockPos pPos, BlockEntity pBlockEntity, Entity pEntity, ItemStack pTool) floatDeprecated.floatstatic intgetId(BlockState pState) floatgetName()protected Function<BlockState, VoxelShape> getShapeForEachState(Function<BlockState, VoxelShape> pShapeGetter) protected Function<BlockState, VoxelShape> getShapeForEachState(Function<BlockState, VoxelShape> pShapeGetter, Property<?>... pProperties) floatgetStateForPlacement(BlockPlaceContext pContext) voidhandlePrecipitation(BlockState pState, Level pLevel, BlockPos pPos, Biome.Precipitation pPrecipitation) booleanstatic booleanisExceptionForConnection(BlockState pState) static booleanisFaceFull(VoxelShape pShape, Direction pFace) booleanisPossibleToRespawnInThis(BlockState pState) static booleanisShapeFullBlock(VoxelShape pShape) voidplayerDestroy(Level pLevel, Player pPlayer, BlockPos pPos, BlockState pState, BlockEntity pBlockEntity, ItemStack pTool) Called after a player has successfully harvested this block.playerWillDestroy(Level pLevel, BlockPos pPos, BlockState pState, Player pPlayer) voidpopExperience(ServerLevel pLevel, BlockPos pPos, int pAmount) Spawns the given amount of experience into the Level as experience orb entities.private static voidpopResource(Level pLevel, Supplier<ItemEntity> pItemEntitySupplier, ItemStack pStack) static voidpopResource(Level pLevel, BlockPos pPos, ItemStack pStack) Spawns the given stack into the Level at the given position, respecting the doTileDrops gamerulestatic voidpopResourceFromFace(Level pLevel, BlockPos pPos, Direction pDirection, ItemStack pStack) static BlockStatepushEntitiesUp(BlockState pOldState, BlockState pNewState, LevelAccessor pLevel, BlockPos pPos) protected final voidregisterDefaultState(BlockState pState) voidsetPlacedBy(Level pLevel, BlockPos pPos, BlockState pState, LivingEntity pPlacer, ItemStack pStack) Called by BlockItem after this block has been placed.private static <S extends StateHolder<?,S>, T extends Comparable<T>>
SsetValueHelper(S pStateHolder, Property<T> pProperty, Object pValue) static booleanshouldRenderFace(BlockState pCurrentFace, BlockState pNeighboringFace, Direction pFace) Deprecated.Neo: use overload with level context insteadstatic booleanshouldRenderFace(BlockGetter level, BlockPos pos, BlockState p_152445_, BlockState p_361252_, Direction p_152448_) protected voidspawnDestroyParticles(Level pLevel, Player pPlayer, BlockPos pPos, BlockState pState) static BlockStatestateById(int pId) voidstepOn(Level pLevel, BlockPos pPos, BlockState pState, Entity pEntity) private static List<ItemEntity> Ends the drop capture process by settingcapturedDropsto null and returning the old list.toString()protected voidtryDropExperience(ServerLevel pLevel, BlockPos pPos, ItemStack pHeldItem, IntProvider pAmount) voidupdateEntityMovementAfterFallOn(BlockGetter pLevel, Entity pEntity) static BlockStateupdateFromNeighbourShapes(BlockState pCurrentState, LevelAccessor pLevel, BlockPos pPos) 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 pOldState, BlockState pNewState, LevelAccessor pLevel, BlockPos pPos, int pFlags) Replaces oldState with newState, possibly playing effects and creating drops.static voidupdateOrDestroy(BlockState pOldState, BlockState pNewState, LevelAccessor pLevel, BlockPos pPos, int pFlags, int pRecursionLeft) voidwasExploded(ServerLevel pLevel, BlockPos pPos, Explosion pExplosion) final BlockStatewithPropertiesOf(BlockState pState) Methods inherited from class net.minecraft.world.level.block.state.BlockBehaviour
affectNeighborsAfterRemoval, attack, canBeReplaced, canBeReplaced, canSurvive, defaultDestroyTime, defaultMapColor, entityInside, getAnalogOutputSignal, getBlockSupportShape, getCloneItemStack, getCollisionShape, getDescriptionId, getDestroyProgress, getDirectSignal, getDrops, getEntityInsideCollisionShape, getFluidState, getInteractionShape, getLightBlock, getLootTable, getMaxHorizontalOffset, getMaxVerticalOffset, getMenuProvider, getOcclusionShape, getRenderShape, getSeed, getShadeBrightness, getShape, getSignal, getSoundType, getVisualShape, hasAnalogOutputSignal, isAir, isCollisionShapeFullBlock, isPathfindable, isRandomlyTicking, isSignalSource, mirror, neighborChanged, onExplosionHit, onPlace, onProjectileHit, propagatesSkylightDown, properties, propertiesCodec, randomTick, requiredFeatures, rotate, shouldChangedStateKeepBlockEntity, 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, ignitedByLava, isBed, isBurning, isConduitFrame, isEmpty, isFertile, isFireSource, isFlammable, isLadder, isPortalFrame, isScaffolding, isSlimeBlock, isStickyBlock, makesOpenTrapdoorAboveClimbable, onBlockExploded, onBlockStateChange, onCaughtFire, onDestroyedByPlayer, onDestroyedByPushReaction, onNeighborChange, onTreeGrow, playFallSound, playStepSound, 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
-
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_SKIP_SHAPE_UPDATE_ON_WIRE
public static final int UPDATE_SKIP_SHAPE_UPDATE_ON_WIRE- See Also:
-
UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS
public static final int UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS- See Also:
-
UPDATE_SKIP_ON_PLACE
public static final int UPDATE_SKIP_ON_PLACE- 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:
-
UPDATE_SKIP_ALL_SIDEEFFECTS
public static final int UPDATE_SKIP_ALL_SIDEEFFECTS- 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
-
item
-
CACHE_SIZE
private static final int CACHE_SIZE- See Also:
-
OCCLUSION_CACHE
private static final ThreadLocal<it.unimi.dsi.fastutil.objects.Object2ByteLinkedOpenHashMap<Block.ShapePairKey>> 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 pOldState, BlockState pNewState, LevelAccessor pLevel, BlockPos pPos) -
box
public static VoxelShape box(double pX1, double pY1, double pZ1, double pX2, double pY2, double pZ2) -
boxes
-
cube
-
cube
-
column
-
column
-
boxZ
-
boxZ
-
boxZ
-
updateFromNeighbourShapes
public static BlockState updateFromNeighbourShapes(BlockState pCurrentState, LevelAccessor pLevel, BlockPos pPos) 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 pOldState, BlockState pNewState, LevelAccessor pLevel, BlockPos pPos, int pFlags) 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 pOldState, BlockState pNewState, LevelAccessor pLevel, BlockPos pPos, int pFlags, int pRecursionLeft) -
isExceptionForConnection
-
dropFromBlockInteractLootTable
protected static boolean dropFromBlockInteractLootTable(ServerLevel pLevel, ResourceKey<LootTable> pLootTable, BlockState pState, @Nullable BlockEntity pBlockEntity, @Nullable ItemStack pTool, @Nullable Entity pEntity, BiConsumer<ServerLevel, ItemStack> pDropConsumer) -
dropFromLootTable
protected static boolean dropFromLootTable(ServerLevel pLevel, ResourceKey<LootTable> pLootTable, Function<LootParams.Builder, LootParams> pParams, BiConsumer<ServerLevel, ItemStack> pDropConsumer) -
shouldRenderFace
@Deprecated public static boolean shouldRenderFace(BlockState pCurrentFace, BlockState pNeighboringFace, Direction pFace) Deprecated.Neo: use overload with level context instead -
shouldRenderFace
public static boolean shouldRenderFace(BlockGetter level, BlockPos pos, BlockState p_152445_, BlockState p_361252_, Direction p_152448_) -
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 pState, ServerLevel pLevel, BlockPos pPos, @Nullable BlockEntity pBlockEntity) -
getDrops
public static List<ItemStack> getDrops(BlockState pState, ServerLevel pLevel, BlockPos pPos, @Nullable BlockEntity pBlockEntity, @Nullable Entity pEntity, ItemStack pTool) -
dropResources
-
dropResources
public static void dropResources(BlockState pState, LevelAccessor pLevel, BlockPos pPos, @Nullable BlockEntity pBlockEntity) -
dropResources
public static void dropResources(BlockState pState, Level pLevel, BlockPos pPos, @Nullable BlockEntity pBlockEntity, @Nullable Entity pEntity, ItemStack pTool) -
popResource
Spawns the given stack into the Level at the given position, respecting the doTileDrops gamerule -
popResourceFromFace
-
popResource
private static void popResource(Level pLevel, Supplier<ItemEntity> pItemEntitySupplier, ItemStack pStack) -
popExperience
Spawns the given amount of experience into the Level as experience orb entities. -
getExplosionResistance
Deprecated. -
wasExploded
-
stepOn
-
getStateForPlacement
-
playerDestroy
public void playerDestroy(Level pLevel, Player pPlayer, BlockPos pPos, BlockState pState, @Nullable BlockEntity pBlockEntity, ItemStack pTool) 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 pLevel, BlockPos pPos, BlockState pState, @Nullable LivingEntity pPlacer, ItemStack pStack) Called by BlockItem after this block has been placed. -
isPossibleToRespawnInThis
-
getName
-
fallOn
public void fallOn(Level pLevel, BlockState pState, BlockPos pPos, Entity pEntity, double pFallDistance) -
updateEntityMovementAfterFallOn
-
getFriction
public float getFriction() -
getSpeedFactor
public float getSpeedFactor() -
getJumpFactor
public float getJumpFactor() -
spawnDestroyParticles
protected void spawnDestroyParticles(Level pLevel, Player pPlayer, BlockPos pPos, BlockState pState) -
playerWillDestroy
-
handlePrecipitation
public void handlePrecipitation(BlockState pState, Level pLevel, BlockPos pPos, Biome.Precipitation pPrecipitation) -
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 pSourceState, BlockState pTargetState, Property<T> pProperty) -
asItem
- Specified by:
asItemin interfaceItemLike- Specified by:
asItemin classBlockBehaviour
-
hasDynamicShape
public boolean hasDynamicShape() -
toString
-
asBlock
- Specified by:
asBlockin classBlockBehaviour
-
getShapeForEachState
protected Function<BlockState,VoxelShape> getShapeForEachState(Function<BlockState, VoxelShape> pShapeGetter) -
getShapeForEachState
protected Function<BlockState,VoxelShape> getShapeForEachState(Function<BlockState, VoxelShape> pShapeGetter, Property<?>... pProperties) -
setValueHelper
private static <S extends StateHolder<?,S>, S setValueHelperT extends Comparable<T>> (S pStateHolder, Property<T> pProperty, Object pValue) -
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.
-
builtInRegistryHolder
Deprecated. -
tryDropExperience
protected void tryDropExperience(ServerLevel pLevel, BlockPos pPos, ItemStack pHeldItem, IntProvider pAmount)
-