76 lines
2.1 KiB
Java
76 lines
2.1 KiB
Java
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 ayg, final InteractionHand ajh, final BlockHitResult cvd) {
|
|
this(ayg.level, ayg, ajh, ayg.getItemInHand(ajh), cvd);
|
|
}
|
|
|
|
protected UseOnContext(final Level bjt, @Nullable final Player ayg, final InteractionHand ajh, final ItemStack bek, final BlockHitResult cvd) {
|
|
this.player = ayg;
|
|
this.hand = ajh;
|
|
this.hitResult = cvd;
|
|
this.itemStack = bek;
|
|
this.level = bjt;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|