readded ability to keep chunks unloaded, fixed entities falling on farmland

This commit is contained in:
GameHerobrine 2024-05-30 03:26:49 +03:00
parent 7bc97cca37
commit 8353607451
4 changed files with 13 additions and 7 deletions

View file

@ -40,12 +40,16 @@ 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){ if(PocketMinecraftServer::$KEEP_CHUNKS_LOADED){
$level->loadChunk($X, $Z); 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");

View file

@ -11,7 +11,7 @@ class PocketMinecraftServer{
private $serverip, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick, $memoryStats, $async = [], $asyncID = 0; private $serverip, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick, $memoryStats, $async = [], $asyncID = 0;
public $doTick, $levelData, $tiles, $entities, $schedule, $scheduleCnt, $whitelist, $spawn, $difficulty, $stop, $asyncThread; public $doTick, $levelData, $tiles, $entities, $schedule, $scheduleCnt, $whitelist, $spawn, $difficulty, $stop, $asyncThread;
public static $FORCE_20_TPS = false; public static $FORCE_20_TPS = false, $KEEP_CHUNKS_LOADED = true;
function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverip = "0.0.0.0"){ function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverip = "0.0.0.0"){
$this->port = (int) $port; $this->port = (int) $port;
$this->doTick = true; $this->doTick = true;
@ -90,13 +90,15 @@ class PocketMinecraftServer{
"16x16x16_chunk_sending" => false, "16x16x16_chunk_sending" => false,
"experimental-mob-ai" => false, "experimental-mob-ai" => false,
"force-20-tps" => false, "force-20-tps" => false,
"enable-mob-pushing" => Living::$entityPushing "enable-mob-pushing" => Living::$entityPushing,
"keep-chunks-loaded" => self::$KEEP_CHUNKS_LOADED
]); ]);
Player::$smallChunks = $this->extraprops->get("16x16x16_chunk_sending"); Player::$smallChunks = $this->extraprops->get("16x16x16_chunk_sending");
Living::$despawnMobs = $this->extraprops->get("despawn-mobs"); Living::$despawnMobs = $this->extraprops->get("despawn-mobs");
Living::$despawnTimer = $this->extraprops->get("mob-despawn-ticks"); Living::$despawnTimer = $this->extraprops->get("mob-despawn-ticks");
Living::$entityPushing = $this->extraprops->get("enable-mob-pushing"); Living::$entityPushing = $this->extraprops->get("enable-mob-pushing");
self::$FORCE_20_TPS = $this->extraprops->get("force-20-tps"); self::$FORCE_20_TPS = $this->extraprops->get("force-20-tps");
self::$KEEP_CHUNKS_LOADED = $this->extraprops->get("keep-chunks-loaded");
PocketMinecraftServer::$SAVE_PLAYER_DATA = $this->extraprops->get("save-player-data"); PocketMinecraftServer::$SAVE_PLAYER_DATA = $this->extraprops->get("save-player-data");
MobController::$ADVANCED = $this->extraprops->get("experimental-mob-ai"); MobController::$ADVANCED = $this->extraprops->get("experimental-mob-ai");
Explosion::$enableExplosions = $this->extraprops->get("enable-explosions"); Explosion::$enableExplosions = $this->extraprops->get("enable-explosions");

View file

@ -184,7 +184,7 @@ class TileNavigator
} }
if($closestToTarget != null){ if($closestToTarget != null){
return $this->reconstructPath($path, $closestToTarget); return $this->reconstructPath($path, $closestToTarget);
} }
return null; return null;

View file

@ -17,7 +17,7 @@ class FarmlandBlock extends TransparentBlock{
} }
public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){
return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 0.9375, $z + 1)]; return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)];
} }
public static function fallOn(Level $level, $x, $y, $z, Entity $entity, $fallDistance){ public static function fallOn(Level $level, $x, $y, $z, Entity $entity, $fallDistance){