From 39bfa7115d94ba1c47edb6b9229f7a611315b276 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Fri, 27 Oct 2023 19:40:35 +0300 Subject: [PATCH] 3 small fixes --- src/Player.php | 1 + src/entity/Entity.php | 2 +- src/material/block/attachable/SignPostBlock.php | 2 +- src/material/block/attachable/WallSignBlock.php | 16 ++++++++++++++++ src/material/block/solid/GlowstoneBlock.php | 4 ++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Player.php b/src/Player.php index b14ca45f..29e2b59c 100755 --- a/src/Player.php +++ b/src/Player.php @@ -128,6 +128,7 @@ class Player{ $this->isSleeping = $pos; $this->sleepingTime = 0; $this->teleport(new Position($pos->x + 0.5, $pos->y + 1, $pos->z + 0.5, $this->level), false, false, false, false); + //TODO change player hitbox size after he starts sleeping if($this->entity instanceof Entity){ $this->entity->updateMetadata(); } diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 43381e85..2ec9d15d 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -408,7 +408,7 @@ class Entity extends Position $endZ = ceil($this->boundingBox->maxZ); $waterDone = false; //$bup = new AxisAlignedBB($startX, $startY + 1, $startZ, $endX, $endY, $endZ); - if(!($this instanceof Painting)){ //TODO better way to fix + if(!($this instanceof Painting) && !($this->isPlayer() && $this->player->isSleeping !== false)){ //TODO better way to fix for($i = 0; $i < 8; ++$i){ $x = ((($i >> 0) % 2) - 0.5) * $this->width * 0.8; $y= ((($i >> 1) % 2) - 0.5) * 0.1; diff --git a/src/material/block/attachable/SignPostBlock.php b/src/material/block/attachable/SignPostBlock.php index 190f6107..09838670 100644 --- a/src/material/block/attachable/SignPostBlock.php +++ b/src/material/block/attachable/SignPostBlock.php @@ -17,7 +17,7 @@ class SignPostBlock extends TransparentBlock{ } public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ - if($target->isSolid && $face !== 0){ + if(($target->isSolid || $target->getID() === SIGN_POST || $target->getID() === WALL_SIGN) && $face !== 0){ if(!isset(self::$faces[$face])){ $this->meta = floor((($player->entity->yaw + 180) * 16 / 360) + 0.5) & 0x0F; $this->level->setBlock($block, BlockAPI::get(SIGN_POST, $this->meta), true, false, true); diff --git a/src/material/block/attachable/WallSignBlock.php b/src/material/block/attachable/WallSignBlock.php index b41f26a1..5f7f0f12 100644 --- a/src/material/block/attachable/WallSignBlock.php +++ b/src/material/block/attachable/WallSignBlock.php @@ -5,11 +5,27 @@ require_once("SignPostBlock.php"); /***REM_END***/ class WallSignBlock extends SignPostBlock{ + + public static $meta2side = [ + 2 => 3, + 3 => 2, + 4 => 5, + 5 => 4 + ]; + + public function __construct($meta = 0){ TransparentBlock::__construct(WALL_SIGN, $meta, "Wall Sign"); + $this->isSolid = false; } public function onUpdate($type){ + $attached = $this->getSide(self::$meta2side[$this->meta] ?? -1); + if(!($attached instanceof Block) || (!$attached->isSolid && $attached->getID() != SIGN_POST && $attached->getID() != WALL_SIGN)){ + $this->level->setBlock($this, new AirBlock(), true, true, true); + (ServerAPI::request())->api->entity->drop(new Position($this->x + 0.5, $this->y + 0.5, $this->z + 0.5, $this->level), BlockAPI::getItem(SIGN, 0, 1)); + } + return false; } } \ No newline at end of file diff --git a/src/material/block/solid/GlowstoneBlock.php b/src/material/block/solid/GlowstoneBlock.php index 01fb5a42..39a70415 100644 --- a/src/material/block/solid/GlowstoneBlock.php +++ b/src/material/block/solid/GlowstoneBlock.php @@ -15,4 +15,8 @@ class GlowstoneBlock extends TransparentBlock implements LightingBlock{ array(GLOWSTONE_DUST, 0, mt_rand(2, 4)), ); } + + public static function getCollisionBoundingBoxes(Level $level, $x, $y, $z, Entity $entity){ + return [new AxisAlignedBB($x, $y, $z, $x + 1, $y + 1, $z + 1)]; + } } \ No newline at end of file