mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
lava movement
This commit is contained in:
parent
f200683643
commit
0ca6becc6a
5 changed files with 51 additions and 68 deletions
|
|
@ -97,7 +97,7 @@ class Entity extends Position
|
||||||
*/
|
*/
|
||||||
public $fireResistance = 1;
|
public $fireResistance = 1;
|
||||||
public $inWeb;
|
public $inWeb;
|
||||||
|
public $inLava;
|
||||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array())
|
function __construct(Level $level, $eid, $class, $type = 0, $data = array())
|
||||||
{
|
{
|
||||||
$this->random = new Random();
|
$this->random = new Random();
|
||||||
|
|
@ -338,6 +338,11 @@ class Entity extends Position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function handleLavaMovement(){ //TODO maybe try merging with water?
|
||||||
|
$this->inLava = $this->level->isLavaInBB($this->boundingBox->expand(-0.1, -0.4, -0.1));
|
||||||
|
return $this->inLava;
|
||||||
|
}
|
||||||
|
|
||||||
public function handleWaterMovement(){
|
public function handleWaterMovement(){
|
||||||
if($this->level->handleMaterialAcceleration($this->boundingBox->expand(0, -0.4, 0)->contract(0.001, 0.001, 0.001), 0, $this)){
|
if($this->level->handleMaterialAcceleration($this->boundingBox->expand(0, -0.4, 0)->contract(0.001, 0.001, 0.001), 0, $this)){
|
||||||
$this->fallDistance = 0;
|
$this->fallDistance = 0;
|
||||||
|
|
@ -419,6 +424,13 @@ class Entity extends Position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$this->isPlayer()) {
|
||||||
|
if($this->handleLavaMovement()){
|
||||||
|
//TODO this.setOnFireFromLava();
|
||||||
|
$this->fallDistance *= 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$startX = floor($this->boundingBox->minX);
|
$startX = floor($this->boundingBox->minX);
|
||||||
$startY = floor($this->boundingBox->minY);
|
$startY = floor($this->boundingBox->minY);
|
||||||
$startZ = floor($this->boundingBox->minZ);
|
$startZ = floor($this->boundingBox->minZ);
|
||||||
|
|
@ -590,11 +602,11 @@ class Entity extends Position
|
||||||
|
|
||||||
$aABB = $this->boundingBox->addCoord($dx, $dy, $dz);
|
$aABB = $this->boundingBox->addCoord($dx, $dy, $dz);
|
||||||
$x0 = floor($aABB->minX);
|
$x0 = floor($aABB->minX);
|
||||||
$x1 = floor($aABB->maxX) + 1;
|
$x1 = floor($aABB->maxX + 1);
|
||||||
$y0 = floor($aABB->minY);
|
$y0 = floor($aABB->minY);
|
||||||
$y1 = floor($aABB->maxY) + 1;
|
$y1 = floor($aABB->maxY + 1);
|
||||||
$z0 = floor($aABB->minZ);
|
$z0 = floor($aABB->minZ);
|
||||||
$z1 = floor($aABB->maxZ) + 1;
|
$z1 = floor($aABB->maxZ + 1);
|
||||||
|
|
||||||
for($x = $x0; $x < $x1; ++$x){
|
for($x = $x0; $x < $x1; ++$x){
|
||||||
for($y = $y0; $y < $y1; ++$y){
|
for($y = $y0; $y < $y1; ++$y){
|
||||||
|
|
@ -750,52 +762,6 @@ class Entity extends Position
|
||||||
$this->updateLast();
|
$this->updateLast();
|
||||||
$this->updatePosition(); //TODO shouldnt be called in Entity
|
$this->updatePosition(); //TODO shouldnt be called in Entity
|
||||||
$this->updateEntityMovement();
|
$this->updateEntityMovement();
|
||||||
/*$update = false;
|
|
||||||
if($this->speedX > -self::MIN_POSSIBLE_SPEED && $this->speedX < self::MIN_POSSIBLE_SPEED){
|
|
||||||
$this->speedX = 0;
|
|
||||||
}
|
|
||||||
if($this->speedZ > -self::MIN_POSSIBLE_SPEED && $this->speedZ < self::MIN_POSSIBLE_SPEED){
|
|
||||||
$this->speedZ = 0;
|
|
||||||
}
|
|
||||||
if($this->speedY > -self::MIN_POSSIBLE_SPEED && $this->speedY < self::MIN_POSSIBLE_SPEED){
|
|
||||||
$this->speedY = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$horizontalMultiplyFactor = 0.91;
|
|
||||||
if($this->onGround){
|
|
||||||
$horizontalMultiplyFactor = 0.54;
|
|
||||||
$b = $this->level->level->getBlockID(floor($this->x), floor($this->boundingBox->minY) - 1, floor($this->z));
|
|
||||||
if($b > 0){
|
|
||||||
$horizontalMultiplyFactor = StaticBlock::getSlipperiness($b) * 0.91;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->inWater){
|
|
||||||
$this->speedX *= 0.8;
|
|
||||||
$this->speedY *= 0.8;
|
|
||||||
$this->speedZ *= 0.8;
|
|
||||||
}else{
|
|
||||||
$this->speedX *= $horizontalMultiplyFactor;
|
|
||||||
$this->speedY *= 0.98;
|
|
||||||
$this->speedZ *= $horizontalMultiplyFactor;
|
|
||||||
}
|
|
||||||
|
|
||||||
$savedSpeedY = $this->speedY;
|
|
||||||
$savedSpeedX = $this->speedX;
|
|
||||||
$savedSpeedZ = $this->speedZ;
|
|
||||||
$ultraMegaOldBB = clone $this->boundingBox;
|
|
||||||
$stepSuccess = false;
|
|
||||||
$beforeStepSpeedY = 0;
|
|
||||||
|
|
||||||
if($this->enableAutojump && $this instanceof Creature){
|
|
||||||
if(!$stepSuccess && $fallingFlag && ($this->speedX != $savedSpeedX || $this->speedZ != $savedSpeedZ)){
|
|
||||||
$this->ai->mobController->setJumping(true);
|
|
||||||
}else{
|
|
||||||
$this->ai->mobController->setJumping(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
if($this->lastX != $this->x || $this->lastZ != $this->z || $this->lastY != $this->z){
|
if($this->lastX != $this->x || $this->lastZ != $this->z || $this->lastY != $this->z){
|
||||||
$this->server->api->handle("entity.move", $this);
|
$this->server->api->handle("entity.move", $this);
|
||||||
|
|
|
||||||
|
|
@ -185,9 +185,19 @@ abstract class Living extends Entity implements Pathfindable{
|
||||||
if($this->isCollidedHorizontally && $this->isFree($this->speedX, $this->speedY + 0.6 - $this->y + $prevPosY, $this->speedZ)){
|
if($this->isCollidedHorizontally && $this->isFree($this->speedX, $this->speedY + 0.6 - $this->y + $prevPosY, $this->speedZ)){
|
||||||
$this->speedY = 0.3;
|
$this->speedY = 0.3;
|
||||||
}
|
}
|
||||||
}
|
}else if($this->inLava){
|
||||||
//TODO lava
|
$prevPosY = $this->y;
|
||||||
else{
|
$this->moveFlying($strafe, $forward, 0.02);
|
||||||
|
$this->move($this->speedX, $this->speedY, $this->speedZ);
|
||||||
|
$this->speedX *= 0.5;
|
||||||
|
$this->speedY *= 0.5;
|
||||||
|
$this->speedZ *= 0.5;
|
||||||
|
$this->speedY -= 0.02;
|
||||||
|
|
||||||
|
if($this->isCollidedHorizontally && $this->isFree($this->speedX, $this->speedY + 0.6 - $this->y + $prevPosY, $this->speedZ)){
|
||||||
|
$this->speedY = 0.3;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
$friction = 0.91;
|
$friction = 0.91;
|
||||||
|
|
||||||
if($this->onGround){
|
if($this->onGround){
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ class TaskSwimming extends TaskBase
|
||||||
|
|
||||||
public function onUpdate(EntityAI $ai)
|
public function onUpdate(EntityAI $ai)
|
||||||
{
|
{
|
||||||
if(!$ai->entity->inWater){
|
if(!$ai->entity->inWater || !$ai->entity->inLava){
|
||||||
$this->reset();
|
$this->reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -26,7 +26,7 @@ class TaskSwimming extends TaskBase
|
||||||
|
|
||||||
public function canBeExecuted(EntityAI $ai)
|
public function canBeExecuted(EntityAI $ai)
|
||||||
{
|
{
|
||||||
return $ai->entity->inWater;
|
return $ai->entity->inWater || $ai->entity->inLava;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,18 +36,6 @@ class FallingSand extends Entity{
|
||||||
$y = floor($this->y);
|
$y = floor($this->y);
|
||||||
$z = floor($this->z);
|
$z = floor($this->z);
|
||||||
|
|
||||||
if($this->fallTime == 1){
|
|
||||||
/* i dont think this is needed here?
|
|
||||||
* if (this.worldObj.getBlockId(var1, var2, var3) != this.blockID)
|
|
||||||
{
|
|
||||||
this.setDead();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.worldObj.setBlockToAir(var1, var2, var3);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->onGround){
|
if($this->onGround){
|
||||||
$this->speedX *= 0.7;
|
$this->speedX *= 0.7;
|
||||||
$this->speedZ *= 0.7;
|
$this->speedZ *= 0.7;
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,26 @@ class Level{
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO mayPlace
|
//TODO mayPlace
|
||||||
|
public function isLavaInBB($aabb){
|
||||||
|
$minX = floor($aabb->minX);
|
||||||
|
$maxX = floor($aabb->maxX + 1);
|
||||||
|
$minY = floor($aabb->minY);
|
||||||
|
$maxY = floor($aabb->maxY + 1);
|
||||||
|
$minZ = floor($aabb->minZ);
|
||||||
|
$maxZ = floor($aabb->maxZ + 1);
|
||||||
|
|
||||||
|
for($x = $minX; $x < $maxX; ++$x){
|
||||||
|
for($y = $minY; $y < $maxY; ++$y){
|
||||||
|
for($z = $minZ; $z < $maxZ; ++$z){
|
||||||
|
$blockId = $this->level->getBlockID($x, $y, $z);
|
||||||
|
|
||||||
|
if($blockId == LAVA || $blockId == STILL_LAVA) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function handleMaterialAcceleration(AxisAlignedBB $aabb, $materialType, Entity $entity){
|
public function handleMaterialAcceleration(AxisAlignedBB $aabb, $materialType, Entity $entity){
|
||||||
$minX = floor($aabb->minX);
|
$minX = floor($aabb->minX);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue