mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Blocks now save their bounding box, fixed entity block collision check
This commit is contained in:
@ -35,7 +35,7 @@ class Bed extends Transparent{
|
||||
$this->hardness = 1;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
$this->x,
|
||||
$this->y,
|
||||
|
@ -528,6 +528,9 @@ class Block extends Position implements Metadatable{
|
||||
public $z = 0;
|
||||
public $frictionFactor = 0.6;
|
||||
|
||||
/** @var AxisAlignedBB */
|
||||
protected $boundingBox = null;
|
||||
|
||||
public static function init(){
|
||||
if(count(self::$list) === 0){
|
||||
self::$list = [
|
||||
@ -897,6 +900,17 @@ class Block extends Position implements Metadatable{
|
||||
* @return AxisAlignedBB
|
||||
*/
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}else{
|
||||
return $this->boundingBox = $this->recalculateBoundingBox();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AxisAlignedBB
|
||||
*/
|
||||
protected function recalculateBoundingBox(){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
$this->x,
|
||||
$this->y,
|
||||
|
@ -42,7 +42,7 @@ class Cactus extends Transparent{
|
||||
$this->hardness = 2;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
$this->x + 0.0625,
|
||||
|
@ -37,7 +37,7 @@ class Cake extends Transparent{
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
$f = (1 + $this->getDamage() * 2) / 16;
|
||||
|
||||
|
@ -53,7 +53,7 @@ class Carpet extends Flowable{
|
||||
$this->isSolid = true;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
$this->x,
|
||||
|
@ -42,7 +42,7 @@ class Chest extends Transparent{
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
$this->x + 0.0625,
|
||||
|
@ -52,7 +52,7 @@ abstract class Door extends Transparent{
|
||||
return $first & 0x07 | ($flag ? 8 : 0) | ($flag1 ? 0x10 : 0);
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
$f = 0.1875;
|
||||
$damage = $this->getFullDamage();
|
||||
|
@ -29,7 +29,7 @@ class EndPortal extends Solid{
|
||||
$this->hardness = 18000000;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
$this->x,
|
||||
|
@ -30,7 +30,7 @@ class Farmland extends Solid{
|
||||
$this->hardness = 3;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
$this->x,
|
||||
|
@ -31,7 +31,7 @@ class Fence extends Transparent{
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
$flag = $this->canConnect($this->getSide(2));
|
||||
$flag1 = $this->canConnect($this->getSide(3));
|
||||
|
@ -38,7 +38,7 @@ class FenceGate extends Transparent{
|
||||
}
|
||||
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
if(($this->getDamage() & 0x04) > 0){
|
||||
return null;
|
||||
|
@ -43,7 +43,7 @@ class Ladder extends Transparent{
|
||||
$entity->onGround = true;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
$f = 0.125;
|
||||
|
||||
|
@ -47,7 +47,7 @@ class Slab extends Transparent{
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
if(($this->meta & 0x08) > 0){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
|
@ -30,7 +30,7 @@ class SoulSand extends Solid{
|
||||
$this->hardness = 2.5;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
$this->x,
|
||||
|
@ -113,7 +113,7 @@ abstract class Stair extends Transparent{
|
||||
}
|
||||
*/
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
if(($this->getDamage() & 0x04) > 0){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
|
@ -36,7 +36,7 @@ class StoneWall extends Transparent{
|
||||
$this->hardness = 30;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
$flag = $this->canConnect($this->getSide(2));
|
||||
$flag1 = $this->canConnect($this->getSide(3));
|
||||
|
@ -29,7 +29,7 @@ abstract class Thin extends Transparent{
|
||||
public $isFullBlock = false;
|
||||
public $isSolid = false;
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
$f = 0.4375;
|
||||
$f1 = 0.5625;
|
||||
|
@ -37,7 +37,7 @@ class Trapdoor extends Transparent{
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
$damage = $this->getDamage();
|
||||
|
||||
|
@ -43,7 +43,7 @@ class Vine extends Transparent{
|
||||
$entity->fallDistance = 0;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
$f1 = 1;
|
||||
$f2 = 1;
|
||||
|
@ -45,7 +45,7 @@ class WoodSlab extends Transparent{
|
||||
$this->hardness = 15;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
protected function recalculateBoundingBox(){
|
||||
|
||||
if(($this->meta & 0x08) > 0){
|
||||
return AxisAlignedBB::getBoundingBoxFromPool(
|
||||
|
Reference in New Issue
Block a user