From 44a30b7fac7ff4f87064171030e7935fc21e1c8d Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 16 Sep 2014 00:32:03 +0200 Subject: [PATCH] Added forced position strong check for Player --- src/pocketmine/Player.php | 4 +- src/pocketmine/block/Stair.php | 76 ++++++++++++++++++++++++++++++++ src/pocketmine/entity/Entity.php | 2 + 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 320ca76e0..79021c0cb 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -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; } diff --git a/src/pocketmine/block/Stair.php b/src/pocketmine/block/Stair.php index bd0dfb71d..a365761c8 100644 --- a/src/pocketmine/block/Stair.php +++ b/src/pocketmine/block/Stair.php @@ -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( diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index f6520a153..027e5ad29 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -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;