Interface IForgeBlockState
- All Known Implementing Classes:
BlockState
public interface IForgeBlockState
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
addLandingEffects(ServerLevel worldserver, 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(Level world, BlockPos pos, Entity entity)
Allows a block to override the standard vanilla running particles.default boolean
canCreatureSpawn(LevelReader world, 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
canDropFromExplosion(BlockGetter world, BlockPos pos, Explosion explosion)
Determines if this block should drop loot when exploded.default boolean
canEntityDestroy(BlockGetter world, BlockPos pos, Entity entity)
Determines if this block is can be destroyed by the specified entities normal behavior.default boolean
canHarvestBlock(BlockGetter world, BlockPos pos, Player player)
Determines if the player can harvest this block, obtaining it's drops when the block is destroyed.default boolean
canRedstoneConnectTo(BlockGetter world, BlockPos pos, Direction direction)
Whether redstone dust should visually connect to this block on a side.default boolean
canStickTo(BlockState other)
Determines if this block can stick to another block when pushed by a piston.default boolean
canSustainPlant(BlockGetter world, BlockPos pos, Direction facing, IPlantable plantable)
Determines if this block can support the passed in plant, allowing it to be planted and grow.default void
catchFire(Level world, BlockPos pos, Direction face, LivingEntity igniter)
If the block is flammable, this is called when it gets lit on fire.default boolean
collisionExtendsVertically(BlockGetter world, BlockPos pos, Entity collidingEntity)
Determines if this block's collision box should be treated as though it can extend above its block space.default BlockPathTypes
getAiPathNodeType(BlockGetter world, BlockPos pos)
Get thePathNodeType
for this block.default BlockPathTypes
getAiPathNodeType(BlockGetter world, BlockPos pos, Mob entity)
Get thePathNodeType
for this block.default float[]
getBeaconColorMultiplier(LevelReader world, BlockPos pos, BlockPos beacon)
default Direction
getBedDirection(LevelReader world, BlockPos pos)
Returns the direction of the block.default float
getEnchantPowerBonus(LevelReader world, BlockPos pos)
Determines the amount of enchanting power this block can provide to an enchanting table.default int
getExpDrop(LevelReader world, BlockPos pos, int fortune, int silktouch)
Gathers how much experience this block drops when broken.default float
getExplosionResistance(BlockGetter world, BlockPos pos, Explosion explosion)
Location sensitive version of getExplosionResistancedefault int
getFireSpreadSpeed(BlockGetter world, BlockPos pos, Direction face)
Called when fire is updating on a neighbor block.default int
getFlammability(BlockGetter world, BlockPos pos, Direction face)
Chance that fire will spread and consume this block.default float
getFriction(LevelReader world, BlockPos pos, Entity entity)
Gets the slipperiness at the given location at the given state.default int
getLightEmission(BlockGetter world, BlockPos pos)
Get a light value for this block, taking into account the given state and coordinates, normal ranges are between 0 and 15default ItemStack
getPickBlock(HitResult target, BlockGetter world, BlockPos pos, Player player)
Called when A user uses the creative pick block button on this blockgetRespawnPosition(EntityType<?> type, LevelReader world, BlockPos pos, float orientation, LivingEntity entity)
Returns the position that the entity is moved to upon respawning at this block.default SoundType
getSoundType(LevelReader world, BlockPos pos, Entity entity)
Sensitive version of getSoundTypedefault BlockState
getStateAtViewpoint(BlockGetter world, BlockPos pos, Vec3 viewpoint)
Used to determine the state 'viewed' by an entity (seeCamera.getBlockAtCamera()
).default BlockState
getToolModifiedState(Level world, BlockPos pos, Player player, ItemStack stack, ToolAction toolAction)
Returns the state that this block should transform into when right clicked by a tool.default boolean
getWeakChanges(LevelReader world, BlockPos pos)
If this block should be notified of weak changes.default boolean
isBed(BlockGetter world, BlockPos pos, LivingEntity sleeper)
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(BlockGetter world, BlockPos pos)
Determines if this block should set fire and deal fire damage to entities coming into contact with it.default boolean
isConduitFrame(LevelReader world, BlockPos pos, BlockPos conduit)
Determines if this block can be used as the frame of a conduit.default boolean
isFertile(BlockGetter world, 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(LevelReader world, BlockPos pos, Direction side)
Currently only called by fire when it is on top of this block.default boolean
isFlammable(BlockGetter world, BlockPos pos, Direction face)
Called when fire is updating, checks if a block face can catch fire.default boolean
isLadder(LevelReader world, BlockPos pos, LivingEntity entity)
Checks if a player or entity can use this block to 'climb' like a ladder.default boolean
isPortalFrame(BlockGetter world, BlockPos pos)
Determines if this block can be used as part of a frame of a nether portal.default boolean
isScaffolding(LivingEntity entity)
Checks if a player or entity handles movement on this block like scaffolding.default boolean
default boolean
default void
onBlockExploded(Level world, BlockPos pos, Explosion explosion)
Called when the block is destroyed by an explosion.default void
onNeighborChange(LevelReader world, BlockPos pos, BlockPos neighbor)
Called when a tile entity on a side of this block changes is created or is destroyed.default boolean
removedByPlayer(Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid)
Called when a player removes a block.default BlockState
rotate(LevelAccessor world, BlockPos pos, Rotation direction)
private BlockState
self()
default void
setBedOccupied(Level world, BlockPos pos, LivingEntity sleeper, boolean occupied)
Called when a user either starts or stops sleeping in the bed.default boolean
shouldCheckWeakPower(LevelReader world, BlockPos pos, Direction side)
Called to determine whether to allow the a block to handle its own indirect power rather than using the default rules.default boolean
shouldDisplayFluidOverlay(BlockAndTintGetter world, 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.
-
Method Details
-
self
-
getFriction
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:
world
- the worldpos
- the position in the worldentity
- 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 -
isLadder
Checks if a player or entity can use this block to 'climb' like a ladder.- Parameters:
world
- The current worldpos
- Block position in worldentity
- The entity trying to use the ladder, CAN be null.- Returns:
- True if the block should act like a ladder
-
canHarvestBlock
Determines if the player can harvest this block, obtaining it's drops when the block is destroyed.- Parameters:
world
- The current worldpos
- The block's current positionplayer
- The player damaging the block- Returns:
- True to spawn the drops
-
removedByPlayer
default boolean removedByPlayer(Level world, 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:
world
- The current worldplayer
- The player damaging the block, may be nullpos
- Block position in worldwillHarvest
- 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 and block state for the position in the world.- Returns:
- True if the block is actually destroyed.
-
isBed
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:
world
- The current worldpos
- Block position in worldsleeper
- The sleeper or camera entity, null in some cases.- Returns:
- True to treat this as a bed
-
canCreatureSpawn
default boolean canCreatureSpawn(LevelReader world, 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:
world
- The current worldpos
- Block position in worldtype
- The Mob Category Type- Returns:
- True to allow a mob of the specified category to spawn, false to prevent it.
-
getRespawnPosition
default Optional<Vec3> getRespawnPosition(EntityType<?> type, LevelReader world, BlockPos pos, float orientation, @Nullable LivingEntity entity)Returns the position that the entity is moved to upon respawning at this block.- Parameters:
type
- The entity type used when checking if a dismount blockstate is dangerous. Currently always PLAYER.world
- The current worldpos
- Block position in worldorientation
- 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
-
setBedOccupied
Called when a user either starts or stops sleeping in the bed.- Parameters:
world
- The current worldpos
- Block position in worldsleeper
- 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- Parameters:
world
- The current worldpos
- Block position in world- Returns:
- Bed direction
-
getExplosionResistance
Location sensitive version of getExplosionResistance- Parameters:
world
- The current worldpos
- Block position in worldexplosion
- The explosion- Returns:
- The amount of the explosion absorbed.
-
getPickBlock
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(ServerLevel worldserver, 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:
worldserver
- The current Server Worldpos
- The position of the block.state2
- The state at the specific world/posentity
- The entity that hit landed on the blocknumberOfParticles
- That vanilla world 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 fromEntity#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:
world
- The world.pos
- The position at the entities feet.entity
- The entity running on the block.- Returns:
- True to prevent vanilla running particles from spawning.
-
canSustainPlant
default boolean canSustainPlant(BlockGetter world, 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:
world
- The current worldfacing
- 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.
-
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:
world
- The current worldpos
- Block position in world- Returns:
- True if the soil should be considered fertile.
-
isConduitFrame
Determines if this block can be used as the frame of a conduit.- Parameters:
world
- The current worldpos
- Block position in worldconduit
- Conduit position in world- 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:
world
- The current worldpos
- Block position in world- Returns:
- True, to support being part of a nether portal frame, false otherwise.
-
getExpDrop
Gathers how much experience this block drops when broken.- Parameters:
world
- The worldpos
- Block positionfortune
-- 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:
world
- The Worldpos
- Block position in world- 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:
world
- The worldpos
- Block position in worldneighbor
- Block position of neighbor
-
shouldCheckWeakPower
Called to determine whether to allow the a block to handle its own indirect power rather than using the default rules.- Parameters:
world
- The worldpos
- Block position in worldside
- 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:
world
- The current worldpos
- Block position in world- Returns:
- true To be notified of changes
-
getSoundType
Sensitive version of getSoundType- Parameters:
world
- The worldpos
- The position. Note that the world 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 float[] getBeaconColorMultiplier(LevelReader world, BlockPos pos, BlockPos beacon)- Parameters:
world
- The worldpos
- The position of this statebeacon
- 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
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:
world
- the worldpos
- the positionviewpoint
- the viewpoint- Returns:
- the block state that should be 'seen'
-
isSlimeBlock
default boolean isSlimeBlock()- Returns:
- true if the block is sticky block which used for pull or push adjacent blocks (use by piston)
-
isStickyBlock
default boolean isStickyBlock()- 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:
other
- 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:
world
- The current worldpos
- Block position in worldface
- The face 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:
world
- The current worldpos
- Block position in worldface
- The face that the fire is coming from- Returns:
- True if the face can be on fire, false otherwise.
-
catchFire
default void catchFire(Level world, BlockPos pos, @Nullable Direction face, @Nullable LivingEntity igniter)If the block is flammable, this is called when it gets lit on fire.- Parameters:
world
- The current worldpos
- Block position in worldface
- The face that the fire is coming fromigniter
- The entity that lit the fire
-
getFireSpreadSpeed
Called when fire is updating on a neighbor block. The higher the number returned, the faster fire will spread around this block.- Parameters:
world
- The current worldpos
- Block position in worldface
- The face that the fire is coming from- Returns:
- A number that is used to determine the speed of fire growth around the block
-
isFireSource
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:
world
- The current worldpos
- Block position in worldside
- The face 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:
world
- The current worldpos
- Block position in world- Returns:
- True to allow the ender dragon to destroy this block
-
isBurning
Determines if this block should set fire and deal fire damage to entities coming into contact with it.- Parameters:
world
- The current worldpos
- Block position in world- Returns:
- True if the block should deal damage
-
getAiPathNodeType
Get thePathNodeType
for this block. Returnnull
for vanilla behavior.- Returns:
- the PathNodeType
-
getAiPathNodeType
@Nullable default BlockPathTypes getAiPathNodeType(BlockGetter world, BlockPos pos, @Nullable Mob entity)Get thePathNodeType
for this block. Returnnull
for vanilla behavior.- Returns:
- the PathNodeType
-
canDropFromExplosion
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:
world
- The current worldpos
- Block position in worldexplosion
- The explosion instance affecting the block
-
collisionExtendsVertically
default boolean collisionExtendsVertically(BlockGetter world, BlockPos pos, Entity collidingEntity)Determines if this block's collision box should be treated as though it can extend above its block space. This can be used to replicate fence and wall behavior. -
shouldDisplayFluidOverlay
default boolean shouldDisplayFluidOverlay(BlockAndTintGetter world, 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:
world
- The worldpos
- Block position in worldfluidState
- The state of the fluid- Returns:
- Whether the fluid overlay texture should be used
-
getToolModifiedState
@Nullable default BlockState getToolModifiedState(Level world, BlockPos pos, Player player, ItemStack stack, ToolAction toolAction)Returns the state that this block should transform into when right clicked by a tool. For example: Used to determine if an axe can strip, a shovel can path, or a hoe can till. Return null if vanilla behavior should be disabled.- Parameters:
world
- The worldpos
- The block position in worldplayer
- The player clicking the blockstack
- The stack being used by the playertoolAction
- The tool type to be considered when performing the action- Returns:
- The resulting state after the action has been performed
-
isScaffolding
Checks if a player or entity handles movement on this block like scaffolding.- Parameters:
entity
- The entity on the scaffolding- Returns:
- True if the block should act like scaffolding
-
canRedstoneConnectTo
default boolean canRedstoneConnectTo(BlockGetter world, BlockPos pos, @Nullable Direction direction)Whether redstone dust should visually connect to this block on a side.Modded redstone wire blocks should call this function to determine visual connections.
- Parameters:
world
- The worldpos
- The block position in worlddirection
- 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
-