From 99954b67d6fe3dc2bb300d7a57d2060dfabebd79 Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Tue, 2 Jul 2024 04:00:14 +0300 Subject: [PATCH] small changes --- src/API/QueryAPI.php | 7 +------ src/Player.php | 24 +++--------------------- src/entity/Living.php | 4 ++-- src/entity/ai/MobController.php | 10 ++-------- src/entity/monster/PigZombie.php | 2 +- src/entity/monster/Spider.php | 6 +++--- src/entity/object/Arrow.php | 2 +- src/material/Item.php | 24 ++++++++++++++++++++++++ 8 files changed, 37 insertions(+), 42 deletions(-) diff --git a/src/API/QueryAPI.php b/src/API/QueryAPI.php index 531b66cb..6e07f725 100644 --- a/src/API/QueryAPI.php +++ b/src/API/QueryAPI.php @@ -2,13 +2,12 @@ class QueryAPI{ - public static $NOT_FOUND_VALUE; //TODO just use null + public static $NOT_FOUND_VALUE = null; private $queryData; private $server; public function __construct(){ $this->server = ServerAPI::request(); - QueryAPI::$NOT_FOUND_VALUE = new NFV(); $this->updateQueryData("splitnum", chr(128)); $this->updateQueryData("hostname", $this->server->name); $this->updateQueryData("gametype", ($this->server->gamemode & 0x01) === 0 ? "SMP" : "CMP"); @@ -35,8 +34,4 @@ class QueryAPI{ public function getQueryData(){ return $this->queryData; } -} - -class NFV{ - } \ No newline at end of file diff --git a/src/Player.php b/src/Player.php index 35a7e8c4..479e9116 100755 --- a/src/Player.php +++ b/src/Player.php @@ -2146,33 +2146,15 @@ class Player{ } switch($packet->event){ case 9: //Eating - $items = [ //TODO rewrite - APPLE => 4, - MUSHROOM_STEW => 10, - BEETROOT_SOUP => 10, - BREAD => 5, - RAW_PORKCHOP => 3, - COOKED_PORKCHOP => 8, - BEEF => 3, - STEAK => 8, - COOKED_CHICKEN => 6, - RAW_CHICKEN => 2, - MELON_SLICE => 2, - GOLDEN_APPLE => 10, - PUMPKIN_PIE => 8, - CARROT => 4, - POTATO => 1, - BAKED_POTATO => 6, - BEETROOT => 1 - ]; $slot = $this->getSlot($this->slot); - if($this->entity->getHealth() < 20 and isset($items[$slot->getID()])){ + $foodHeal = Item::getFoodHeal($slot->getID()); + if($this->entity->getHealth() < 20 && $foodHeal != 0){ $pk = new EntityEventPacket; $pk->eid = 0; $pk->event = 9; $this->dataPacket($pk); - $this->entity->heal($items[$slot->getID()], "eating"); + $this->entity->heal($foodHeal, "eating"); --$slot->count; if($slot->count <= 0){ $this->setSlot($this->slot, BlockAPI::getItem(AIR, 0, 0), false); diff --git a/src/entity/Living.php b/src/entity/Living.php index 79fe2263..b2e94bdf 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -15,8 +15,8 @@ abstract class Living extends Entity implements Pathfindable{ public $pathFinder, $path = null, $currentIndex = 0, $currentNode, $pathFollower; public $ticksExisted = 0; - public $landMovementFactor = 0.1; //TODO may not be constant - public $jumpMovementFactor = 0.02; //TODO may not be constant + public $landMovementFactor = 0.1; + public $jumpMovementFactor = 0.02; public $aiMoveSpeed; public $renderYawOffset = 0.0; //used by head rotation, TODO better name diff --git a/src/entity/ai/MobController.php b/src/entity/ai/MobController.php index ca89a811..4d4078d2 100644 --- a/src/entity/ai/MobController.php +++ b/src/entity/ai/MobController.php @@ -106,13 +106,7 @@ class MobController $v10 = (atan2($diffZ, $diffX) * 180 / M_PI) - 90; $this->entity->yaw = self::limitAngle($this->entity->yaw, $v10, 30); $this->entity->setAIMoveSpeed($this->speedMultiplier * $this->entity->getSpeed() * $this->entity->getSpeedModifer()); - //TODO 0.8.1 doesnt seem to make 2 multiplications here - /* - * v15 = this->controlledEntity; - speedMultiplier = this->speedMultiplier; - v17 = v15->vtable->_virt_getBaseSpeed(v15); - Mob::setSpeed(v15, speedMultiplier * v17); - */ + if($diffY > 0 && $diffX*$diffX + $diffZ*$diffZ < 1) $this->setJumping(true); } } @@ -127,7 +121,7 @@ class MobController public function updateHeadYaw(){ $diffX = $this->entity->x - $this->entity->lastX; $diffZ = $this->entity->z - $this->entity->lastZ; - if(($diffX*$diffX + $diffZ*$diffZ) > 2.500000277905201E-7){ //TODO convert notation + if(($diffX*$diffX + $diffZ*$diffZ) > 0.00000025){ $this->entity->renderYawOffset = $this->entity->yaw; $this->entity->headYaw = self::limitAngle2($this->entity->renderYawOffset, $this->entity->headYaw, 75); $this->headYaw = $this->entity->headYaw; diff --git a/src/entity/monster/PigZombie.php b/src/entity/monster/PigZombie.php index ac3b67b4..9f819ce0 100644 --- a/src/entity/monster/PigZombie.php +++ b/src/entity/monster/PigZombie.php @@ -11,7 +11,7 @@ class PigZombie extends Monster{ //TODO extends zombie $this->ai->addTask(new TaskLookAround()); $this->ai->addTask(new TaskRandomWalk(1.0)); $this->ai->addTask(new TaskSwimming()); - $this->ai->addTask(new TaskAttackPlayer(1.0, 16)); //TODO fix range? + $this->ai->addTask(new TaskAttackPlayer(1.0, 16)); } public function getAttackDamage(){ return 5; diff --git a/src/entity/monster/Spider.php b/src/entity/monster/Spider.php index ee0a6637..8bbcc28a 100644 --- a/src/entity/monster/Spider.php +++ b/src/entity/monster/Spider.php @@ -8,10 +8,10 @@ class Spider extends Monster{ $this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 8, "generic"); $this->setName("Spider"); $this->setSpeed(0.3); - $this->ai->addTask(new TaskRandomWalk(1.0)); //TODO this mob doesnt use newAI -> speed is not correct - $this->ai->addTask(new TaskLookAround()); //TODO this mob doesnt use newAI + $this->ai->addTask(new TaskRandomWalk(1.0)); + $this->ai->addTask(new TaskLookAround()); $this->ai->addTask(new TaskSwimming()); - $this->ai->addTask(new TaskAttackPlayer(1.0, 16)); //TODO fix range? + $this->ai->addTask(new TaskAttackPlayer(1.0, 16)); } public function getAttackDamage(){ diff --git a/src/entity/object/Arrow.php b/src/entity/object/Arrow.php index ff1e86af..c2213d94 100644 --- a/src/entity/object/Arrow.php +++ b/src/entity/object/Arrow.php @@ -77,7 +77,7 @@ class Arrow extends Entity{ $this->pitch = (atan2($d1, $f3) * 180) / M_PI; $this->updatePosition(); //$this->update(); - //TODO i guess? $ticksInGround = 0; + $this->groundTicks = 0; } public function update($now){ diff --git a/src/material/Item.php b/src/material/Item.php index bc86aa47..31e0dd16 100755 --- a/src/material/Item.php +++ b/src/material/Item.php @@ -311,4 +311,28 @@ class Item{ return false; } + public static function getFoodHeal($id){ + return match($id){ + APPLE => 4, + MUSHROOM_STEW => 10, + BEETROOT_SOUP => 10, + BREAD => 5, + RAW_PORKCHOP => 3, + COOKED_PORKCHOP => 8, + BEEF => 3, + STEAK => 8, + COOKED_CHICKEN => 6, + RAW_CHICKEN => 2, + MELON_SLICE => 2, + GOLDEN_APPLE => 10, + PUMPKIN_PIE => 8, + CARROT => 4, + POTATO => 1, + BAKED_POTATO => 6, + BEETROOT => 1, + + default => 0 + }; + } + }