small tweaks to tall plants

This commit is contained in:
GameHerobrine 2023-12-01 11:07:49 +03:00
parent 1e9b5b571b
commit 03d5a05149
3 changed files with 13 additions and 9 deletions

View file

@ -263,7 +263,8 @@ class BlockAPI{
[DOUBLE_PLANT, 1],
[DOUBLE_PLANT, 2],
[DOUBLE_PLANT, 3],
[DOUBLE_PLANT, 4],
[DOUBLE_PLANT, 5],
];
private $server;
private $scheduledUpdates = [];

View file

@ -7,19 +7,21 @@ class DoubleTallGrass extends FlowableBlock
1 => "Lilac",
2 => "Tall Grass",
3 => "Tall Fern",
4 => "Rose Bush",
5 => "Peony",
];
public function __construct($meta = 1){
parent::__construct(DOUBLE_PLANT, $meta, "Tall Grass");
$this->name = self::$NAMES[$this->meta];
$this->name = self::$NAMES[$this->meta] ?? "Tall Grass";
$this->hardness = 0;
}
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){ //TODO destroy if 2nd block occupied
if($this->getSide(0)->isTransparent === true){//Replace with common break method
$this->level->setBlock($this, new AirBlock(), false, false, true);
return BLOCK_UPDATE_NORMAL;
}
//if($this->meta & 0x8 == 0 && $this->getSide(0)->isTransparent === true){ //Replace with common break method
///$this->level->setBlock($this, new AirBlock(), false, false, true);
//return BLOCK_UPDATE_NORMAL;
//} //TODO fix
}
return false;
}
@ -32,6 +34,7 @@ class DoubleTallGrass extends FlowableBlock
$down = $this->getSide(0);
if($down->getID() == 2 or $down->getID() == 3){ //TODO destroy the block above(tested only in creative)
$this->level->setBlock($block, $this, true, false, true);
$this->level->setBlock($block->add(0, 1, 0), new DoubleTallGrass($this->meta ^ 0x8), true, false, true);
return true;
}
return false;

View file

@ -2,11 +2,11 @@
class TallGrassBlock extends FlowableBlock{
public function __construct($meta = 1){
parent::__construct(TALL_GRASS, $meta, "Tall Grass");
parent::__construct(TALL_GRASS, $meta, "Grass");
$this->isReplaceable = true;
$names = array(
0 => "Dead Shrub",
1 => "Tall Grass",
1 => "Grass",
2 => "Fern",
);
$this->name = $names[$this->meta & 0x02];
@ -15,7 +15,7 @@ class TallGrassBlock extends FlowableBlock{
public function onUpdate($type){
if($type === BLOCK_UPDATE_NORMAL){
if($this->getSide(0)->isTransparent === true){//Replace with common break method
if($this->getSide(0)->isTransparent === true){ //Replace with common break method
$this->level->setBlock($this, new AirBlock(), false, false, true);
if(Utils::chance(15)) ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(WHEAT_SEEDS));
return BLOCK_UPDATE_NORMAL;