added double tall grass

This commit is contained in:
GameHerobrine 2023-12-01 09:15:56 +03:00
parent 728b8f6d2e
commit d334b85c63
3 changed files with 47 additions and 1 deletions

View file

@ -258,7 +258,11 @@ class BlockAPI{
[DYE, 11],
[DYE, 10],
[DYE, 9],
[DYE, 8]
[DYE, 8],
[DOUBLE_PLANT, 0],
[DOUBLE_PLANT, 1],
[DOUBLE_PLANT, 2],
[DOUBLE_PLANT, 3],
];
private $server;

View file

@ -151,6 +151,7 @@ abstract class Block extends Position{
PODZOL => "PodzolBlock",
STAINED_CLAY => "StainedClayBlock",
LILY_PAD => "LilypadBlock",
DOUBLE_PLANT => "DoubleTallGrass",
);
protected $id;
protected $meta;

View file

@ -0,0 +1,41 @@
<?php
class DoubleTallGrass extends FlowableBlock
{
public static $NAMES = [
0 => "Sunflower",
1 => "Lilac",
2 => "Tall Grass",
3 => "Tall Fern",
];
public function __construct($meta = 1){
parent::__construct(DOUBLE_PLANT, $meta, "Tall Grass");
$this->name = self::$NAMES[$this->meta];
$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;
}
}
return false;
}
public function getDrops(Item $item, Player $player){ //TODO vanilla?
return [];
}
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){ //TODO destroy the block above(tested only in creative)
$this->level->setBlock($block, $this, true, false, true);
return true;
}
return false;
}
}