mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
Add API to get exact interaction point in PlayerInteractEvent
This commit is contained in:
parent
4c5a75dc4e
commit
f3d8fe46e3
1 changed files with 18 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
package org.bukkit.event.player;
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
|
@ -234,13 +235,30 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
|
||||||
* <p>
|
* <p>
|
||||||
* All vector components are between 0.0 and 1.0 inclusive.
|
* All vector components are between 0.0 and 1.0 inclusive.
|
||||||
*
|
*
|
||||||
|
* @deprecated misleading, use {@link #getInteractionPoint()}
|
||||||
* @return the clicked position. May be null.
|
* @return the clicked position. May be null.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@Deprecated // Paper
|
||||||
public Vector getClickedPosition() {
|
public Vector getClickedPosition() {
|
||||||
return clickedPosistion;
|
return clickedPosistion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Paper start
|
||||||
|
/**
|
||||||
|
* The exact point at which the interaction occurred. May be null.
|
||||||
|
*
|
||||||
|
* @return the exact interaction point. May be null.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Location getInteractionPoint() {
|
||||||
|
if (this.blockClicked == null || this.clickedPosistion == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.blockClicked.getLocation().add(this.clickedPosistion);
|
||||||
|
}
|
||||||
|
// Paper end
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
|
Loading…
Reference in a new issue