From 102f5154691170c3760da28917f9840bf01e5853 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Mon, 9 Oct 2023 21:01:50 +0300 Subject: [PATCH] microtweaks --- src/entity/Entity.php | 2 +- src/material/Item.php | 12 ++++++------ src/material/block/attachable/LadderBlock.php | 16 +++++++++------- src/material/block/attachable/SignPostBlock.php | 8 ++++---- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 73ff0c01..64150576 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -913,7 +913,7 @@ class Entity extends Position ] ]; $d[16]["value"] = $this->data["State"]; - if($this->class === ENTITY_PLAYER){ + if($this->isPlayer()){ if($this->player->isSleeping !== false){ $d[16]["value"] = 2; $d[17]["value"] = [ diff --git a/src/material/Item.php b/src/material/Item.php index d695adf4..801e99d3 100755 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -129,13 +129,13 @@ class Item{ SHEARS => "ShearsItem", ); - protected $block; - protected $id; - protected $meta; + public $block; + public $id; + public $meta; public $count; - protected $maxStackSize = 64; - protected $durability = 0; - protected $name; + public $maxStackSize = 64; + public $durability = 0; + public $name; public $isActivable = false; public function __construct($id, $meta = 0, $count = 1, $name = "Unknown"){ diff --git a/src/material/block/attachable/LadderBlock.php b/src/material/block/attachable/LadderBlock.php index 9b3f939a..efa624ad 100644 --- a/src/material/block/attachable/LadderBlock.php +++ b/src/material/block/attachable/LadderBlock.php @@ -1,6 +1,14 @@ 2, + 2 => 3, + 5 => 4, + 4 => 5, + ]; + public function __construct($meta = 0){ parent::__construct(LADDER, $meta, "Ladder"); $this->isSolid = false; @@ -23,13 +31,7 @@ class LadderBlock extends TransparentBlock{ if($type === BLOCK_UPDATE_NORMAL){ $side = $this->getMetadata(); - $faces = array( //magical tranformation - 3 => 2, - 2 => 3, - 5 => 4, - 4 => 5, - ); - if($this->getSide($faces[$side]) instanceof AirBlock){ //Replace with common break method + if($this->getSide(self::$faces[$side]) instanceof AirBlock){ //Replace with common break method ServerAPI::request()->api->entity->drop($this, BlockAPI::getItem($this->id, 0, 1)); $this->level->setBlock($this, new AirBlock(), true, false, true); return BLOCK_UPDATE_NORMAL; diff --git a/src/material/block/attachable/SignPostBlock.php b/src/material/block/attachable/SignPostBlock.php index 3dc7b5d6..190f6107 100644 --- a/src/material/block/attachable/SignPostBlock.php +++ b/src/material/block/attachable/SignPostBlock.php @@ -2,12 +2,12 @@ class SignPostBlock extends TransparentBlock{ - private $faces = array( + public static $faces = [ 2 => 2, 3 => 3, 4 => 4, 5 => 5, - ); + ]; public function __construct($meta = 0){ parent::__construct(SIGN_POST, $meta, "Sign Post"); @@ -18,12 +18,12 @@ 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(!isset($this->faces[$face])){ + 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); return true; }else{ - $this->meta = $this->faces[$face]; + $this->meta = self::$faces[$face]; $this->level->setBlock($block, BlockAPI::get(WALL_SIGN, $this->meta, true, false, true)); return true; }