22declare(strict_types=1);
34use
function array_intersect_key;
40 protected array $faces = [];
43 $w->horizontalFacingFlags($this->faces);
47 public function getFaces() : array{ return $this->faces; }
49 public function hasFace(
int $face) : bool{
50 return isset($this->faces[$face]);
60 foreach($faces as $face){
61 if($face !== Facing::NORTH && $face !== Facing::SOUTH && $face !== Facing::WEST && $face !== Facing::EAST){
62 throw new \InvalidArgumentException(
"Facing can only be north, east, south or west");
64 $uniqueFaces[$face] = $face;
66 $this->faces = $uniqueFaces;
71 public function setFace(
int $face,
bool $value) : self{
73 throw new \InvalidArgumentException(
"Facing can only be north, east, south or west");
76 $this->faces[$face] = $face;
78 unset($this->faces[$face]);
96 $entity->resetFallDistance();
105 if(!$blockReplace->getSide(
Facing::opposite($face))->isFullCube() ||
Facing::axis($face) ===
Axis::Y){
109 $this->faces = $blockReplace instanceof
Vine ? $blockReplace->faces : [];
110 $this->faces[Facing::opposite($face)] = Facing::opposite($face);
112 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
118 $up = $this->getSide(Facing::UP);
120 $supportedFaces = $up instanceof
Vine ? array_intersect_key($this->faces, $up->faces) : [];
122 foreach($this->faces as $face){
123 if(!isset($supportedFaces[$face]) && !$this->getSide($face)->isSolid()){
124 unset($this->faces[$face]);
130 $world = $this->position->getWorld();
131 if(count($this->faces) === 0){
132 $world->useBreakOn($this->position);
134 $world->setBlock($this->position, $this);
147 public function getDrops(
Item $item) : array{
148 if(($item->getBlockToolType() &
BlockToolType::SHEARS) !== 0){
149 return $this->getDropsForCompatibleTool($item);
setFace(int $face, bool $value)
recalculateCollisionBoxes()
describeBlockOnlyState(RuntimeDataDescriber $w)
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player=null)
onEntityInside(Entity $entity)