[Anti XRay] Don't trigger updates on the clicked block - fixes block lag caused when mining ores quickly.

This commit is contained in:
md_5 2013-07-15 14:14:45 +10:00
parent e881f8990f
commit a144cc905b

View File

@ -1,4 +1,4 @@
From 68276a3d08af1b9ebe3cc824c77ff7216c10cf35 Mon Sep 17 00:00:00 2001 From c436351acab50d84569551262783648c617ad71e Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au> From: md_5 <md_5@live.com.au>
Date: Thu, 16 May 2013 18:51:05 +1000 Date: Thu, 16 May 2013 18:51:05 +1000
Subject: [PATCH] Orebfuscator Subject: [PATCH] Orebfuscator
@ -108,7 +108,7 @@ index a7afa55..1a60229 100644
diff --git a/src/main/java/org/spigotmc/AntiXray.java b/src/main/java/org/spigotmc/AntiXray.java diff --git a/src/main/java/org/spigotmc/AntiXray.java b/src/main/java/org/spigotmc/AntiXray.java
new file mode 100644 new file mode 100644
index 0000000..48c8a99 index 0000000..c165304
--- /dev/null --- /dev/null
+++ b/src/main/java/org/spigotmc/AntiXray.java +++ b/src/main/java/org/spigotmc/AntiXray.java
@@ -0,0 +1,204 @@ @@ -0,0 +1,204 @@
@ -167,7 +167,7 @@ index 0000000..48c8a99
+ if ( world.spigotConfig.antiXray ) + if ( world.spigotConfig.antiXray )
+ { + {
+ update.startTiming(); + update.startTiming();
+ updateNearbyBlocks( world, x, y, z, 2 ); // 2 is the radius, we shouldn't change it as that would make it exponentially slower + updateNearbyBlocks( world, x, y, z, 2, false ); // 2 is the radius, we shouldn't change it as that would make it exponentially slower
+ update.stopTiming(); + update.stopTiming();
+ } + }
+ } + }
@ -264,7 +264,7 @@ index 0000000..48c8a99
+ } + }
+ } + }
+ +
+ private void updateNearbyBlocks(World world, int x, int y, int z, int radius) + private void updateNearbyBlocks(World world, int x, int y, int z, int radius, boolean updateSelf)
+ { + {
+ // If the block in question is loaded + // If the block in question is loaded
+ if ( world.isLoaded( x, y, z ) ) + if ( world.isLoaded( x, y, z ) )
@ -273,7 +273,7 @@ index 0000000..48c8a99
+ int id = world.getTypeId( x, y, z ); + int id = world.getTypeId( x, y, z );
+ +
+ // See if it needs update + // See if it needs update
+ if ( obfuscateBlocks[id] ) + if ( updateSelf && obfuscateBlocks[id] )
+ { + {
+ // Send the update + // Send the update
+ world.notify( x, y, z ); + world.notify( x, y, z );
@ -282,12 +282,12 @@ index 0000000..48c8a99
+ // Check other blocks for updates + // Check other blocks for updates
+ if ( radius > 0 ) + if ( radius > 0 )
+ { + {
+ updateNearbyBlocks( world, x + 1, y, z, radius - 1 ); + updateNearbyBlocks( world, x + 1, y, z, radius - 1, true );
+ updateNearbyBlocks( world, x - 1, y, z, radius - 1 ); + updateNearbyBlocks( world, x - 1, y, z, radius - 1, true );
+ updateNearbyBlocks( world, x, y + 1, z, radius - 1 ); + updateNearbyBlocks( world, x, y + 1, z, radius - 1, true );
+ updateNearbyBlocks( world, x, y - 1, z, radius - 1 ); + updateNearbyBlocks( world, x, y - 1, z, radius - 1, true );
+ updateNearbyBlocks( world, x, y, z + 1, radius - 1 ); + updateNearbyBlocks( world, x, y, z + 1, radius - 1, true );
+ updateNearbyBlocks( world, x, y, z - 1, radius - 1 ); + updateNearbyBlocks( world, x, y, z - 1, radius - 1, true );
+ } + }
+ } + }
+ } + }