made pushing disableable in config, php8.1+particial 8.2 comp(not recommended)

This commit is contained in:
GameHerobrine 2023-02-24 06:10:41 +03:00
parent 79831c457d
commit cb6e649081
19 changed files with 55 additions and 40 deletions

View file

@ -1,5 +1,4 @@
<?php
/**
*
* ____ _ _ __ __ _ __ __ ____

View file

@ -3,7 +3,7 @@
class ConsoleAPI{
private $loop, $server, $event, $help, $cmds, $alias;
public $last;
function __construct(){
$this->help = [];
$this->cmds = [];

View file

@ -4,7 +4,7 @@ class EntityAPI{
public $entities;
private $server;
private $eCnt = 1;
private $serverSpawnAnimals, $serverSpawnMobs;
function __construct(){
$this->entities = [];
$this->server = ServerAPI::request();

View file

@ -56,6 +56,10 @@ class ServerAPI{
* @var PluginAPI
*/
public $plugin;
/**
* @var QueryHandler
*/
public $query;
private $asyncCalls = [];
private $server;

View file

@ -411,8 +411,8 @@ class Player{
if(!($this->entity instanceof Entity) or $this->connected === false){
return false;
}
$X = $this->entity->x >> 4;
$Z = $this->entity->z >> 4;
$X = ((int)$this->entity->x) >> 4;
$Z = ((int)$this->entity->z) >> 4;
$v = new Vector2($X, $Z);
$this->chunksOrder = [];
for($x = 0; $x < 16; ++$x){

View file

@ -9,7 +9,9 @@ class PocketMinecraftServer{
*/
public $api;
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;
function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverip = "0.0.0.0"){
$this->port = (int) $port;
$this->doTick = true;
@ -84,8 +86,10 @@ class PocketMinecraftServer{
"discord-bot-name" => "NostalgiaCore Logger",
"despawn-mobs" => true,
"mob-despawn-ticks" => 18000,
"entity-pushing" => false
]);
Living::$entityPushing = $this->extraprops->get("entity-pushing");
Living::$despawnMobs = $this->extraprops->get("despawn-mobs");
Living::$despawnTimer = $this->extraprops->get("mob-despawn-ticks");
Entity::$allowedAI = $this->extraprops->get("enable-mob-ai");

View file

@ -72,6 +72,8 @@ class Entity extends Position
public $inAction = false;
public $hasKnockback;
public $hasJumped;
public $invincible, $crouched, $fire, $health, $status;
public $position;
public $onGround, $inWater;
public $carryoverDamage;
function __construct(Level $level, $eid, $class, $type = 0, $data = array())

View file

@ -2,7 +2,7 @@
abstract class Living extends Entity implements Damageable, Pathfindable{
public static $despawnMobs, $despawnTimer;
public static $despawnMobs, $despawnTimer, $entityPushing;
public $target, $ai;
public $pathFinder, $path = null, $currentIndex = 0, $currentNode, $pathFollower;
@ -65,7 +65,9 @@ abstract class Living extends Entity implements Damageable, Pathfindable{
}
$this->ai->mobController->rotateTick();
$this->ai->mobController->movementTick();
$this->collideHandler();
if(self::$entityPushing){
$this->collideHandler();
}
if($this->onGround){
//if(!$this->hasPath() && $this->pathFinder instanceof ITileNavigator){
// $this->path = $this->pathFinder->navigate(new PathTileXYZ($this->x, $this->y, $this->z, $this->level), new PathTileXYZ($this->x + mt_rand(-10, 10), $this->y + mt_rand(-1, 1), $this->z + mt_rand(-10, 10), $this->level), 10);

View file

@ -20,19 +20,19 @@ class Matrix implements ArrayAccess{
}
}
}
#[\ReturnTypeWillChange]
public function offsetExists($offset){
return isset($this->matrix[(int) $offset]);
}
#[\ReturnTypeWillChange]
public function offsetGet($offset){
return $this->matrix[(int) $offset];
}
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value){
$this->matrix[(int) $offset] = $value;
}
#[\ReturnTypeWillChange]
public function offsetUnset($offset){
unset($this->matrix[(int) $offset]);
}

View file

@ -5,7 +5,7 @@ class MinecraftInterface{
public $bandwidth;
private $socket;
private $packets;
public $start;
function __construct($server, $port = 25565, $serverip = "0.0.0.0"){
$this->socket = new UDPSocket($server, $port, true, $serverip);
if($this->socket->connected === false){

View file

@ -2,8 +2,8 @@
class UDPSocket{
public $connected, $sock, $server;
public $connected, $sock, $server, $port;
function __construct($server, $port, $listen = false, $serverip = "0.0.0.0"){
$this->server = $server;
$this->port = $port;

View file

@ -3,15 +3,15 @@
class RakNetCodec{
public $packet;
public $buffer;
public function __construct(RakNetPacket $packet){
$this->packet = $packet;
$this->buffer =& $this->packet->buffer;
$this->buffer = &$this->packet->buffer;
$this->encode();
}
private function encode(){
if(strlen($this->packet->buffer) > 0){
if($this->packet->buffer != null && strlen($this->packet->buffer) > 0){
return;
}
$this->buffer .= chr($this->packet->pid());

View file

@ -139,7 +139,7 @@ abstract class RakNetDataPacket extends stdClass{
}
protected function putByte($v){
$this->buffer .= chr($v);
$this->buffer .= chr((int)$v);
}
protected function getString(){

View file

@ -11,7 +11,7 @@ class PMFLevel extends PMF{
private $payloadOffset = 0;
private $chunks = [];
private $chunkChange = [];
public $level;
public function __construct($file, $blank = false){
if(is_array($blank)){
$this->create($file, 0);

View file

@ -84,9 +84,9 @@ class Async extends Thread{
public function run(){
if(($this->result = call_user_func_array($this->method, $this->params))){
return true;
//return true;
}else{
return false;
//return false;
}
}

View file

@ -6,7 +6,9 @@ class Random{
private $x, $y, $z, $w;
private $haveNextNextGaussian = false;
private $nextNextGaussian = 0;
public $state;
public $i, $j;
public function __construct($seed = false){
$this->setSeed($seed);
}

View file

@ -41,7 +41,7 @@ class Utils{
public static function wrapAngleTo360($angle)
{
$angle %= 360;
$angle = fmod($angle, 360);
return $angle < 0 ? $angle + 360 : $angle;
}
public static function wrapAngleTo180($angle)

View file

@ -16,9 +16,9 @@ class Level{
*/
public $entityChunked;
public $tiles, $blockUpdates, $nextSave, $players = [], $level;
public $tiles, $blockUpdates, $nextSave, $players = [], $level, $mobSpawner;
private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $stopTime;
public function __construct(PMFLevel $level, Config $entities, Config $tiles, Config $blockUpdates, $name){
$this->server = ServerAPI::request();
$this->level = $level;
@ -298,12 +298,12 @@ class Level{
}
}
public function applyCallbackToNearbyEntities(Entity $e, callable $c, $radius = 5){
$minChunkX = ((int)($e->x - $radius)) >> 4;
$minChunkY = ((int)($e->y - $radius)) >> 4;
$minChunkZ = ((int)($e->z - $radius)) >> 4;
$maxChunkX = ((int)($e->x + $radius)) >> 4;
$maxChunkY = ((int)($e->y + $radius)) >> 4;
$maxChunkZ = ((int)($e->z + $radius)) >> 4;
$minChunkX = ((int)($e->x - $radius)) >> 2;
$minChunkY = ((int)($e->y - $radius)) >> 2;
$minChunkZ = ((int)($e->z - $radius)) >> 2;
$maxChunkX = ((int)($e->x + $radius)) >> 2;
$maxChunkY = ((int)($e->y + $radius)) >> 2;
$maxChunkZ = ((int)($e->z + $radius)) >> 2;
$ents = [];
for($chunkX = $minChunkX; $chunkX <= $maxChunkX; ++$chunkX){
for($chunkY = $minChunkY; $chunkY <= $maxChunkY; ++$chunkY){
@ -318,12 +318,12 @@ class Level{
//unset($ents[$e->eid]);
}
public function getEntitiesNearby(Entity $e, $radius = 5){
$minChunkX = ((int)($e->x - $radius)) >> 4;
$minChunkY = ((int)($e->y - $radius)) >> 4;
$minChunkZ = ((int)($e->z - $radius)) >> 4;
$maxChunkX = ((int)($e->x + $radius)) >> 4;
$maxChunkY = ((int)($e->y + $radius)) >> 4;
$maxChunkZ = ((int)($e->z + $radius)) >> 4;
$minChunkX = ((int)($e->x - $radius)) >> 2;
$minChunkY = ((int)($e->y - $radius)) >> 2;
$minChunkZ = ((int)($e->z - $radius)) >> 2;
$maxChunkX = ((int)($e->x + $radius)) >> 2;
$maxChunkY = ((int)($e->y + $radius)) >> 2;
$maxChunkZ = ((int)($e->z + $radius)) >> 2;
$ents = [];
for($chunkX = $minChunkX; $chunkX <= $maxChunkX; ++$chunkX){
for($chunkY = $minChunkY; $chunkY <= $maxChunkY; ++$chunkY){
@ -516,7 +516,7 @@ class Level{
*/
public function getBlockWithoutVector($x, $y, $z, $positionfy = true){
$b = $this->level->getBlock($x, $y, $z);
$b = $this->level->getBlock((int)$x, (int)$y, (int)$z);
return BlockAPI::get($b[0], $b[1], $positionfy ? new Position($x, $y, $z, $this) : false);
}

View file

@ -14,7 +14,9 @@ class Tile extends Position{
public $metadata;
public $closed;
private $server;
public $scheduledUpdate, $lastUpdate;
function __construct(Level $level, $id, $class, $x, $y, $z, $data = []){
$this->server = ServerAPI::request();
$this->level = $level;