bonemeal on sugarcane tweaks, using block send queue to send UpdateBlockPackets

This commit is contained in:
GameHerobrine 2023-12-31 17:42:59 +03:00
parent 7ecfcacec6
commit 229a563ff5
8 changed files with 84 additions and 70 deletions

View file

@ -133,12 +133,12 @@ abstract class Block extends Position{
INFO_UPDATE2 => "InfoUpdate2Block",
RESERVED6 => "Reserved6Block",
);
protected $id;
protected $meta;
protected $name;
protected $breakTime;
public $id;
public $meta;
public $name;
public $breakTime;
public $boundingBox;
protected $hardness;
public $hardness;
public $isActivable = false;
public $breakable = true;
public $isFlowable = false;

View file

@ -8,24 +8,24 @@ class SugarcaneBlock extends FlowableBlock{
}
public function getDrops(Item $item, Player $player){
return array(
array(SUGARCANE, 0, 1),
);
return [
[SUGARCANE, 0, 1],
];
}
public function onActivate(Item $item, Player $player){
if($item->getID() === DYE and $item->getMetadata() === 0x0F){ //Bonemeal
if($this->getSide(0)->getID() !== SUGARCANE_BLOCK){
if($this->level->level->getBlockID($this->x, $this->y - 1, $this->z) != SUGARCANE_BLOCK){
for($y = 1; $y < 3; ++$y){
$b = $this->level->getBlock(new Vector3($this->x, $this->y + $y, $this->z));
if($b->getID() === AIR){
$this->level->setBlock($b, new SugarcaneBlock(), true, false, true);
break;
$b = $this->level->level->getBlockID($this->x, $this->y + $y, $this->z);
if($b == AIR){
$this->level->fastSetBlockUpdate($this->x, $this->y + $y, $this->z, SUGARCANE_BLOCK, 0, true);
}
}
$this->meta = 0;
$this->level->setBlock($this, $this, true, false, true);
$this->level->fastSetBlockUpdateMeta($this->x, $this->y, $this->z, $this->meta, true);
}
if(($player->gamemode & 0x01) === 0){
$player->removeItem(DYE,0x0F,1);
}

View file

@ -30,10 +30,6 @@ class DirtBlock extends SolidBlock{
}*/
}
public function getBlockID($x, $y, $z){
return $this->level->getBlock(new Vector3($x, $y, $z))->getID();
}
public static function getGrassInRadius(Level $level, $x, $y, $z){ //umwut (although kinda faster than for loop =D)
if($level->level->getBlockID($x+1, $y, $z+1) == 2) return true;
if($level->level->getBlockID($x+1, $y, $z) == 2) return true;