Fixed entities not being pushed out of blocks

This commit is contained in:
Shoghi Cervantes 2014-10-20 12:37:17 +02:00
parent 481e2b08ee
commit fec387d2ec
5 changed files with 19 additions and 20 deletions

View File

@ -41,7 +41,7 @@ class TNT extends Solid{
public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::FLINT_STEEL){
$item->useOn($this);
$this->getLevel()->setBlock($this, new Air(), false, false, true);
$this->getLevel()->setBlock($this, new Air(), true);
$mot = (new Random())->nextSignedFloat() * M_PI * 2;
$tnt = new PrimedTNT($this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [

View File

@ -85,7 +85,7 @@ class Arrow extends Projectile{
$this->motionY -= $this->gravity;
$this->inBlock = $this->checkObstruction($this->x, ($this->boundingBox->minY + $this->boundingBox->maxY) / 2, $this->z);
$this->keepMovement = $this->checkObstruction($this->x, ($this->boundingBox->minY + $this->boundingBox->maxY) / 2, $this->z);
$moveVector = new Vector3($this->x + $this->motionX, $this->y + $this->motionY, $this->z + $this->motionZ);

View File

@ -93,7 +93,7 @@ class DroppedItem extends Entity{
$this->motionY -= $this->gravity;
$this->inBlock = $this->checkObstruction($this->x, ($this->boundingBox->minY + $this->boundingBox->maxY) / 2, $this->z);
$this->keepMovement = $this->checkObstruction($this->x, ($this->boundingBox->minY + $this->boundingBox->maxY) / 2, $this->z);
$this->move($this->motionX, $this->motionY, $this->motionZ);
$friction = 1 - $this->drag;
@ -126,7 +126,7 @@ class DroppedItem extends Entity{
$this->timings->stopTiming();
return $hasUpdate or !$this->onGround or ($this->motionX == 0 and $this->motionY == 0 and $this->motionZ == 0);
return $hasUpdate or !$this->onGround or $this->motionX != 0 or $this->motionY != 0 or $this->motionZ != 0;
}
public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){

View File

@ -122,7 +122,7 @@ abstract class Entity extends Location implements Metadatable{
protected $ySize = 0;
protected $stepHeight = 0;
public $keepMovement = true;
public $keepMovement = false;
public $fallDistance;
public $ticksLived;
@ -777,12 +777,11 @@ abstract class Entity extends Location implements Metadatable{
return true;
}
//if($this->inBlock){ //TODO: noclip
// $this->boundingBox->offset($dx, $dy, $dz);
// $this->x = ($this->boundingBox->minX + $this->boundingBox->maxX) / 2;
// $this->y = $this->boundingBox->minY/* + $this->height*/;
// $this->z = ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2;
//}else{
if($this->keepMovement){
$this->boundingBox->offset($dx, $dy, $dz);
$pos = new Vector3(($this->boundingBox->minX + $this->boundingBox->maxX) / 2, $this->boundingBox->minY - $this->ySize, ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2);
$this->setPosition($pos);
}else{
Timings::$entityMoveTimer->startTiming();
@ -841,7 +840,7 @@ abstract class Entity extends Location implements Metadatable{
$this->boundingBox->offset(0, $dy, 0);
if(!$this->keepMovement and $movY != $dy){
if($movY != $dy){
$dx = 0;
$dy = 0;
$dz = 0;
@ -855,7 +854,7 @@ abstract class Entity extends Location implements Metadatable{
$this->boundingBox->offset($dx, 0, 0);
if(!$this->keepMovement and $movX != $dx){
if($movX != $dx){
$dx = 0;
$dy = 0;
$dz = 0;
@ -867,7 +866,7 @@ abstract class Entity extends Location implements Metadatable{
$this->boundingBox->offset(0, 0, $dz);
if(!$this->keepMovement and $movZ != $dz){
if($movZ != $dz){
$dx = 0;
$dy = 0;
$dz = 0;
@ -893,7 +892,7 @@ abstract class Entity extends Location implements Metadatable{
}
$this->boundingBox->offset(0, $dy, 0);
if(!$this->keepMovement and $movY != $dy){
if($movY != $dy){
$dx = 0;
$dy = 0;
$dz = 0;
@ -904,7 +903,7 @@ abstract class Entity extends Location implements Metadatable{
}
$this->boundingBox->offset($dx, 0, 0);
if(!$this->keepMovement and $movX != $dx){
if($movX != $dx){
$dx = 0;
$dy = 0;
$dz = 0;
@ -915,13 +914,13 @@ abstract class Entity extends Location implements Metadatable{
}
$this->boundingBox->offset(0, 0, $dz);
if(!$this->keepMovement and $movZ != $dz){
if($movZ != $dz){
$dx = 0;
$dy = 0;
$dz = 0;
}
if(!$this->keepMovement and $movY != $dy){
if($movY != $dy){
$dx = 0;
$dy = 0;
$dz = 0;
@ -990,7 +989,7 @@ abstract class Entity extends Location implements Metadatable{
Timings::$entityMoveTimer->stopTiming();
return $result;
//}
}
}
protected function checkBlockCollision(){

View File

@ -1105,7 +1105,7 @@ class Level implements ChunkManager, Metadatable{
}
}
if(!($player instanceof Player) or ($player->getGamemode() & 0x01) === 0){
if(!($player instanceof Player) or $player->isSurvival() === 0){
foreach($drops as $drop){
if($drop[2] > 0){
$this->dropItem($vector->add(0.5, 0.5, 0.5), Item::get(...$drop));