Documentation

Bed extends Transparent
in package
Uses ColoredTrait, HorizontalFacingTrait

Table of Contents

INTERNAL_METADATA_BITS  = 4
INTERNAL_METADATA_MASK  = ~(~0 << self::INTERNAL_METADATA_BITS)
$breakInfo  : BlockBreakInfo
$collisionBoxes  : array<string|int, mixed>|null
$facing  : int
$fallbackName  : string
$head  : bool
$idInfo  : BlockIdentifier
$occupied  : bool
$position  : Position
$color  : DyeColor
__clone()  : mixed
__construct()  : mixed
__toString()  : string
addVelocityToEntity()  : Vector3|null
asItem()  : Item
blocksDirectSkyLight()  : bool
Returns whether this block blocks direct sky light from passing through it. This is independent from the light filter value, which is used during propagation.
burnsForever()  : bool
Returns whether fire lit on this block will burn indefinitely.
calculateIntercept()  : RayTraceResult|null
canBeFlowedInto()  : bool
AKA: Block->isFlowable
canBePlaced()  : bool
AKA: Block->isPlaceable
canBePlacedAt()  : bool
canBeReplaced()  : bool
canClimb()  : bool
Returns whether entities can climb up this block.
collidesWithBB()  : bool
Checks for collision against an AxisAlignedBB
getAffectedBlocks()  : array<string|int, mixed>
getAllSides()  : array<string|int, Block>|Generator
Returns the six blocks around this block.
getBreakInfo()  : BlockBreakInfo
Returns an object containing information about the destruction requirements of this block.
getCollisionBoxes()  : array<string|int, AxisAlignedBB>
getColor()  : DyeColor
getDrops()  : array<string|int, mixed>
getDropsForCompatibleTool()  : array<string|int, Item>
Returns an array of Items to be dropped when the block is broken using the correct tool type.
getDropsForIncompatibleTool()  : array<string|int, Item>
Returns the items dropped by this block when broken with an incorrect tool type (or tool with a too-low tier).
getFacing()  : int
getFlameEncouragement()  : int
Returns the chance that the block will catch fire from nearby fire sources. Higher values lead to faster catching fire.
getFlammability()  : int
Returns the base flammability of this block. Higher values lead to the block burning away more quickly.
getFrictionFactor()  : float
getFuelTime()  : int
Returns the time in ticks which the block will fuel a furnace for.
getHorizontalSides()  : array<string|int, Block>|Generator
Returns the 4 blocks on the horizontal axes around the block (north, south, east, west)
getId()  : int
getIdInfo()  : BlockIdentifier
getLightFilter()  : int
Returns the amount of light this block will filter out when light passes through this block.
getLightLevel()  : int
getMaxStackSize()  : int
Returns the maximum number of this block that can fit into a single item stack.
getMeta()  : int
getModelPositionOffset()  : Vector3|null
Returns an additional fractional vector to shift the block model's position by based on the current position.
getName()  : string
getOtherHalf()  : Bed|null
getPickedItem()  : Item
Returns the item that players will equip when middle-clicking on this block.
getPosition()  : Position
getSide()  : Block
Returns the Block on the side $side, works like Vector3::getSide()
getSilkTouchDrops()  : array<string|int, Item>
Returns an array of Items to be dropped when the block is broken using a compatible Silk Touch-enchanted tool.
getStateBitmask()  : int
getXpDropForTool()  : int
Returns how much XP will be dropped by breaking this block with the given item.
hasEntityCollision()  : bool
isAffectedBySilkTouch()  : bool
Returns whether Silk Touch enchanted tools will cause this block to drop as itself.
isFlammable()  : bool
Returns whether this block can catch fire.
isFullCube()  : bool
isHeadPart()  : bool
isOccupied()  : bool
isSameState()  : bool
Returns whether the given block has the same type and properties as this block.
isSameType()  : bool
Returns whether the given block has an equivalent type to this one. This compares base legacy ID and variant.
isSolid()  : bool
isTransparent()  : bool
onAttack()  : bool
Called when this block is attacked (left-clicked). This is called when a player left-clicks the block to try and start to break it in survival mode.
onBreak()  : bool
Do the actions needed so the block is broken with the Item
onEntityInside()  : bool
Called when an entity's bounding box clips inside this block's cell. Note that the entity may not be intersecting with the collision box or bounding box.
onEntityLand()  : float|null
onIncinerate()  : void
Called when this block is burned away by being on fire.
onInteract()  : bool
onNearbyBlockChange()  : void
onPostPlace()  : void
onRandomTick()  : void
Called when this block is randomly updated due to chunk ticking.
onScheduledUpdate()  : void
Called when this block is updated by the delayed blockupdate scheduler in the world.
place()  : bool
readStateFromData()  : void
readStateFromWorld()  : void
setColor()  : $this
setFacing()  : $this
setHead()  : $this
setOccupied()  : $this
ticksRandomly()  : bool
Returns whether random block updates will be done on this block.
writeStateToWorld()  : void
getXpDropAmount()  : int
Returns how much XP this block will drop when broken with an appropriate tool.
recalculateCollisionBoxes()  : array<string|int, AxisAlignedBB>
writeStateToItemMeta()  : int
writeStateToMeta()  : int
getOtherHalfSide()  : int

