mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 12:39:43 +00:00
bounds for pmflevel methods, random block ticking ported from 0.1.3 core, player height was decreased a bit
This commit is contained in:
parent
84dd0b82b3
commit
3dd9e38a37
22 changed files with 326 additions and 216 deletions
|
|
@ -7,6 +7,30 @@ class CactusBlock extends TransparentBlock{
|
|||
$this->hardness = 2;
|
||||
}
|
||||
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
//$b = $level->level->getBlock($x, $y - 1, $z);
|
||||
$underID = $level->level->getBlockID($x, $y - 1, $z);
|
||||
$b = $level->level->getBlock($x, $y, $z);
|
||||
$id = $b[0];
|
||||
$meta = $b[1];
|
||||
if($underID !== CACTUS){
|
||||
if($meta == 0x0F){
|
||||
for($yy = 1; $yy < 3; ++$yy){
|
||||
$bID = $level->level->getBlockID($x, $y + $yy, $z);
|
||||
if($bID === AIR){
|
||||
$level->setBlock(new Position($x, $y, $z, $level), new CactusBlock(), true, false, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$meta = 0;
|
||||
$level->fastSetBlockUpdate($x, $y, $z, $id, $meta);
|
||||
}else{
|
||||
$level->fastSetBlockUpdate($x, $y, $z, $id, $meta + 1);
|
||||
}
|
||||
return BLOCK_UPDATE_RANDOM;
|
||||
}
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === BLOCK_UPDATE_NORMAL){
|
||||
$down = $this->getSide(0);
|
||||
|
|
@ -19,24 +43,6 @@ class CactusBlock extends TransparentBlock{
|
|||
ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem($this->id));
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
}
|
||||
}elseif($type === BLOCK_UPDATE_RANDOM){
|
||||
if($this->getSide(0)->getID() !== CACTUS){
|
||||
if($this->meta == 0x0F){
|
||||
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 CactusBlock(), true, false, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->meta = 0;
|
||||
$this->level->setBlock($this, $this, false);
|
||||
}else{
|
||||
++$this->meta;
|
||||
$this->level->setBlock($this, $this, false);
|
||||
}
|
||||
return BLOCK_UPDATE_RANDOM;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue