fix of some gamebreaking bugs/things which didnt work(1.0.1_01

This commit is contained in:
GameHerobrine 2022-11-15 10:12:38 +03:00
parent fd99971503
commit ec46feabbd
7 changed files with 42 additions and 24 deletions

View file

@ -269,8 +269,9 @@ class ConsoleAPI{
if(defined("NO_THREADS")){ if(defined("NO_THREADS")){
return; return;
} }
if($this->loop->line !== false){ $line = $this->loop->line;
$line = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", trim($this->loop->line)); if($line !== false){
$line = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", trim($line));
$this->loop->line = false; $this->loop->line = false;
$output = $this->run($line, "console"); $output = $this->run($line, "console");
if($output != ""){ if($output != ""){
@ -319,15 +320,18 @@ class ConsoleLoop extends Thread{
$this->fp = fopen("php://stdin", "r"); $this->fp = fopen("php://stdin", "r");
} }
while($this->stop === false){ while(!$this->stop){
$this->line = $this->readLine(); $this->synchronized(function($t){
$this->wait(); $t->line = $t->readLine();
$t->wait();
}, $this);
$this->line = false; $this->line = false;
} }
if(!extension_loaded("readline")){ if(!extension_loaded("readline")){
@fclose($fp); @fclose($this->fp);
} }
exit(0); exit(0);
} }
} }

View file

@ -125,7 +125,7 @@ class PluginAPI extends stdClass{
} }
$className = $info["class"]; $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)){ 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!"); console("[WARNING] Plugin \"".$info["name"]."\" may not be compatible with the API (".$info["apiversion"]." != ".CURRENT_API_VERSION.")! It can crash or corrupt the server!");
} }

View file

@ -67,7 +67,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . FILE_PATH);
ini_set("memory_limit", "128M"); //Default ini_set("memory_limit", "128M"); //Default
define("LOG", true); define("LOG", true);
define("START_TIME", microtime(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("CODENAME", "懐かしさ (Nostalgia)"); //i'm not very creative - kotyaralih
define("CURRENT_MINECRAFT_VERSION", "v0.8.1 alpha"); define("CURRENT_MINECRAFT_VERSION", "v0.8.1 alpha");
define("CURRENT_API_VERSION", 12); define("CURRENT_API_VERSION", 12);

View file

@ -30,8 +30,12 @@ class TrapdoorBlock extends TransparentBlock{
} }
$this->hardness = 15; $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){ 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( $faces = array(
2 => 0, 2 => 0,
3 => 1, 3 => 1,

View file

@ -28,7 +28,7 @@ class NetherReactorBlock extends SolidBlock{
public function onActivate(Item $item, Player $player){ 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(($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()); NetherReactorStructure::buildReactor($this->level, $this->getX(),$this->getY(),$this->getZ());
$this->meta = 1; $this->meta = 1;
$this->level->setBlock($this,$this); $this->level->setBlock($this,$this);

View file

@ -35,7 +35,7 @@ class TNTBlock extends SolidBlock{
"x" => $this->x + 0.5, "x" => $this->x + 0.5,
"y" => $this->y + 0.5, "y" => $this->y + 0.5,
"z" => $this->z + 0.5, "z" => $this->z + 0.5,
"power" => 4, "power" => 3,
"fuse" => 20 * 4, //4 seconds "fuse" => 20 * 4, //4 seconds
); );
$this->level->setBlock($this, new AirBlock(), false, false, true); $this->level->setBlock($this, new AirBlock(), false, false, true);

View file

@ -214,10 +214,26 @@ class Entity extends Position{
} }
$this->updateLast(); $this->updateLast();
$this->updatePosition(); $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(); $this->close();
} }
} }
public function dropAnEgg(){ 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)); 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")); $this->server->schedule(mt_rand(0,6000) + 6000, array($this, "dropAnEgg"));
@ -385,20 +401,14 @@ class Entity extends Position{
} }
} }
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){ if($this->dead === true){
$this->fire = 0; $this->fire = 0;
$this->air = 300; $this->air = 300;
return false; return false;
} }
if($this->y < -16){ if($this->isInVoid()){
$this->harm(8, "void", true); $this->outOfWorld();
$hasUpdate = true;
} }
if($this->fire > 0){ if($this->fire > 0){