mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 12:39:43 +00:00
small changes
This commit is contained in:
parent
973589869e
commit
99954b67d6
8 changed files with 37 additions and 42 deletions
|
|
@ -2,13 +2,12 @@
|
||||||
|
|
||||||
class QueryAPI{
|
class QueryAPI{
|
||||||
|
|
||||||
public static $NOT_FOUND_VALUE; //TODO just use null
|
public static $NOT_FOUND_VALUE = null;
|
||||||
private $queryData;
|
private $queryData;
|
||||||
private $server;
|
private $server;
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
$this->server = ServerAPI::request();
|
$this->server = ServerAPI::request();
|
||||||
QueryAPI::$NOT_FOUND_VALUE = new NFV();
|
|
||||||
$this->updateQueryData("splitnum", chr(128));
|
$this->updateQueryData("splitnum", chr(128));
|
||||||
$this->updateQueryData("hostname", $this->server->name);
|
$this->updateQueryData("hostname", $this->server->name);
|
||||||
$this->updateQueryData("gametype", ($this->server->gamemode & 0x01) === 0 ? "SMP" : "CMP");
|
$this->updateQueryData("gametype", ($this->server->gamemode & 0x01) === 0 ? "SMP" : "CMP");
|
||||||
|
|
@ -36,7 +35,3 @@ class QueryAPI{
|
||||||
return $this->queryData;
|
return $this->queryData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NFV{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -2146,33 +2146,15 @@ class Player{
|
||||||
}
|
}
|
||||||
switch($packet->event){
|
switch($packet->event){
|
||||||
case 9: //Eating
|
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);
|
$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 = new EntityEventPacket;
|
||||||
$pk->eid = 0;
|
$pk->eid = 0;
|
||||||
$pk->event = 9;
|
$pk->event = 9;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
|
|
||||||
$this->entity->heal($items[$slot->getID()], "eating");
|
$this->entity->heal($foodHeal, "eating");
|
||||||
--$slot->count;
|
--$slot->count;
|
||||||
if($slot->count <= 0){
|
if($slot->count <= 0){
|
||||||
$this->setSlot($this->slot, BlockAPI::getItem(AIR, 0, 0), false);
|
$this->setSlot($this->slot, BlockAPI::getItem(AIR, 0, 0), false);
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ abstract class Living extends Entity implements Pathfindable{
|
||||||
public $pathFinder, $path = null, $currentIndex = 0, $currentNode, $pathFollower;
|
public $pathFinder, $path = null, $currentIndex = 0, $currentNode, $pathFollower;
|
||||||
public $ticksExisted = 0;
|
public $ticksExisted = 0;
|
||||||
|
|
||||||
public $landMovementFactor = 0.1; //TODO may not be constant
|
public $landMovementFactor = 0.1;
|
||||||
public $jumpMovementFactor = 0.02; //TODO may not be constant
|
public $jumpMovementFactor = 0.02;
|
||||||
public $aiMoveSpeed;
|
public $aiMoveSpeed;
|
||||||
|
|
||||||
public $renderYawOffset = 0.0; //used by head rotation, TODO better name
|
public $renderYawOffset = 0.0; //used by head rotation, TODO better name
|
||||||
|
|
|
||||||
|
|
@ -106,13 +106,7 @@ class MobController
|
||||||
$v10 = (atan2($diffZ, $diffX) * 180 / M_PI) - 90;
|
$v10 = (atan2($diffZ, $diffX) * 180 / M_PI) - 90;
|
||||||
$this->entity->yaw = self::limitAngle($this->entity->yaw, $v10, 30);
|
$this->entity->yaw = self::limitAngle($this->entity->yaw, $v10, 30);
|
||||||
$this->entity->setAIMoveSpeed($this->speedMultiplier * $this->entity->getSpeed() * $this->entity->getSpeedModifer());
|
$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);
|
if($diffY > 0 && $diffX*$diffX + $diffZ*$diffZ < 1) $this->setJumping(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +121,7 @@ class MobController
|
||||||
public function updateHeadYaw(){
|
public function updateHeadYaw(){
|
||||||
$diffX = $this->entity->x - $this->entity->lastX;
|
$diffX = $this->entity->x - $this->entity->lastX;
|
||||||
$diffZ = $this->entity->z - $this->entity->lastZ;
|
$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->renderYawOffset = $this->entity->yaw;
|
||||||
$this->entity->headYaw = self::limitAngle2($this->entity->renderYawOffset, $this->entity->headYaw, 75);
|
$this->entity->headYaw = self::limitAngle2($this->entity->renderYawOffset, $this->entity->headYaw, 75);
|
||||||
$this->headYaw = $this->entity->headYaw;
|
$this->headYaw = $this->entity->headYaw;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class PigZombie extends Monster{ //TODO extends zombie
|
||||||
$this->ai->addTask(new TaskLookAround());
|
$this->ai->addTask(new TaskLookAround());
|
||||||
$this->ai->addTask(new TaskRandomWalk(1.0));
|
$this->ai->addTask(new TaskRandomWalk(1.0));
|
||||||
$this->ai->addTask(new TaskSwimming());
|
$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(){
|
public function getAttackDamage(){
|
||||||
return 5;
|
return 5;
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ class Spider extends Monster{
|
||||||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 8, "generic");
|
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 8, "generic");
|
||||||
$this->setName("Spider");
|
$this->setName("Spider");
|
||||||
$this->setSpeed(0.3);
|
$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 TaskRandomWalk(1.0));
|
||||||
$this->ai->addTask(new TaskLookAround()); //TODO this mob doesnt use newAI
|
$this->ai->addTask(new TaskLookAround());
|
||||||
$this->ai->addTask(new TaskSwimming());
|
$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(){
|
public function getAttackDamage(){
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ class Arrow extends Entity{
|
||||||
$this->pitch = (atan2($d1, $f3) * 180) / M_PI;
|
$this->pitch = (atan2($d1, $f3) * 180) / M_PI;
|
||||||
$this->updatePosition();
|
$this->updatePosition();
|
||||||
//$this->update();
|
//$this->update();
|
||||||
//TODO i guess? $ticksInGround = 0;
|
$this->groundTicks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update($now){
|
public function update($now){
|
||||||
|
|
|
||||||
|
|
@ -311,4 +311,28 @@ class Item{
|
||||||
return false;
|
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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue