mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
water damage tweaks, using php8 pack functions
This commit is contained in:
parent
229a563ff5
commit
68b8232f07
17 changed files with 46 additions and 76 deletions
|
|
@ -46,8 +46,8 @@ abstract class Animal extends Creature implements Ageable, Breedable{
|
|||
return $ent->eid != $this->eid && $this->type === $ent->type && $this->isInLove() && $ent->isInLove();
|
||||
}
|
||||
|
||||
public function update(){
|
||||
parent::update();
|
||||
public function update($now){
|
||||
parent::update($now);
|
||||
$age = $this->getAge() + 1; //100 - fast. debug, 1 - normal
|
||||
if($age >= 0 && $this->isBaby()){
|
||||
$this->setAge($age);
|
||||
|
|
|
|||
|
|
@ -318,10 +318,12 @@ class Entity extends Position
|
|||
}
|
||||
}
|
||||
|
||||
public function environmentUpdate()
|
||||
public function environmentUpdate($time)
|
||||
{
|
||||
$hasUpdate = $this->class === ENTITY_MOB; // force true for mobs
|
||||
$time = microtime(true);
|
||||
|
||||
$tickDiff = ($time - $this->lastUpdate) / 0.05;
|
||||
|
||||
if($this->class === ENTITY_PLAYER and ($this->player instanceof Player) and $this->player->spawned === true and $this->player->blocked !== true && ! $this->dead){
|
||||
$myBB = $this->boundingBox->grow(1, 0.5, 1);
|
||||
foreach($this->server->api->entity->getRadius($this, 2, ENTITY_ITEM) as $item){
|
||||
|
|
@ -419,9 +421,11 @@ class Entity extends Position
|
|||
$f = LiquidBlock::getPercentAir($this->level->level->getBlockDamage($x, $y, $z)) - 0.1111111;
|
||||
$f1 = ($y + 1) - $f;
|
||||
if($d < $f1){
|
||||
--$this->air;
|
||||
if($this->air <= 0){
|
||||
$this->air -= 1*$tickDiff;
|
||||
if($this->isPlayer())console($this->air.":".$tickDiff.":".($time - $this->lastUpdate));
|
||||
if($this->air <= -20){
|
||||
$this->harm(2, "water");
|
||||
$this->air = 0; //harm every 1 second
|
||||
}
|
||||
}else{
|
||||
$this->air = $this->maxAir;
|
||||
|
|
@ -491,18 +495,17 @@ class Entity extends Position
|
|||
return $this->y < -1.6;
|
||||
}
|
||||
|
||||
public function update(){
|
||||
public function update($now){
|
||||
if($this->closed === true){
|
||||
return false;
|
||||
}
|
||||
|
||||
$now = microtime(true);
|
||||
if($this->check === false){
|
||||
$this->lastUpdate = $now;
|
||||
return;
|
||||
}
|
||||
|
||||
$hasUpdate = $this->environmentUpdate();
|
||||
$hasUpdate = $this->environmentUpdate($now);
|
||||
|
||||
if($this->closed === true){
|
||||
return false;
|
||||
|
|
@ -906,7 +909,7 @@ class Entity extends Position
|
|||
],
|
||||
1 => [
|
||||
"type" => 1,
|
||||
"value" => $this->air
|
||||
"value" => (int)$this->air
|
||||
],
|
||||
14 => [
|
||||
"type" => 0,
|
||||
|
|
|
|||
|
|
@ -66,14 +66,14 @@ abstract class Living extends Entity implements Damageable, Pathfindable{
|
|||
}
|
||||
}
|
||||
|
||||
public function update(){
|
||||
public function update($now){
|
||||
if(self::$despawnMobs && ++$this->ticksExisted > self::$despawnTimer){
|
||||
$this->close();
|
||||
return;
|
||||
}
|
||||
if($this->closed) return;
|
||||
|
||||
parent::update();
|
||||
parent::update($now);
|
||||
}
|
||||
|
||||
public function updateEntityMovement(){
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ class Chicken extends Animal{
|
|||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 4, "generic");
|
||||
$this->setName('Chicken');
|
||||
$this->setSpeed(0.25);
|
||||
$this->update();
|
||||
}
|
||||
public function isFood($id){
|
||||
return $id === PUMPKIN_SEEDS || $id === MELON_SEEDS || $id === BEETROOT_SEEDS || $id === WHEAT_SEEDS;
|
||||
|
|
@ -18,8 +17,8 @@ class Chicken extends Animal{
|
|||
|
||||
public function fall(){} //chickens have no fall dmg?
|
||||
|
||||
public function update(){
|
||||
parent::update();
|
||||
public function update($now){
|
||||
parent::update($now);
|
||||
if($this->timeUntilEgg-- <= 0 && !$this->isBaby()){
|
||||
$this->dropAnEgg();
|
||||
$this->timeUntilEgg = mt_rand(0,6000) + 6000;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ class Cow extends Animal{
|
|||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 10, "generic");
|
||||
$this->setName("Cow");
|
||||
$this->setSpeed(0.2);
|
||||
$this->update();
|
||||
}
|
||||
|
||||
public function isFood($id){
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ class Pig extends Animal implements Rideable{
|
|||
$this->server = ServerAPI::request();
|
||||
$this->setName("Pig");
|
||||
$this->setSpeed(0.25);
|
||||
$this->update();
|
||||
}
|
||||
/**
|
||||
* @return boolean
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
class Sheep extends Animal{
|
||||
public $color;
|
||||
const TYPE = MOB_SHEEP;
|
||||
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = []){
|
||||
$this->setSize($this->isBaby() ? 0.45 : 0.9, $this->isBaby() ? 0.675 : 1.3);
|
||||
parent::__construct($level, $eid, $class, $type, $data);
|
||||
|
|
@ -11,9 +12,9 @@ class Sheep extends Animal{
|
|||
$this->data["Sheared"] = isset($this->data["Sheared"]) ? $this->data["Sheared"] : 0;
|
||||
$this->data["Color"] = isset($this->data["Color"]) ? $this->data["Color"] : $this->sheepColor();
|
||||
$this->setSpeed(0.25);
|
||||
$this->update();
|
||||
$this->ai->addTask(new TaskEatTileGoal());
|
||||
}
|
||||
|
||||
public function createSaveData(){
|
||||
$data = parent::createSaveData();
|
||||
$data["Color"] = @$this->data["Color"];
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ class Creeper extends Monster{
|
|||
$this->setName("Creeper");
|
||||
$this->ignited = 0;
|
||||
$this->setSpeed(0.25);
|
||||
$this->update();
|
||||
$this->timeUntilExplode = $this->isIgnited() ? self::EXPL_TIME : 0;
|
||||
}
|
||||
|
||||
|
|
@ -58,8 +57,8 @@ class Creeper extends Monster{
|
|||
}
|
||||
|
||||
}
|
||||
public function update(){
|
||||
if($this->isIgnited() && $this->target instanceof Entity && Utils::distance_noroot($this->target, $this) > 49){
|
||||
public function update($now){
|
||||
if($this->isIgnited() && $this->target instanceof Entity && Utils::distance_noroot($this->target, $this) > 49){ //TODO move somewhere else
|
||||
$this->setIgnited(-1); //broken in vanilla too
|
||||
$this->timeUntilExplode = 0;
|
||||
}
|
||||
|
|
@ -69,7 +68,7 @@ class Creeper extends Monster{
|
|||
if($this->timeUntilExplode >= 0){
|
||||
--$this->timeUntilExplode;
|
||||
}
|
||||
parent::update();
|
||||
parent::update($now);
|
||||
}
|
||||
|
||||
public function explode()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ class PigZombie extends Monster{
|
|||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 12, "generic");
|
||||
$this->setName("Pigman");
|
||||
$this->setSpeed(0.25);
|
||||
$this->update();
|
||||
}
|
||||
public function getAttackDamage(){
|
||||
return 5;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ class Skeleton extends Monster{
|
|||
$this->ai->removeTask("TaskAttackPlayer");
|
||||
//$this->ai->addTask(new TaskDestroyServerPerformance());
|
||||
$this->setSpeed(0.25);
|
||||
$this->update();
|
||||
}
|
||||
|
||||
public function getAttackDamage(){
|
||||
|
|
@ -36,9 +35,9 @@ class Skeleton extends Monster{
|
|||
}
|
||||
}
|
||||
|
||||
public function update(){
|
||||
public function update($now){
|
||||
$this->updateBurning();
|
||||
parent::update();
|
||||
parent::update($now);
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ class Spider extends Monster{
|
|||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 8, "generic");
|
||||
$this->setName("Spider");
|
||||
$this->setSpeed(0.3);
|
||||
$this->update();
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ class Zombie extends Monster{
|
|||
$this->setHealth(isset($this->data["Health"]) ? $this->data["Health"] : 12, "generic");
|
||||
$this->setName("Zombie");
|
||||
$this->setSpeed(0.23);
|
||||
$this->update();
|
||||
}
|
||||
|
||||
public function getArmorValue(){
|
||||
|
|
@ -38,9 +37,9 @@ class Zombie extends Monster{
|
|||
return 4; //TODO vanillafy(zombies might be able to hold items)
|
||||
}
|
||||
|
||||
public function update(){
|
||||
public function update($now){
|
||||
$this->updateBurning();
|
||||
parent::update();
|
||||
parent::update($now);
|
||||
}
|
||||
|
||||
public function getDrops(){
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class Arrow extends Projectile{
|
|||
$p->directDataPacket(clone $pk);
|
||||
}
|
||||
}
|
||||
public function update(){
|
||||
public function update($now){
|
||||
$this->needsUpdate = false; //TODO reenable
|
||||
return;
|
||||
//parent::update();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue