From a3711cfded967b2e73cc5fdb1511c28ae220ac2e Mon Sep 17 00:00:00 2001 From: kotyara Date: Sun, 26 Feb 2023 16:47:40 +0500 Subject: [PATCH] no kb if entity is dead + Utils::getUniqueID change --- src/entity/Entity.php | 3 +++ src/utils/Utils.php | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index a9ec8b6f..53c85eaa 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1434,6 +1434,9 @@ class Entity extends Position public function knockBack($d, $d1) { + if($this->closed || $this->dead){ + return false; + } $f = sqrt($d * $d + $d1 * $d1); $f1 = 0.4; $this->speedX /= 2; diff --git a/src/utils/Utils.php b/src/utils/Utils.php index c72f305d..0f2bfd38 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -99,13 +99,14 @@ class Utils{ public static function getUniqueID($raw = false, $extra = ""){ $machine = php_uname("a"); - $machine .= file_exists("/proc/cpuinfo") ? file_get_contents("/proc/cpuinfo") : ""; + $machine .= file_exists("/proc/cpuinfo") ? `cat /proc/cpuinfo | grep "model name"` : ""; $machine .= sys_get_temp_dir(); $machine .= $extra; - if(Utils::getOS() == "win"){ - exec("ipconfig /ALL", $mac); + $os = Utils::getOS(); + if($os === "win"){ + @exec("ipconfig /ALL", $mac); $mac = implode("\n", $mac); - if(preg_match_all("#Physical Address[. ]{1,}: ([0-9A-F\-]{17})#", $mac, $matches)){ + if(preg_match_all("#Physical Address[. ]{1,}: ([0-9A-F\\-]{17})#", $mac, $matches)){ foreach($matches[1] as $i => $v){ if($v == "00-00-00-00-00-00"){ unset($matches[1][$i]); @@ -113,6 +114,17 @@ class Utils{ } $machine .= implode(" ", $matches[1]); //Mac Addresses } + }elseif($os === "linux"){ + @exec("ifconfig", $mac); + $mac = implode("\n", $mac); + if(preg_match_all("#HWaddr[ \t]{1,}([0-9a-f:]{17})#", $mac, $matches)){ + foreach($matches[1] as $i => $v){ + if($v == "00:00:00:00:00:00"){ + unset($matches[1][$i]); + } + } + $machine .= implode(" ", $matches[1]); //Mac Addresses + } } $data = $machine . PHP_MAXPATHLEN; $data .= PHP_INT_MAX;