<commit_before>--- ../src-base/minecraft/net/minecraft/server/management/PlayerInteractionManager.java
+++ ../src-work/minecraft/net/minecraft/server/management/PlayerInteractionManager.java
@@ -27,6 +27,8 @@
 
 public class PlayerInteractionManager
 {
+    /** Forge reach distance */
+    private double blockReachDistance = 5.0d;
     public World field_73092_a;
     public EntityPlayerMP field_73090_b;
     private WorldSettings.GameType field_73091_c = WorldSettings.GameType.NOT_SET;
@@ -88,7 +90,7 @@
             IBlockState iblockstate = this.field_73092_a.func_180495_p(this.field_180241_i);
             Block block = iblockstate.func_177230_c();
 
-            if (iblockstate.func_185904_a() == Material.field_151579_a)
+            if (block.isAir(iblockstate, field_73092_a, field_180241_i))
             {
                 this.field_73097_j = false;
             }
@@ -115,7 +117,7 @@
             IBlockState iblockstate1 = this.field_73092_a.func_180495_p(this.field_180240_f);
             Block block1 = iblockstate1.func_177230_c();
 
-            if (iblockstate1.func_185904_a() == Material.field_151579_a)
+            if (block1.isAir(iblockstate1, field_73092_a, field_180240_f))
             {
                 this.field_73092_a.func_175715_c(this.field_73090_b.func_145782_y(), this.field_180240_f, -1);
                 this.field_73094_o = -1;
@@ -124,7 +126,7 @@
             else
             {
                 int k = this.field_73100_i - this.field_73089_e;
-                float f1 = iblockstate1.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, this.field_180241_i) * (float)(k + 1);
+                float f1 = iblockstate1.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, this.field_180240_f) * (float)(k + 1); // Forge: Fix network break progress using wrong position
                 int l = (int)(f1 * 10.0F);
 
                 if (l != this.field_73094_o)
@@ -138,6 +140,14 @@
 
     public void func_180784_a(BlockPos p_180784_1_, EnumFacing p_180784_2_)
     {
+        net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_73090_b,
+                net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, field_73092_a, p_180784_1_, p_180784_2_, net.minecraftforge.common.ForgeHooks.rayTraceEyeHitVec(field_73090_b, getBlockReachDistance() + 1));
+        if (event.isCanceled())
+        {
+            field_73090_b.field_71135_a.func_147359_a(new SPacketBlockChange(field_73092_a, p_180784_1_));
+            return;
+        }
+
         if (this.func_73083_d())
         {
             if (!this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_))
@@ -173,17 +183,32 @@
                 }
             }
 
-            this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_);
             this.field_73089_e = this.field_73100_i;
             float f = 1.0F;
 
-            if (iblockstate.func_185904_a() != Material.field_151579_a)
+            if (!iblockstate.func_177230_c().isAir(iblockstate, field_73092_a, p_180784_1_))
             {
-                block.func_180649_a(this.field_73092_a, p_180784_1_, this.field_73090_b);
+                if (event.useBlock != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+                {
+                    block.func_180649_a(this.field_73092_a, p_180784_1_, this.field_73090_b);
+                    this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_);
+                }
+                else
+                { 
+                    field_73090_b.field_71135_a.func_147359_a(new SPacketBlockChange(field_73092_a, p_180784_1_));
+                }
                 f = iblockstate.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, p_180784_1_);
             }
