40 use MultiAnySupportTrait;
58 return SupportType::NONE;
69 return $blockReplace instanceof
GlowLichen ? $blockReplace->faces : [];
72 private function getSpreadBlock(
Block $replace,
int $spreadFace) : ?
Block{
73 if($replace instanceof self && $replace->hasSameTypeId($this)){
74 if($replace->hasFace($spreadFace)){
78 }elseif($replace->getTypeId() === BlockTypeIds::AIR){
79 $result = VanillaBlocks::GLOW_LICHEN();
84 return $result->setFace($spreadFace,
true);
87 private function spread(World $world, Vector3 $replacePos,
int $spreadFace) : bool{
88 $supportBlock = $world->getBlock($replacePos->getSide($spreadFace));
89 $supportFace = Facing::opposite($spreadFace);
91 if($supportBlock->getSupportType($supportFace) !== SupportType::FULL){
95 $replacedBlock = $supportBlock->getSide($supportFace);
96 $replacementBlock = $this->getSpreadBlock($replacedBlock, Facing::opposite($supportFace));
97 if($replacementBlock ===
null){
101 return BlockEventHelper::spread($replacedBlock, $replacementBlock, $this);
107 private static function getShuffledSpreadFaces(
int $sourceFace) : \Generator{
108 $skipAxis = Facing::axis($sourceFace);
110 $faces = Facing::ALL;
112 foreach($faces as $spreadFace){
113 if(Facing::axis($spreadFace) !== $skipAxis){
119 private function spreadAroundSupport(
int $sourceFace) : bool{
120 $world = $this->position->getWorld();
122 $supportPos = $this->position->getSide($sourceFace);
123 foreach(self::getShuffledSpreadFaces($sourceFace) as $spreadFace){
124 $replacePos = $supportPos->getSide($spreadFace);
125 if($this->spread($world, $replacePos, Facing::opposite($spreadFace))){
133 private function spreadAdjacentToSupport(
int $sourceFace) : bool{
134 $world = $this->position->getWorld();
136 foreach(self::getShuffledSpreadFaces($sourceFace) as $spreadFace){
137 $replacePos = $this->position->getSide($spreadFace);
138 if($this->spread($world, $replacePos, $sourceFace)){
145 private function spreadWithinSelf(
int $sourceFace) : bool{
146 foreach(self::getShuffledSpreadFaces($sourceFace) as $spreadFace){
147 if(!$this->hasFace($spreadFace) && $this->spread($this->position->getWorld(), $this->position, $spreadFace)){
156 if($item instanceof
Fertilizer && count($this->faces) > 0){
157 $shuffledFaces = $this->faces;
158 shuffle($shuffledFaces);
161 $this->spreadAroundSupport(...),
162 $this->spreadAdjacentToSupport(...),
163 $this->spreadWithinSelf(...),
165 shuffle($spreadMethods);
167 foreach($shuffledFaces as $sourceFace){
168 foreach($spreadMethods as $spreadMethod){
169 if($spreadMethod($sourceFace)){
182 if(($item->getBlockToolType() &
BlockToolType::SHEARS) !== 0){
183 return $this->getDropsForCompatibleTool($item);