39 use MultiAnySupportTrait;
54 return SupportType::NONE;
65 return $blockReplace instanceof
GlowLichen ? $blockReplace->faces : [];
68 private function getSpreadBlock(
Block $replace,
int $spreadFace) : ?
Block{
69 if($replace instanceof self && $replace->hasSameTypeId($this)){
70 if($replace->hasFace($spreadFace)){
74 }elseif($replace->getTypeId() === BlockTypeIds::AIR){
75 $result = VanillaBlocks::GLOW_LICHEN();
80 return $result->setFace($spreadFace,
true);
83 private function spread(World $world, Vector3 $replacePos,
int $spreadFace) : bool{
84 $supportBlock = $world->getBlock($replacePos->getSide($spreadFace));
85 $supportFace = Facing::opposite($spreadFace);
87 if($supportBlock->getSupportType($supportFace) !== SupportType::FULL){
91 $replacedBlock = $supportBlock->getSide($supportFace);
92 $replacementBlock = $this->getSpreadBlock($replacedBlock, Facing::opposite($supportFace));
93 if($replacementBlock ===
null){
97 return BlockEventHelper::spread($replacedBlock, $replacementBlock, $this);
103 private static function getShuffledSpreadFaces(
int $sourceFace) : \Generator{
104 $skipAxis = Facing::axis($sourceFace);
106 $faces = Facing::ALL;
108 foreach($faces as $spreadFace){
109 if(Facing::axis($spreadFace) !== $skipAxis){
115 private function spreadAroundSupport(
int $sourceFace) : bool{
116 $world = $this->position->getWorld();
118 $supportPos = $this->position->getSide($sourceFace);
119 foreach(self::getShuffledSpreadFaces($sourceFace) as $spreadFace){
120 $replacePos = $supportPos->getSide($spreadFace);
121 if($this->spread($world, $replacePos, Facing::opposite($spreadFace))){
129 private function spreadAdjacentToSupport(
int $sourceFace) : bool{
130 $world = $this->position->getWorld();
132 foreach(self::getShuffledSpreadFaces($sourceFace) as $spreadFace){
133 $replacePos = $this->position->getSide($spreadFace);
134 if($this->spread($world, $replacePos, $sourceFace)){
141 private function spreadWithinSelf(
int $sourceFace) : bool{
142 foreach(self::getShuffledSpreadFaces($sourceFace) as $spreadFace){
143 if(!$this->hasFace($spreadFace) && $this->spread($this->position->getWorld(), $this->position, $spreadFace)){
152 if($item instanceof
Fertilizer && count($this->faces) > 0){
153 $shuffledFaces = $this->faces;
154 shuffle($shuffledFaces);
157 $this->spreadAroundSupport(...),
158 $this->spreadAdjacentToSupport(...),
159 $this->spreadWithinSelf(...),
161 shuffle($spreadMethods);
163 foreach($shuffledFaces as $sourceFace){
164 foreach($spreadMethods as $spreadMethod){
165 if($spreadMethod($sourceFace)){
178 if(($item->getBlockToolType() &
BlockToolType::SHEARS) !== 0){
179 return $this->getDropsForCompatibleTool($item);