Constants

INTERNAL_METADATA_BITS

public mixed INTERNAL_METADATA_BITS = 4

INTERNAL_METADATA_MASK

public mixed INTERNAL_METADATA_MASK = ~(~0 << self::INTERNAL_METADATA_BITS)

Properties

$collisionBoxes

protected array<string|int, mixed>|null $collisionBoxes = null

$fallbackName

protected string $fallbackName

$head

protected bool $head = false

$occupied

protected bool $occupied = false

Methods

__clone()

public __clone() : mixed
Return values
mixed —

__toString()

public __toString() : string
Return values
string —

blocksDirectSkyLight()

Returns whether this block blocks direct sky light from passing through it. This is independent from the light filter value, which is used during propagation.

public blocksDirectSkyLight() : bool

In most cases, this is the same as isTransparent(); however, some special cases exist such as leaves and cobwebs, which don't have any additional effect on light propagation, but don't allow direct sky light to pass through.

Return values
bool —

burnsForever()

Returns whether fire lit on this block will burn indefinitely.

public burnsForever() : bool
Return values
bool —

canBeFlowedInto()

AKA: Block->isFlowable

public canBeFlowedInto() : bool
Return values
bool —

canBePlaced()

AKA: Block->isPlaceable

public canBePlaced() : bool
Return values
bool —

canBePlacedAt()

public canBePlacedAt(Block $blockReplace, Vector3 $clickVector, int $face, bool $isClickedBlock) : bool
Parameters
$blockReplace : Block
$clickVector : Vector3
$face : int
$isClickedBlock : bool
Return values
bool —

canBeReplaced()

public canBeReplaced() : bool
Return values
bool —

canClimb()

Returns whether entities can climb up this block.

public canClimb() : bool
Return values
bool —

collidesWithBB()

Checks for collision against an AxisAlignedBB

public collidesWithBB(AxisAlignedBB $bb) : bool
Parameters
$bb : AxisAlignedBB
Return values
bool —

getAffectedBlocks()

public getAffectedBlocks() : array<string|int, mixed>
Return values
array<string|int, mixed> —

getAllSides()

Returns the six blocks around this block.

public getAllSides() : array<string|int, Block>|Generator
Tags
phpstan-return

\Generator<int, Block, void, void>

Return values
array<string|int, Block>|Generator —

getBreakInfo()

Returns an object containing information about the destruction requirements of this block.

public getBreakInfo() : BlockBreakInfo
Return values
BlockBreakInfo —

getDrops()

public getDrops(Item $item) : array<string|int, mixed>
Parameters
$item : Item
Return values
array<string|int, mixed> —

getDropsForCompatibleTool()

Returns an array of Items to be dropped when the block is broken using the correct tool type.

public getDropsForCompatibleTool(Item $item) : array<string|int, Item>
Parameters
$item : Item
Return values
array<string|int, Item> —

getDropsForIncompatibleTool()

Returns the items dropped by this block when broken with an incorrect tool type (or tool with a too-low tier).

public getDropsForIncompatibleTool(Item $item) : array<string|int, Item>
Parameters
$item : Item
Return values
array<string|int, Item> —

getFlameEncouragement()

Returns the chance that the block will catch fire from nearby fire sources. Higher values lead to faster catching fire.

public getFlameEncouragement() : int
Return values
int —

getFlammability()

Returns the base flammability of this block. Higher values lead to the block burning away more quickly.

public getFlammability() : int
Return values
int —

getFrictionFactor()

public getFrictionFactor() : float
Return values
float —

getFuelTime()

Returns the time in ticks which the block will fuel a furnace for.

public getFuelTime() : int
Return values
int —

getHorizontalSides()

Returns the 4 blocks on the horizontal axes around the block (north, south, east, west)

public getHorizontalSides() : array<string|int, Block>|Generator
Tags
phpstan-return

\Generator<int, Block, void, void>

Return values
array<string|int, Block>|Generator —

getId()

public getId() : int
Return values
int —

getLightFilter()

Returns the amount of light this block will filter out when light passes through this block.

public getLightFilter() : int

This value is used in light spread calculation.

Return values
int —

0-15

getLightLevel()

public getLightLevel() : int
Return values
int —

0-15

getMaxStackSize()

Returns the maximum number of this block that can fit into a single item stack.

public getMaxStackSize() : int
Return values
int —

getMeta()

public getMeta() : int
Return values
int —

getModelPositionOffset()

Returns an additional fractional vector to shift the block model's position by based on the current position.

public getModelPositionOffset() : Vector3|null

Used to randomize position of things like bamboo canes and tall grass.

Return values
Vector3|null —

getName()

public getName() : string
Return values
string —

getOtherHalf()

public getOtherHalf() : Bed|null
Return values
Bed|null —

getPickedItem()

Returns the item that players will equip when middle-clicking on this block.

