Merge branch 'stable' into master

# Conflicts:
#	composer.lock
#	resources/vanilla
#	src/entity/Living.php
#	src/pocketmine/Player.php
#	src/pocketmine/VersionInfo.php
#	src/pocketmine/block/Potato.php
#	src/pocketmine/block/Sugarcane.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/item/Item.php
#	src/pocketmine/level/format/Chunk.php
#	src/pocketmine/level/format/io/leveldb/LevelDB.php
#	src/world/generator/GeneratorRegisterTask.php
#	tests/phpstan/configs/check-explicit-mixed-baseline.neon
#	tests/phpstan/configs/l7-baseline.neon
#	tests/phpstan/configs/l8-baseline.neon
#	tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskMainLoggerTest.php
#	tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskMemoryLeakTest.php
#	tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskPublishProgressRaceTest.php
This commit is contained in:
Dylan K. Taylor
2020-09-04 01:43:52 +01:00
18 changed files with 126 additions and 66 deletions

View File

@@ -75,6 +75,7 @@ use const M_PI_2;
abstract class Entity{
public const MOTION_THRESHOLD = 0.00001;
protected const STEP_CLIP_MULTIPLIER = 0.4;
/** @var int */
private static $entityCount = 1;
@@ -137,6 +138,8 @@ abstract class Entity{
/** @var int */
private $maxHealth = 20;
/** @var float */
protected $ySize = 0.0;
/** @var float */
protected $stepHeight = 0.0;
/** @var bool */
@@ -329,10 +332,10 @@ abstract class Entity{
$this->boundingBox = new AxisAlignedBB(
$this->location->x - $halfWidth,
$this->location->y,
$this->location->y + $this->ySize,
$this->location->z - $halfWidth,
$this->location->x + $halfWidth,
$this->location->y + $this->height,
$this->location->y + $this->height + $this->ySize,
$this->location->z + $halfWidth
);
}
@@ -1081,6 +1084,7 @@ abstract class Entity{
if($this->keepMovement){
$this->boundingBox->offset($dx, $dy, $dz);
}else{
$this->ySize *= self::STEP_CLIP_MULTIPLIER;
/*
if($this->isColliding){ //With cobweb?
@@ -1175,7 +1179,12 @@ abstract class Entity{
$stepBB->offset(0, 0, $dz);
//TODO: here we need to shift back down on the Y-axis to the top of the target block (we don't want to jump into the air when walking onto carpet)
$reverseDY = -$dy;
foreach($list as $bb){
$reverseDY = $bb->calculateYOffset($stepBB, $reverseDY);
}
$dy += $reverseDY;
$stepBB->offset(0, $reverseDY, 0);
if(($cx ** 2 + $cz ** 2) >= ($dx ** 2 + $dz ** 2)){
$dx = $cx;
@@ -1183,6 +1192,7 @@ abstract class Entity{
$dz = $cz;
}else{
$moveBB = $stepBB;
$this->ySize += $dy;
}
}
@@ -1190,7 +1200,7 @@ abstract class Entity{
}
$this->location->x = ($this->boundingBox->minX + $this->boundingBox->maxX) / 2;
$this->location->y = $this->boundingBox->minY;
$this->location->y = $this->boundingBox->minY - $this->ySize;
$this->location->z = ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2;
$this->checkChunks();
@@ -1420,6 +1430,7 @@ abstract class Entity{
if($ev->isCancelled()){
return false;
}
$this->ySize = 0;
$pos = $ev->getTo();
$this->setMotion(new Vector3(0, 0, 0));