Resolved issues with incorrect item and TNT position offsets, close #848

This commit is contained in:
Dylan K. Taylor 2017-05-04 13:52:10 +01:00
parent edf1fbb6e6
commit c537cea87e
3 changed files with 8 additions and 2 deletions

View File

@ -279,6 +279,8 @@ abstract class Entity extends Location implements Metadatable{
public $width;
public $length;
protected $baseOffset = 0.0;
/** @var int */
private $health = 20;
private $maxHealth = 20;
@ -1116,7 +1118,7 @@ abstract class Entity extends Location implements Metadatable{
$diffMotion = ($this->motionX - $this->lastMotionX) ** 2 + ($this->motionY - $this->lastMotionY) ** 2 + ($this->motionZ - $this->lastMotionZ) ** 2;
if($diffPosition > 0.04 or $diffRotation > 2.25 and ($diffMotion > 0.0001 and $this->getMotion()->lengthSquared() <= 0.00001)){ //0.2 ** 2, 1.5 ** 2
if($diffPosition > 0.0001 or $diffRotation > 1.0){
$this->lastX = $this->x;
$this->lastY = $this->y;
$this->lastZ = $this->z;
@ -1124,7 +1126,7 @@ abstract class Entity extends Location implements Metadatable{
$this->lastYaw = $this->yaw;
$this->lastPitch = $this->pitch;
$this->level->addEntityMovement($this->chunk->getX(), $this->chunk->getZ(), $this->id, $this->x, $this->y, $this->z, $this->yaw, $this->pitch, $this->yaw);
$this->level->addEntityMovement($this->chunk->getX(), $this->chunk->getZ(), $this->id, $this->x, $this->y + $this->baseOffset, $this->z, $this->yaw, $this->pitch, $this->yaw);
}
if($diffMotion > 0.0025 or ($diffMotion > 0.0001 and $this->getMotion()->lengthSquared() <= 0.0001)){ //0.05 ** 2

View File

@ -43,6 +43,8 @@ class Item extends Entity{
public $width = 0.25;
public $length = 0.25;
public $height = 0.25;
protected $baseOffset = 0.125;
protected $gravity = 0.04;
protected $drag = 0.02;

View File

@ -35,6 +35,8 @@ class PrimedTNT extends Entity implements Explosive{
public $length = 0.98;
public $height = 0.98;
protected $baseOffset = 0.49;
protected $gravity = 0.04;
protected $drag = 0.02;