Skip to content

Commit

Permalink
fix of some gamebreaking bugs/things which didnt work(1.0.1_01
Browse files Browse the repository at this point in the history
  • Loading branch information
GameHerobrine committed Nov 15, 2022
1 parent fd99971 commit ec46fea
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 24 deletions.
18 changes: 11 additions & 7 deletions src/API/ConsoleAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 != ""){
Expand Down Expand Up @@ -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);
}
}
}
4 changes: 2 additions & 2 deletions src/API/PluginAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
}
Expand Down Expand Up @@ -261,4 +261,4 @@ public function init(){

public function __destruct(){
}
}
}
4 changes: 2 additions & 2 deletions src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
}
}
6 changes: 5 additions & 1 deletion src/material/block/attachable/Trapdoor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/material/block/misc/NetherReactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/material/block/misc/TNT.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
30 changes: 20 additions & 10 deletions src/world/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -384,21 +400,15 @@ 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;
$this->air = 300;
return false;
}

if($this->y < -16){
$this->harm(8, "void", true);
$hasUpdate = true;
if($this->isInVoid()){
$this->outOfWorld();
}

if($this->fire > 0){
Expand Down Expand Up @@ -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})";
}

}
}

0 comments on commit ec46fea

Please sign in to comment.