package net.minecraft.world.item;

import net.minecraft.world.phys.Vec3;
import net.minecraft.core.Direction;
import net.minecraft.core.BlockPos;
import javax.annotation.Nullable;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;

public class UseOnContext {
    protected final Player player;
    protected final InteractionHand hand;
    protected final BlockHitResult hitResult;
    protected final Level level;
    protected final ItemStack itemStack;
    
    public UseOnContext(final Player bec, final InteractionHand anf, final BlockHitResult deh) {
        this(bec.level, bec, anf, bec.getItemInHand(anf), deh);
    }
    
    protected UseOnContext(final Level bqb, @Nullable final Player bec, final InteractionHand anf, final ItemStack bki, final BlockHitResult deh) {
        this.player = bec;
        this.hand = anf;
        this.hitResult = deh;
        this.itemStack = bki;
        this.level = bqb;
    }
    
    public BlockPos getClickedPos() {
        return this.hitResult.getBlockPos();
    }
    
    public Direction getClickedFace() {
        return this.hitResult.getDirection();
    }
    
    public Vec3 getClickLocation() {
        return this.hitResult.getLocation();
    }
    
    public boolean isInside() {
        return this.hitResult.isInside();
    }
    
    public ItemStack getItemInHand() {
        return this.itemStack;
    }
    
    @Nullable
    public Player getPlayer() {
        return this.player;
    }
    
    public InteractionHand getHand() {
        return this.hand;
    }
    
    public Level getLevel() {
        return this.level;
    }
    
    public Direction getHorizontalDirection() {
        return (this.player == null) ? Direction.NORTH : this.player.getDirection();
    }
    
    public boolean isSecondaryUseActive() {
        return this.player != null && this.player.isSecondaryUseActive();
    }
    
    public float getRotation() {
        return (this.player == null) ? 0.0f : this.player.yRot;
    }
}
