diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index f3eac4a7..6d3dacd0 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -706,27 +706,21 @@ class BlockAPI{ } }*/ - public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){ - if(!($pos instanceof Block)){ - $block = $pos->level->getBlock($pos); - }else{ - $block = $pos; - } - + public function blockUpdateAround(Position $pos, $type = BLOCK_UPDATE_NORMAL, $delay = false){ if($delay !== false){ - $this->scheduleBlockUpdate($block->getSide(0), $delay, $type); - $this->scheduleBlockUpdate($block->getSide(1), $delay, $type); - $this->scheduleBlockUpdate($block->getSide(2), $delay, $type); - $this->scheduleBlockUpdate($block->getSide(3), $delay, $type); - $this->scheduleBlockUpdate($block->getSide(4), $delay, $type); - $this->scheduleBlockUpdate($block->getSide(5), $delay, $type); + $this->scheduleBlockUpdate($pos->getSide(0), $delay, $type); + $this->scheduleBlockUpdate($pos->getSide(1), $delay, $type); + $this->scheduleBlockUpdate($pos->getSide(2), $delay, $type); + $this->scheduleBlockUpdate($pos->getSide(3), $delay, $type); + $this->scheduleBlockUpdate($pos->getSide(4), $delay, $type); + $this->scheduleBlockUpdate($pos->getSide(5), $delay, $type); }else{ - $this->blockUpdate($block->getSide(0), $type); - $this->blockUpdate($block->getSide(1), $type); - $this->blockUpdate($block->getSide(2), $type); - $this->blockUpdate($block->getSide(3), $type); - $this->blockUpdate($block->getSide(4), $type); - $this->blockUpdate($block->getSide(5), $type); + $this->blockUpdate($pos->getSide(0), $type); + $this->blockUpdate($pos->getSide(1), $type); + $this->blockUpdate($pos->getSide(2), $type); + $this->blockUpdate($pos->getSide(3), $type); + $this->blockUpdate($pos->getSide(4), $type); + $this->blockUpdate($pos->getSide(5), $type); } } diff --git a/src/PocketMinecraftServer.php b/src/PocketMinecraftServer.php index 90703f8a..f820a026 100644 --- a/src/PocketMinecraftServer.php +++ b/src/PocketMinecraftServer.php @@ -107,7 +107,7 @@ class PocketMinecraftServer{ public function checkTicks(){ if($this->getTPS() < 12){ - console("[WARNING] Can\'t keep up! Is the server overloaded?"); + console("[WARNING] Can't keep up! Is the server overloaded?"); } } diff --git a/src/constants/GeneralConstants.php b/src/constants/GeneralConstants.php index 4990d778..79fc1508 100644 --- a/src/constants/GeneralConstants.php +++ b/src/constants/GeneralConstants.php @@ -65,7 +65,7 @@ define("ENTITY_OBJECT", 3); define("ENTITY_ITEM", 4); -define("ENTITY_FALLING", 4); +define("ENTITY_FALLING", 5); define("FALLING_SAND", 66); diff --git a/src/material/block/FallableBlock.php b/src/material/block/FallableBlock.php index 90a8474f..fa7b9031 100644 --- a/src/material/block/FallableBlock.php +++ b/src/material/block/FallableBlock.php @@ -33,24 +33,7 @@ class FallableBlock extends SolidBlock{ public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $ret = $this->level->setBlock($this, $this, true, false, true); - ServerAPI::request()->api->block->blockUpdate($this, BLOCK_UPDATE_NORMAL); + ServerAPI::request()->api->block->blockUpdate(clone $this, BLOCK_UPDATE_NORMAL); return $ret; } - - public function onUpdate($type){ - if($this->getSide(0)->getID() === AIR){ - $data = array( - "x" => $this->x + 0.5, - "y" => $this->y + 0.5, - "z" => $this->z + 0.5, - "Tile" => $this->id, - ); - $server = ServerAPI::request(); - $this->level->setBlock($this, new AirBlock(), false, false, true); - $e = $server->api->entity->add($this->level, ENTITY_FALLING, FALLING_SAND, $data); - $server->api->entity->spawnToAll($this->level, $e->eid); - return BLOCK_UPDATE_NORMAL; - } - return false; - } } \ No newline at end of file diff --git a/src/material/block/GenericBlock.php b/src/material/block/GenericBlock.php index 1f99f446..6b85406b 100644 --- a/src/material/block/GenericBlock.php +++ b/src/material/block/GenericBlock.php @@ -39,14 +39,30 @@ class GenericBlock extends Block{ } public function onBreak(Item $item, Player $player){ - return $this->level->setBlock($this, new AirBlock()); + return $this->level->setBlock($this, new AirBlock(), true, false, true); } public function onUpdate($type){ + if($this->hasPhysics === true){ + if($this->getSide(0)->getID() === AIR){ + $data = array( + "x" => $this->x + 0.5, + "y" => $this->y + 0.5, + "z" => $this->z + 0.5, + "Tile" => $this->id, + ); + $server = ServerAPI::request(); + $this->level->setBlock($this, new AirBlock(), false, false, true); + $e = $server->api->entity->add($this->level, ENTITY_FALLING, FALLING_SAND, $data); + $server->api->entity->spawnToAll($this->level, $e->eid); + $server->api->block->blockUpdateAround(clone $this, BLOCK_UPDATE_NORMAL, 1); + } + return false; + } return false; } public function onActivate(Item $item, Player $player){ - return ($this->isActivable); + return $this->isActivable; } } \ No newline at end of file diff --git a/src/world/Entity.php b/src/world/Entity.php index cde9da6e..dc658864 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -415,7 +415,7 @@ class Entity extends Position{ } if($support === false){ - $this->speedY -= ($this->class === ENTITY_FALLING ? 16:32) * $tdiff; + $this->speedY -= ($this->class === ENTITY_FALLING ? 18:32) * $tdiff; $update = true; }elseif($this->speedY <= 0.1){ $this->speedX = 0; diff --git a/src/world/Level.php b/src/world/Level.php index 288ae4b5..b75f3769 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -216,15 +216,13 @@ class Level{ "meta" => $block->getMetadata(), )); }elseif($direct === false){ - if(!($block->level instanceof Level)){ - $block->position($pos); - } + $block->position($pos); $i = ($pos->x >> 4).":".($pos->y >> 4).":".($pos->z >> 4); if(!isset($this->changedBlocks[$i])){ $this->changedBlocks[$i] = array(); $this->changedCount[$i] = 0; } - $this->changedBlocks[$i][] = $block; + $this->changedBlocks[$i][] = clone $block; ++$this->changedCount[$i]; } } @@ -241,9 +239,8 @@ class Level{ if(!($pos instanceof Position)){ $pos = new Position($pos->x, $pos->y, $pos->z, $this); } - if(!($block->level instanceof Level)){ - $block->position($pos); - } + $block->position($pos); + if($direct === true){ $this->server->api->player->broadcastPacket($this->players, MC_UPDATE_BLOCK, array( "x" => $pos->x, @@ -258,12 +255,11 @@ class Level{ $this->changedBlocks[$i] = array(); $this->changedCount[$i] = 0; } - $this->changedBlocks[$i][] = $block; + $this->changedBlocks[$i][] = clone $block; ++$this->changedCount[$i]; } - if($update === true){ - + if($update === true){ $this->server->api->block->blockUpdateAround($pos, BLOCK_UPDATE_NORMAL, 1); } if($tiles === true){