Hopper
extends Transparent
in package
Uses
PoweredByRedstoneTrait
Table of Contents
- INTERNAL_METADATA_BITS = 4
- INTERNAL_METADATA_MASK = ~(~0 << self::INTERNAL_METADATA_BITS)
- $breakInfo : BlockBreakInfo
- $collisionBoxes : array<string|int, mixed>|null
- $fallbackName : string
- $idInfo : BlockIdentifier
- $position : Position
- $powered : bool
- $facing : int
- __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, Block>
- Returns a list of blocks that this block is part of. In most cases, only contains the block itself, but in cases such as double plants, beds and doors, will contain both halves.
- 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>
- getDrops() : array<string|int, Item>
- Returns an array of Item objects to be dropped
- 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
- 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
- isPowered() : 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
- Called when an entity lands on this block (usually due to falling).
- onIncinerate() : void
- Called when this block is burned away by being on fire.
- onInteract() : bool
- onNearbyBlockChange() : void
- Called when this block or a block immediately adjacent to it changes state.
- onPostPlace() : void
- onRandomTick() : void
- Called when this block is randomly updated due to chunk ticking.
- onScheduledUpdate() : void
- place() : bool
- readStateFromData() : void
- readStateFromWorld() : void
- Called when this block is created, set, or has a neighbouring block update, to re-detect dynamic properties which are not saved on the world.
- setFacing() : $this
- setPowered() : $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, mixed>
- writeStateToItemMeta() : int
- writeStateToMeta() : 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
$breakInfo
protected
BlockBreakInfo
$breakInfo
$collisionBoxes
protected
array<string|int, mixed>|null
$collisionBoxes
= null
$fallbackName
protected
string
$fallbackName
$idInfo
protected
BlockIdentifier
$idInfo
$position
protected
Position
$position
$powered
protected
bool
$powered
= false
$facing
private
int
$facing
= \pocketmine\math\Facing::DOWN
Methods
__clone()
public
__clone() : mixed
Return values
mixed —__construct()
public
__construct(BlockIdentifier $idInfo, string $name, BlockBreakInfo $breakInfo) : mixed
Parameters
- $idInfo : BlockIdentifier
- $name : string
-
English name of the block type (TODO: implement translations)
- $breakInfo : BlockBreakInfo
Return values
mixed —__toString()
public
__toString() : string
Return values
string —addVelocityToEntity()
public
addVelocityToEntity(Entity $entity) : Vector3|null
Parameters
- $entity : Entity
Return values
Vector3|null —asItem()
public
asItem() : Item
Return values
Item —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 —calculateIntercept()
public
calculateIntercept(Vector3 $pos1, Vector3 $pos2) : RayTraceResult|null
Parameters
Return values
RayTraceResult|null —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
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()
Returns a list of blocks that this block is part of. In most cases, only contains the block itself, but in cases such as double plants, beds and doors, will contain both halves.
public
getAffectedBlocks() : array<string|int, Block>
Return values
array<string|int, Block> —getAllSides()
Returns the six blocks around this block.
public
getAllSides() : array<string|int, Block>|Generator
Tags
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 —getCollisionBoxes()
public
final getCollisionBoxes() : array<string|int, AxisAlignedBB>
Return values
array<string|int, AxisAlignedBB> —getDrops()
Returns an array of Item objects to be dropped
public
getDrops(Item $item) : array<string|int, Item>
Parameters
- $item : Item
Return values
array<string|int, Item> —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> —getFacing()
public
getFacing() : int
Return values
int —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
Return values
array<string|int, Block>|Generator —getId()
public
getId() : int
Return values
int —getIdInfo()
public
getIdInfo() : BlockIdentifier
Return values
BlockIdentifier —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 —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 —getPosition()
public
final getPosition() : Position
Return values
Position —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 —isPowered()
public
isPowered() : 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
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
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()
Called when an entity lands on this block (usually due to falling).
public
onEntityLand(Entity $entity) : float|null
Parameters
- $entity : Entity
Return values
float|null —The new vertical velocity of the entity, or null if unchanged.
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
Return values
bool —onNearbyBlockChange()
Called when this block or a block immediately adjacent to it changes state.
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()
public
onScheduledUpdate() : void
Return values
void —place()
public
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector[, Player|null $player = null ]) : bool
Parameters
- $tx : BlockTransaction
- $item : Item
- $blockReplace : Block
- $blockClicked : Block
- $face : int
- $clickVector : Vector3
- $player : Player|null = null
Return values
bool —readStateFromData()
public
readStateFromData(int $id, int $stateMeta) : void
Parameters
- $id : int
- $stateMeta : int
Return values
void —readStateFromWorld()
Called when this block is created, set, or has a neighbouring block update, to re-detect dynamic properties which are not saved on the world.
public
readStateFromWorld() : void
Clears any cached precomputed objects, such as bounding boxes. Remove any outdated precomputed things such as AABBs and force recalculation.
Return values
void —setFacing()
public
setFacing(int $facing) : $this
Parameters
- $facing : int
Return values
$this —setPowered()
public
setPowered(bool $powered) : $this
Parameters
- $powered : bool
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, mixed>
Return values
array<string|int, mixed> —writeStateToItemMeta()
protected
writeStateToItemMeta() : int
Return values
int —writeStateToMeta()
protected
writeStateToMeta() : int