+            if (event.useItem == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+            {
+                if (f >= 1.0F)
+                {
+                    field_73090_b.field_71135_a.func_147359_a(new SPacketBlockChange(field_73092_a, p_180784_1_));
+                }
+                return;
+            }
 
-            if (iblockstate.func_185904_a() != Material.field_151579_a && f >= 1.0F)
+            if (iblockstate.func_177230_c().isAir(iblockstate, field_73092_a, p_180784_1_) && f >= 1.0F)
             {
                 this.func_180237_b(p_180784_1_);
             }
@@ -205,7 +230,7 @@
             int i = this.field_73100_i - this.field_73089_e;
             IBlockState iblockstate = this.field_73092_a.func_180495_p(p_180785_1_);
 
-            if (iblockstate.func_185904_a() != Material.field_151579_a)
+            if (iblockstate.func_177230_c().isAir(iblockstate, field_73092_a, p_180785_1_))
             {
                 float f = iblockstate.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, p_180785_1_) * (float)(i + 1);
 
@@ -234,13 +259,18 @@
 
     private boolean func_180235_c(BlockPos p_180235_1_)
     {
-        IBlockState iblockstate = this.field_73092_a.func_180495_p(p_180235_1_);<commit_msg>Fix digging blocks in survival.<commit_after>--- ../src-base/minecraft/net/minecraft/server/management/PlayerInteractionManager.java
+++ ../src-work/minecraft/net/minecraft/server/management/PlayerInteractionManager.java
@@ -27,6 +27,8 @@
 
 public class PlayerInteractionManager
 {
+    /** Forge reach distance */
+    private double blockReachDistance = 5.0d;
     public World field_73092_a;
     public EntityPlayerMP field_73090_b;
     private WorldSettings.GameType field_73091_c = WorldSettings.GameType.NOT_SET;
@@ -88,7 +90,7 @@
             IBlockState iblockstate = this.field_73092_a.func_180495_p(this.field_180241_i);
             Block block = iblockstate.func_177230_c();
 
-            if (iblockstate.func_185904_a() == Material.field_151579_a)
+            if (block.isAir(iblockstate, field_73092_a, field_180241_i))
             {
                 this.field_73097_j = false;
             }
@@ -115,7 +117,7 @@
             IBlockState iblockstate1 = this.field_73092_a.func_180495_p(this.field_180240_f);
             Block block1 = iblockstate1.func_177230_c();
 
-            if (iblockstate1.func_185904_a() == Material.field_151579_a)
+            if (block1.isAir(iblockstate1, field_73092_a, field_180240_f))
             {
                 this.field_73092_a.func_175715_c(this.field_73090_b.func_145782_y(), this.field_180240_f, -1);
                 this.field_73094_o = -1;
@@ -124,7 +126,7 @@
             else
             {
                 int k = this.field_73100_i - this.field_73089_e;
-                float f1 = iblockstate1.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, this.field_180241_i) * (float)(k + 1);
+                float f1 = iblockstate1.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, this.field_180240_f) * (float)(k + 1); // Forge: Fix network break progress using wrong position
                 int l = (int)(f1 * 10.0F);
 
                 if (l != this.field_73094_o)
@@ -138,6 +140,14 @@
 
     public void func_180784_a(BlockPos p_180784_1_, EnumFacing p_180784_2_)
     {
+        net.minecraftforge.event.entity.player.PlayerInteractEvent event = net.minecraftforge.event.ForgeEventFactory.onPlayerInteract(field_73090_b,
+                net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, field_73092_a, p_180784_1_, p_180784_2_, net.minecraftforge.common.ForgeHooks.rayTraceEyeHitVec(field_73090_b, getBlockReachDistance() + 1));
+        if (event.isCanceled())
+        {
+            field_73090_b.field_71135_a.func_147359_a(new SPacketBlockChange(field_73092_a, p_180784_1_));
+            return;
+        }
+
         if (this.func_73083_d())
         {
             if (!this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_))
@@ -173,17 +183,32 @@
                 }
             }
 
-            this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_);
             this.field_73089_e = this.field_73100_i;
             float f = 1.0F;
 
-            if (iblockstate.func_185904_a() != Material.field_151579_a)
+            if (!iblockstate.func_177230_c().isAir(iblockstate, field_73092_a, p_180784_1_))
             {
-                block.func_180649_a(this.field_73092_a, p_180784_1_, this.field_73090_b);
+                if (event.useBlock != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+                {
+                    block.func_180649_a(this.field_73092_a, p_180784_1_, this.field_73090_b);
+                    this.field_73092_a.func_175719_a((EntityPlayer)null, p_180784_1_, p_180784_2_);
+                }
+                else
+                {
+                    field_73090_b.field_71135_a.func_147359_a(new SPacketBlockChange(field_73092_a, p_180784_1_));
+                }
                 f = iblockstate.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, p_180784_1_);
             }
+            if (event.useItem == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
+            {
+                if (f >= 1.0F)
+                {
+                    field_73090_b.field_71135_a.func_147359_a(new SPacketBlockChange(field_73092_a, p_180784_1_));
+                }
+                return;
+            }
 
-            if (iblockstate.func_185904_a() != Material.field_151579_a && f >= 1.0F)
+            if (iblockstate.func_177230_c().isAir(iblockstate, field_73092_a, p_180784_1_) && f >= 1.0F)
             {
                 this.func_180237_b(p_180784_1_);
             }
@@ -205,7 +230,7 @@
             int i = this.field_73100_i - this.field_73089_e;
             IBlockState iblockstate = this.field_73092_a.func_180495_p(p_180785_1_);
 
-            if (iblockstate.func_185904_a() != Material.field_151579_a)
+            if (!iblockstate.func_177230_c().isAir(iblockstate, field_73092_a, p_180785_1_))
             {
                 float f = iblockstate.func_185903_a(this.field_73090_b, this.field_73090_b.field_70170_p, p_180785_1_) * (float)(i + 1);
 
@@ -234,13 +259,18 @@
 
     private boolean func_180235_c(BlockPos p_180235_1_)
     {
-        IBlockState iblockstate = this.field_73092_a.func_180495_p(p_180235_1_);
{'fraction_non_alphanumeric': 0.11042944785276074, 'fraction_numerical': 0.1526073619631902, 'mean_word_length': 2.3884378044819745, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1797413', 'n_tokens_mistral': 4762, 'n_tokens_neox': 3819, 'n_words': 441}