84 protected function findLog(
Vector3 $pos, array &$visited = [],
int $distance = 0) : bool{
85 $index =
World::blockHash($pos->x, $pos->y, $pos->z);
86 if(isset($visited[$index])){
89 $visited[$index] =
true;
91 $block = $this->position->getWorld()->getBlock($pos);
92 if($block instanceof
Wood){
96 if($block instanceof Leaves && $distance <= self::MAX_LOG_DISTANCE){
97 foreach(Facing::ALL as $side){
98 if($this->findLog($pos->
getSide($side), $visited, $distance + 1)){
119 if(!$this->noDecay && $this->checkDecay){
121 if(LeavesDecayEvent::hasHandlers()){
124 $cancelled = $ev->isCancelled();
127 $world = $this->position->getWorld();
128 if($cancelled || $this->findLog($this->position)){
129 $this->checkDecay =
false;
130 $world->setBlock($this->position, $this,
false);
132 $world->useBreakOn($this->position);
143 if(($item->getBlockToolType() &
BlockToolType::SHEARS) !== 0){
144 return parent::getDropsForCompatibleTool($item);
148 if(FortuneDropHelper::bonusChanceDivisor($item, 20, 4)){
150 $sapling = (match($this->leavesType){
151 LeavesType::ACACIA => VanillaBlocks::ACACIA_SAPLING(),
152 LeavesType::BIRCH => VanillaBlocks::BIRCH_SAPLING(),
153 LeavesType::DARK_OAK => VanillaBlocks::DARK_OAK_SAPLING(),
154 LeavesType::JUNGLE => VanillaBlocks::JUNGLE_SAPLING(),
155 LeavesType::OAK => VanillaBlocks::OAK_SAPLING(),
156 LeavesType::SPRUCE => VanillaBlocks::SPRUCE_SAPLING(),
157 LeavesType::MANGROVE,
158 LeavesType::AZALEA, LeavesType::FLOWERING_AZALEA =>
null,
159 LeavesType::CHERRY =>
null,
161 if($sapling !==
null){
166 ($this->leavesType === LeavesType::OAK || $this->leavesType === LeavesType::DARK_OAK) &&
167 FortuneDropHelper::bonusChanceDivisor($item, 200, 20)
169 $drops[] = VanillaItems::APPLE();
171 if(FortuneDropHelper::bonusChanceDivisor($item, 50, 5)){
172 $drops[] = VanillaItems::STICK()->setCount(mt_rand(1, 2));