mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Fix PlayerInteractEvent#getClickedBlock()
returning wrong block in adventure mode (#10019)
This commit is contained in:
parent
a889754d39
commit
3a2229c5f3
2 changed files with 1 additions and 6 deletions
|
@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ } else { // Paper start - Fix interact event not being called sometimes
|
||||
+ GameType gameType = this.player.gameMode.getGameModeForPlayer();
|
||||
+ if (gameType == GameType.ADVENTURE && result.getHitBlock() != null) {
|
||||
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, io.papermc.paper.util.MCUtil.toBlockPosition(result.getHitPosition()), org.bukkit.craftbukkit.block.CraftBlock.blockFaceToNotch(result.getHitBlockFace()), this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
|
||||
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, ((org.bukkit.craftbukkit.block.CraftBlock) result.getHitBlock()).getPosition(), org.bukkit.craftbukkit.block.CraftBlock.blockFaceToNotch(result.getHitBlockFace()), this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
|
||||
+ } else if (gameType != GameType.CREATIVE && result.getHitEntity() != null && origin.toVector().distanceSquared(result.getHitPosition()) > 3.0D * 3.0D) {
|
||||
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
|
||||
+ }
|
||||
|
|
|
@ -3507,7 +3507,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+import org.bukkit.block.BlockFace;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.bukkit.craftbukkit.util.Waitable;
|
||||
+import org.bukkit.util.Vector;
|
||||
+import org.spigotmc.AsyncCatcher;
|
||||
+
|
||||
+import javax.annotation.Nonnull;
|
||||
|
@ -3960,10 +3959,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ return new BlockPos(pos.blockX(), pos.blockY(), pos.blockZ());
|
||||
+ }
|
||||
+
|
||||
+ public static BlockPos toBlockPosition(Vector vec) {
|
||||
+ return new BlockPos(vec.getBlockX(), vec.getBlockY(), vec.getBlockZ());
|
||||
+ }
|
||||
+
|
||||
+ public static FinePosition toPosition(Vec3 vector) {
|
||||
+ return Position.fine(vector.x, vector.y, vector.z);
|
||||
+ }
|
||||
|
|
Loading…
Reference in a new issue