2025-11-24 22:52:51 +03:00

87 lines
2.3 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* org.jspecify.annotations.Nullable
*/
package net.minecraft.world.item.context;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import org.jspecify.annotations.Nullable;
public class UseOnContext {
private final @Nullable Player player;
private final InteractionHand hand;
private final BlockHitResult hitResult;
private final Level level;
private final ItemStack itemStack;
public UseOnContext(Player player, InteractionHand hand, BlockHitResult hitResult) {
this(player.level(), player, hand, player.getItemInHand(hand), hitResult);
}
protected UseOnContext(Level level, @Nullable Player player, InteractionHand hand, ItemStack itemStack, BlockHitResult hitResult) {
this.player = player;
this.hand = hand;
this.hitResult = hitResult;
this.itemStack = itemStack;
this.level = level;
}
protected final BlockHitResult getHitResult() {
return this.hitResult;
}
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;
}
public @Nullable 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.getYRot();
}
}