mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
better movement in water, tnt will not fall through grass now
This commit is contained in:
parent
4b17edfc05
commit
d622c5e5cf
5 changed files with 44 additions and 14 deletions
|
|
@ -1221,7 +1221,7 @@ class Player{
|
|||
$move = new MoveEntityPacket_PosRot();
|
||||
$move->eid = $e->eid;
|
||||
$move->x = $e->x;
|
||||
$move->y = $e->y; //TODO fix items getting into farmland in client side somehow else
|
||||
$move->y = $e->y;
|
||||
$move->z = $e->z;
|
||||
$move->yaw = $e->yaw;
|
||||
$move->pitch = $e->pitch;
|
||||
|
|
|
|||
|
|
@ -90,6 +90,8 @@ class Entity extends Position
|
|||
public $chunkX = 0;
|
||||
public $chunkZ = 0;
|
||||
|
||||
public $isCollidedHorizontally, $isCollidedVertically, $isCollided;
|
||||
|
||||
function __construct(Level $level, $eid, $class, $type = 0, $data = array())
|
||||
{
|
||||
$this->random = new Random();
|
||||
|
|
@ -552,9 +554,9 @@ class Entity extends Position
|
|||
$z0 = floor($aABB->minZ);
|
||||
$z1 = floor($aABB->maxZ) + 1;
|
||||
|
||||
for($x = $x0; $x <= $x1; ++$x){
|
||||
for($y = $y0; $y <= $y1; ++$y){
|
||||
for($z = $z0; $z <= $z1; ++$z){
|
||||
for($x = $x0; $x < $x1; ++$x){
|
||||
for($y = $y0; $y < $y1; ++$y){
|
||||
for($z = $z0; $z < $z1; ++$z){
|
||||
$b = $this->level->level->getBlockID($x, $y, $z);
|
||||
if($b != 0){
|
||||
$blockBounds = Block::$class[$b]::getCollisionBoundingBoxes($this->level, $x, $y, $z, $this);
|
||||
|
|
@ -619,10 +621,10 @@ class Entity extends Position
|
|||
$this->x = ($this->boundingBox->minX + $this->boundingBox->maxX) / 2;
|
||||
$this->y = $this->boundingBox->minY + $this->yOffset;
|
||||
$this->z = ($this->boundingBox->minZ + $this->boundingBox->maxZ) / 2;
|
||||
//$this.isCollidedHorizontally = savedDX != dx || savedDZ != dz;
|
||||
//$this.isCollidedVertically = savedDY != dy;
|
||||
$this->isCollidedHorizontally = $savedDX != $dx || $savedDZ != $dz;
|
||||
$this->isCollidedVertically = $savedDY != $dy;
|
||||
$this->onGround = $savedDY != $dy && $savedDY < 0.0;
|
||||
//$this.isCollided = this.isCollidedHorizontally || this.isCollidedVertically;
|
||||
$this->isCollided = $this->isCollidedHorizontally || $this->isCollidedVertically;
|
||||
$this->updateFallState($this->speedY);
|
||||
|
||||
|
||||
|
|
@ -643,6 +645,35 @@ class Entity extends Position
|
|||
}
|
||||
}
|
||||
|
||||
//in MCP it is called isOffsetPositionInLiquid, in 0.8 - isFree
|
||||
public function isFree($offsetX, $offsetY, $offsetZ){
|
||||
$offsetBB = $this->boundingBox->getOffsetBoundingBox($offsetX, $offsetY, $offsetZ);
|
||||
|
||||
$minX = floor($offsetBB->minX);
|
||||
$minY = floor($offsetBB->minY);
|
||||
$minZ = floor($offsetBB->minZ);
|
||||
$maxX = floor($offsetBB->maxX + 1);
|
||||
$maxY = floor($offsetBB->maxY + 1);
|
||||
$maxZ = floor($offsetBB->maxZ + 1);
|
||||
|
||||
$hasLiquid = false;
|
||||
$result = false;
|
||||
for($x = $minX; $x < $maxX; ++$x){
|
||||
for($z = $minZ; $z < $maxZ; ++$z){
|
||||
for($y = $minY - 1; $y < $maxY; ++$y){
|
||||
$v12 = $this->level->level->getBlockID($x, $y, $z);
|
||||
if($y != ($minY - 1)) $hasLiquid |= StaticBlock::getIsLiquid($v12);
|
||||
if($v12 != 0){
|
||||
$result = true;
|
||||
break 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($result) return !$hasLiquid;
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isInVoid(){
|
||||
return $this->y < -1.6;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,8 +170,10 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
if($this->jumpTicks > 0) --$this->jumpTicks;
|
||||
}
|
||||
|
||||
|
||||
public function moveEntityWithHeading($strafe, $forward){
|
||||
if($this->inWater){ //also check is player, and can it fly or not
|
||||
$prevPosY = $this->y;
|
||||
$this->moveFlying($strafe, $forward, 0.04); //TODO speed: this.isAIEnabled() ? 0.04F : 0.02F
|
||||
$this->move($this->speedX, $this->speedY, $this->speedZ);
|
||||
$this->speedX *= 0.8;
|
||||
|
|
@ -179,11 +181,10 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
$this->speedZ *= 0.8;
|
||||
$this->speedY -= 0.02;
|
||||
|
||||
//TODO: static speedY
|
||||
//if (this.isCollidedHorizontally && this.isOffsetPositionInLiquid(this.motionX, this.motionY + 0.6 - this.posY + var9, this.motionZ))
|
||||
//{
|
||||
// this.motionY = 0.3;
|
||||
//}
|
||||
|
||||
if($this->isCollidedHorizontally && $this->isFree($this->speedX, $this->speedY + 0.6 - $this->y + $prevPosY, $this->speedZ)){
|
||||
$this->speedY = 0.3;
|
||||
}
|
||||
}
|
||||
//TODO lava
|
||||
else{
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ class ItemEntity extends Entity{
|
|||
if($this->closed) return;
|
||||
|
||||
$friction = 0.98;
|
||||
|
||||
if($this->onGround){
|
||||
$friction = 0.588;
|
||||
$v3 = $this->level->level->getBlockID($this->x, floor($this->boundingBox->minY) - 1, $this->z);
|
||||
|
|
|
|||
|
|
@ -477,7 +477,6 @@ class Level{
|
|||
$maxChunkX = ((int)($bb->maxX)) >> 4;
|
||||
$maxChunkZ = ((int)($bb->maxZ)) >> 4;
|
||||
$ents = [];
|
||||
console("nya $minChunkX $minChunkZ $maxChunkX $maxChunkZ");
|
||||
for($chunkX = $minChunkX; $chunkX <= $maxChunkX; ++$chunkX){
|
||||
for($chunkZ = $minChunkZ; $chunkZ <= $maxChunkZ; ++$chunkZ){
|
||||
$ind = "$chunkX $chunkZ";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue