mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
readded fly kicking(toggleable), small tweaks to fall damage
This commit is contained in:
parent
81aa575749
commit
a980eda1be
3 changed files with 41 additions and 5 deletions
|
|
@ -119,7 +119,7 @@ class ServerAPI{
|
|||
"spawn-protection" => 16,
|
||||
"view-distance" => 10,
|
||||
"max-players" => 20,
|
||||
"allow-flight" => false,
|
||||
"allow-flight" => true,
|
||||
"spawn-animals" => true,
|
||||
"spawn-mobs" => true,
|
||||
"mobs-amount" => 50,
|
||||
|
|
@ -138,7 +138,10 @@ class ServerAPI{
|
|||
"enable-mob-ai" => true,
|
||||
"abort-reading-after-N-packets" => PocketMinecraftServer::$PACKET_READING_LIMIT
|
||||
]);
|
||||
|
||||
Entity::$allowFly = $this->getProperty("allow-flight", true);
|
||||
if(!Entity::$allowFly){
|
||||
ConsoleAPI::warn("Fly checking is enabled! Players may experience issues with kicking while not flying!");
|
||||
}
|
||||
$this->parseProperties();
|
||||
MobSpawner::$MOB_LIMIT = $this->getProperty("mobs-amount", 50);
|
||||
Entity::$allowedAI = $this->getProperty("enable-mob-ai", true);
|
||||
|
|
|
|||
|
|
@ -285,6 +285,7 @@ class Player{
|
|||
$this->lastCorrect = $pos;
|
||||
$this->entity->fallY = false;
|
||||
$this->entity->fallStart = false;
|
||||
$this->entity->notOnGroundTicks = 0;
|
||||
$this->entity->setPosition($pos, $yaw, $pitch);
|
||||
$this->entity->resetSpeed();
|
||||
$this->entity->updateLast();
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class Entity extends Position
|
|||
public $counter = 0;
|
||||
public $fallDistance = 0;
|
||||
public static $updateOnTick, $allowedAI;
|
||||
public static $allowFly = true;
|
||||
public $canBeAttacked;
|
||||
public $moveTime, $lookTime, $idleTime, $knockbackTime = 0;
|
||||
public $attackTimeout = 0;
|
||||
|
|
@ -105,6 +106,7 @@ class Entity extends Position
|
|||
|
||||
public $inWeb;
|
||||
public $inLava;
|
||||
public $notOnGroundTicks = 0;
|
||||
|
||||
public $moveStrafing, $moveForward;
|
||||
|
||||
|
|
@ -769,14 +771,29 @@ class Entity extends Position
|
|||
$fireMaxY = floor($contractedCollisionBB->maxY + 1);
|
||||
$fireMaxZ = floor($contractedCollisionBB->maxZ + 1);
|
||||
|
||||
$bbbottom = $this->boundingBox->addCoord(0, -0.05, 0);
|
||||
$bbbottom->minX = round($this->x, 3) - $this->radius;
|
||||
$bbbottom->maxX = round($this->x, 3) + $this->radius;
|
||||
$bbbottom->minZ = round($this->z, 3) - $this->radius;
|
||||
$bbbottom->maxZ = round($this->z, 3) + $this->radius;
|
||||
|
||||
$handleFire = false;
|
||||
$handleCactus = false;
|
||||
|
||||
for($x = floor($this->boundingBox->minX); $x < ceil($this->boundingBox->maxX); ++$x){
|
||||
for($z = floor($this->boundingBox->minZ); $z < ceil($this->boundingBox->maxZ); ++$z){
|
||||
for($y = floor($this->boundingBox->minY - 1); $y < ceil($this->boundingBox->maxY); ++$y){
|
||||
$intersects = 0;
|
||||
$id = $this->level->level->getBlockID($x, $y, $z);
|
||||
$bounds = StaticBlock::$prealloc[$id]::getCollisionBoundingBoxes($this->level, $x, $y, $z, $this);
|
||||
foreach($bounds as $bb){
|
||||
if($bbbottom->intersectsWith($bb)){
|
||||
++$intersects;
|
||||
}
|
||||
}
|
||||
|
||||
intersects:
|
||||
if($y <= floor($this->boundingBox->minY) && !$this->onGround){
|
||||
$this->onGround = StaticBlock::getIsSolid($this->level->level->getBlockID($x, $y, $z));
|
||||
if($intersects > 0) $this->onGround = count($bounds) > 0;
|
||||
}else{
|
||||
$block = $this->level->level->getBlock($x, $y, $z);
|
||||
$id = $block[0];
|
||||
|
|
@ -794,6 +811,21 @@ class Entity extends Position
|
|||
}
|
||||
}
|
||||
|
||||
if($prevGroundState == $this->onGround && !$this->onGround){
|
||||
++$this->notOnGroundTicks;
|
||||
}else if($this->onGround){
|
||||
$this->notOnGroundTicks = 0;
|
||||
}
|
||||
|
||||
if($this->notOnGroundTicks > 80){ //~70 ticks is needed to reach from 127 to 0
|
||||
if(($this->player->gamemode & 1) != CREATIVE && !$this->player->blocked && $this->player->spawned){ //survival(0), adventure(2)
|
||||
if(!Entity::$allowFly){
|
||||
$this->player->close("flying");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($this->isOnLadder()){
|
||||
$this->fallDistance = 0;
|
||||
$this->fallStart = $this->y;
|
||||
|
|
@ -835,7 +867,7 @@ class Entity extends Position
|
|||
|
||||
$this->counterUpdate();
|
||||
|
||||
if($this->isPlayer() || $update){
|
||||
if($this->isPlayer()){
|
||||
$this->updateMovement();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue