fixed placement on farmland of sapling and tallgrass

This commit is contained in:
GameHerobrine 2024-08-14 06:20:21 +03:00
parent f66b6adfa1
commit e594fc2f8c
2 changed files with 6 additions and 4 deletions

View file

@ -44,7 +44,8 @@ class SaplingBlock extends FlowableBlock{
return false;
}
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
if(StaticBlock::getIsTransparent($level->level->getBlockID($x, $y - 1, $z))){ //Replace with common break method
$downID = $level->level->getBlockID($x, $y - 1, $z);
if(StaticBlock::getIsTransparent($downID) && $downID !== FARMLAND){ //Replace with common break method
[$id, $meta] = $level->level->getBlock($x, $y, $z);
ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem($id, $meta));
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
@ -67,4 +68,4 @@ class SaplingBlock extends FlowableBlock{
array($this->id, $this->meta & 0x03, 1),
);
}
}
}

View file

@ -15,7 +15,8 @@ class TallGrassBlock extends FlowableBlock{
}
public static function neighborChanged(Level $level, $x, $y, $z, $nX, $nY, $nZ, $oldID){
if(StaticBlock::getIsTransparent($level->level->getBlockID($x, $y - 1, $z))){ //Replace with common break method
$downID = $level->level->getBlockID($x, $y - 1, $z);
if(StaticBlock::getIsTransparent($downID) && $downID !== FARMLAND){ //Replace with common break method
if(Utils::chance(15)) ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(WHEAT_SEEDS));
$level->fastSetBlockUpdate($x, $y, $z, 0, 0);
}
@ -34,7 +35,7 @@ class TallGrassBlock extends FlowableBlock{
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
$down = $this->getSide(0);
if($down->getID() == 2 or $down->getID() == 3){
if($down->getID() == GRASS or $down->getID() == DIRT || $down->getID() == FARMLAND){
$this->level->setBlock($block, $this, true, false, true);
return true;
}