diff --git a/src/material/StaticBlock.php b/src/material/StaticBlock.php index cf6c75a2..15269ab5 100644 --- a/src/material/StaticBlock.php +++ b/src/material/StaticBlock.php @@ -74,6 +74,7 @@ class StaticBlock self::setBlockBounds(SUGARCANE_BLOCK, 0.5 - 0.375, 0, 0.5 - 0.375, 0.5 + 0.375, 1, 0.5 + 0.375); self::setBlockBounds(SNOW_LAYER, 0, 0, 0, 1, 0.125, 1); + self::setBlockBounds(CARPET, 0, 0, 0, 1, 0, 1); //Stairs: based on different factors //Stone wall: based on state diff --git a/src/material/block/nonfull/CarpetBlock.php b/src/material/block/nonfull/CarpetBlock.php index 47820c7c..60b93a98 100644 --- a/src/material/block/nonfull/CarpetBlock.php +++ b/src/material/block/nonfull/CarpetBlock.php @@ -27,7 +27,9 @@ class CarpetBlock extends FlowableBlock{ $this->isFullBlock = false; $this->isSolid = true; } - + public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ + return [static::getAABB($level, $x, $y, $z)]; + } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ $down = $this->getSide(0); if($down->getID() !== AIR){ diff --git a/src/math/AxisAlignedBB.php b/src/math/AxisAlignedBB.php index f98b1db3..187700ca 100644 --- a/src/math/AxisAlignedBB.php +++ b/src/math/AxisAlignedBB.php @@ -171,7 +171,7 @@ class AxisAlignedBB{ } public function intersectsWith(AxisAlignedBB $bb){ - return $bb->maxX > $this->minX and $bb->minX < $this->maxX && $bb->maxZ > $this->minZ and $bb->minZ < $this->maxZ && $bb->maxY > $this->minY and $bb->minY < $this->maxY; + return $bb->maxX >= $this->minX && $bb->minX <= $this->maxX && $bb->maxZ >= $this->minZ && $bb->minZ <= $this->maxZ && $bb->maxY >= $this->minY && $bb->minY <= $this->maxY; } public function isXYZInsideNS($x, $y, $z){ if($x < $this->minX or $x > $this->maxX){ @@ -184,20 +184,20 @@ class AxisAlignedBB{ return $z > $this->minZ and $z < $this->maxZ; } public function isXYZInside($x, $y, $z){ - if($x <= $this->minX or $x >= $this->maxX){ + if($x < $this->minX or $x > $this->maxX){ return false; } - if($y <= $this->minY or $y >= $this->maxY){ + if($y < $this->minY or $y > $this->maxY){ return false; } return $z > $this->minZ and $z < $this->maxZ; } public function isVectorInside(Vector3 $vector){ - if($vector->x <= $this->minX or $vector->x >= $this->maxX){ + if($vector->x < $this->minX or $vector->x > $this->maxX){ return false; } - if($vector->y <= $this->minY or $vector->y >= $this->maxY){ + if($vector->y < $this->minY or $vector->y > $this->maxY){ return false; } diff --git a/src/world/Level.php b/src/world/Level.php index ffa7ed81..f92e6284 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -285,7 +285,7 @@ class Level{ $t = $this->getTime() % 19200; return $t < TimeAPI::$phases["sunrise"] && $t > TimeAPI::$phases["sunset"]; } - public function save($force = false, $extra = true){ + public function save($force = false, $entities = true, $tiles = true, $blockupdates = true){ if(!isset($this->level)){ return false; } @@ -293,7 +293,7 @@ class Level{ return; } - if($extra !== false){ + if($entities){ $entities = []; foreach($this->entityList as $entity){ @@ -303,13 +303,16 @@ class Level{ } $this->entities->setAll($entities); $this->entities->save(); + } + if($tiles){ $tiles = []; foreach($this->server->api->tile->getAll($this) as $tile){ $tiles[] = $tile->data; } $this->tiles->setAll($tiles); $this->tiles->save(); - + } + if($blockupdates){ $blockUpdates = []; $updates = $this->server->query("SELECT x,y,z,type,delay FROM blockUpdates WHERE level = '" . $this->getName() . "';"); if($updates !== false and $updates !== true){ @@ -322,7 +325,6 @@ class Level{ $this->blockUpdates->setAll($blockUpdates); $this->blockUpdates->save(); - } $this->level->setData("time", (int) $this->time); @@ -422,9 +424,9 @@ class Level{ $this->changedBlocks = []; } } - + if($this->nextSave < $now){ - $this->save(false, false); + $this->save(false, true, true, true); } }