mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
Merge branch 'master' into leveltweaks
This commit is contained in:
commit
dee0ea09fb
5 changed files with 88 additions and 23 deletions
|
|
@ -2423,8 +2423,37 @@ class Player{
|
|||
break;
|
||||
}
|
||||
if($this->isSleeping) break;
|
||||
|
||||
|
||||
//prevent crash caused by nan values
|
||||
if(is_nan($packet->x) || is_nan($packet->y) || is_nan($packet->z)){
|
||||
ConsoleAPI::warn("{$this->username} Attempted to crash the server using NaN position!");
|
||||
$this->close("invalid position");
|
||||
break;
|
||||
}
|
||||
|
||||
if(is_infinite($packet->yaw) || is_infinite($packet->pitch) || is_infinite($packet->bodyYaw)){
|
||||
ConsoleAPI::warn("{$this->username} Attempted to crash other clients using INF rotation!");
|
||||
$this->close("invalid rotation");
|
||||
break;
|
||||
}
|
||||
|
||||
//doesnt crash anything but allows players to break their model rendering(make them/head invisible)
|
||||
if(is_nan($packet->yaw) || is_nan($packet->pitch) || is_nan($packet->bodyYaw)){
|
||||
ConsoleAPI::warn("{$this->username} Attempted to break their model using NAN rotation!");
|
||||
$this->close("invalid rotation");
|
||||
break;
|
||||
}
|
||||
|
||||
if(($this->entity instanceof Entity) && $packet->messageIndex > $this->lastMovement){
|
||||
$this->lastMovement = $packet->messageIndex;
|
||||
//prevent all movement this far - vanilla collisions break there
|
||||
//farther distances(like inf) may cause client and server crash
|
||||
if(abs($packet->x) >= 8388608 || abs($packet->y) >= 8388608 || abs($packet->z) >= 8388608){
|
||||
$this->addEntityMovementUpdateToQueue($this->entity);
|
||||
break;
|
||||
}
|
||||
|
||||
$newPos = new Vector3($packet->x, $packet->y, $packet->z);
|
||||
if($this->forceMovement instanceof Vector3){
|
||||
if($this->forceMovement->distance($newPos) <= 0.7){
|
||||
|
|
|
|||
|
|
@ -39,34 +39,70 @@ function parseOffset(string $offset) : string|false{
|
|||
|
||||
if(ini_get("date.timezone") == ""){ //No Timezone set
|
||||
date_default_timezone_set("GMT");
|
||||
if(str_contains(" " . strtoupper(php_uname("s")), " WIN")){
|
||||
|
||||
$regex = '/(UTC)(\+*\-*\d*\d*\:*\d*\d*)/';
|
||||
if(str_contains(" " . strtoupper(php_uname("s")), " WIN")){ //windows
|
||||
$keyPath = 'HKLM\\SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation';
|
||||
$timezone = 'UTC'; //default
|
||||
|
||||
/*
|
||||
* wmic timezone get Caption
|
||||
* Get the timezone offset
|
||||
* Get the timezone offset through the registry
|
||||
*
|
||||
* Sample Output var_dump
|
||||
* array(3) {
|
||||
* [0] =>
|
||||
* string(7) "Caption"
|
||||
* [1] =>
|
||||
* string(20) "(UTC+09:30) Adelaide"
|
||||
* [2] =>
|
||||
* string(0) ""
|
||||
* }
|
||||
* array(13) {
|
||||
* [0]=>
|
||||
* string(0) ""
|
||||
* [1]=>
|
||||
* string(71) "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation"
|
||||
* [2]=>
|
||||
* string(35) " Bias REG_DWORD 0xfffffe20"
|
||||
* [3]=>
|
||||
* string(43) " DaylightBias REG_DWORD 0xffffffc4"
|
||||
* [4]=>
|
||||
* string(45) " DaylightName REG_SZ @tzres.dll,-571"
|
||||
* [5]=>
|
||||
* string(67) " DaylightStart REG_BINARY 00000000000000000000000000000000"
|
||||
* [6]=>
|
||||
* string(36) " StandardBias REG_DWORD 0x0"
|
||||
* [7]=>
|
||||
* string(45) " StandardName REG_SZ @tzres.dll,-572"
|
||||
* [8]=>
|
||||
* string(67) " StandardStart REG_BINARY 00000000000000000000000000000000"
|
||||
* [9]=>
|
||||
* string(52) " TimeZoneKeyName REG_SZ China Standard Time"
|
||||
* [10]=>
|
||||
* string(51) " DynamicDaylightTimeDisabled REG_DWORD 0x0"
|
||||
* [11]=>
|
||||
* string(45) " ActiveTimeBias REG_DWORD 0xfffffe20"
|
||||
* [12]=>
|
||||
* string(0) ""
|
||||
* }
|
||||
*/
|
||||
exec("wmic timezone get Caption", $output);
|
||||
exec("reg query " . escapeshellarg($keyPath), $output);
|
||||
|
||||
$string = trim(implode("\n", $output));
|
||||
foreach($output as $line){
|
||||
if(preg_match('/ActiveTimeBias\s+REG_DWORD\s+0x([0-9a-fA-F]+)/', $line, $matches) > 0){
|
||||
$offsetMinutes = ((int) hexdec(trim($matches[1]))) << 32 >> 32; //sign int
|
||||
|
||||
//Detect the Time Zone string
|
||||
preg_match($regex, $string, $matches);
|
||||
if($offsetMinutes === 0){
|
||||
break; //UTC
|
||||
}
|
||||
|
||||
if(!isset($matches[2]) or ($timezone = parseOffset($matches[2])) === false){
|
||||
$timezone = 'UTC';
|
||||
$sign = $offsetMinutes <= 0 ? '+' : '-'; //windows timezone + and - are opposite
|
||||
$absMinutes = abs($offsetMinutes);
|
||||
$hours = floor($absMinutes / 60);
|
||||
$minutes = $absMinutes % 60;
|
||||
|
||||
$offset = sprintf(
|
||||
"%s%02d:%02d",
|
||||
$sign,
|
||||
$hours,
|
||||
$minutes
|
||||
);
|
||||
|
||||
$timezone = parseOffset($offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(date_default_timezone_set($timezone)){
|
||||
ini_set("date.timezone", $timezone);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class SignPostBlock extends TransparentBlock{
|
|||
}
|
||||
|
||||
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||
if(($target->isSolid || $target->getID() === SIGN_POST || $target->getID() === WALL_SIGN) && $face !== 0){
|
||||
if(($target->isSolid || $target->getID() === SIGN_POST || $target->getID() === WALL_SIGN || $target->getID() === GLASS_PANE || $target->getID() === IRON_BARS || $target->getID() === STONE_WALL) && $face !== 0){
|
||||
if(!isset(self::$faces[$face])){
|
||||
$this->meta = floor((($player->entity->yaw + 180) * 16 / 360) + 0.5) & 0x0F;
|
||||
$this->level->setBlock($block, BlockAPI::get(SIGN_POST, $this->meta), true, false, true);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class WallSignBlock extends SignPostBlock{
|
|||
default => WALL_SIGN
|
||||
};
|
||||
|
||||
if(!StaticBlock::getIsSolid($attached) && $attached != SIGN_POST && $attached != WALL_SIGN){
|
||||
if(!StaticBlock::getIsSolid($attached) && $attached != SIGN_POST && $attached != WALL_SIGN && $attached != GLASS_PANE && $attached != IRON_BARS && $attached != STONE_WALL){
|
||||
$level->fastSetBlockUpdate($x, $y, $z, 0, 0, true, true);
|
||||
(ServerAPI::request())->api->entity->drop(new Position($x + 0.5, $y + 0.5, $z + 0.5, $level), BlockAPI::getItem(SIGN, 0, 1));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class BucketItem extends Item{
|
|||
return true;
|
||||
}
|
||||
}elseif($this->meta === WATER){
|
||||
if($block->getID() === AIR || $block instanceof LiquidBlock){
|
||||
if($block->getID() === AIR || $block->getID() === TORCH || $block instanceof LiquidBlock){
|
||||
$water = new WaterBlock();
|
||||
$level->setBlock($block, $water, true, false, true);
|
||||
//$water->place($this, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||
|
|
@ -54,7 +54,7 @@ class BucketItem extends Item{
|
|||
return true;
|
||||
}
|
||||
}elseif($this->meta === LAVA){
|
||||
if($block->getID() === AIR || $block instanceof LiquidBlock){
|
||||
if($block->getID() === AIR || $block->getID() === TORCH || $block instanceof LiquidBlock){
|
||||
$lava = new LavaBlock();
|
||||
$level->setBlock($block, $lava, true, false, true);
|
||||
//$lava->place(clone $this, $player, $block, $target, $face, $fx, $fy, $fz);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue