From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nassim Jahnke <nassim@njahnke.dev>
Date: Wed, 8 Jun 2022 10:52:18 +0200
Subject: [PATCH] Move range check for block placing up


diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 3737b9c62d8d1820041e49e4ec75a61fcfbcf10b..7a7ce8bf83f02fc17e68fe4468d80f79490c9daa 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1833,6 +1833,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
         ItemStack itemstack = this.player.getItemInHand(enumhand);
         BlockHitResult movingobjectpositionblock = packet.getHitResult();
         Vec3 vec3d = movingobjectpositionblock.getLocation();
+        // Paper start - improve distance check
+        if (!Double.isFinite(vec3d.x) || !Double.isFinite(vec3d.y) || !Double.isFinite(vec3d.z)) {
+            return;
+        }
+        // Paper end
         BlockPos blockposition = movingobjectpositionblock.getBlockPos();
         Vec3 vec3d1 = Vec3.atCenterOf(blockposition);
 
