mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 20:19:44 +00:00
onUpdate is now static, disabled rail, water and lava updates to rework.
This commit is contained in:
parent
3c37dc446e
commit
ee989ef556
38 changed files with 329 additions and 367 deletions
|
|
@ -36,27 +36,23 @@ class SugarcaneBlock extends FlowableBlock{
|
|||
return false;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
||||
$down = $this->getSide(0);
|
||||
if($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){
|
||||
$block0 = $down->getSide(2);
|
||||
$block1 = $down->getSide(3);
|
||||
$block2 = $down->getSide(4);
|
||||
$block3 = $down->getSide(5);
|
||||
if(!($block0 instanceof WaterBlock) and !($block1 instanceof WaterBlock) and !($block2 instanceof WaterBlock) and !($block3 instanceof WaterBlock)){
|
||||
$this->level->setBlock($this, new AirBlock(), true, false, true);
|
||||
ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem(SUGARCANE));
|
||||
public static function onUpdate(Level $level, $x, $y, $z, $type){
|
||||
$down = $level->level->getBlockID($x, $y - 1, $z);
|
||||
if($down == GRASS or $down == DIRT or $down == SAND){
|
||||
$b0 = $level->level->getBlockID($x, $y - 1, $z - 1);
|
||||
$b1 = $level->level->getBlockID($x, $y - 1, $z + 1);
|
||||
$b2 = $level->level->getBlockID($x - 1, $y - 1, $z);
|
||||
$b3 = $level->level->getBlockID($x + 1, $y - 1, $z);
|
||||
if($b0 != WATER && $b0 != STILL_WATER && $b1 != WATER && $b1 != STILL_WATER && $b2 != WATER && $b2 != STILL_WATER && $b3 != WATER && $b3 != STILL_WATER){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem(SUGARCANE));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if($type === BLOCK_UPDATE_NORMAL){
|
||||
$down = $this->getSide(0);
|
||||
if($down->isTransparent === true and $down->getID() !== SUGARCANE_BLOCK){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y, $this->z+0.5, $this->level), BlockAPI::getItem(SUGARCANE));
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
if(StaticBlock::getIsTransparent($down) && $down != SUGARCANE_BLOCK){ //Replace with common break method
|
||||
ServerAPI::request()->api->entity->drop(new Position($x+0.5, $y, $z+0.5, $level), BlockAPI::getItem(SUGARCANE));
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true);
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue