mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 13:09:44 +00:00
water damage rewroked, small rotation changes
This commit is contained in:
parent
adf84efbd7
commit
0dacbe0b36
5 changed files with 48 additions and 23 deletions
|
|
@ -770,7 +770,7 @@ class Player{
|
||||||
if($data->eid === $this->eid or $data->level !== $this->level){
|
if($data->eid === $this->eid or $data->level !== $this->level){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(($data->speedX === 0 && $data->speedY === 0 && $data->speedZ === 0) || ($data->speedX === $data->lastSpeedX && $data->speedY === $data->lastSpeedY && $data->lastSpeedZ === $data->speedZ)){ //causer of packet flood is eliminated.
|
if(($data->speedX === 0 && $data->speedY === 0 && $data->speedZ === 0) || ($data->speedX === $data->lastSpeedX && $data->speedY === $data->lastSpeedY && $data->lastSpeedZ === $data->speedZ)){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$pk = new SetEntityMotionPacket;
|
$pk = new SetEntityMotionPacket;
|
||||||
|
|
|
||||||
|
|
@ -425,6 +425,33 @@ class Entity extends Position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//air damage
|
||||||
|
if($this->isPlayer() || $this instanceof Living){
|
||||||
|
$d = $this->y + $this->getEyeHeight();
|
||||||
|
$x = floor($this->x);
|
||||||
|
$y = floor($d);
|
||||||
|
$z = floor($this->z);
|
||||||
|
|
||||||
|
$id = $this->level->level->getBlockID($x, $y, $z);
|
||||||
|
if($id == WATER || $id == STILL_WATER){
|
||||||
|
$f = LiquidBlock::getPercentAir($this->level->level->getBlockDamage($x, $y, $z)) - 0.1111111;
|
||||||
|
$f1 = ($y + 1) - $f;
|
||||||
|
if($d < $f1){
|
||||||
|
console("losing air");
|
||||||
|
--$this->air;
|
||||||
|
if($this->air <= 0){
|
||||||
|
$this->harm(2, "water");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$this->air = 200; //TODO $this->maxAir;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$this->air = 200; //TODO $this->maxAir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for ($y = $startY; $y <= $endY; ++$y){
|
for ($y = $startY; $y <= $endY; ++$y){
|
||||||
for ($x = $startX; $x <= $endX; ++$x){
|
for ($x = $startX; $x <= $endX; ++$x){
|
||||||
for ($z = $startZ; $z <= $endZ; ++$z){
|
for ($z = $startZ; $z <= $endZ; ++$z){
|
||||||
|
|
@ -438,16 +465,6 @@ class Entity extends Position
|
||||||
$this->fire = 0;
|
$this->fire = 0;
|
||||||
$this->updateMetadata();
|
$this->updateMetadata();
|
||||||
}
|
}
|
||||||
if ($this->air <= 0 && ! $waterDone) {
|
|
||||||
$this->harm(2, "water");
|
|
||||||
$hasUpdate = true;
|
|
||||||
$waterDone = true;
|
|
||||||
} elseif ($x == ($endX - 1) and $y == $endY and $z == ($endZ - 1) and ($this->class === ENTITY_MOB or $this->class === ENTITY_PLAYER) and !$waterDone) {
|
|
||||||
$this->air -= 1;
|
|
||||||
$waterDone = true;
|
|
||||||
$this->updateMetadata();
|
|
||||||
$hasUpdate = true;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case LAVA: // Lava damage
|
case LAVA: // Lava damage
|
||||||
case STILL_LAVA:
|
case STILL_LAVA:
|
||||||
|
|
@ -473,11 +490,6 @@ class Entity extends Position
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if($this->inBlock(new Vector3($x, $y, $z), 0.7) && $y == $endY and !StaticBlock::getIsTransparent($id) && ($this->class === ENTITY_MOB || $this->class === ENTITY_PLAYER)){
|
|
||||||
|
|
||||||
}elseif($x == ($endX - 1) and $y == $endY and $z == ($endZ - 1)){
|
|
||||||
$this->air = 200;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -521,13 +533,13 @@ class Entity extends Position
|
||||||
if($this->isStatic === false){
|
if($this->isStatic === false){
|
||||||
if(!$this->isPlayer()){
|
if(!$this->isPlayer()){
|
||||||
$update = false;
|
$update = false;
|
||||||
if(Utils::in_range($this->speedX, -0.01, 0.01)){
|
if($this->speedX >= -0.001 && $this->speedX <= 0.001){
|
||||||
$this->speedX = 0;
|
$this->speedX = 0;
|
||||||
}
|
}
|
||||||
if(Utils::in_range($this->speedZ, -0.01, 0.01)){
|
if($this->speedZ >= -0.001 && $this->speedZ <= 0.001){
|
||||||
$this->speedZ = 0;
|
$this->speedZ = 0;
|
||||||
}
|
}
|
||||||
if(Utils::in_range($this->speedY, -0.007, 0.007)){
|
if($this->speedY >= -0.001 && $this->speedY <= 0.001){
|
||||||
$this->speedY = 0;
|
$this->speedY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -539,6 +551,7 @@ class Entity extends Position
|
||||||
$horizontalMultiplyFactor = StaticBlock::getSlipperiness($b) * 0.91;
|
$horizontalMultiplyFactor = StaticBlock::getSlipperiness($b) * 0.91;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->inWater){
|
if($this->inWater){
|
||||||
$this->speedX *= 0.8;
|
$this->speedX *= 0.8;
|
||||||
$this->speedY *= 0.8;
|
$this->speedY *= 0.8;
|
||||||
|
|
@ -812,8 +825,8 @@ class Entity extends Position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEyeHeight(){
|
public function getEyeHeight(){ //TODO in vanilla player's eyeHeight is 0.12
|
||||||
return $this->isPlayer() ? 1.62 : $this->width;
|
return $this->isPlayer() ? $this->height - 0.12 : $this->width * 0.85;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function interactWith(Entity $e, $action)
|
public function interactWith(Entity $e, $action)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,10 @@ class MobController
|
||||||
$this->jumping = $b;
|
$this->jumping = $b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isRotationCompleted(){
|
||||||
|
return $this->finalHeadYaw === $this->entity->headYaw;
|
||||||
|
}
|
||||||
|
|
||||||
public function moveNonInstant($x, $y, $z){
|
public function moveNonInstant($x, $y, $z){
|
||||||
if($x == 0 && $y == 0 && $z == 0){
|
if($x == 0 && $y == 0 && $z == 0){
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -87,7 +91,7 @@ class MobController
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->faceEntity($ox, $oy, $oz);
|
$this->faceEntity($ox, $oy, $oz);
|
||||||
if($this->entity->knockbackTime <= 0){
|
if($this->entity->knockbackTime <= 0 && $this->isRotationCompleted()){
|
||||||
$this->entity->moveEntityWithOffset($ox, $oy, $oz);
|
$this->entity->moveEntityWithOffset($ox, $oy, $oz);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class TaskLookAtPlayer extends TaskBase{
|
||||||
public $target = false;
|
public $target = false;
|
||||||
private $state, $yaw, $pitch;
|
private $state, $yaw, $pitch;
|
||||||
public function canBeExecuted(EntityAI $ai){
|
public function canBeExecuted(EntityAI $ai){
|
||||||
return !$ai->entity->inPanic && lcg_value() < 0.02 && !$ai->entity->isMovingHorizontally() && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskTempt") && !$ai->entity->hasPath();
|
return !$ai->entity->inPanic && lcg_value() < 0.02 && !$ai->entity->isMovingHorizontally() && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskTempt") && !$ai->isStarted("TaskPanic") && !$ai->entity->hasPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function findTarget($e, $r){
|
protected function findTarget($e, $r){
|
||||||
|
|
@ -61,6 +61,7 @@ class TaskLookAtPlayer extends TaskBase{
|
||||||
public function onEnd(EntityAI $ai){
|
public function onEnd(EntityAI $ai){
|
||||||
unset($this->target);
|
unset($this->target);
|
||||||
$ai->entity->pitch = 0;
|
$ai->entity->pitch = 0;
|
||||||
|
$ai->entity->sendMoveUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,13 @@ class LiquidBlock extends TransparentBlock{
|
||||||
$this->isFullBlock = true;
|
$this->isFullBlock = true;
|
||||||
$this->hardness = 500;
|
$this->hardness = 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getPercentAir($meta){
|
||||||
|
if($meta >= 8) $meta = 0;
|
||||||
|
$f = ($meta + 1) / 9;
|
||||||
|
return $f;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDrops(Item $item, Player $player){
|
public function getDrops(Item $item, Player $player){
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue