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 aoz, final Level bqb) {
        super(aoz, bqb);
    }
    
    @Override
    public Path createPath(final BlockPos fu, final int integer) {
        this.pathToPosition = fu;
        return super.createPath(fu, integer);
    }
    
    @Override
    public Path createPath(final Entity aom, final int integer) {
        this.pathToPosition = aom.blockPosition();
        return super.createPath(aom, integer);
    }
    
    @Override
    public boolean moveTo(final Entity aom, final double double2) {
        final Path czf5 = this.createPath(aom, 0);
        if (czf5 != null) {
            return this.moveTo(czf5, double2);
        }
        this.pathToPosition = aom.blockPosition();
        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();
    }
}
