38 protected DripleafState $leafState = DripleafState::STABLE;
42 $w->
enum($this->leafState);
45 protected function isHead() : bool{
49 public function getLeafState() : DripleafState{
50 return $this->leafState;
55 $this->leafState = $leafState;
63 private function setTiltAndScheduleTick(DripleafState $tilt) : void{
64 $this->position->getWorld()->setBlock($this->position, $this->setLeafState($tilt));
65 $delay = $tilt->getScheduledUpdateDelayTicks();
67 $this->position->getWorld()->scheduleDelayedBlockUpdate($this->position, $delay);
71 private function getLeafTopOffset() : float{
72 return match($this->leafState){
73 DripleafState::STABLE, DripleafState::UNSTABLE => 1 / 16,
74 DripleafState::PARTIAL_TILT => 3 / 16,
80 if(!$entity instanceof
Projectile && $this->leafState === DripleafState::STABLE){
82 $intersection = AxisAlignedBB::one()
83 ->offset($this->position->x, $this->position->y, $this->position->z)
84 ->trim(Facing::DOWN, 1 - $this->getLeafTopOffset());
85 if($entity->getBoundingBox()->intersectsWith($intersection)){
86 $this->setTiltAndScheduleTick(DripleafState::UNSTABLE);
94 if($this->leafState !== DripleafState::FULL_TILT){
95 $this->setTiltAndScheduleTick(DripleafState::FULL_TILT);
101 if($this->leafState !== DripleafState::STABLE){
102 if($this->leafState === DripleafState::FULL_TILT){
103 $this->position->getWorld()->setBlock($this->position, $this->setLeafState(DripleafState::STABLE));
106 $this->setTiltAndScheduleTick(match($this->leafState){
107 DripleafState::UNSTABLE => DripleafState::PARTIAL_TILT,
108 DripleafState::PARTIAL_TILT => DripleafState::FULL_TILT,
116 if($this->leafState !== DripleafState::FULL_TILT){
119 ->trim(Facing::DOWN, 11 / 16)
120 ->trim(Facing::UP, $this->getLeafTopOffset())