mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
better collisions between entities
This commit is contained in:
parent
869b8b111a
commit
fc334e7c99
4 changed files with 14 additions and 14 deletions
|
|
@ -1216,7 +1216,7 @@ class Player{
|
|||
$moveSent = false;
|
||||
$headSent = false;
|
||||
if($e->speedX != 0 || $e->speedY != 0 || $e->speedZ != 0 || $e->speedY != $e->lastSpeedY || $e->speedX != $e->lastSpeedX || $e->speedZ != $e->lastSpeedZ){
|
||||
if(!($e->speedY < 0 && $e->onGround)){
|
||||
if(!($e->speedY < 0 && $e->onGround) || $e->speedX != 0 || $e->speedZ != 0 || $e->speedY != $e->lastSpeedY || $e->speedX != $e->lastSpeedX || $e->speedZ != $e->lastSpeedZ){
|
||||
$motion = new SetEntityMotionPacket();
|
||||
$motion->eid = $e->eid;
|
||||
$motion->speedX = $e->speedX;
|
||||
|
|
|
|||
|
|
@ -622,6 +622,7 @@ class PocketMinecraftServer{
|
|||
try{
|
||||
$return = @call_user_func($this->schedule[$cid][0] ?? function(){}, $this->schedule[$cid][1], $this->schedule[$cid][2]); //somehow args can be null
|
||||
}catch(TypeError $e){
|
||||
ConsoleAPI::error($e->getTraceAsString());
|
||||
$return = false;
|
||||
}
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -63,11 +63,11 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
return true;
|
||||
}
|
||||
public function collideHandler(){
|
||||
$rd = ceil($this->radius);
|
||||
$minChunkX = ((int)($this->x - $rd)) >> 4;
|
||||
$minChunkZ = ((int)($this->z - $rd)) >> 4;
|
||||
$maxChunkX = ((int)($this->x + $rd)) >> 4;
|
||||
$maxChunkZ = ((int)($this->z + $rd)) >> 4;
|
||||
$bb = $this->boundingBox->expand(0.2, 0, 0.2);
|
||||
$minChunkX = ((int)($bb->minX)) >> 4;
|
||||
$minChunkZ = ((int)($bb->minZ)) >> 4;
|
||||
$maxChunkX = ((int)($bb->minX)) >> 4;
|
||||
$maxChunkZ = ((int)($bb->minZ)) >> 4;
|
||||
|
||||
//TODO also index by chunkY?
|
||||
for($chunkX = $minChunkX; $chunkX <= $maxChunkX; ++$chunkX){
|
||||
|
|
@ -75,7 +75,9 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
$ind = "$chunkX $chunkZ";
|
||||
foreach($this->level->entityListPositioned[$ind] ?? [] as $entid){
|
||||
if($this->level->entityList[$entid] instanceof Entity){
|
||||
$this->applyCollision($this->level->entityList[$entid]);
|
||||
if($bb->intersectsWith($this->level->entityList[$entid]->boundingBox)){
|
||||
$this->applyCollision($this->level->entityList[$entid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -83,7 +85,7 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
}
|
||||
|
||||
public function applyCollision(Entity $collided){
|
||||
if($collided->boundingBox->intersectsWith($this->boundingBox) && !($this->isPlayer() && $collided->isPlayer()) && $this->eid != $collided->eid){
|
||||
if(!($this->isPlayer() && $collided->isPlayer()) && $this->eid != $collided->eid){
|
||||
$diffX = $collided->x - $this->x;
|
||||
$diffZ = $collided->z - $this->z;
|
||||
$maxDiff = max(abs($diffX), abs($diffZ));
|
||||
|
|
@ -154,15 +156,12 @@ abstract class Living extends Entity implements Pathfindable{
|
|||
$this->landMovementFactor *= $this->getSpeedModifer();
|
||||
$this->moveEntityWithHeading($this->moveStrafing, $this->moveForward);
|
||||
$this->landMovementFactor = $savedLandFactor;
|
||||
//Yaw rotation in 1.5 is handled in a bit different place but hopefully this will work too
|
||||
$this->ai->mobController->updateHeadYaw();
|
||||
|
||||
if(self::$entityPushing){
|
||||
$this->collideHandler();
|
||||
}
|
||||
|
||||
//Yaw rotation in 1.5 is handled in a bit different place but hopefully this will work too
|
||||
$this->ai->mobController->updateHeadYaw();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function jump(){
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class Zombie extends Monster{
|
|||
}
|
||||
|
||||
public function updateBurning(){
|
||||
if($this->fire > 0 or !$this->level->isDay() || $this->inWater){ //TODO fix burning in water
|
||||
if($this->fire > 0 || !$this->level->isDay() || $this->inWater){ //TODO fix burning in water
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue