Fixed tallgrass being unplaceable since d9b050fb688155ec962f574388eb48342fc8f9d1 (#5197)

This commit is contained in:
Colin 2022-07-27 03:43:05 +02:00 committed by GitHub
parent 79125b8426
commit 723ae9eca0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,9 +37,12 @@ class TallGrass extends Flowable{
return true;
}
private function canBeSupportedBy(Block $block) : bool{
return $block->hasTypeTag(BlockTypeTags::DIRT) || $block->hasTypeTag(BlockTypeTags::MUD);
}
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{
$down = $this->getSide(Facing::DOWN);
if($down->hasTypeTag(BlockTypeTags::DIRT) || $down->hasTypeTag(BlockTypeTags::MUD)){
if($this->canBeSupportedBy($this->getSide(Facing::DOWN))){
return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
}
@ -47,8 +50,7 @@ class TallGrass extends Flowable{
}
public function onNearbyBlockChange() : void{
$down = $this->getSide(Facing::DOWN);
if($down->hasTypeTag(BlockTypeTags::DIRT) || $down->hasTypeTag(BlockTypeTags::MUD)){ //Replace with common break method
if(!$this->canBeSupportedBy($this->getSide(Facing::DOWN))){ //Replace with common break method
$this->position->getWorld()->useBreakOn($this->position);
}
}