mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 21:19:44 +00:00
force load all chunks on load, check is entity correct or not
This commit is contained in:
parent
cfabae7583
commit
869b8b111a
3 changed files with 77 additions and 1 deletions
|
|
@ -40,6 +40,12 @@ class LevelAPI{
|
||||||
console("[ERROR] Could not load level \"" . $name . "\"");
|
console("[ERROR] Could not load level \"" . $name . "\"");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
for($X = 0; $X < 16; ++$X){
|
||||||
|
for($Z = 0; $Z < 16; ++$Z){
|
||||||
|
$level->loadChunk($X, $Z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$entities = new Config($path . "entities.yml", CONFIG_YAML);
|
$entities = new Config($path . "entities.yml", CONFIG_YAML);
|
||||||
if(file_exists($path . "tileEntities.yml")){
|
if(file_exists($path . "tileEntities.yml")){
|
||||||
@rename($path . "tileEntities.yml", $path . "tiles.yml");
|
@rename($path . "tileEntities.yml", $path . "tiles.yml");
|
||||||
|
|
@ -94,6 +100,7 @@ class LevelAPI{
|
||||||
foreach($blockUpdates->getAll() as $bupdate){
|
foreach($blockUpdates->getAll() as $bupdate){
|
||||||
if($bupdate["type"] !== BLOCK_UPDATE_RANDOM) $this->server->api->block->scheduleBlockUpdate(new Position((int) $bupdate["x"], (int) $bupdate["y"], (int) $bupdate["z"], $this->levels[$name]), (float) $bupdate["delay"], (int) $bupdate["type"]);
|
if($bupdate["type"] !== BLOCK_UPDATE_RANDOM) $this->server->api->block->scheduleBlockUpdate(new Position((int) $bupdate["x"], (int) $bupdate["y"], (int) $bupdate["z"], $this->levels[$name]), (float) $bupdate["delay"], (int) $bupdate["type"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -34,4 +34,34 @@ define("TILE_SIGN", "Sign");
|
||||||
define("TILE_CHEST", "Chest");
|
define("TILE_CHEST", "Chest");
|
||||||
define("CHEST_SLOTS", 27);
|
define("CHEST_SLOTS", 27);
|
||||||
define("TILE_FURNACE", "Furnace");
|
define("TILE_FURNACE", "Furnace");
|
||||||
define("FURNACE_SLOTS", 3);
|
define("FURNACE_SLOTS", 3);
|
||||||
|
|
||||||
|
const CORRECT_ENTITY_CLASSES = [
|
||||||
|
ENTITY_PLAYER => true,
|
||||||
|
ENTITY_MOB => [
|
||||||
|
MOB_CHICKEN => true,
|
||||||
|
MOB_COW => true,
|
||||||
|
MOB_PIG => true,
|
||||||
|
MOB_SHEEP => true,
|
||||||
|
|
||||||
|
MOB_ZOMBIE => true,
|
||||||
|
MOB_SKELETON => true,
|
||||||
|
MOB_SPIDER => true,
|
||||||
|
MOB_CREEPER => true,
|
||||||
|
MOB_PIGMAN => true
|
||||||
|
],
|
||||||
|
ENTITY_OBJECT => [
|
||||||
|
OBJECT_TRIPOD_CAMERA => true,
|
||||||
|
OBJECT_PRIMEDTNT => true,
|
||||||
|
OBJECT_ARROW => true,
|
||||||
|
OBJECT_SNOWBALL => true,
|
||||||
|
OBJECT_EGG => true,
|
||||||
|
OBJECT_PAINTING => true,
|
||||||
|
OBJECT_MINECART => true,
|
||||||
|
],
|
||||||
|
ENTITY_ITEM => true,
|
||||||
|
ENTITY_FALLING => [
|
||||||
|
FALLING_SAND => true
|
||||||
|
]
|
||||||
|
|
||||||
|
];
|
||||||
|
|
|
||||||
|
|
@ -401,8 +401,47 @@ class Level{
|
||||||
}
|
}
|
||||||
$this->totalMobsAmount = 0;
|
$this->totalMobsAmount = 0;
|
||||||
$post = [];
|
$post = [];
|
||||||
|
//console("ELP {$this->getName()}");
|
||||||
|
//var_dump($this->entityListPositioned);
|
||||||
foreach($this->entityList as $k => $e){
|
foreach($this->entityList as $k => $e){
|
||||||
|
|
||||||
|
if(!isset(CORRECT_ENTITY_CLASSES[$e->class])){
|
||||||
|
ConsoleAPI::warn("Entity $k has invalid class type! {$e->class}");
|
||||||
|
$e->close();
|
||||||
|
unset($this->entityList[$k]);
|
||||||
|
unset($this->server->entities[$k]);
|
||||||
|
|
||||||
|
$curChunkX = (int)$e->x >> 4;
|
||||||
|
$curChunkZ = (int)$e->z >> 4;
|
||||||
|
$index = "$curChunkX $curChunkZ";
|
||||||
|
|
||||||
|
if(isset($this->entityListPositioned[$index]) && isset($this->entityListPositioned[$index][$k])){
|
||||||
|
unset($this->entityListPositioned[$index][$k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$dd = CORRECT_ENTITY_CLASSES[$e->class];
|
||||||
|
if($dd !== true && !isset($dd[$e->type])){
|
||||||
|
ConsoleAPI::warn("Entity $k has invalid entity type! {$e->class} {$e->type}");
|
||||||
|
$e->close();
|
||||||
|
|
||||||
|
unset($this->entityList[$k]);
|
||||||
|
unset($this->server->entities[$k]);
|
||||||
|
|
||||||
|
$curChunkX = (int)$e->x >> 4;
|
||||||
|
$curChunkZ = (int)$e->z >> 4;
|
||||||
|
$index = "$curChunkX $curChunkZ";
|
||||||
|
|
||||||
|
if(isset($this->entityListPositioned[$index]) && isset($this->entityListPositioned[$index][$k])){
|
||||||
|
unset($this->entityListPositioned[$index][$k]);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(!($e instanceof Entity)){
|
if(!($e instanceof Entity)){
|
||||||
unset($this->entityList[$k]);
|
unset($this->entityList[$k]);
|
||||||
unset($this->server->entities[$k]);
|
unset($this->server->entities[$k]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue