diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 756d7e4f7..9e478bd08 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -752,7 +752,7 @@ class BlockAPI{ $level = $block->onUpdate($type); if($level === BLOCK_UPDATE_NORMAL){ $this->blockUpdateAround($block, $level); - $this->server->api->entity->updateRadius($pos, 3); + $this->server->api->entity->updateRadius($pos, 1); }elseif($level === BLOCK_UPDATE_RANDOM){ $this->nextRandomUpdate($pos); } @@ -794,7 +794,7 @@ class BlockAPI{ }else{ break; } - $offset += 5; + $offset += mt_rand(25, 75); } $this->scheduleBlockUpdate($pos, $t / 0.05, BLOCK_UPDATE_RANDOM); } diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index b94709eb3..ca5e2cab0 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -609,7 +609,7 @@ class PocketMinecraftServer{ if(!is_callable($schedule[0])){ $return = false; }else{ - $return = call_user_func($schedule[0],$schedule[1],$schedule[2]); + $return = call_user_func($schedule[0], $schedule[1], $schedule[2]); } if($action["repeat"] === 0 or $return === false){ diff --git a/src/material/block/solid/BurningFurnace.php b/src/material/block/solid/BurningFurnace.php index 1b207347a..766232221 100644 --- a/src/material/block/solid/BurningFurnace.php +++ b/src/material/block/solid/BurningFurnace.php @@ -44,7 +44,6 @@ class BurningFurnaceBlock extends SolidBlock{ } public function onBreak(Item $item, Player $player){ - $server = ServerAPI::request(); $this->level->setBlock($this, new AirBlock(), true, true); return true; } diff --git a/src/material/block/solid/Chest.php b/src/material/block/solid/Chest.php index 0bb4058b5..ed55f8b29 100644 --- a/src/material/block/solid/Chest.php +++ b/src/material/block/solid/Chest.php @@ -58,7 +58,6 @@ class ChestBlock extends TransparentBlock{ } public function onBreak(Item $item, Player $player){ - $server = ServerAPI::request(); $this->level->setBlock($this, new AirBlock(), true, true); return true; } diff --git a/src/material/block/solid/Leaves.php b/src/material/block/solid/Leaves.php index 07cb210aa..0f8fbb0c0 100644 --- a/src/material/block/solid/Leaves.php +++ b/src/material/block/solid/Leaves.php @@ -40,60 +40,61 @@ class LeavesBlock extends TransparentBlock{ $this->name = $names[$this->meta & 0x03]; } - private function findLog(Block $pos, array $visited, $distance, $fromSide = null){ + private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null){ + ++$check; $index = $pos->x.".".$pos->y.".".$pos->z; if(isset($visited[$index])){ return false; } if($pos->getID() === WOOD){ return true; - }elseif($pos->getID() === LEAVES and $distance < 4){ + }elseif($pos->getID() === LEAVES and $distance < 3){ $visited[$index] = true; $down = $pos->getSide(0)->getID(); - if($down === WOOD or $down == LEAVES){ + if($down === WOOD){ return true; } if($fromSide === null){ for($side = 2; $side <= 5; ++$side){ - if($this->findLog($pos->getSide($side), $visited, $distance + 1, $side) === true){ + if($this->findLog($pos->getSide($side), $visited, $distance + 1, $check, $side) === true){ return true; } } }else{ //No more loops switch($fromSide){ case 2: - if($this->findLog($pos->getSide(2), $visited, $distance + 1, $fromSide) === true){ + if($this->findLog($pos->getSide(2), $visited, $distance + 1, $check, $fromSide) === true){ return true; - }elseif($this->findLog($pos->getSide(4), $visited, $distance + 1, $fromSide) === true){ + }elseif($this->findLog($pos->getSide(4), $visited, $distance + 1, $check, $fromSide) === true){ return true; - }elseif($this->findLog($pos->getSide(5), $visited, $distance + 1, $fromSide) === true){ + }elseif($this->findLog($pos->getSide(5), $visited, $distance + 1, $check, $fromSide) === true){ return true; } break; case 3: - if($this->findLog($pos->getSide(3), $visited, $distance + 1, $fromSide) === true){ + if($this->findLog($pos->getSide(3), $visited, $distance + 1, $check, $fromSide) === true){ return true; - }elseif($this->findLog($pos->getSide(4), $visited, $distance + 1, $fromSide) === true){ + }elseif($this->findLog($pos->getSide(4), $visited, $distance + 1, $check, $fromSide) === true){ return true; - }elseif($this->findLog($pos->getSide(5), $visited, $distance + 1, $fromSide) === true){ + }elseif($this->findLog($pos->getSide(5), $visited, $distance + 1, $check, $fromSide) === true){ return true; } break; case 4: - if($this->findLog($pos->getSide(2), $visited, $distance + 1, $fromSide) === true){ + if($this->findLog($pos->getSide(2), $visited, $distance + 1, $check, $fromSide) === true){ return true; - }elseif($this->findLog($pos->getSide(3), $visited, $distance + 1, $fromSide) === true){ + }elseif($this->findLog($pos->getSide(3), $visited, $distance + 1, $check, $fromSide) === true){ return true; - }elseif($this->findLog($pos->getSide(4), $visited, $distance + 1, $fromSide) === true){ + }elseif($this->findLog($pos->getSide(4), $visited, $distance + 1, $check, $fromSide) === true){ return true; } break; case 5: - if($this->findLog($pos->getSide(2), $visited, $distance + 1, $fromSide) === true){ + if($this->findLog($pos->getSide(2), $visited, $distance + 1, $check, $fromSide) === true){ return true; - }elseif($this->findLog($pos->getSide(3), $visited, $distance + 1, $fromSide) === true){ + }elseif($this->findLog($pos->getSide(3), $visited, $distance + 1, $check, $fromSide) === true){ return true; - }elseif($this->findLog($pos->getSide(5), $visited, $distance + 1, $fromSide) === true){ + }elseif($this->findLog($pos->getSide(5), $visited, $distance + 1, $check, $fromSide) === true){ return true; } break; @@ -115,7 +116,8 @@ class LeavesBlock extends TransparentBlock{ if(($this->meta & 0b00001100) === 0x08){ $this->meta &= 0x03; $visited = array(); - if($this->findLog($this, $visited, 0) === true){ + $check = 0; + if($this->findLog($this, $visited, 0, $check) === true){ $this->level->setBlock($this, $this, false); }else{ $this->level->setBlock($this, new AirBlock(), false); diff --git a/src/world/Entity.php b/src/world/Entity.php index acdabee4e..5bf7c9988 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -113,7 +113,7 @@ class Entity extends Position{ $this->setHealth(5, "generic"); $this->server->schedule(6010, array($this, "update")); //Despawn $this->update(); - $this->size = 0.5; + $this->size = 0.75; break; case ENTITY_MOB: $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"]:10, "generic"); @@ -137,8 +137,8 @@ class Entity extends Position{ $this->isStatic = true; }elseif($this->type === OBJECT_ARROW){ $this->server->schedule(1210, array($this, "update")); //Despawn + $this->update(); } - $this->update(); break; } $this->updateLast(); @@ -368,7 +368,6 @@ class Entity extends Position{ if($this->closed === true){ return false; } - $now = microtime(true); if($this->check === false){ $this->lastUpdate = $now; @@ -435,7 +434,7 @@ class Entity extends Position{ if($this->level->getBlock(new Vector3($x, $y, $z))->isSolid === true){ $ny = $y + 1; $this->speedY = 0; - $this->support = true; + $support = true; if($this->class === ENTITY_FALLING){ $this->y = $ny; $fall = $this->level->getBlock(new Vector3(intval($this->x - 0.5), intval(ceil($this->y)), intval($this->z - 0.5))); @@ -784,9 +783,9 @@ class Entity extends Position{ } public function isSupport(Vector3 $pos, $radius = 1){ - $me = new Vector3($this->x - 0.5, $pos->y, $this->z - 0.5); + $me = new Vector2($this->x - 0.5, $this->z - 0.5); $diff = $this->y - $pos->y; - if($me->distance($pos) < $radius and $diff > 0 and $diff < 1.6){ + if($me->distance(new Vector2($pos->x, $pos->z)) < $radius and $diff > 0 and $diff < 1.6){ return true; } return false; @@ -944,5 +943,9 @@ class Entity extends Position{ public function getHealth(){ return $this->health; } + + public function __toString(){ + return "Entity(x={$this->x},y={$this->y},z={$this->z},level=".$this->level->getName().",class={$this->class},type={$this->type})"; + } }