mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
Save block bounding boxes, improves block cache
This commit is contained in:
parent
5448a48f67
commit
1eec333501
@ -36,7 +36,11 @@ class Bed extends Transparent{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return new AxisAlignedBB(
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -513,6 +513,7 @@ class Block extends Position implements Metadatable{
|
||||
protected $name = "Unknown";
|
||||
protected $breakTime = 0.20;
|
||||
protected $hardness = 10;
|
||||
protected $boundingBox = null;
|
||||
public $hasEntityCollision = false;
|
||||
public $isActivable = false;
|
||||
public $breakable = true;
|
||||
@ -820,6 +821,7 @@ class Block extends Position implements Metadatable{
|
||||
$this->y = (int) $v->y;
|
||||
$this->z = (int) $v->z;
|
||||
$this->level = $v->level;
|
||||
$this->boundingBox = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -898,7 +900,11 @@ class Block extends Position implements Metadatable{
|
||||
* @return AxisAlignedBB
|
||||
*/
|
||||
public function getBoundingBox(){
|
||||
return new AxisAlignedBB(
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -43,7 +43,11 @@ class Cactus extends Transparent{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return new AxisAlignedBB(
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x + 0.0625,
|
||||
$this->y,
|
||||
$this->z + 0.0625,
|
||||
|
@ -38,9 +38,13 @@ class Cake extends Transparent{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
$f = (1 + $this->getDamage() * 2) / 16;
|
||||
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x + $f,
|
||||
$this->y,
|
||||
$this->z + 0.0625,
|
||||
|
@ -54,7 +54,11 @@ class Carpet extends Flowable{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return new AxisAlignedBB(
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -43,7 +43,11 @@ class Chest extends Transparent{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return new AxisAlignedBB(
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x + 0.0625,
|
||||
$this->y,
|
||||
$this->z + 0.0625,
|
||||
|
@ -53,6 +53,10 @@ abstract class Door extends Transparent{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
$f = 0.1875;
|
||||
$damage = $this->getFullDamage();
|
||||
|
||||
@ -195,7 +199,7 @@ abstract class Door extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
return $bb;
|
||||
return $this->boundingBox = $bb;
|
||||
}
|
||||
|
||||
public function onUpdate($type){
|
||||
|
@ -30,7 +30,11 @@ class EndPortal extends Solid{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return new AxisAlignedBB(
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -31,7 +31,11 @@ class Farmland extends Solid{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return new AxisAlignedBB(
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -32,6 +32,10 @@ class Fence extends Transparent{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
$flag = $this->canConnect($this->getSide(2));
|
||||
$flag1 = $this->canConnect($this->getSide(3));
|
||||
$flag2 = $this->canConnect($this->getSide(4));
|
||||
@ -42,7 +46,7 @@ class Fence extends Transparent{
|
||||
$f2 = $flag ? 0 : 0.375;
|
||||
$f3 = $flag1 ? 1 : 0.625;
|
||||
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x + $f,
|
||||
$this->y,
|
||||
$this->z + $f2,
|
||||
|
@ -39,13 +39,17 @@ class FenceGate extends Transparent{
|
||||
|
||||
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
if(($this->getDamage() & 0x04) > 0){
|
||||
return null;
|
||||
}
|
||||
|
||||
$i = ($this->getDamage() & 0x03);
|
||||
if($i === 2 and $i === 0){
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z + 0.375,
|
||||
@ -54,7 +58,7 @@ class FenceGate extends Transparent{
|
||||
$this->z + 0.625
|
||||
);
|
||||
}else{
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x + 0.375,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -44,10 +44,14 @@ class Ladder extends Transparent{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
$f = 0.125;
|
||||
|
||||
if($this->meta === 2){
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z + 1 - $f,
|
||||
@ -56,7 +60,7 @@ class Ladder extends Transparent{
|
||||
$this->z + 1
|
||||
);
|
||||
}elseif($this->meta === 3){
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
@ -65,7 +69,7 @@ class Ladder extends Transparent{
|
||||
$this->z + $f
|
||||
);
|
||||
}elseif($this->meta === 4){
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x + 1 - $f,
|
||||
$this->y,
|
||||
$this->z,
|
||||
@ -74,7 +78,7 @@ class Ladder extends Transparent{
|
||||
$this->z + 1
|
||||
);
|
||||
}elseif($this->meta === 5){
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -36,10 +36,6 @@ class Lava extends Liquid{
|
||||
$this->hardness = 0;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$entity->fallDistance *= 0.5;
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
|
||||
|
@ -414,4 +414,8 @@ abstract class Liquid extends Transparent{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return null;
|
||||
}
|
||||
}
|
@ -48,8 +48,12 @@ class Slab extends Transparent{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
if(($this->meta & 0x08) > 0){
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y + 0.5,
|
||||
$this->z,
|
||||
@ -58,7 +62,7 @@ class Slab extends Transparent{
|
||||
$this->z + 1
|
||||
);
|
||||
}else{
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -31,7 +31,11 @@ class SoulSand extends Solid{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return new AxisAlignedBB(
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -114,8 +114,12 @@ abstract class Stair extends Transparent{
|
||||
*/
|
||||
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
if(($this->getDamage() & 0x04) > 0){
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y + 0.5,
|
||||
$this->z,
|
||||
@ -124,7 +128,7 @@ abstract class Stair extends Transparent{
|
||||
$this->z + 1
|
||||
);
|
||||
}else{
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
@ -27,8 +27,4 @@ class StillLava extends Lava{
|
||||
$this->hardness = 500;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -37,6 +37,10 @@ class StoneWall extends Transparent{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
$flag = $this->canConnect($this->getSide(2));
|
||||
$flag1 = $this->canConnect($this->getSide(3));
|
||||
$flag2 = $this->canConnect($this->getSide(4));
|
||||
@ -58,7 +62,7 @@ class StoneWall extends Transparent{
|
||||
$f3 = 0.6875;
|
||||
}
|
||||
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x + $f,
|
||||
$this->y,
|
||||
$this->z + $f2,
|
||||
|
@ -30,6 +30,10 @@ abstract class Thin extends Transparent{
|
||||
public $isSolid = false;
|
||||
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
$f = 0.4375;
|
||||
$f1 = 0.5625;
|
||||
$f2 = 0.4375;
|
||||
@ -62,7 +66,7 @@ abstract class Thin extends Transparent{
|
||||
$f3 = 1;
|
||||
}
|
||||
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x + $f,
|
||||
$this->y,
|
||||
$this->z + $f2,
|
||||
|
@ -38,6 +38,10 @@ class Trapdoor extends Transparent{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
$damage = $this->getDamage();
|
||||
|
||||
$f = 0.1875;
|
||||
@ -104,7 +108,7 @@ class Trapdoor extends Transparent{
|
||||
}
|
||||
}
|
||||
|
||||
return $bb;
|
||||
return $this->boundingBox = $bb;
|
||||
}
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
|
@ -44,6 +44,10 @@ class Vine extends Transparent{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
$f1 = 1;
|
||||
$f2 = 1;
|
||||
$f3 = 1;
|
||||
@ -92,7 +96,7 @@ class Vine extends Transparent{
|
||||
$f6 = 1;
|
||||
}
|
||||
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x + $f1,
|
||||
$this->y + $f2,
|
||||
$this->z + $f3,
|
||||
|
@ -30,10 +30,6 @@ class Water extends Liquid{
|
||||
parent::__construct(self::WATER, $meta, "Water");
|
||||
$this->hardness = 500;
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
return null;
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$entity->fallDistance = 0;
|
||||
|
@ -46,8 +46,12 @@ class WoodSlab extends Transparent{
|
||||
}
|
||||
|
||||
public function getBoundingBox(){
|
||||
if($this->boundingBox !== null){
|
||||
return $this->boundingBox;
|
||||
}
|
||||
|
||||
if(($this->meta & 0x08) > 0){
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y + 0.5,
|
||||
$this->z,
|
||||
@ -56,7 +60,7 @@ class WoodSlab extends Transparent{
|
||||
$this->z + 1
|
||||
);
|
||||
}else{
|
||||
return new AxisAlignedBB(
|
||||
return $this->boundingBox = new AxisAlignedBB(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z,
|
||||
|
Loading…
x
Reference in New Issue
Block a user