Added forced position strong check for Player

This commit is contained in:
Shoghi Cervantes 2014-09-16 00:32:03 +02:00
parent 50b2f55583
commit 44a30b7fac
3 changed files with 81 additions and 1 deletions

View File

@ -1336,6 +1336,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
}
$newPos = new Vector3($packet->x, $packet->y, $packet->z);
$oldPos = new Vector3($this->x, $this->y, $this->z);
$revert = false;
@ -1382,7 +1383,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$diff = $diffX ** 2 + $diffY ** 2 + $diffZ ** 2;
if(!$revert and $diff > 0.15 and !$this->isSleeping() and $this->isSurvival()){
if(!$revert and $diff > 0.0625 and !$this->isSleeping() and $this->isSurvival()){
$revert = true;
$this->server->getLogger()->warning($this->getName()." moved wrongly!");
}
@ -1399,6 +1400,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$pk->yaw = $this->yaw;
$pk->teleport = true;
$this->directDataPacket($pk);
$this->forceMovement = new Vector3($this->x, $this->y, $this->z);
}else{
$this->forceMovement = null;
}

View File

@ -37,6 +37,82 @@ class Stair extends Transparent{
$this->hardness = 30;
}
/*
public function collidesWithBB(AxisAlignedBB $bb, &$list = []){
$damage = $this->getDamage();
$j = $damage & 0x03;
$f = 0;
$f1 = 0.5;
$f2 = 0.5;
$f3 = 1;
if(($damage & 0x04) > 0){
$f = 0.5;
$f1 = 1;
$f2 = 0;
$f3 = 0.5;
}
if($bb->intersectsWith($bb2 = new AxisAlignedBB(
$this->x,
$this->y + $f,
$this->z,
$this->x + 1,
$this->y + $f1,
$this->z + 1
))){
$list[] = $bb2;
}
if($j === 0){
if($bb->intersectsWith($bb2 = new AxisAlignedBB(
$this->x + 0.5,
$this->y + $f2,
$this->z,
$this->x + 1,
$this->y + $f3,
$this->z + 1
))){
$list[] = $bb2;
}
}elseif($j === 1){
if($bb->intersectsWith($bb2 = new AxisAlignedBB(
$this->x,
$this->y + $f2,
$this->z,
$this->x + 0.5,
$this->y + $f3,
$this->z + 1
))){
$list[] = $bb2;
}
}elseif($j === 2){
if($bb->intersectsWith($bb2 = new AxisAlignedBB(
$this->x,
$this->y + $f2,
$this->z + 0.5,
$this->x + 1,
$this->y + $f3,
$this->z + 1
))){
$list[] = $bb2;
}
}elseif($j === 3){
if($bb->intersectsWith($bb2 = new AxisAlignedBB(
$this->x,
$this->y + $f2,
$this->z,
$this->x + 1,
$this->y + $f3,
$this->z + 0.5
))){
$list[] = $bb2;
}
}
}
*/
public function getBoundingBox(){
if(($this->getDamage() & 0x04) > 0){
return new AxisAlignedBB(

View File

@ -729,6 +729,7 @@ abstract class Entity extends Position implements Metadatable{
$this->ySize *= 0.4;
/*
if($this->isColliding){ //With cobweb?
$this->isColliding = false;
$dx *= 0.25;
@ -738,6 +739,7 @@ abstract class Entity extends Position implements Metadatable{
$this->motionY = 0;
$this->motionZ = 0;
}
*/
$movX = $dx;
$movY = $dy;