Entity: Fixed intersecting with blocks they aren't actually intersecting with...

at the expense of magma no longer working (which will need to be done better anyway).

This:
- reverts the +0.01 outset which hugely exacerbated the lava bug (fixes #1892)
- adds a 0.001 inset (PC-style) which prevents entities incorrectly intersecting with diagonally adjacent blocks at far-ish coordinates (lava at x=4000, z=4000 is a good way to test this).

PR #1880 does also solve this issue, but again at the expense of magma. Since the bugfix does not require a big bounding-box handling refactor, it has been separated out.
This commit is contained in:
Dylan K. Taylor 2018-01-11 11:10:15 +00:00
parent 71d11c73f0
commit cb90e30bcf

View File

@ -1639,13 +1639,14 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
*/
public function getBlocksAround() : array{
if($this->blocksAround === null){
$bb = $this->boundingBox->grow(0.01, 0.01, 0.01);
$minX = Math::floorFloat($bb->minX);
$minY = Math::floorFloat($bb->minY);
$minZ = Math::floorFloat($bb->minZ);
$maxX = Math::ceilFloat($bb->maxX);
$maxY = Math::ceilFloat($bb->maxY);
$maxZ = Math::ceilFloat($bb->maxZ);
$inset = 0.001; //Offset against floating-point errors
$minX = Math::floorFloat($this->boundingBox->minX + $inset);
$minY = Math::floorFloat($this->boundingBox->minY + $inset);
$minZ = Math::floorFloat($this->boundingBox->minZ + $inset);
$maxX = Math::ceilFloat($this->boundingBox->maxX - $inset);
$maxY = Math::ceilFloat($this->boundingBox->maxY - $inset);
$maxZ = Math::ceilFloat($this->boundingBox->maxZ - $inset);
$this->blocksAround = [];