diff --git a/src/pocketmine/utils/Binary.php b/src/pocketmine/utils/Binary.php index c78861e7f..6ae9ce3a5 100644 --- a/src/pocketmine/utils/Binary.php +++ b/src/pocketmine/utils/Binary.php @@ -55,6 +55,20 @@ class Binary{ return $value & 0xffffffff; } + + public static function flipShortEndianness(int $value) : int{ + return self::readLShort(self::writeShort($value)); + } + + public static function flipIntEndianness(int $value) : int{ + return self::readLInt(self::writeInt($value)); + } + + public static function flipLongEndianness(int $value) : int{ + return self::readLLong(self::writeLong($value)); + } + + private static function checkLength($str, $expect){ assert(($len = strlen($str)) === $expect, "Expected $expect bytes, got $len"); }