// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.npc.corecomponents;

import java.util.logging.Level;
import com.hypixel.hytale.server.npc.blackboard.Blackboard;
import com.hypixel.hytale.server.npc.entities.NPCEntity;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.hypixel.hytale.server.npc.blackboard.view.resource.ResourceView;
import com.hypixel.hytale.math.vector.Vector3d;

public class BlockTarget
{
    private final Vector3d position;
    private int chunkChangeRevision;
    private int foundBlockType;
    @Nullable
    private ResourceView reservationHolder;
    
    public BlockTarget() {
        this.position = new Vector3d(Vector3d.MIN);
        this.chunkChangeRevision = -1;
        this.foundBlockType = Integer.MIN_VALUE;
    }
    
    @Nonnull
    public Vector3d getPosition() {
        return this.position;
    }
    
    public int getChunkChangeRevision() {
        return this.chunkChangeRevision;
    }
    
    public int getFoundBlockType() {
        return this.foundBlockType;
    }
    
    public void setChunkChangeRevision(final int chunkChangeRevision) {
        this.chunkChangeRevision = chunkChangeRevision;
    }
    
    public void setFoundBlockType(final int foundBlockType) {
        this.foundBlockType = foundBlockType;
    }
    
    public void setReservationHolder(final ResourceView resourceView) {
        this.reservationHolder = resourceView;
    }
    
    public void reset(@Nonnull final NPCEntity parent) {
        if (this.reservationHolder != null) {
            this.reservationHolder.clearReservation(parent.getReference());
            Blackboard.LOGGER.at(Level.FINE).log("Entity %s cleared reservation at %s", parent.getRoleName(), this.position);
        }
        this.reservationHolder = null;
        this.position.assign(Vector3d.MIN);
        this.chunkChangeRevision = -1;
        this.foundBlockType = Integer.MIN_VALUE;
    }
    
    public boolean isActive() {
        return this.foundBlockType >= 0;
    }
}
