small changes

This commit is contained in:
GameHerobrine 2024-07-02 04:00:14 +03:00
parent 973589869e
commit 99954b67d6
8 changed files with 37 additions and 42 deletions

View file

@ -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{
}

View file

@ -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);

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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(){

View file

@ -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){

View file

@ -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
};
}
}