Interface IForgeBlock
- All Known Implementing Classes:
AbstractBannerBlock
,AbstractCandleBlock
,AbstractCauldronBlock
,AbstractChestBlock
,AbstractFurnaceBlock
,AbstractGlassBlock
,AbstractSkullBlock
,AirBlock
,AmethystBlock
,AmethystClusterBlock
,AnvilBlock
,AttachedStemBlock
,AzaleaBlock
,BambooSaplingBlock
,BambooStalkBlock
,BannerBlock
,BarrelBlock
,BarrierBlock
,BaseCoralFanBlock
,BaseCoralPlantBlock
,BaseCoralPlantTypeBlock
,BaseCoralWallFanBlock
,BaseEntityBlock
,BaseFireBlock
,BasePressurePlateBlock
,BaseRailBlock
,BeaconBlock
,BedBlock
,BeehiveBlock
,BeetrootBlock
,BellBlock
,BigDripleafBlock
,BigDripleafStemBlock
,BlastFurnaceBlock
,Block
,BrewingStandBlock
,BrushableBlock
,BubbleColumnBlock
,BuddingAmethystBlock
,BushBlock
,ButtonBlock
,CactusBlock
,CakeBlock
,CalibratedSculkSensorBlock
,CampfireBlock
,CandleBlock
,CandleCakeBlock
,CarpetBlock
,CarrotBlock
,CartographyTableBlock
,CarvedPumpkinBlock
,CauldronBlock
,CaveVinesBlock
,CaveVinesPlantBlock
,CeilingHangingSignBlock
,ChainBlock
,CherryLeavesBlock
,ChestBlock
,ChiseledBookShelfBlock
,ChorusFlowerBlock
,ChorusPlantBlock
,CocoaBlock
,CommandBlock
,ComparatorBlock
,ComposterBlock
,ConcretePowderBlock
,ConduitBlock
,CoralBlock
,CoralFanBlock
,CoralPlantBlock
,CoralWallFanBlock
,CraftingTableBlock
,CropBlock
,CrossCollisionBlock
,CryingObsidianBlock
,DaylightDetectorBlock
,DeadBushBlock
,DecoratedPotBlock
,DetectorRailBlock
,DiodeBlock
,DirectionalBlock
,DirtPathBlock
,DispenserBlock
,DoorBlock
,DoublePlantBlock
,DragonEggBlock
,DropExperienceBlock
,DropperBlock
,EnchantmentTableBlock
,EnderChestBlock
,EndGatewayBlock
,EndPortalBlock
,EndPortalFrameBlock
,EndRodBlock
,EquipableCarvedPumpkinBlock
,FaceAttachedHorizontalDirectionalBlock
,FallingBlock
,FarmBlock
,FenceBlock
,FenceGateBlock
,FireBlock
,FletchingTableBlock
,FlowerBlock
,FlowerPotBlock
,FrogspawnBlock
,FrostedIceBlock
,FungusBlock
,FurnaceBlock
,GlassBlock
,GlazedTerracottaBlock
,GlowLichenBlock
,GrassBlock
,GravelBlock
,GrindstoneBlock
,GrowingPlantBlock
,GrowingPlantBodyBlock
,GrowingPlantHeadBlock
,HalfTransparentBlock
,HangingRootsBlock
,HayBlock
,HoneyBlock
,HopperBlock
,HorizontalDirectionalBlock
,HugeMushroomBlock
,IceBlock
,InfestedBlock
,InfestedRotatedPillarBlock
,IronBarsBlock
,JigsawBlock
,JukeboxBlock
,KelpBlock
,KelpPlantBlock
,LadderBlock
,LanternBlock
,LavaCauldronBlock
,LayeredCauldronBlock
,LeavesBlock
,LecternBlock
,LeverBlock
,LightBlock
,LightningRodBlock
,LiquidBlock
,LoomBlock
,MagmaBlock
,MangroveLeavesBlock
,MangrovePropaguleBlock
,MangroveRootsBlock
,MelonBlock
,MossBlock
,MovingPistonBlock
,MudBlock
,MultifaceBlock
,MushroomBlock
,MyceliumBlock
,NetherPortalBlock
,NetherrackBlock
,NetherSproutsBlock
,NetherWartBlock
,NoteBlock
,NyliumBlock
,ObserverBlock
,PiglinWallSkullBlock
,PinkPetalsBlock
,PipeBlock
,PistonBaseBlock
,PistonHeadBlock
,PitcherCropBlock
,PlayerHeadBlock
,PlayerWallHeadBlock
,PointedDripstoneBlock
,PotatoBlock
,PowderSnowBlock
,PowderSnowCauldronBlock
,PoweredBlock
,PoweredRailBlock
,PressurePlateBlock
,PumpkinBlock
,RailBlock
,RedstoneLampBlock
,RedStoneOreBlock
,RedstoneTorchBlock
,RedstoneWallTorchBlock
,RedStoneWireBlock
,RepeaterBlock
,RespawnAnchorBlock
,RodBlock
,RootedDirtBlock
,RootsBlock
,RotatedPillarBlock
,SandBlock
,SaplingBlock
,ScaffoldingBlock
,SculkBlock
,SculkCatalystBlock
,SculkSensorBlock
,SculkShriekerBlock
,SculkVeinBlock
,SeagrassBlock
,SeaPickleBlock
,ShulkerBoxBlock
,SignBlock
,SkullBlock
,SlabBlock
,SlimeBlock
,SmallDripleafBlock
,SmithingTableBlock
,SmokerBlock
,SnifferEggBlock
,SnowLayerBlock
,SnowyDirtBlock
,SoulFireBlock
,SoulSandBlock
,SpawnerBlock
,SpongeBlock
,SporeBlossomBlock
,SpreadingSnowyDirtBlock
,StainedGlassBlock
,StainedGlassPaneBlock
,StairBlock
,StandingSignBlock
,StemBlock
,StemGrownBlock
,StonecutterBlock
,StructureBlock
,StructureVoidBlock
,SugarCaneBlock
,SweetBerryBushBlock
,TallFlowerBlock
,TallGrassBlock
,TallSeagrassBlock
,TargetBlock
,TintedGlassBlock
,TntBlock
,TorchBlock
,TorchflowerCropBlock
,TrapDoorBlock
,TrappedChestBlock
,TripWireBlock
,TripWireHookBlock
,TurtleEggBlock
,TwistingVinesBlock
,TwistingVinesPlantBlock
,VineBlock
,WallBannerBlock
,WallBlock
,WallHangingSignBlock
,WallSignBlock
,WallSkullBlock
,WallTorchBlock
,WaterlilyBlock
,WeatheringCopperFullBlock
,WeatheringCopperSlabBlock
,WeatheringCopperStairBlock
,WebBlock
,WeepingVinesBlock
,WeepingVinesPlantBlock
,WeightedPressurePlateBlock
,WetSpongeBlock
,WitherRoseBlock
,WitherSkullBlock
,WitherWallSkullBlock
,WoolCarpetBlock
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
addLandingEffects
(BlockState state1, ServerLevel level, BlockPos pos, BlockState state2, LivingEntity entity, int numberOfParticles) Allows a block to override the standard EntityLivingBase.updateFallState particles, this is a server side method that spawns particles with WorldServer.spawnParticle.default boolean
addRunningEffects
(BlockState state, Level level, BlockPos pos, Entity entity) Allows a block to override the standard vanilla running particles.default boolean
canBeHydrated
(BlockState state, BlockGetter getter, BlockPos pos, FluidState fluid, BlockPos fluidPos) Returns whether the block can be hydrated by a fluid.default boolean
canConnectRedstone
(BlockState state, BlockGetter level, BlockPos pos, @Nullable Direction direction) Whether redstone dust should visually connect to this block on a given sidedefault boolean
canDropFromExplosion
(BlockState state, BlockGetter level, BlockPos pos, Explosion explosion) Determines if this block should drop loot when exploded.default boolean
canEntityDestroy
(BlockState state, BlockGetter level, BlockPos pos, Entity entity) Determines if this block is can be destroyed by the specified entities normal behavior.default boolean
canHarvestBlock
(BlockState state, BlockGetter level, BlockPos pos, Player player) Determines if the player can harvest this block, obtaining it's drops when the block is destroyed.default boolean
canStickTo
(BlockState state, BlockState other) Determines if this block can stick to another block when pushed by a piston.boolean
canSustainPlant
(BlockState state, BlockGetter level, BlockPos pos, Direction facing, IPlantable plantable) Determines if this block can support the passed in plant, allowing it to be planted and grow.default boolean
collisionExtendsVertically
(BlockState state, BlockGetter level, BlockPos pos, Entity collidingEntity) Determines if this block's collision box should be treated as though it can extend above its block space.default @Nullable BlockPathTypes
getAdjacentBlockPathType
(BlockState state, BlockGetter level, BlockPos pos, @Nullable Mob mob, BlockPathTypes originalType) Gets the path type of the adjacent block to a pathfinding entity.default BlockState
getAppearance
(BlockState state, BlockAndTintGetter level, BlockPos pos, Direction side, @Nullable BlockState queryState, @Nullable BlockPos queryPos) Returns theBlockState
that this block reports to look like on the given side, for querying by other mods.default @org.jetbrains.annotations.Nullable float[]
getBeaconColorMultiplier
(BlockState state, LevelReader level, BlockPos pos, BlockPos beaconPos) default Direction
getBedDirection
(BlockState state, LevelReader level, BlockPos pos) Returns the direction of the block.default @Nullable BlockPathTypes
getBlockPathType
(BlockState state, BlockGetter level, BlockPos pos, @Nullable Mob mob) Gets the path type of this block when an entity is pathfinding.default ItemStack
getCloneItemStack
(BlockState state, HitResult target, BlockGetter level, BlockPos pos, Player player) Called when A user uses the creative pick block button on this blockdefault float
getEnchantPowerBonus
(BlockState state, LevelReader level, BlockPos pos) Determines the amount of enchanting power this block can provide to an enchanting table.default int
getExpDrop
(BlockState state, LevelReader level, RandomSource randomSource, BlockPos pos, int fortuneLevel, int silkTouchLevel) Gathers how much experience this block drops when broken.default float
getExplosionResistance
(BlockState state, BlockGetter level, BlockPos pos, Explosion explosion) Location sensitive version of getExplosionResistancedefault int
getFireSpreadSpeed
(BlockState state, BlockGetter level, BlockPos pos, Direction direction) Called when fire is updating on a neighbor block.default int
getFlammability
(BlockState state, BlockGetter level, BlockPos pos, Direction direction) Chance that fire will spread and consume this block. 300 being a 100% chance, 0, being a 0% chance.default float
getFriction
(BlockState state, LevelReader level, BlockPos pos, @Nullable Entity entity) Gets the slipperiness at the given location at the given state.default int
getLightEmission
(BlockState state, BlockGetter level, BlockPos pos) Get a light value for this block, taking into account the given state and coordinates, normal ranges are between 0 and 15default MapColor
getMapColor
(BlockState state, BlockGetter level, BlockPos pos, MapColor defaultColor) Returns theMapColor
shown on the map.default @Nullable PushReaction
getPistonPushReaction
(BlockState state) Returns the reaction of the block when pushed or pulled by a piston.getRespawnPosition
(BlockState state, EntityType<?> type, LevelReader levelReader, BlockPos pos, float orientation, @Nullable LivingEntity entity) Returns the position that the entity is moved to upon respawning at this block.default SoundType
getSoundType
(BlockState state, LevelReader level, BlockPos pos, @Nullable Entity entity) Sensitive version of getSoundTypedefault BlockState
getStateAtViewpoint
(BlockState state, BlockGetter level, BlockPos pos, Vec3 viewpoint) Used to determine the state 'viewed' by an entity (seeCamera.getBlockAtCamera()
).default @Nullable BlockState
getToolModifiedState
(BlockState state, UseOnContext context, ToolAction toolAction, boolean simulate) Returns the state that this block should transform into when right-clicked by a tool.default boolean
getWeakChanges
(BlockState state, LevelReader level, BlockPos pos) If this block should be notified of weak changes.default boolean
hidesNeighborFace
(BlockGetter level, BlockPos pos, BlockState state, BlockState neighborState, Direction dir) Whether this block hides the neighbors face pointed towards by the given direction.default boolean
isBed
(BlockState state, BlockGetter level, BlockPos pos, @Nullable Entity player) Determines if this block is classified as a Bed, Allowing players to sleep in it, though the block has to specifically perform the sleeping functionality in it's activated event.default boolean
isBurning
(BlockState state, BlockGetter level, BlockPos pos) Determines if this block should set fire and deal fire damage to entities coming into contact with it.default boolean
isConduitFrame
(BlockState state, LevelReader level, BlockPos pos, BlockPos conduit) Determines if this block can be used as the frame of a conduit.default boolean
isFertile
(BlockState state, BlockGetter level, BlockPos pos) Checks if this soil is fertile, typically this means that growth rates of plants on this soil will be slightly sped up.default boolean
isFireSource
(BlockState state, LevelReader level, BlockPos pos, Direction direction) Currently only called by fire when it is on top of this block.default boolean
isFlammable
(BlockState state, BlockGetter level, BlockPos pos, Direction direction) Called when fire is updating, checks if a block face can catch fire.default boolean
isLadder
(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) Checks if a player or entity can use this block to 'climb' like a ladder.default boolean
isPortalFrame
(BlockState state, BlockGetter level, BlockPos pos) Determines if this block can be used as part of a frame of a nether portal.default boolean
isScaffolding
(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) Checks if a player or entity handles movement on this block like scaffolding.default boolean
isSlimeBlock
(BlockState state) default boolean
isStickyBlock
(BlockState state) default boolean
isValidSpawn
(BlockState state, BlockGetter level, BlockPos pos, SpawnPlacements.Type type, EntityType<?> entityType) Determines if a specified mob type can spawn on this block, returning false will prevent any mob from spawning on the block.default boolean
makesOpenTrapdoorAboveClimbable
(BlockState state, LevelReader level, BlockPos pos, BlockState trapdoorState) Checks if this block makes an open trapdoor above it climbable.default void
onBlockExploded
(BlockState state, Level level, BlockPos pos, Explosion explosion) Called when the block is destroyed by an explosion.default void
onBlockStateChange
(LevelReader level, BlockPos pos, BlockState oldState, BlockState newState) Called after theBlockState
at the givenBlockPos
was changed and neighbors were updated.default void
onCaughtFire
(BlockState state, Level level, BlockPos pos, @Nullable Direction direction, @Nullable LivingEntity igniter) If the block is flammable, this is called when it gets lit on fire.default boolean
onDestroyedByPlayer
(BlockState state, Level level, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) Called when a player removes a block.default void
onNeighborChange
(BlockState state, LevelReader level, BlockPos pos, BlockPos neighbor) Called when a tile entity on a side of this block changes is created or is destroyed.default boolean
onTreeGrow
(BlockState state, LevelReader level, BiConsumer<BlockPos, BlockState> placeFunction, RandomSource randomSource, BlockPos pos, TreeConfiguration config) Called when a tree grows on top of this block and tries to set it to dirt by the trunk placer.default BlockState
rotate
(BlockState state, LevelAccessor level, BlockPos pos, Rotation direction) private Block
self()
default void
setBedOccupied
(BlockState state, Level level, BlockPos pos, LivingEntity sleeper, boolean occupied) Called when a user either starts or stops sleeping in the bed.default boolean
shouldCheckWeakPower
(BlockState state, SignalGetter level, BlockPos pos, Direction side) Called to determine whether to allow the block to handle its own indirect power rather than using the default rules.default boolean
shouldDisplayFluidOverlay
(BlockState state, BlockAndTintGetter level, BlockPos pos, FluidState fluidState) Called to determine whether this block should use the fluid overlay texture or flowing texture when it is placed under the fluid.default boolean
Whether this block allows a neighboring block to hide the face of this block it touches.
-
Method Details
-
self
-
getFriction
default float getFriction(BlockState state, LevelReader level, BlockPos pos, @Nullable @Nullable Entity entity) Gets the slipperiness at the given location at the given state. Normally between 0 and 1.Note that entities may reduce slipperiness by a certain factor of their own; for
LivingEntity
, this is.91
.ItemEntity
uses.98
, andFishingHook
uses.92
.- Parameters:
state
- state of the blocklevel
- the levelpos
- the position in the levelentity
- the entity in question- Returns:
- the factor by which the entity's motion should be multiplied
-
getLightEmission
Get a light value for this block, taking into account the given state and coordinates, normal ranges are between 0 and 15- Parameters:
state
- The state of this blocklevel
- The level this block is inpos
- The position of this block in the level, will beBlockPos.ZERO
when the chunk being loaded or generated calls this to check whether it contains any light sources- Returns:
- The light value
- Implementation Note:
-
If the given state of this block may emit light but requires position context to determine the light
value, then it must return a non-zero light value if
(pos == BlockPos.ZERO)
in order for the chunk calling this to be considered as containing light sources. -
The given
BlockGetter
may be a chunk. Block, fluid or block entity accesses outside of its bounds will cause issues such as wrapping coordinates returning values from the opposing chunk edge -
This method may be called on a worker thread and must therefore use
IForgeBlockGetter.getExistingBlockEntity(BlockPos)
to retrieve theBlockEntity
at the given position
-
If the given state of this block may emit light but requires position context to determine the light
value, then it must return a non-zero light value if
-
isLadder
Checks if a player or entity can use this block to 'climb' like a ladder.- Parameters:
state
- The current statelevel
- The current levelpos
- Block position in levelentity
- The entity trying to use the ladder, CAN be null.- Returns:
- True if the block should act like a ladder
-
makesOpenTrapdoorAboveClimbable
default boolean makesOpenTrapdoorAboveClimbable(BlockState state, LevelReader level, BlockPos pos, BlockState trapdoorState) Checks if this block makes an open trapdoor above it climbable.- Parameters:
state
- The current statelevel
- The current levelpos
- Block position in leveltrapdoorState
- The current state of the open trapdoor above- Returns:
- True if the block should act like a ladder
-
isBurning
Determines if this block should set fire and deal fire damage to entities coming into contact with it.- Parameters:
level
- The current levelpos
- Block position in level- Returns:
- True if the block should deal damage
-
canHarvestBlock
Determines if the player can harvest this block, obtaining it's drops when the block is destroyed.- Parameters:
level
- The current levelpos
- The block's current positionplayer
- The player damaging the block- Returns:
- True to spawn the drops
-
onDestroyedByPlayer
default boolean onDestroyedByPlayer(BlockState state, Level level, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) Called when a player removes a block. This is responsible for actually destroying the block, and the block is intact at time of call. This is called regardless of whether the player can harvest the block or not. Return true if the block is actually destroyed. Note: When used in multiplayer, this is called on both client and server sides!- Parameters:
state
- The current state.level
- The current levelplayer
- The player damaging the block, may be nullpos
- Block position in levelwillHarvest
- True if Block.harvestBlock will be called after this, if the return in true. Can be useful to delay the destruction of tile entities till after harvestBlockfluid
- The current fluid state at current position- Returns:
- True if the block is actually destroyed.
-
isBed
default boolean isBed(BlockState state, BlockGetter level, BlockPos pos, @Nullable @Nullable Entity player) Determines if this block is classified as a Bed, Allowing players to sleep in it, though the block has to specifically perform the sleeping functionality in it's activated event.- Parameters:
state
- The current statelevel
- The current levelpos
- Block position in levelplayer
- The player or camera entity, null in some cases.- Returns:
- True to treat this as a bed
-
getRespawnPosition
default Optional<Vec3> getRespawnPosition(BlockState state, EntityType<?> type, LevelReader levelReader, BlockPos pos, float orientation, @Nullable @Nullable LivingEntity entity) Returns the position that the entity is moved to upon respawning at this block.- Parameters:
state
- The current statetype
- The entity type used when checking if a dismount blockstate is dangerous. Currently always PLAYER.levelReader
- The current levelpos
- Block position in levelorientation
- The angle the entity had when setting the respawn pointentity
- The entity respawning, often null- Returns:
- The spawn position or the empty optional if respawning here is not possible
-
isValidSpawn
default boolean isValidSpawn(BlockState state, BlockGetter level, BlockPos pos, SpawnPlacements.Type type, EntityType<?> entityType) Determines if a specified mob type can spawn on this block, returning false will prevent any mob from spawning on the block.- Parameters:
state
- The current statelevel
- The current levelpos
- Block position in leveltype
- The Mob Category Type- Returns:
- True to allow a mob of the specified category to spawn, false to prevent it.
-
setBedOccupied
default void setBedOccupied(BlockState state, Level level, BlockPos pos, LivingEntity sleeper, boolean occupied) Called when a user either starts or stops sleeping in the bed.- Parameters:
level
- The current levelpos
- Block position in levelsleeper
- The sleeper or camera entity, null in some cases.occupied
- True if we are occupying the bed, or false if they are stopping use of the bed
-
getBedDirection
Returns the direction of the block. Same values that are returned by BlockDirectional. Called every frame tick for every living entity. Be VERY fast.- Parameters:
state
- The current statelevel
- The current levelpos
- Block position in level- Returns:
- Bed direction
-
getExplosionResistance
default float getExplosionResistance(BlockState state, BlockGetter level, BlockPos pos, Explosion explosion) Location sensitive version of getExplosionResistance- Parameters:
level
- The current levelpos
- Block position in levelexplosion
- The explosion- Returns:
- The amount of the explosion absorbed.
-
getCloneItemStack
default ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter level, BlockPos pos, Player player) Called when A user uses the creative pick block button on this block- Parameters:
target
- The full target the player is looking at- Returns:
- A ItemStack to add to the player's inventory, empty itemstack if nothing should be added.
-
addLandingEffects
default boolean addLandingEffects(BlockState state1, ServerLevel level, BlockPos pos, BlockState state2, LivingEntity entity, int numberOfParticles) Allows a block to override the standard EntityLivingBase.updateFallState particles, this is a server side method that spawns particles with WorldServer.spawnParticle.- Parameters:
level
- The current server levelpos
- The position of the block.state2
- The state at the specific level/posentity
- The entity that hit landed on the blocknumberOfParticles
- That vanilla level have spawned- Returns:
- True to prevent vanilla landing particles from spawning
-
addRunningEffects
Allows a block to override the standard vanilla running particles. This is called from Entity.spawnSprintParticle and is called both, Client and server side, it's up to the implementor to client check / server check. By default vanilla spawns particles only on the client and the server methods no-op.- Parameters:
state
- The BlockState the entity is running on.level
- The level.pos
- The position at the entities feet.entity
- The entity running on the block.- Returns:
- True to prevent vanilla running particles from spawning.
-
canSustainPlant
boolean canSustainPlant(BlockState state, BlockGetter level, BlockPos pos, Direction facing, IPlantable plantable) Determines if this block can support the passed in plant, allowing it to be planted and grow. Some examples: Reeds check if its a reed, or if its sand/dirt/grass and adjacent to water Cacti checks if its a cacti, or if its sand Nether types check for soul sand Crops check for tilled soil Caves check if it's a solid surface Plains check if its grass or dirt Water check if its still water- Parameters:
state
- The Current statelevel
- The current levelfacing
- The direction relative to the given position the plant wants to be, typically its UPplantable
- The plant that wants to check- Returns:
- True to allow the plant to be planted/stay.
-
onTreeGrow
default boolean onTreeGrow(BlockState state, LevelReader level, BiConsumer<BlockPos, BlockState> placeFunction, RandomSource randomSource, BlockPos pos, TreeConfiguration config) Called when a tree grows on top of this block and tries to set it to dirt by the trunk placer. An override that returns true is responsible for using the place function to set blocks in the world properly during generation. A modded grass block might override this method to ensure it turns into the corresponding modded dirt instead of regular dirt when a tree grows on it. For modded grass blocks, returning true from this method is NOT a substitute for adding your block to the #minecraft:dirt tag, rather for changing the behaviour to something other than setting to dirt. NOTE: This happens DURING world generation, the generation may be incomplete when this is called. Use the placeFunction when modifying the level.- Parameters:
state
- The current statelevel
- The current levelplaceFunction
- Function to set blocks in the level for the tree, use this instead of the level directlyrandomSource
- The random sourcepos
- Position of the block to be set to dirtconfig
- Configuration of the trunk placer. Consider azalea trees, which should place rooted dirt instead of regular dirt.- Returns:
- True to ignore vanilla behaviour
-
isFertile
Checks if this soil is fertile, typically this means that growth rates of plants on this soil will be slightly sped up. Only vanilla case is tilledField when it is within range of water.- Parameters:
level
- The current levelpos
- Block position in level- Returns:
- True if the soil should be considered fertile.
-
isConduitFrame
Determines if this block can be used as the frame of a conduit.- Parameters:
level
- The current levelpos
- Block position in levelconduit
- Conduit position in level- Returns:
- True, to support the conduit, and make it active with this block.
-
isPortalFrame
Determines if this block can be used as part of a frame of a nether portal.- Parameters:
state
- The current statelevel
- The current levelpos
- Block position in level- Returns:
- True, to support being part of a nether portal frame, false otherwise.
-
getExpDrop
default int getExpDrop(BlockState state, LevelReader level, RandomSource randomSource, BlockPos pos, int fortuneLevel, int silkTouchLevel) Gathers how much experience this block drops when broken.- Parameters:
state
- The current statelevel
- The levelrandomSource
- Random source to use for experience randomnesspos
- Block positionfortuneLevel
- fortune enchantment level of tool being usedsilkTouchLevel
- silk touch enchantment level of tool being used- Returns:
- Amount of XP from breaking this block.
-
rotate
-
getEnchantPowerBonus
Determines the amount of enchanting power this block can provide to an enchanting table.- Parameters:
level
- The levelpos
- Block position in level- Returns:
- The amount of enchanting power this block produces.
-
onNeighborChange
Called when a tile entity on a side of this block changes is created or is destroyed.- Parameters:
level
- The levelpos
- Block position in levelneighbor
- Block position of neighbor
-
shouldCheckWeakPower
default boolean shouldCheckWeakPower(BlockState state, SignalGetter level, BlockPos pos, Direction side) Called to determine whether to allow the block to handle its own indirect power rather than using the default rules.- Parameters:
level
- The levelpos
- Block position in levelside
- The INPUT side of the block to be powered - ie the opposite of this block's output side- Returns:
- Whether Block#isProvidingWeakPower should be called when determining indirect power
-
getWeakChanges
If this block should be notified of weak changes. Weak changes are changes 1 block away through a solid block. Similar to comparators.- Parameters:
level
- The current levelpos
- Block position in level- Returns:
- true To be notified of changes
-
getSoundType
default SoundType getSoundType(BlockState state, LevelReader level, BlockPos pos, @Nullable @Nullable Entity entity) Sensitive version of getSoundType- Parameters:
state
- The statelevel
- The levelpos
- The position. Note that the level may not necessarily havestate
here!entity
- The entity that is breaking/stepping on/placing/hitting/falling on this block, or null if no entity is in this context- Returns:
- A SoundType to use
-
getBeaconColorMultiplier
@Nullable default @org.jetbrains.annotations.Nullable float[] getBeaconColorMultiplier(BlockState state, LevelReader level, BlockPos pos, BlockPos beaconPos) - Parameters:
state
- The statelevel
- The levelpos
- The position of this statebeaconPos
- The position of the beacon- Returns:
- A float RGB [0.0, 1.0] array to be averaged with a beacon's existing beam color, or null to do nothing to the beam
-
getStateAtViewpoint
default BlockState getStateAtViewpoint(BlockState state, BlockGetter level, BlockPos pos, Vec3 viewpoint) Used to determine the state 'viewed' by an entity (seeCamera.getBlockAtCamera()
). Can be used by fluid blocks to determine if the viewpoint is within the fluid or not.- Parameters:
state
- the statelevel
- the levelpos
- the positionviewpoint
- the viewpoint- Returns:
- the block state that should be 'seen'
-
getBlockPathType
@Nullable default @Nullable BlockPathTypes getBlockPathType(BlockState state, BlockGetter level, BlockPos pos, @Nullable @Nullable Mob mob) Gets the path type of this block when an entity is pathfinding. Whennull
, uses vanilla behavior.- Parameters:
state
- the state of the blocklevel
- the level which contains this blockpos
- the position of the blockmob
- the mob currently pathfinding, may benull
- Returns:
- the path type of this block
-
getAdjacentBlockPathType
@Nullable default @Nullable BlockPathTypes getAdjacentBlockPathType(BlockState state, BlockGetter level, BlockPos pos, @Nullable @Nullable Mob mob, BlockPathTypes originalType) Gets the path type of the adjacent block to a pathfinding entity. Path types with a negative malus are not traversable for the entity. Pathfinding entities will favor paths consisting of a lower malus. Whennull
, uses vanilla behavior.- Parameters:
state
- the state of the blocklevel
- the level which contains this blockpos
- the position of the blockmob
- the mob currently pathfinding, may benull
originalType
- the path type of the source the entity is on- Returns:
- the path type of this block
-
isSlimeBlock
- Parameters:
state
- The state- Returns:
- true if the block is sticky block which used for pull or push adjacent blocks (use by piston)
-
isStickyBlock
- Parameters:
state
- The state- Returns:
- true if the block is sticky block which used for pull or push adjacent blocks (use by piston)
-
canStickTo
Determines if this block can stick to another block when pushed by a piston.- Parameters:
state
- My stateother
- Other block- Returns:
- True to link blocks
-
getFlammability
Chance that fire will spread and consume this block. 300 being a 100% chance, 0, being a 0% chance.- Parameters:
state
- The current statelevel
- The current levelpos
- Block position in leveldirection
- The direction that the fire is coming from- Returns:
- A number ranging from 0 to 300 relating used to determine if the block will be consumed by fire
-
isFlammable
Called when fire is updating, checks if a block face can catch fire.- Parameters:
state
- The current statelevel
- The current levelpos
- Block position in leveldirection
- The direction that the fire is coming from- Returns:
- True if the face can be on fire, false otherwise.
-
onCaughtFire
default void onCaughtFire(BlockState state, Level level, BlockPos pos, @Nullable @Nullable Direction direction, @Nullable @Nullable LivingEntity igniter) If the block is flammable, this is called when it gets lit on fire.- Parameters:
state
- The current statelevel
- The current levelpos
- Block position in leveldirection
- The direction that the fire is coming fromigniter
- The entity that lit the fire
-
getFireSpreadSpeed
default int getFireSpreadSpeed(BlockState state, BlockGetter level, BlockPos pos, Direction direction) Called when fire is updating on a neighbor block. The higher the number returned, the faster fire will spread around this block.- Parameters:
state
- The current statelevel
- The current levelpos
- Block position in leveldirection
- The direction that the fire is coming from- Returns:
- A number that is used to determine the speed of fire growth around the block
-
isFireSource
default boolean isFireSource(BlockState state, LevelReader level, BlockPos pos, Direction direction) Currently only called by fire when it is on top of this block. Returning true will prevent the fire from naturally dying during updating. Also prevents firing from dying from rain.- Parameters:
state
- The current statelevel
- The current levelpos
- Block position in leveldirection
- The direction that the fire is coming from- Returns:
- True if this block sustains fire, meaning it will never go out.
-
canEntityDestroy
Determines if this block is can be destroyed by the specified entities normal behavior.- Parameters:
state
- The current statelevel
- The current levelpos
- Block position in level- Returns:
- True to allow the ender dragon to destroy this block
-
canDropFromExplosion
default boolean canDropFromExplosion(BlockState state, BlockGetter level, BlockPos pos, Explosion explosion) Determines if this block should drop loot when exploded. -
onBlockExploded
Called when the block is destroyed by an explosion. Useful for allowing the block to take into account tile entities, state, etc. when exploded, before it is removed.- Parameters:
level
- The current levelpos
- Block position in levelexplosion
- The explosion instance affecting the block
-
collisionExtendsVertically
default boolean collisionExtendsVertically(BlockState state, BlockGetter level, BlockPos pos, Entity collidingEntity) Determines if this block's collision box should be treated as though it can extend above its block space. Use this to replicate fence and wall behavior. -
shouldDisplayFluidOverlay
default boolean shouldDisplayFluidOverlay(BlockState state, BlockAndTintGetter level, BlockPos pos, FluidState fluidState) Called to determine whether this block should use the fluid overlay texture or flowing texture when it is placed under the fluid.- Parameters:
state
- The current statelevel
- The levelpos
- Block position in levelfluidState
- The state of the fluid- Returns:
- Whether the fluid overlay texture should be used
-
getToolModifiedState
@Nullable default @Nullable BlockState getToolModifiedState(BlockState state, UseOnContext context, ToolAction toolAction, boolean simulate) Returns the state that this block should transform into when right-clicked by a tool. For example: Used to determine ifan axe can strip
,a shovel can path
, ora hoe can till
. Returnsnull
if nothing should happen.- Parameters:
state
- The current statecontext
- The use on context that the action was performed intoolAction
- The action being performed by the toolsimulate
- Iftrue
, no actions that modify the world in any way should be performed. Iffalse
, the world may be modified.- Returns:
- The resulting state after the action has been performed
-
isScaffolding
default boolean isScaffolding(BlockState state, LevelReader level, BlockPos pos, LivingEntity entity) Checks if a player or entity handles movement on this block like scaffolding.- Parameters:
state
- The current statelevel
- The current levelpos
- The block position in levelentity
- The entity on the scaffolding- Returns:
- True if the block should act like scaffolding
-
canConnectRedstone
default boolean canConnectRedstone(BlockState state, BlockGetter level, BlockPos pos, @Nullable @Nullable Direction direction) Whether redstone dust should visually connect to this block on a given sideThe default implementation is identical to
RedStoneWireBlock#shouldConnectTo(BlockState, Direction)
RedStoneWireBlock
updates its visual connection whenBlockBehaviour.BlockStateBase.updateShape(Direction, BlockState, LevelAccessor, BlockPos, BlockPos)
is called, this callback is used during the evaluation of its new shape.- Parameters:
state
- The current statelevel
- The levelpos
- The block position in leveldirection
- The coming direction of the redstone dust connection (with respect to the block at pos)- Returns:
- True if redstone dust should visually connect on the side passed
If the return value is evaluated based on level and pos (e.g. from BlockEntity), then the implementation of this block should notify its neighbors to update their shapes when necessary. Consider using
BlockBehaviour.BlockStateBase.updateNeighbourShapes(LevelAccessor, BlockPos, int, int)
orBlockBehaviour.BlockStateBase.updateShape(Direction, BlockState, LevelAccessor, BlockPos, BlockPos)
.Example:
1.
yourBlockState.updateNeighbourShapes(level, yourBlockPos, UPDATE_ALL);
2.
neighborState.updateShape(fromDirection, stateOfYourBlock, level, neighborBlockPos, yourBlockPos)
, wherefromDirection
is defined from the neighbor block's point of view.
-
hidesNeighborFace
default boolean hidesNeighborFace(BlockGetter level, BlockPos pos, BlockState state, BlockState neighborState, Direction dir) Whether this block hides the neighbors face pointed towards by the given direction.This method should only be used for blocks you don't control, for your own blocks override
BlockBehaviour.skipRendering(BlockState, BlockState, Direction)
on the respective block insteadWARNING: This method is likely to be called from a worker thread! If you want to retrieve a
BlockEntity
from the given level, make sure to useIForgeBlockGetter.getExistingBlockEntity(BlockPos)
to not accidentally create a new or delete an oldBlockEntity
off of the main thread as this would cause a write operation to the givenBlockGetter
and cause a CME in the process. Any other direct or indirect write operation to theBlockGetter
will have the same outcome.- Parameters:
level
- The worldpos
- The blocks position in the worldstate
- The blocksBlockState
neighborState
- The neighboring blocksBlockState
dir
- The direction towards the neighboring block
-
supportsExternalFaceHiding
Whether this block allows a neighboring block to hide the face of this block it touches. If this returns true,IForgeBlockState.hidesNeighborFace(BlockGetter, BlockPos, BlockState, Direction)
will be called on the neighboring block. -
onBlockStateChange
default void onBlockStateChange(LevelReader level, BlockPos pos, BlockState oldState, BlockState newState) Called after theBlockState
at the givenBlockPos
was changed and neighbors were updated. This method is called on the server and client side. Modifying the level is disallowed in this method. Useful for calculating additional data based on the new state and the neighbor's reactions to the state change.- Parameters:
level
- The level the state was modified inpos
- The blocks position in the leveloldState
- The previous state of the block at the given position, may be a different block than this onenewState
- The new state of the block at the given position
-
canBeHydrated
default boolean canBeHydrated(BlockState state, BlockGetter getter, BlockPos pos, FluidState fluid, BlockPos fluidPos) Returns whether the block can be hydrated by a fluid.Hydration is an arbitrary word which depends on the block.
- A farmland has moisture
- A sponge can soak up the liquid
- A coral can live
- Parameters:
state
- the state of the block being hydratedgetter
- the getter which can get the blockpos
- the position of the block being hydratedfluid
- the state of the fluidfluidPos
- the position of the fluid- Returns:
true
if the block can be hydrated,false
otherwise
-
getMapColor
default MapColor getMapColor(BlockState state, BlockGetter level, BlockPos pos, MapColor defaultColor) Returns theMapColor
shown on the map.- Parameters:
state
- The state of this blocklevel
- The level this block is inpos
- The blocks position in the leveldefaultColor
- TheMapColor
configured for the givenBlockState
in theBlockBehaviour.Properties
-
getAppearance
default BlockState getAppearance(BlockState state, BlockAndTintGetter level, BlockPos pos, Direction side, @Nullable @Nullable BlockState queryState, @Nullable @Nullable BlockPos queryPos) Returns theBlockState
that this block reports to look like on the given side, for querying by other mods. Note: Overriding this does not change how this block renders. That must still be handled in the block's model.Common implementors would be covers and facades, or any other mimic blocks that proxy another block's model. Common consumers would be models with connected textures that wish to seamlessly connect to mimic blocks.
Note that this method may be called on the server, or on any of the client's meshing threads.
As such, if you need any data from yourBlockEntity
, you should put it inModelData
to guarantee safe concurrent access to it on the client.
CallingIForgeBlockGetter.getModelDataManager()
will returnnull
if in a server context, where it is safe to query yourBlockEntity
directly. Otherwise,ModelDataManager.getAt(BlockPos)
will return theModelData
for the queried block, ornull
if none is present.- Parameters:
state
- The state of this blocklevel
- The level this block is inpos
- The block's position in the levelside
- The side of the block that is being queriedqueryState
- The state of the block that is querying the appearance, ornull
if not applicablequeryPos
- The position of the block that is querying the appearance, ornull
if not applicable- Returns:
- The appearance of this block on the given side. By default, the current state
- See Also:
-
getPistonPushReaction
Returns the reaction of the block when pushed or pulled by a piston. This method should be not called directly, instead viaBlockBehaviour.BlockStateBase.getPistonPushReaction()
.- NORMAL: is pushable and pullable by sticky pistons
- DESTROY: is being destroyed on pushing and pulling
- BLOCK: is not being able to be moved
- IGNORE: only usable by entities
- PUSH_ONLY: can only be pushed, blocks on trying to be pulled
null
: use the PistonPushReaction from the BlockBehaviour.Properties passed into the Block Constructor
- Parameters:
state
- The state of this block- Returns:
- the PushReaction of this state or
null
if the one passed into the block properties should be used
-