2014-03-23 01:06:43 +01:00
|
|
|
From 709f06163f0640d423ef0a76b7a045a1eb7aeda7 Mon Sep 17 00:00:00 2001
|
2013-03-23 00:58:55 +01:00
|
|
|
From: md_5 <md_5@live.com.au>
|
2013-05-16 10:51:25 +02:00
|
|
|
Date: Thu, 16 May 2013 18:51:05 +1000
|
2013-05-16 10:10:23 +02:00
|
|
|
Subject: [PATCH] Orebfuscator
|
2013-01-21 07:00:31 +01:00
|
|
|
|
|
|
|
|
2013-02-20 01:58:31 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
2014-03-23 01:06:43 +01:00
|
|
|
index bc51217..8335e89 100644
|
2013-02-20 01:58:31 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
2013-07-02 05:03:56 +02:00
|
|
|
@@ -86,6 +86,7 @@ public class EntityFallingBlock extends Entity {
|
2013-03-15 22:35:56 +01:00
|
|
|
}
|
2013-02-20 01:58:31 +01:00
|
|
|
|
2013-03-15 22:35:56 +01:00
|
|
|
this.world.setAir(i, j, k);
|
2013-06-20 10:52:23 +02:00
|
|
|
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
|
2013-02-20 01:58:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.onGround) {
|
2013-09-30 13:54:44 +02:00
|
|
|
@@ -101,6 +102,7 @@ public class EntityFallingBlock extends Entity {
|
|
|
|
}
|
2013-12-01 04:40:53 +01:00
|
|
|
this.world.setTypeAndData(i, j, k, this.id, this.data, 3);
|
2013-09-30 13:54:44 +02:00
|
|
|
// CraftBukkit end
|
|
|
|
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
|
|
|
|
|
2013-12-01 04:40:53 +01:00
|
|
|
if (this.id instanceof BlockFalling) {
|
|
|
|
((BlockFalling) this.id).a(this.world, i, j, k, this.data);
|
2013-01-21 07:00:31 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
|
2014-03-23 01:06:43 +01:00
|
|
|
index d6ac728..229b296 100644
|
2013-01-21 07:00:31 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/Explosion.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Explosion.java
|
2013-12-01 04:40:53 +01:00
|
|
|
@@ -239,6 +239,7 @@ public class Explosion {
|
2013-01-21 07:00:31 +01:00
|
|
|
j = chunkposition.y;
|
|
|
|
k = chunkposition.z;
|
2013-12-01 04:40:53 +01:00
|
|
|
block = this.world.getType(i, j, k);
|
2013-06-20 10:52:23 +02:00
|
|
|
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
|
2013-01-21 07:00:31 +01:00
|
|
|
if (flag) {
|
|
|
|
double d0 = (double) ((float) i + this.world.random.nextFloat());
|
|
|
|
double d1 = (double) ((float) j + this.world.random.nextFloat());
|
2013-12-01 07:12:38 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
2014-02-04 07:24:18 +01:00
|
|
|
index 09b34e9..3006712 100644
|
2013-12-01 07:12:38 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
|
|
|
@@ -28,6 +28,7 @@ public class PacketPlayOutMapChunk extends Packet {
|
|
|
|
|
|
|
|
this.d = chunkmap.c;
|
|
|
|
this.c = chunkmap.b;
|
2014-02-04 07:24:18 +01:00
|
|
|
+ chunk.world.spigotConfig.antiXrayInstance.obfuscateSync(chunk.locX, chunk.locZ, i, chunkmap.a, chunk.world); // Spigot
|
2013-12-01 07:12:38 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
this.buffer = chunkmap.a;
|
2013-12-01 04:40:53 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java
|
2014-02-04 07:24:18 +01:00
|
|
|
index bf3a139..30bf8a7 100644
|
2013-12-01 04:40:53 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunkBulk.java
|
2014-02-04 07:24:18 +01:00
|
|
|
@@ -26,6 +26,7 @@ public class PacketPlayOutMapChunkBulk extends Packet {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
// CraftBukkit end
|
|
|
|
+ private World world; // Spigot
|
|
|
|
|
|
|
|
public PacketPlayOutMapChunkBulk() {}
|
|
|
|
|
|
|
|
@@ -44,6 +45,9 @@ public class PacketPlayOutMapChunkBulk extends Packet {
|
2013-01-21 07:00:31 +01:00
|
|
|
Chunk chunk = (Chunk) list.get(k);
|
2013-12-01 04:40:53 +01:00
|
|
|
ChunkMap chunkmap = PacketPlayOutMapChunk.a(chunk, true, '\uffff');
|
2013-01-21 07:00:31 +01:00
|
|
|
|
2014-02-04 07:24:18 +01:00
|
|
|
+ // Spigot start
|
|
|
|
+ world = chunk.world;
|
|
|
|
+ /*
|
2013-01-21 07:00:31 +01:00
|
|
|
if (buildBuffer.length < j + chunkmap.a.length) {
|
|
|
|
byte[] abyte = new byte[j + chunkmap.a.length];
|
2014-02-04 07:24:18 +01:00
|
|
|
|
|
|
|
@@ -52,6 +56,8 @@ public class PacketPlayOutMapChunkBulk extends Packet {
|
|
|
|
}
|
|
|
|
|
|
|
|
System.arraycopy(chunkmap.a, 0, buildBuffer, j, chunkmap.a.length);
|
|
|
|
+ */
|
|
|
|
+ // Spigot end
|
|
|
|
j += chunkmap.a.length;
|
|
|
|
this.a[k] = chunk.locX;
|
|
|
|
this.b[k] = chunk.locZ;
|
|
|
|
@@ -79,6 +85,22 @@ public class PacketPlayOutMapChunkBulk extends Packet {
|
|
|
|
if (this.buffer != null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
+ // Spigot start
|
|
|
|
+ int finalBufferSize = 0;
|
|
|
|
+ // Obfuscate all sections
|
|
|
|
+ for (int i = 0; i < a.length; i++) {
|
|
|
|
+ world.spigotConfig.antiXrayInstance.obfuscate(a[i], b[i], c[i], inflatedBuffers[i], world);
|
|
|
|
+ finalBufferSize += inflatedBuffers[i].length;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Now it's time to efficiently copy the chunk to the build buffer
|
|
|
|
+ buildBuffer = new byte[finalBufferSize];
|
|
|
|
+ int bufferLocation = 0;
|
|
|
|
+ for (int i = 0; i < a.length; i++) {
|
|
|
|
+ System.arraycopy(inflatedBuffers[i], 0, buildBuffer, bufferLocation, inflatedBuffers[i].length);
|
|
|
|
+ bufferLocation += inflatedBuffers[i].length;
|
|
|
|
+ }
|
|
|
|
+ // Spigot end
|
|
|
|
|
|
|
|
Deflater deflater = localDeflater.get();
|
|
|
|
deflater.reset();
|
2013-01-21 07:00:31 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
2014-03-23 01:06:43 +01:00
|
|
|
index 2db45ad..97fe53c 100644
|
2013-01-21 07:00:31 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
2013-12-01 04:40:53 +01:00
|
|
|
@@ -173,6 +173,7 @@ public class PlayerInteractManager {
|
|
|
|
this.o = i1;
|
2013-01-21 07:00:31 +01:00
|
|
|
}
|
|
|
|
}
|
2013-06-20 10:52:23 +02:00
|
|
|
+ world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, i, j, k); // Spigot
|
2013-01-21 07:00:31 +01:00
|
|
|
}
|
2013-05-16 10:10:23 +02:00
|
|
|
}
|
2013-01-21 07:00:31 +01:00
|
|
|
|
2013-11-27 12:01:50 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2014-03-23 01:06:43 +01:00
|
|
|
index 835baf5..7e2c574 100644
|
2013-11-27 12:01:50 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2014-03-23 01:06:43 +01:00
|
|
|
@@ -470,6 +470,7 @@ public abstract class World implements IBlockAccess {
|
2013-12-01 04:40:53 +01:00
|
|
|
this.e(i, j + 1, k, block);
|
|
|
|
this.e(i, j, k - 1, block);
|
|
|
|
this.e(i, j, k + 1, block);
|
2013-11-27 12:01:50 +01:00
|
|
|
+ spigotConfig.antiXrayInstance.updateNearbyBlocks(this, i, j, k); // Spigot
|
|
|
|
}
|
|
|
|
|
2013-12-01 04:40:53 +01:00
|
|
|
public void b(int i, int j, int k, Block block, int l) {
|
2013-06-20 10:52:23 +02:00
|
|
|
diff --git a/src/main/java/org/spigotmc/AntiXray.java b/src/main/java/org/spigotmc/AntiXray.java
|
2013-01-21 07:00:31 +01:00
|
|
|
new file mode 100644
|
2014-02-05 22:40:15 +01:00
|
|
|
index 0000000..3853903
|
2013-01-21 07:00:31 +01:00
|
|
|
--- /dev/null
|
2013-06-20 10:52:23 +02:00
|
|
|
+++ b/src/main/java/org/spigotmc/AntiXray.java
|
2014-02-05 22:40:15 +01:00
|
|
|
@@ -0,0 +1,202 @@
|
2013-03-23 00:58:55 +01:00
|
|
|
+package org.spigotmc;
|
2013-01-21 07:00:31 +01:00
|
|
|
+
|
2013-07-28 13:47:45 +02:00
|
|
|
+import gnu.trove.set.TByteSet;
|
|
|
|
+import gnu.trove.set.hash.TByteHashSet;
|
2013-01-21 07:00:31 +01:00
|
|
|
+import net.minecraft.server.Block;
|
|
|
|
+import net.minecraft.server.World;
|
|
|
|
+
|
2013-06-20 10:52:23 +02:00
|
|
|
+public class AntiXray
|
2013-05-16 11:21:46 +02:00
|
|
|
+{
|
2013-01-21 07:00:31 +01:00
|
|
|
+
|
2013-05-16 11:21:46 +02:00
|
|
|
+ private static final CustomTimingsHandler update = new CustomTimingsHandler( "xray - update" );
|
|
|
|
+ private static final CustomTimingsHandler obfuscate = new CustomTimingsHandler( "xray - obfuscate" );
|
2013-05-16 10:51:25 +02:00
|
|
|
+ /*========================================================================*/
|
2013-01-21 07:00:31 +01:00
|
|
|
+ // Used to keep track of which blocks to obfuscate
|
2013-06-20 10:52:23 +02:00
|
|
|
+ private final boolean[] obfuscateBlocks = new boolean[ Short.MAX_VALUE ];
|
2013-07-28 13:47:45 +02:00
|
|
|
+ // Used to select a random replacement ore
|
2013-12-13 01:28:47 +01:00
|
|
|
+ private final byte[] replacementOres;
|
2013-01-21 07:00:31 +01:00
|
|
|
+
|
2013-06-20 10:52:23 +02:00
|
|
|
+ public AntiXray(SpigotWorldConfig config)
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2013-05-16 10:51:25 +02:00
|
|
|
+ // Set all listed blocks as true to be obfuscated
|
2013-12-13 01:28:47 +01:00
|
|
|
+ for ( int id : ( config.engineMode == 1 ) ? config.hiddenBlocks : config.replaceBlocks )
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2013-03-23 00:58:55 +01:00
|
|
|
+ obfuscateBlocks[id] = true;
|
|
|
|
+ }
|
2013-07-28 13:47:45 +02:00
|
|
|
+
|
|
|
|
+ // For every block
|
|
|
|
+ TByteSet blocks = new TByteHashSet();
|
2013-12-13 01:28:47 +01:00
|
|
|
+ for ( Integer i : config.hiddenBlocks )
|
2013-07-28 07:58:10 +02:00
|
|
|
+ {
|
2013-12-13 01:28:47 +01:00
|
|
|
+ Block block = Block.e( i );
|
|
|
|
+ // Check it exists and is not a tile entity
|
2014-02-04 07:24:18 +01:00
|
|
|
+ if ( block != null && !block.isTileEntity() )
|
2013-07-28 13:47:45 +02:00
|
|
|
+ {
|
2014-02-04 07:24:18 +01:00
|
|
|
+ // Add it to the set of replacement blocks
|
|
|
|
+ blocks.add( (byte) (int) i );
|
2013-07-28 13:47:45 +02:00
|
|
|
+ }
|
2013-07-28 07:58:10 +02:00
|
|
|
+ }
|
2013-07-28 13:47:45 +02:00
|
|
|
+ // Bake it to a flat array of replacements
|
|
|
|
+ replacementOres = blocks.toArray();
|
2013-01-21 07:00:31 +01:00
|
|
|
+ }
|
|
|
|
+
|
2013-05-16 10:51:25 +02:00
|
|
|
+ /**
|
|
|
|
+ * Starts the timings handler, then updates all blocks within the set radius
|
|
|
|
+ * of the given coordinate, revealing them if they are hidden ores.
|
|
|
|
+ */
|
2013-06-20 10:52:23 +02:00
|
|
|
+ public void updateNearbyBlocks(World world, int x, int y, int z)
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2013-06-20 10:52:23 +02:00
|
|
|
+ if ( world.spigotConfig.antiXray )
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2013-05-16 10:51:25 +02:00
|
|
|
+ update.startTiming();
|
2013-07-15 06:14:45 +02:00
|
|
|
+ updateNearbyBlocks( world, x, y, z, 2, false ); // 2 is the radius, we shouldn't change it as that would make it exponentially slower
|
2013-05-16 10:51:25 +02:00
|
|
|
+ update.stopTiming();
|
|
|
|
+ }
|
2013-02-16 00:13:00 +01:00
|
|
|
+ }
|
|
|
|
+
|
2013-05-16 10:51:25 +02:00
|
|
|
+ /**
|
2014-02-04 07:24:18 +01:00
|
|
|
+ * Starts the timings handler, and then removes all non exposed ores from
|
|
|
|
+ * the chunk buffer.
|
|
|
|
+ */
|
|
|
|
+ public void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
|
|
|
|
+ {
|
|
|
|
+ if ( world.spigotConfig.antiXray )
|
|
|
|
+ {
|
|
|
|
+ obfuscate.startTiming();
|
|
|
|
+ obfuscate( chunkX, chunkY, bitmask, buffer, world );
|
|
|
|
+ obfuscate.stopTiming();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
2013-05-16 10:51:25 +02:00
|
|
|
+ * Removes all non exposed ores from the chunk buffer.
|
|
|
|
+ */
|
2014-02-04 07:24:18 +01:00
|
|
|
+ public void obfuscate(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2013-05-16 10:51:25 +02:00
|
|
|
+ // If the world is marked as obfuscated
|
2013-06-20 10:52:23 +02:00
|
|
|
+ if ( world.spigotConfig.antiXray )
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2013-06-03 09:51:31 +02:00
|
|
|
+ // Initial radius to search around for air
|
|
|
|
+ int initialRadius = 1;
|
2013-05-16 10:51:25 +02:00
|
|
|
+ // Which block in the buffer we are looking at, anywhere from 0 to 16^4
|
2013-01-21 07:00:31 +01:00
|
|
|
+ int index = 0;
|
2013-05-16 10:51:25 +02:00
|
|
|
+ // The iterator marking which random ore we should use next
|
|
|
|
+ int randomOre = 0;
|
|
|
|
+
|
|
|
|
+ // Chunk corner X and Z blocks
|
2013-01-21 07:00:31 +01:00
|
|
|
+ int startX = chunkX << 4;
|
2014-02-04 07:24:18 +01:00
|
|
|
+ int startZ = chunkY << 4;
|
2013-05-16 10:51:25 +02:00
|
|
|
+
|
|
|
|
+ // Chunks can have up to 16 sections
|
2013-05-16 11:21:46 +02:00
|
|
|
+ for ( int i = 0; i < 16; i++ )
|
|
|
|
+ {
|
2013-01-21 07:00:31 +01:00
|
|
|
+ // If the bitmask indicates this chunk is sent...
|
2013-05-16 11:21:46 +02:00
|
|
|
+ if ( ( bitmask & 1 << i ) != 0 )
|
|
|
|
+ {
|
2013-05-16 10:51:25 +02:00
|
|
|
+ // Work through all blocks in the chunk, y,z,x
|
2013-05-16 11:21:46 +02:00
|
|
|
+ for ( int y = 0; y < 16; y++ )
|
|
|
|
+ {
|
|
|
|
+ for ( int z = 0; z < 16; z++ )
|
|
|
|
+ {
|
|
|
|
+ for ( int x = 0; x < 16; x++ )
|
|
|
|
+ {
|
2013-07-04 04:09:15 +02:00
|
|
|
+ // For some reason we can get too far ahead of ourselves (concurrent modification on bulk chunks?) so if we do, just abort and move on
|
|
|
|
+ if ( index >= buffer.length )
|
|
|
|
+ {
|
2014-02-05 22:40:15 +01:00
|
|
|
+ index++;
|
2013-07-04 04:09:15 +02:00
|
|
|
+ continue;
|
|
|
|
+ }
|
2013-05-16 10:51:25 +02:00
|
|
|
+ // Grab the block ID in the buffer.
|
|
|
|
+ // TODO: extended IDs are not yet supported
|
|
|
|
+ int blockId = buffer[index] & 0xFF;
|
|
|
|
+ // Check if the block should be obfuscated
|
2013-07-28 13:47:45 +02:00
|
|
|
+ if ( obfuscateBlocks[blockId] )
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2014-02-05 22:40:15 +01:00
|
|
|
+ // The world isn't loaded, bail out
|
|
|
|
+ if ( !isLoaded( world, startX + x, ( i << 4 ) + y, startZ + z, initialRadius ) )
|
2013-06-03 09:51:31 +02:00
|
|
|
+ {
|
2014-02-05 22:40:15 +01:00
|
|
|
+ index++;
|
2013-06-03 09:51:31 +02:00
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // On the otherhand, if radius is 0, or the nearby blocks are all non air, we can obfuscate
|
2014-02-05 22:40:15 +01:00
|
|
|
+ if ( !hasTransparentBlockAdjacent( world, startX + x, ( i << 4 ) + y, startZ + z, initialRadius ) )
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2013-06-20 10:52:23 +02:00
|
|
|
+ switch ( world.spigotConfig.engineMode )
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2013-05-16 10:51:25 +02:00
|
|
|
+ case 1:
|
2013-02-16 00:13:00 +01:00
|
|
|
+ // Replace with stone
|
2013-12-01 05:36:32 +01:00
|
|
|
+ buffer[index] = 1;
|
2013-05-16 10:51:25 +02:00
|
|
|
+ break;
|
|
|
|
+ case 2:
|
2013-07-28 13:47:45 +02:00
|
|
|
+ // Replace with random ore.
|
|
|
|
+ if ( randomOre >= replacementOres.length )
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2013-07-28 07:58:10 +02:00
|
|
|
+ randomOre = 0;
|
2013-05-16 10:51:25 +02:00
|
|
|
+ }
|
2013-07-28 13:47:45 +02:00
|
|
|
+ buffer[index] = replacementOres[randomOre++];
|
2013-05-16 10:51:25 +02:00
|
|
|
+ break;
|
2013-02-16 00:13:00 +01:00
|
|
|
+ }
|
2013-01-21 07:00:31 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
2013-05-16 10:51:25 +02:00
|
|
|
+
|
2013-07-04 04:09:15 +02:00
|
|
|
+ index++;
|
2013-01-21 07:00:31 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2013-07-15 06:14:45 +02:00
|
|
|
+ private void updateNearbyBlocks(World world, int x, int y, int z, int radius, boolean updateSelf)
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2013-05-16 10:51:25 +02:00
|
|
|
+ // If the block in question is loaded
|
2013-05-16 11:21:46 +02:00
|
|
|
+ if ( world.isLoaded( x, y, z ) )
|
|
|
|
+ {
|
2013-01-21 07:00:31 +01:00
|
|
|
+ // Get block id
|
2014-02-04 07:24:18 +01:00
|
|
|
+ Block block = world.getType(x, y, z);
|
2013-01-21 07:00:31 +01:00
|
|
|
+
|
|
|
|
+ // See if it needs update
|
2014-02-04 07:24:18 +01:00
|
|
|
+ if ( updateSelf && obfuscateBlocks[Block.b(block)] )
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2013-01-21 07:00:31 +01:00
|
|
|
+ // Send the update
|
2013-05-16 11:21:46 +02:00
|
|
|
+ world.notify( x, y, z );
|
2013-01-21 07:51:34 +01:00
|
|
|
+ }
|
2013-01-21 07:00:31 +01:00
|
|
|
+
|
2013-01-21 07:51:34 +01:00
|
|
|
+ // Check other blocks for updates
|
2013-05-16 11:34:00 +02:00
|
|
|
+ if ( radius > 0 )
|
2013-05-16 11:21:46 +02:00
|
|
|
+ {
|
2013-07-15 06:14:45 +02:00
|
|
|
+ updateNearbyBlocks( world, x + 1, y, z, radius - 1, true );
|
|
|
|
+ updateNearbyBlocks( world, x - 1, y, z, radius - 1, true );
|
|
|
|
+ updateNearbyBlocks( world, x, y + 1, z, radius - 1, true );
|
|
|
|
+ updateNearbyBlocks( world, x, y - 1, z, radius - 1, true );
|
|
|
|
+ updateNearbyBlocks( world, x, y, z + 1, radius - 1, true );
|
|
|
|
+ updateNearbyBlocks( world, x, y, z - 1, radius - 1, true );
|
2013-01-21 07:00:31 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2013-05-16 10:10:23 +02:00
|
|
|
+
|
2013-06-03 09:51:31 +02:00
|
|
|
+ private static boolean isLoaded(World world, int x, int y, int z, int radius)
|
|
|
|
+ {
|
|
|
|
+ return world.isLoaded( x, y, z )
|
2014-02-05 22:40:15 +01:00
|
|
|
+ && ( radius == 0 ||
|
|
|
|
+ ( isLoaded( world, x + 1, y, z, radius - 1 )
|
|
|
|
+ && isLoaded( world, x - 1, y, z, radius - 1 )
|
|
|
|
+ && isLoaded( world, x, y + 1, z, radius - 1 )
|
|
|
|
+ && isLoaded( world, x, y - 1, z, radius - 1 )
|
|
|
|
+ && isLoaded( world, x, y, z + 1, radius - 1 )
|
|
|
|
+ && isLoaded( world, x, y, z - 1, radius - 1 ) ) );
|
2013-06-03 09:51:31 +02:00
|
|
|
+ }
|
|
|
|
+
|
2013-05-16 11:21:46 +02:00
|
|
|
+ private static boolean hasTransparentBlockAdjacent(World world, int x, int y, int z, int radius)
|
|
|
|
+ {
|
2014-02-04 07:24:18 +01:00
|
|
|
+ return !world.getType(x, y, z).r() /* isSolidBlock */
|
2013-05-16 12:05:02 +02:00
|
|
|
+ || ( radius > 0
|
|
|
|
+ && ( hasTransparentBlockAdjacent( world, x + 1, y, z, radius - 1 )
|
|
|
|
+ || hasTransparentBlockAdjacent( world, x - 1, y, z, radius - 1 )
|
|
|
|
+ || hasTransparentBlockAdjacent( world, x, y + 1, z, radius - 1 )
|
|
|
|
+ || hasTransparentBlockAdjacent( world, x, y - 1, z, radius - 1 )
|
|
|
|
+ || hasTransparentBlockAdjacent( world, x, y, z + 1, radius - 1 )
|
|
|
|
+ || hasTransparentBlockAdjacent( world, x, y, z - 1, radius - 1 ) ) );
|
2013-01-21 07:00:31 +01:00
|
|
|
+ }
|
|
|
|
+}
|
2013-06-20 10:52:23 +02:00
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2014-03-09 22:37:28 +01:00
|
|
|
index 2ec047c..2c0501d 100644
|
2013-06-20 10:52:23 +02:00
|
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2013-07-28 13:47:45 +02:00
|
|
|
@@ -1,5 +1,6 @@
|
2013-06-20 10:52:23 +02:00
|
|
|
package org.spigotmc;
|
|
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
2014-01-14 09:16:43 +01:00
|
|
|
@@ -210,4 +211,36 @@ public class SpigotWorldConfig
|
2013-12-13 01:10:33 +01:00
|
|
|
arrowDespawnRate = getInt( "arrow-despawn-rate", 1200 );
|
|
|
|
log( "Arrow Despawn Rate: " + arrowDespawnRate );
|
2013-06-20 10:52:23 +02:00
|
|
|
}
|
2013-12-13 01:10:33 +01:00
|
|
|
+
|
2013-12-13 01:28:47 +01:00
|
|
|
+ public boolean antiXray;
|
|
|
|
+ public int engineMode;
|
|
|
|
+ public List<Integer> hiddenBlocks;
|
|
|
|
+ public List<Integer> replaceBlocks;
|
2013-06-20 10:52:23 +02:00
|
|
|
+ public AntiXray antiXrayInstance;
|
|
|
|
+ private void antiXray()
|
|
|
|
+ {
|
2013-12-13 01:28:47 +01:00
|
|
|
+ antiXray = getBoolean( "anti-xray.enabled", true );
|
2013-06-20 10:52:23 +02:00
|
|
|
+ log( "Anti X-Ray: " + antiXray );
|
|
|
|
+
|
2013-12-13 01:28:47 +01:00
|
|
|
+ engineMode = getInt( "anti-xray.engine-mode", 1 );
|
2013-06-20 10:52:23 +02:00
|
|
|
+ log( "\tEngine Mode: " + engineMode );
|
|
|
|
+
|
2013-12-13 01:28:47 +01:00
|
|
|
+ if ( SpigotConfig.version < 5 )
|
2013-07-13 03:37:21 +02:00
|
|
|
+ {
|
2013-12-13 01:28:47 +01:00
|
|
|
+ set( "anti-xray.blocks", null );
|
2013-07-13 03:37:21 +02:00
|
|
|
+ }
|
2013-12-13 01:28:47 +01:00
|
|
|
+ hiddenBlocks = getList( "anti-xray.hide-blocks", Arrays.asList( new Integer[]
|
|
|
|
+ {
|
|
|
|
+ 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130
|
|
|
|
+ } ) );
|
|
|
|
+ log( "\tHidden Blocks: " + hiddenBlocks );
|
|
|
|
+
|
|
|
|
+ replaceBlocks = getList( "anti-xray.replace-blocks", Arrays.asList( new Integer[]
|
|
|
|
+ {
|
|
|
|
+ 1, 5
|
|
|
|
+ } ) );
|
2014-01-06 01:38:59 +01:00
|
|
|
+ log( "\tReplace Blocks: " + replaceBlocks );
|
2013-07-13 03:37:21 +02:00
|
|
|
+
|
2013-06-20 10:52:23 +02:00
|
|
|
+ antiXrayInstance = new AntiXray( this );
|
|
|
|
+ }
|
|
|
|
}
|
2013-01-21 07:00:31 +01:00
|
|
|
--
|
2014-03-23 01:06:43 +01:00
|
|
|
1.8.5.2.msysgit.0
|
2013-01-21 07:00:31 +01:00
|
|
|
|