From ec46feabbd751ab1e113f7d30c5d85df1721909d Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Tue, 15 Nov 2022 10:12:38 +0300 Subject: [PATCH] fix of some gamebreaking bugs/things which didnt work(1.0.1_01 --- src/API/ConsoleAPI.php | 18 ++++++++----- src/API/PluginAPI.php | 4 +-- src/config.php | 4 +-- src/material/block/attachable/Trapdoor.php | 6 ++++- src/material/block/misc/NetherReactor.php | 2 +- src/material/block/misc/TNT.php | 2 +- src/world/Entity.php | 30 ++++++++++++++-------- 7 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/API/ConsoleAPI.php b/src/API/ConsoleAPI.php index 4d1eda54d..14442bf7f 100644 --- a/src/API/ConsoleAPI.php +++ b/src/API/ConsoleAPI.php @@ -269,8 +269,9 @@ public function handle($time){ if(defined("NO_THREADS")){ return; } - if($this->loop->line !== false){ - $line = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", trim($this->loop->line)); + $line = $this->loop->line; + if($line !== false){ + $line = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", trim($line)); $this->loop->line = false; $output = $this->run($line, "console"); if($output != ""){ @@ -319,15 +320,18 @@ public function run(){ $this->fp = fopen("php://stdin", "r"); } - while($this->stop === false){ - $this->line = $this->readLine(); - $this->wait(); + while(!$this->stop){ + $this->synchronized(function($t){ + $t->line = $t->readLine(); + $t->wait(); + }, $this); $this->line = false; } if(!extension_loaded("readline")){ - @fclose($fp); + @fclose($this->fp); } + exit(0); } -} +} \ No newline at end of file diff --git a/src/API/PluginAPI.php b/src/API/PluginAPI.php index 8980f2391..e01e417f8 100644 --- a/src/API/PluginAPI.php +++ b/src/API/PluginAPI.php @@ -125,7 +125,7 @@ public function load($file){ } $className = $info["class"]; - $apiversion = array_map("intval", explode(",", (string) $info["apiversion"])); + $apiversion = array_map("floatval", explode(",", (string) $info["apiversion"])); if(!in_array((string) CURRENT_API_VERSION, $apiversion)){ console("[WARNING] Plugin \"".$info["name"]."\" may not be compatible with the API (".$info["apiversion"]." != ".CURRENT_API_VERSION.")! It can crash or corrupt the server!"); } @@ -261,4 +261,4 @@ public function init(){ public function __destruct(){ } -} +} \ No newline at end of file diff --git a/src/config.php b/src/config.php index f28435fe0..37af678cf 100644 --- a/src/config.php +++ b/src/config.php @@ -67,7 +67,7 @@ ini_set("memory_limit", "128M"); //Default define("LOG", true); define("START_TIME", microtime(true)); -define("MAJOR_VERSION", "1.0.1 (Alpha_1.3.12)"); +define("MAJOR_VERSION", "1.0.1_01 (Alpha_1.3.12)"); define("CODENAME", "懐かしさ (Nostalgia)"); //i'm not very creative - kotyaralih define("CURRENT_MINECRAFT_VERSION", "v0.8.1 alpha"); define("CURRENT_API_VERSION", 12); @@ -77,4 +77,4 @@ define("GIT_COMMIT", strtolower(trim(file_get_contents(FILE_PATH.".git/refs/heads/master")))); }else{ //Unknown :( define("GIT_COMMIT", str_repeat("00", 20)); -} +} \ No newline at end of file diff --git a/src/material/block/attachable/Trapdoor.php b/src/material/block/attachable/Trapdoor.php index 1776a81d9..3650ef01d 100644 --- a/src/material/block/attachable/Trapdoor.php +++ b/src/material/block/attachable/Trapdoor.php @@ -30,8 +30,12 @@ public function __construct($meta = 0){ } $this->hardness = 15; } + public function canAttachTo(Block $target){ + $id = $target->getID(); + return $id === SLAB || $id === GLOWSTONE || $id === SLAB || $id === WOOD_SLAB || (!$target->isTransparent || $target instanceof StairBlock); + } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ - if(($target->isTransparent === false or $target->getID() === SLAB) and $face !== 0 and $face !== 1){ + if(($this->canAttachTo($target)) and $face !== 0 and $face !== 1){ $faces = array( 2 => 0, 3 => 1, diff --git a/src/material/block/misc/NetherReactor.php b/src/material/block/misc/NetherReactor.php index 048fd4d52..fb302ad01 100644 --- a/src/material/block/misc/NetherReactor.php +++ b/src/material/block/misc/NetherReactor.php @@ -28,7 +28,7 @@ public function __construct($meta = 0){ public function onActivate(Item $item, Player $player){ //if(($item->getID() === IRON_SWORD || $item->getID() === WOODEN_SWORD || $item->getID() === STONE_SWORD || $item->getID() === DIAMOND_SWORD || $item->getID() === GOLD_SWORD) /*&& $player->gamemode === 0*/){ - if($this->isCorrect($this->getX(),$this->getY(),$this->getZ()) && $this->getY() < 101){ + if(self::$enableReactor && ($player->gamemode & 0x1) === 0 && $this->isCorrect($this->getX(),$this->getY(),$this->getZ()) && $this->getY() < 101){ NetherReactorStructure::buildReactor($this->level, $this->getX(),$this->getY(),$this->getZ()); $this->meta = 1; $this->level->setBlock($this,$this); diff --git a/src/material/block/misc/TNT.php b/src/material/block/misc/TNT.php index 8ac827636..b9e8270fa 100644 --- a/src/material/block/misc/TNT.php +++ b/src/material/block/misc/TNT.php @@ -35,7 +35,7 @@ public function onActivate(Item $item, Player $player){ "x" => $this->x + 0.5, "y" => $this->y + 0.5, "z" => $this->z + 0.5, - "power" => 4, + "power" => 3, "fuse" => 20 * 4, //4 seconds ); $this->level->setBlock($this, new AirBlock(), false, false, true); diff --git a/src/world/Entity.php b/src/world/Entity.php index 385d4be31..9e433d60e 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -214,10 +214,26 @@ function __construct(Level $level, $eid, $class, $type = 0, $data = array()){ } $this->updateLast(); $this->updatePosition(); - if($this->y < 0 and $this->class !== ENTITY_PLAYER){ + if($this->isInVoid()){ + $this->outOfWorld(); + } + } + + public function isInVoid(){ + return $this->y < -1.6; + } + + /** + * Handle fall out of world + */ + public function outOfWorld(){ + if($this->player instanceof Player){ + $this->harm($this->health, "void", true); + }else{ $this->close(); } } + public function dropAnEgg(){ ServerAPI::request()->api->entity->drop(new Position($this->x + 0.5, $this->y, $this->z + 0.5, $this->level), BlockAPI::getItem(EGG,0,1)); $this->server->schedule(mt_rand(0,6000) + 6000, array($this, "dropAnEgg")); @@ -384,11 +400,6 @@ public function environmentUpdate(){ break; } } - - if($this->class !== ENTITY_PLAYER and ($this->x <= 0 or $this->z <= 0 or $this->x >= 256 or $this->z >= 256 or $this->y >= 128 or $this->y <= 0)){ - $this->close(); - return false; - } if($this->dead === true){ $this->fire = 0; @@ -396,9 +407,8 @@ public function environmentUpdate(){ return false; } - if($this->y < -16){ - $this->harm(8, "void", true); - $hasUpdate = true; + if($this->isInVoid()){ + $this->outOfWorld(); } if($this->fire > 0){ @@ -1213,4 +1223,4 @@ public function __toString(){ return "Entity(x={$this->x},y={$this->y},z={$this->z},level=".$this->level->getName().",class={$this->class},type={$this->type})"; } -} +} \ No newline at end of file