mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 03:59:43 +00:00
decreased block updates per chunk from 80 to 20, PMFLevel block methods should be a bit faster now, grass spread rework, leaf decay fix
This commit is contained in:
parent
3dd9e38a37
commit
4544b7bb63
9 changed files with 73 additions and 60 deletions
|
|
@ -21,13 +21,13 @@ class DirtBlock extends SolidBlock{
|
|||
return false;
|
||||
}
|
||||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
if(mt_rand(0, 3) == 0){
|
||||
/*if(mt_rand(0, 3) == 0){
|
||||
$up = $level->getBlockWithoutVector($x, $y + 1, $z, false); //$this->getSide(1);
|
||||
if(($up->isTransparent === false) or ($up->isLiquid) or ($up->getID() == 60)) return false;
|
||||
if(self::getGrassInRadius($level, $x, $y, $z)){
|
||||
$level->setBlock(new Position($x, $y, $z, $level), BlockAPI::get(GRASS), true, false, true);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public function getBlockID($x, $y, $z){
|
||||
|
|
|
|||
|
|
@ -49,6 +49,18 @@ class GrassBlock extends SolidBlock{
|
|||
public static function onRandomTick(Level $level, $x, $y, $z){
|
||||
if(!$level->getBlockWithoutVector($x, $y + 1, $z, false)->isTransparent && mt_rand(0, 2) == 1){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, DIRT, 0);
|
||||
}else{
|
||||
for($cnt = 0; $cnt < 4; ++$cnt){
|
||||
$x = $x + mt_rand(0, 2) - 1;
|
||||
$y = $y + mt_rand(0, 4) - 3;
|
||||
$z = $z + mt_rand(0, 2) - 1;
|
||||
|
||||
$blockUp = $level->getBlockWithoutVector($x, $y + 1, $z, false);
|
||||
if($blockUp->isTransparent && !$blockUp->isLiquid && !($blockUp->getID() === 60) && $level->level->getBlockID($x, $y, $z) === DIRT){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, GRASS, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ class LeavesBlock extends TransparentBlock{
|
|||
$b = $level->level->getBlock($x, $y, $z);
|
||||
$id = $b[0];
|
||||
$meta = $b[1];
|
||||
|
||||
if(($meta & 0b00001100) === 0x08){
|
||||
$meta &= 0x03;
|
||||
$visited = array();
|
||||
|
|
@ -55,7 +54,8 @@ class LeavesBlock extends TransparentBlock{
|
|||
if(($meta & 0x03) === LeavesBlock::OAK and mt_rand(1,200) === 1){ //Apples
|
||||
ServerAPI::request()->api->entity->drop(new Position($x, $y, $z, $level), BlockAPI::getItem(APPLE, 0, 1));
|
||||
}
|
||||
return BLOCK_UPDATE_NORMAL;
|
||||
}else{
|
||||
$level->fastSetBlockUpdate($x, $y, $z, $id, $meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ class LeavesBlock extends TransparentBlock{
|
|||
if($type === BLOCK_UPDATE_NORMAL){
|
||||
if(($this->meta & 0b00001100) === 0){
|
||||
$this->meta |= 0x08;
|
||||
$this->level->setBlock($this, $this, false, false, true);
|
||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, $this->id, $this->meta);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,23 @@ class WoodBlock extends SolidBlock{
|
|||
$this->level->setBlock($block, $this, true, false, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function onBreak(Item $item, Player $player){
|
||||
parent::onBreak($item, $player);
|
||||
for($xOff = -4; $xOff <= 4; ++$xOff){
|
||||
for($yOff = -4; $yOff <= 4; ++$yOff){
|
||||
for($zOff = -4; $zOff <= 4; ++$zOff){
|
||||
$b = $player->level->level->getBlock($this->x + $xOff, $this->y + $yOff, $this->z + $zOff);
|
||||
$id = $b[0];
|
||||
$meta = $b[1];
|
||||
if($id === LEAVES){
|
||||
if(($meta & 0x8) === 0){
|
||||
$player->level->fastSetBlockUpdate($this->x + $xOff, $this->y + $yOff, $this->z + $zOff, $id, $meta | 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function getDrops(Item $item, Player $player){
|
||||
return array(
|
||||
array($this->id, $this->meta & 0x03, 1),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue