From 19a400854308c2f4ba6cae2cfe4627fe30e43c6f Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Sat, 23 Nov 2024 05:35:41 +0300 Subject: [PATCH] fixed inability to collect entity drop, fixed player not getting damage while standing on cactus, tweaked some other stuff --- src/entity/Entity.php | 12 +++++++----- src/entity/ai/MobController.php | 2 +- src/entity/ai/tasks/TaskBase.php | 2 +- src/entity/ai/tasks/TaskLookAtPlayer.php | 2 +- src/world/Level.php | 2 +- src/world/generator/vanilla/feature/ClayFeature.php | 1 - 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 8d0b0561..ee68991c 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -370,7 +370,7 @@ class Entity extends Position private function spawnDrops() { foreach($this->getDrops() as $drop){ - $this->server->api->entity->drop($this, BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2] & 0xFF), true); + $this->server->api->entity->drop($this, BlockAPI::getItem($drop[0] & 0xFFFF, $drop[1] & 0xFFFF, $drop[2] & 0xFF)); } } @@ -549,11 +549,11 @@ class Entity extends Position public function updateEntityMovement(){} public function doBlocksCollision(){ - $minX = floor($this->boundingBox->minX + 0.001); $minY = floor($this->boundingBox->minY + 0.001); + $maxY = floor($this->boundingBox->maxY - 0.001); + $minX = floor($this->boundingBox->minX + 0.001); $minZ = floor($this->boundingBox->minZ + 0.001); $maxX = floor($this->boundingBox->maxX - 0.001); - $maxY = floor($this->boundingBox->maxY - 0.001); $maxZ = floor($this->boundingBox->maxZ - 0.001); for($x = $minX; $x <= $maxX; ++$x){ @@ -803,12 +803,13 @@ class Entity extends Position intersects: if($y <= floor($this->boundingBox->minY) && !$this->onGround){ if($intersects > 0) $this->onGround = count($bounds) > 0; - }else{ + } + if($y >= floor($this->boundingBox->minY)){ $block = $this->level->level->getBlock($x, $y, $z); $id = $block[0]; $meta = $block[1]; $handleFire = $handleFire || (($id == FIRE || $id == STILL_LAVA || $id == LAVA) && $x >= $fireMinX && $x < $fireMaxX && $y >= $fireMinY && $y < $fireMaxY && $z >= $fireMinZ && $z < $fireMaxZ); - $handleCactus = $handleCactus || ($id == CACTUS && $x >= $fireMinX && $x <= $fireMaxX && $y >= $fireMinY && $y <= $fireMaxY && $z >= $fireMinZ && $z <= $fireMaxZ); + $handleCactus = $handleCactus || ($id == CACTUS && $x >= $fireMinX && $x < $fireMaxX && $y >= $fireMinY && $y < $fireMaxY && $z >= $fireMinZ && $z < $fireMaxZ); if($id === WATER || $id === STILL_WATER || $id === COBWEB){ $this->fallDistance = 0; @@ -819,6 +820,7 @@ class Entity extends Position } } } + if($prevGroundState == $this->onGround && !$this->onGround && $this->player->isSleeping == false){ //isSleeping may be a vector ++$this->notOnGroundTicks; }else if($this->onGround){ diff --git a/src/entity/ai/MobController.php b/src/entity/ai/MobController.php index 4d4078d2..fd6d772e 100644 --- a/src/entity/ai/MobController.php +++ b/src/entity/ai/MobController.php @@ -102,7 +102,7 @@ class MobController $v8 = $diffX*$diffX + $diffY*$diffY + $diffZ*$diffZ; - if($v8 >= 2.500000277905201E-7){ //TODO convert notation + if($v8 >= 0.00000025){ $v10 = (atan2($diffZ, $diffX) * 180 / M_PI) - 90; $this->entity->yaw = self::limitAngle($this->entity->yaw, $v10, 30); $this->entity->setAIMoveSpeed($this->speedMultiplier * $this->entity->getSpeed() * $this->entity->getSpeedModifer()); diff --git a/src/entity/ai/tasks/TaskBase.php b/src/entity/ai/tasks/TaskBase.php index 56eaf4fb..14f776eb 100644 --- a/src/entity/ai/tasks/TaskBase.php +++ b/src/entity/ai/tasks/TaskBase.php @@ -1,5 +1,5 @@ target instanceof Entity) || Utils::distance($ai->entity, $this->target) > 6 || $this->target->level->getName() != $ai->entity->level->getName()){ //TODO max distance for different mobs + if(!($this->target instanceof Entity) || Utils::distance($ai->entity, $this->target) > $this->distance || $this->target->level->getName() != $ai->entity->level->getName()){ $this->reset(); $this->onEnd($ai); return; diff --git a/src/world/Level.php b/src/world/Level.php index 17d0cb26..34efba44 100644 --- a/src/world/Level.php +++ b/src/world/Level.php @@ -82,7 +82,7 @@ class Level{ return true; } - // TODO neccessary for projectiles + public function rayTraceBlocks(Vector3 $start, Vector3 $end){ $par3 = false; //TODO move to params? diff --git a/src/world/generator/vanilla/feature/ClayFeature.php b/src/world/generator/vanilla/feature/ClayFeature.php index d6a2d392..32e51e0c 100644 --- a/src/world/generator/vanilla/feature/ClayFeature.php +++ b/src/world/generator/vanilla/feature/ClayFeature.php @@ -39,7 +39,6 @@ class ClayFeature $d6 = (($i4 + 0.5) - $d3) / ($sin3 / 2); if(($d4*$d4)+($d5*$d5)+($d6*$d6)<1 && $level->level->getBlockID($i2, $i3, $i4) == SAND){ $level->level->setBlockID($i2, $i3, $i4, $clayid); - console("Placed clay at".$i2.":".$i4); } } }