From a62986a8d636533d9cdb7bd2ca8237a224340d09 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Thu, 3 Jul 2025 20:57:00 +0300 Subject: [PATCH] fixed division by zero when breaking tnt, (hopefully?) fixed empty chests --- src/Player.php | 1 - src/material/Block.php | 3 ++- src/world/Tile.php | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Player.php b/src/Player.php index aa25083e..fef8a973 100755 --- a/src/Player.php +++ b/src/Player.php @@ -1696,7 +1696,6 @@ class Player{ $len = 1 + strlen($pk->buffer); $MTU = $this->MTU - 24; if($len > $MTU) return $this->blockQueueDataPacket_big($pk); - if(($this->blockUpdateQueueLength + $len) >= $MTU){ $this->sendBlockUpdateQueue(); } diff --git a/src/material/Block.php b/src/material/Block.php index 21527a26..34209442 100755 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -271,12 +271,13 @@ abstract class Block extends Position{ public function getDestroyProgress(Player $player){ if($this->breakTime < 0) return 0; + if($this->breakTime == 0) return INF; //instabreak $id = $this->getID(); $meta = $this->getMetadata(); if($player->canDestroy($id, $meta)){ return $player->getDestroySpeed($id, $meta) / $this->breakTime / 30; } - if($this->breakTime == 0) return INF; //instabreak + return (1 / $this->breakTime) / 100; } diff --git a/src/world/Tile.php b/src/world/Tile.php index 1497923a..da471f13 100644 --- a/src/world/Tile.php +++ b/src/world/Tile.php @@ -266,7 +266,9 @@ class Tile extends Position{ $pk->z = $ob->z; $pk->case1 = 1; $pk->case2 = 2; - $this->server->api->player->broadcastPacket($all, $pk); + foreach($this->level->players as $pl){ + $pl->blockQueueDataPacket(clone $pk); + } for($s = 0; $s < CHEST_SLOTS; ++$s){ $slot = $ob->getSlot($s); if($slot->getID() > AIR and $slot->count > 0){ @@ -283,8 +285,8 @@ class Tile extends Position{ $pk->z = $this->z; $pk->case1 = 1; $pk->case2 = 2; - foreach($this->level->players as $player){ - $player->blockQueueDataPacket(clone $pk); + foreach($this->level->players as $pl){ + $pl->blockQueueDataPacket(clone $pk); } for($s = 0; $s < CHEST_SLOTS; ++$s){