fix: tried fix not full blocks for path follower

This commit is contained in:
Andrey Terentev 2025-05-07 02:36:42 +07:00
parent 6bbd44be85
commit 8125d04013
3 changed files with 10 additions and 11 deletions

View File

@ -130,16 +130,12 @@ public class AI {
if (nextTarget == null) nextTarget = destinationData.position();
boolean nextIsRePath = nextTarget.sameBlock(Pos.ZERO);
var prevPos = entity.getPosition();
nodeFollower.moveTowards(currentTarget, nodeFollower.movementSpeed(), nextIsRePath ? currentTarget : nextTarget);
var delta = entity.getPosition().sub(prevPos);
if (delta.isZero()) {
nodeFollower.jump(currentTarget, nextTarget);
}
// TODO: исправить баг, в данном месте, когда Entity не движется вообще. Сделать хорошую проверку на застревание
// TODO: присутствует баг, что если как-то помешать Entity следовать до точки, например поставить перед ним блок, то он перестанет идти
// TODO: хождение по неполноценным блокам - огромная проблема. Entity попросту застревает в них
// TODO: Бля, этот поиск пути говнище полное! Он не учитывает ни заборы, ни полублоки, ни ковры и остальные неполноценные блоки. Трава - это вообще пиздец.
// TODO: использовать CollisionUtils для просчета поиска путей
if (nodeFollower.isAtPoint(currentTarget)) path.next();
else if (path.getCurrentType() == PathNode.Type.JUMP) nodeFollower.jump(currentTarget, nextTarget);

View File

@ -37,8 +37,7 @@ public class GroundNodeFollower implements NodeFollower {
var speedZ = Math.sin(radians) * speed;
var yaw = PositionUtils.getLookYaw(dxLook, dzLook);
var pitch = PositionUtils.getLookPitch(dxLook, dyLook, dzLook);
var physicsResult = CollisionUtils.handlePhysics(entity, new Vec(speedX, 0, speedZ));
var physicsResult = CollisionUtils.handlePhysics(entity, new Vec(speedX, dy > 0? (dy + 0.1) : 0, speedZ));
var newPosition = Pos.fromPoint(physicsResult.newPosition());
entity.refreshPosition(newPosition.withView(yaw, pitch));
}
@ -46,7 +45,7 @@ public class GroundNodeFollower implements NodeFollower {
@Override
public void jump(@Nullable Point point, @Nullable Point target) {
if (entity.isOnGround()) {
jump(4f);
jump(entity.getJumpHeight());
}
}
@ -56,8 +55,8 @@ public class GroundNodeFollower implements NodeFollower {
return d.x() * d.x() + d.z() * d.z() < 0.5 * 0.5;
}
public void jump(float height) {
entity.setVelocity(new Vec(0, height * 2.5f, 0));
public void jump(double height) {
entity.setVelocity(new Vec(0, height, 0));
}
@Override

View File

@ -75,4 +75,8 @@ public class EntityAI extends LivingEntity {
super.remove(permanent);
ai.getActor().setActive(false);
}
public double getJumpHeight() {
return 2.1;
}
}