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 ayj, final InteractionHand ajk, final BlockHitResult cvg) {
        this(ayj.level, ayj, ajk, ayj.getItemInHand(ajk), cvg);
    }
    
    protected UseOnContext(final Level bjw, @Nullable final Player ayj, final InteractionHand ajk, final ItemStack ben, final BlockHitResult cvg) {
        this.player = ayj;
        this.hand = ajk;
        this.hitResult = cvg;
        this.itemStack = ben;
        this.level = bjw;
    }
    
    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;
    }
}