public getPickedItem([bool $addUserData = false ]) : Item
Parameters
$addUserData : bool = false
Return values
Item —

getSide()

Returns the Block on the side $side, works like Vector3::getSide()

public getSide(int $side[, int $step = 1 ]) : Block
Parameters
$side : int
$step : int = 1
Return values
Block —

getSilkTouchDrops()

Returns an array of Items to be dropped when the block is broken using a compatible Silk Touch-enchanted tool.

public getSilkTouchDrops(Item $item) : array<string|int, Item>
Parameters
$item : Item
Return values
array<string|int, Item> —

getStateBitmask()

public getStateBitmask() : int
Return values
int —

getXpDropForTool()

Returns how much XP will be dropped by breaking this block with the given item.

public getXpDropForTool(Item $item) : int
Parameters
$item : Item
Return values
int —

hasEntityCollision()

public hasEntityCollision() : bool
Return values
bool —

isAffectedBySilkTouch()

Returns whether Silk Touch enchanted tools will cause this block to drop as itself.

public isAffectedBySilkTouch() : bool
Return values
bool —

isFlammable()

Returns whether this block can catch fire.

public isFlammable() : bool
Return values
bool —

isFullCube()

public isFullCube() : bool
Return values
bool —

isHeadPart()

public isHeadPart() : bool
Return values
bool —

isOccupied()

public isOccupied() : bool
Return values
bool —

isSameState()

Returns whether the given block has the same type and properties as this block.

public isSameState(Block $other) : bool
Parameters
$other : Block
Return values
bool —

isSameType()

Returns whether the given block has an equivalent type to this one. This compares base legacy ID and variant.

public isSameType(Block $other) : bool

Note: This ignores additional IDs used to represent additional states. This means that, for example, a lit furnace and unlit furnace are considered the same type.

Parameters
$other : Block
Return values
bool —

isSolid()

public isSolid() : bool
Return values
bool —

isTransparent()

public isTransparent() : bool
Return values
bool —

onAttack()

Called when this block is attacked (left-clicked). This is called when a player left-clicks the block to try and start to break it in survival mode.

public onAttack(Item $item, int $face[, Player|null $player = null ]) : bool
Parameters
$item : Item
$face : int
$player : Player|null = null
Return values
bool —

if an action took place, prevents starting to break the block if true.

onBreak()

Do the actions needed so the block is broken with the Item

public onBreak(Item $item[, Player|null $player = null ]) : bool
Parameters
$item : Item
$player : Player|null = null
Return values
bool —

onEntityInside()

Called when an entity's bounding box clips inside this block's cell. Note that the entity may not be intersecting with the collision box or bounding box.

public onEntityInside(Entity $entity) : bool
Parameters
$entity : Entity
Return values
bool —

Whether the block is still the same after the intersection. If it changed (e.g. due to an explosive being ignited), this should return false.

onEntityLand()

public onEntityLand(Entity $entity) : float|null
Parameters
$entity : Entity
Return values
float|null —

onIncinerate()

Called when this block is burned away by being on fire.

public onIncinerate() : void
Return values
void —

onInteract()

public onInteract(Item $item, int $face, Vector3 $clickVector[, Player|null $player = null ]) : bool
Parameters
$item : Item
$face : int
$clickVector : Vector3
$player : Player|null = null
Return values
bool —

onNearbyBlockChange()

public onNearbyBlockChange() : void
Return values
void —

onPostPlace()

public onPostPlace() : void
Return values
void —

onRandomTick()

Called when this block is randomly updated due to chunk ticking.

public onRandomTick() : void

WARNING: This will not be called if ticksRandomly() does not return true!

Return values
void —

onScheduledUpdate()

Called when this block is updated by the delayed blockupdate scheduler in the world.

public onScheduledUpdate() : void
Return values
void —

readStateFromData()

public readStateFromData(int $id, int $stateMeta) : void
Parameters
$id : int
$stateMeta : int
Return values
void —

readStateFromWorld()

public readStateFromWorld() : void
Return values
void —

setFacing()

public setFacing(int $facing) : $this
Parameters
$facing : int
Return values
$this —

setHead()

public setHead(bool $head) : $this
Parameters
$head : bool
Return values
$this —

setOccupied()

public setOccupied([bool $occupied = true ]) : $this
Parameters
$occupied : bool = true
Return values
$this —

ticksRandomly()

Returns whether random block updates will be done on this block.

public ticksRandomly() : bool
Return values
bool —

writeStateToWorld()

public writeStateToWorld() : void
Return values
void —

getXpDropAmount()

Returns how much XP this block will drop when broken with an appropriate tool.

protected getXpDropAmount() : int
Return values
int —

recalculateCollisionBoxes()

protected recalculateCollisionBoxes() : array<string|int, AxisAlignedBB>
Return values
array<string|int, AxisAlignedBB> —

writeStateToItemMeta()

protected writeStateToItemMeta() : int
Return values
int —

writeStateToMeta()

protected writeStateToMeta() : int
Return values
int —

getOtherHalfSide()

private getOtherHalfSide() : int
Return values
int —

Search results