/*
 *  Copyright 2025-2026 R3944Realms
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package top.r3944realms.eroticdungeongame.content.entity.npc.ai.navigation;

import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.pathfinder.PathFinder;
import net.minecraft.world.level.pathfinder.SwimNodeEvaluator;
import net.minecraft.world.phys.Vec3;
import top.r3944realms.eroticdungeongame.content.entity.npc.NPCServerPlayer;
import top.r3944realms.eroticdungeongame.content.entity.npc.ai.navigation.pathfinder.NPCPathFinder;
import top.r3944realms.eroticdungeongame.content.entity.npc.ai.navigation.pathfinder.NPCSwimNodeEvaluator;

public class NPCWaterBoundPathNavigation extends NPCPathNavigation {
    private boolean allowBreaching;

    public NPCWaterBoundPathNavigation(NPCServerPlayer npc, Level level) {
        super(npc, level);
    }

    protected NPCPathFinder createPathFinder(int maxVisitedNodes) {
        this.allowBreaching = false; //todo 考虑下这里修改适配NPC
        this.nodeEvaluator = new NPCSwimNodeEvaluator(false);
        return new NPCPathFinder(this.nodeEvaluator, maxVisitedNodes);
    }

    protected boolean canUpdatePath() {
        return this.allowBreaching || this.isInLiquid();
    }

    protected Vec3 getTempMobPos() {
        return new Vec3(this.npc.getX(), this.npc.getY(0.5D), this.npc.getZ());
    }

    protected double getGroundY(Vec3 vec) {
        return vec.y;
    }

    /**
     * Checks if the specified entity can safely walk to the specified location.
     */
    protected boolean canMoveDirectly(Vec3 posVec31, Vec3 posVec32) {
        return isClearForMovementBetween(this.npc, posVec31, posVec32, false);
    }

    public boolean isStableDestination(BlockPos pos) {
        return !this.level.getBlockState(pos).isSolidRender(this.level, pos);
    }

    public void setCanFloat(boolean canSwim) {
    }
}
