names were fixed, ->loop->stop();

This commit is contained in:
GameHerobrine 2023-01-04 20:46:17 +03:00
parent 50006a0189
commit f6897cf862
242 changed files with 111 additions and 166 deletions

View file

@ -573,11 +573,7 @@ class BlockAPI{
public function nextRandomUpdate(Position $pos){
if(!isset($this->scheduledUpdates[$pos->x . "." . $pos->y . "." . $pos->z . "." . $pos->level->getName() . "." . BLOCK_UPDATE_RANDOM])){
$X = (($pos->x >> 4) << 4);
$Y = (($pos->y >> 4) << 4);
$Z = (($pos->z >> 4) << 4);
$time = microtime(true);
$i = 0;
$offset = 0;
while(true){
$t = $offset + Utils::getRandomUpdateTicks() * 0.05;

View file

@ -51,7 +51,6 @@ class ConsoleAPI{
$this->loop->notify();
//@fclose($this->loop->fp);
usleep(50000);
$this->loop->kill();
//$this->loop->join();
}
}
@ -294,7 +293,6 @@ class ConsoleLoop extends Thread{
public $base;
public $ev;
public $fp;
public function __construct(){
$this->line = false;
$this->stop = false;

View file

@ -54,7 +54,7 @@ class EntityAPI{
}
$mobName = ucfirst(array_flip($mob)[$type]);
if((strtolower($args[1] === "baby") or strtolower($args[2] === "baby")) and !Utils::in_range($type, 10, 13)){
if((isset($args[1]) || isset($args[2])) && (strtolower($args[1] === "baby") or strtolower($args[2] === "baby")) and !Utils::in_range($type, 10, 13)){
$output .= "$mobName cannot be a baby!";
break;
}

View file

@ -1,19 +1,5 @@
<?php
interface OtherPluginRequirement{
public function getRequiredPlugins();
}
interface Plugin{
public function __construct(ServerAPI $api, $server = false);
public function init();
//public function __destruct(); useless
}
class PluginAPI extends stdClass{
private $server;
@ -323,14 +309,4 @@ class RequiredPluginEntry{ //Use this as object of requirements array
}
}
class DummyPlugin implements Plugin{
public function __construct(ServerAPI $api, $server = false){
}
public function init(){
}
public function __destruct(){
}
}

View file

@ -70,8 +70,9 @@ class PocketMinecraftServer{
console("[INFO] Loading extra.properties...");
$this->extraprops = new Config(DATA_PATH . "extra.properties", CONFIG_PROPERTIES, [
"version" => "5",
"experemental-mob-features" => false,
"enable-nether-reactor" => true,
"experemental-mob-features" => true,
"enable-mob-ai" => false,
"enable-nether-reactor" => true,
"enable-explosions" => true,
"enable-rail-connection" => false,
"save-player-data" => true,
@ -82,6 +83,7 @@ class PocketMinecraftServer{
"discord-webhook-url" => "none",
"discord-bot-name" => "NostalgiaCore Logger"
]);
Entity::$allowedAI = $this->extraprops->get("enable-mob-ai");
Entity::$updateOnTick = $this->extraprops->get("experemental-mob-features");
if(Entity::$updateOnTick){
console("[WARNING] Experemental mob features are enabled. Unpredictable behavior.");

View file

@ -48,7 +48,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . FILE_PATH);
ini_set("memory_limit", "256M"); //Default
define("LOG", true);
define("START_TIME", microtime(true));
define("MAJOR_VERSION", "1.0.2dev (Alpha_1.3.12)");
define("MAJOR_VERSION", "1.0.2dev");
define("CODENAME", "懐かしさ (Nostalgia)"); //i'm not very creative - kotyaralih
define("CURRENT_MINECRAFT_VERSION", "v0.8.1 alpha");
define("CURRENT_API_VERSION", '12.1');

View file

@ -123,8 +123,16 @@ require_once(FILE_PATH . "/src/material/item/armor/ArmorItem.php");
require_once(FILE_PATH . "/src/structure/Structure.php");
require_once(FILE_PATH . "/src/plugin/Plugin.php");
require_once(FILE_PATH . "/src/plugin/OtherPluginRequirement.php");
require_once(FILE_PATH . "/src/plugin/DummyPlugin.php");
require_once(FILE_PATH . "/src/plugin/phar/IClassLoader.php");
require_once(FILE_PATH . "/src/plugin/phar/PharUtils.php");
require_all(FILE_PATH . "src/");
$inc = get_included_files();
$inc[] = array_shift($inc);
$srcdir = realpath(FILE_PATH . "src/");

View file

@ -14,6 +14,7 @@ abstract class Animal extends Creature implements Ageable, Breedable{
if(isset($this->data["IsBaby"]) && $this->data["IsBaby"] && $this->getAge() >= 0){
$this->setAge(-24000);
}
$this->ai->addTask(new TaskTempt());
}

View file

@ -12,12 +12,11 @@ abstract class Creature extends Living{
$this->inPanic = false; //force for now
parent::__construct($level, $eid, $class, $type, $data);
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 1, "generic");
//$this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type));
if(Entity::$updateOnTick){
$this->ai->addTask(new TaskLookAround());
$this->ai->addTask(new TaskRandomWalk());
$this->ai->addTask(new TaskLookAtPlayer());
}
// $this->setName((isset($mobs[$this->type]) ? $mobs[$this->type]:$this->type));
$this->ai->addTask(new TaskLookAround());
$this->ai->addTask(new TaskRandomWalk());
$this->ai->addTask(new TaskLookAtPlayer());
}

View file

@ -6,7 +6,7 @@ class Entity extends Position
const TYPE = - 1;
const CLASS_TYPE = - 1;
public static $updateOnTick;
public static $updateOnTick, $allowedAI;
public $isCollidable;
public $canBeAttacked;
public $moveTime, $lookTime, $idleTime;

View file

@ -27,7 +27,7 @@ abstract class Living extends Entity implements Damageable, Pathfindable{
}
public function update(){
if($this->idleTime <= 0) {
if(Entity::$allowedAI && $this->idleTime <= 0) {
$this->ai->updateTasks();
}

View file

@ -0,0 +1,14 @@
<?php
class EntityList{
public function getEntities(){
return $this->entities;
}
public function addEntity(PropertyEntity $property){
$this->entities[$property->getEntityType()] = $property;
}
public function getEntityFromTypeAndClass($type, $class){
return isset($this->entities[$type]) && $this->entities[$type]->getEntityClass() === $class ? $this->entities[$type] : 0;
}
private $entities = [];
}

View file

@ -1,39 +1,6 @@
<?php
class PropertyEntity{
private $class,$type,$name;
function __construct($class, $type, $name){
$this->class = $class;
$this->type = $type;
$this->name = $name;
}
public function getEntityClass(){
return $this->class;
}
public function getEntityType(){
return $this->type;
}
public function getEntityName(){
return $this->name;
}
}
class EntityList{
public function getEntities(){
return $this->entities;
}
public function addEntity(PropertyEntity $property){
$this->entities[$property->getEntityType()] = $property;
}
public function getEntityFromTypeAndClass($type, $class){
return isset($this->entities[$type]) && $this->entities[$type]->getEntityClass() === $class ? $this->entities[$type] : 0;
}
private $entities = [];
}
class EntityRegistry{
class EntityRegistry{
public static $entityList;
/*Register all entities*/
public static function registerEntities(){

View file

@ -0,0 +1,21 @@
<?php
class PropertyEntity{
private $class,$type,$name;
function __construct($class, $type, $name){
$this->class = $class;
$this->type = $type;
$this->name = $name;
}
public function getEntityClass(){
return $this->class;
}
public function getEntityType(){
return $this->type;
}
public function getEntityName(){
return $this->name;
}
}

View file

@ -1,7 +1,7 @@
<?php
/***REM_START***/
require_once("SignPost.php");
require_once("SignPostBlock.php");
/***REM_END***/
class WallSignBlock extends SignPostBlock{

View file

@ -2,7 +2,7 @@
/***REM_START***/
require_once("Water.php");
require_once("WaterBlock.php"); //TODO class loader?
/***REM_END***/
class StillWaterBlock extends WaterBlock{

View file

@ -58,7 +58,7 @@ class NetherReactorBlock extends SolidBlock{
}
private function decay($x, $y, $z, $aOne, $aTwo, $aThree, $bOne, $bTwo, $bThree, $cOne, $cTwo, $cThree) {
for($a = $aOne; $a < $aTwo; $a += $aThree) { //wth those cycles are?
for($a = $aOne; $a < $aTwo; $a += $aThree) { //wth those cycles are? TODO simplify if possible(makes server lag)
for($b = $bOne; $b < $bTwo; $b += $bThree) {
for($c = $cOne; $c < $cTwo; $c += $cThree) {
if ($this->level->getBlock(new Vector3($x+$a, $y+$b, $z+$c))->getID() === 87 && Utils::randomFloat() > 0.75){
@ -188,24 +188,25 @@ class NetherReactorBlock extends SolidBlock{
foreach($this->core as $yOffset => $layer){
foreach($layer as $line){
foreach(str_split($line) as $char){
$b = $this->level->getBlockWithoutVector(new Vector3($x + $offsetX, $y + $yOffset, $z + $offsetZ));
switch($char){
case "G":
if($this->level->getBlock(new Vector3($x + $offsetX, $y + $yOffset, $z + $offsetZ))->getID() === GOLD_BLOCK){
if($b === GOLD_BLOCK){ //TODO make it use structure class
break;
}
return false;
case "C":
if($this->level->getBlock(new Vector3($x + $offsetX, $y + $yOffset, $z + $offsetZ))->getID() === COBBLESTONE){
if($b === COBBLESTONE){
break;
}
return false;
case "R":
if($this->level->getBlock(new Vector3($x + $offsetX, $y + $yOffset, $z + $offsetZ))->getID() === NETHER_REACTOR){
if($b === NETHER_REACTOR){
break;
}
return false;
case " ":
if($this->level->getBlock(new Vector3($x + $offsetX, $y + $yOffset, $z + $offsetZ))->getID() === 0){
if($b->getID() === 0){
break;
}
return false;

View file

@ -30,7 +30,7 @@ class RailBlock extends FlowableBlock{
if(!($rail instanceof RailBlock)) return null;
$damage = $rail->meta;
if ($damage < 0 || $damage > 10) return null;
$delta = array(
$delta = array( //TODO make static
array(array(0, 1), array(0, -1)),
array(array(1, 0), array(-1, 0)),
array(array(1, 0), array(-1, 0)),

View file

@ -3,7 +3,7 @@
class SlabBlock extends TransparentBlock{
public function __construct($meta = 0){
parent::__construct(SLAB, $meta, "Slab");
$names = array(
$names = array( //TODO make it static
0 => "Stone",
1 => "Sandstone",
2 => "Wooden",

View file

@ -1,7 +1,7 @@
<?php
/***REM_START***/
require_once("BurningFurnace.php");
require_once("BurningFurnaceBlock.php");
/***REM_END***/

Some files were not shown because too many files have changed in this diff Show more