package net.minecraft.world.entity.ai.navigation;

import net.minecraft.core.Position;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.pathfinder.Path;
import net.minecraft.world.level.Level;
import net.minecraft.world.entity.Mob;
import net.minecraft.core.BlockPos;

public class WallClimberNavigation extends GroundPathNavigation {
    private BlockPos pathToPosition;
    
    public WallClimberNavigation(final Mob ala, final Level bjw) {
        super(ala, bjw);
    }
    
    @Override
    public Path createPath(final BlockPos fk, final int integer) {
        this.pathToPosition = fk;
        return super.createPath(fk, integer);
    }
    
    @Override
    public Path createPath(final Entity akq, final int integer) {
        this.pathToPosition = new BlockPos(akq);
        return super.createPath(akq, integer);
    }
    
    @Override
    public boolean moveTo(final Entity akq, final double double2) {
        final Path cqq5 = this.createPath(akq, 0);
        if (cqq5 != null) {
            return this.moveTo(cqq5, double2);
        }
        this.pathToPosition = new BlockPos(akq);
        this.speedModifier = double2;
        return true;
    }
    
    @Override
    public void tick() {
        if (this.isDone()) {
            if (this.pathToPosition != null) {
                if (this.pathToPosition.closerThan(this.mob.position(), this.mob.getBbWidth()) || (this.mob.getY() > this.pathToPosition.getY() && new BlockPos(this.pathToPosition.getX(), this.mob.getY(), this.pathToPosition.getZ()).closerThan(this.mob.position(), this.mob.getBbWidth()))) {
                    this.pathToPosition = null;
                }
                else {
                    this.mob.getMoveControl().setWantedPosition(this.pathToPosition.getX(), this.pathToPosition.getY(), this.pathToPosition.getZ(), this.speedModifier);
                }
            }
            return;
        }
        super.tick();
    }
}
