2013-06-16 19:45:21 +08:00
|
|
|
From d270363d40175512df3af1f7dbbb4722d6ab684a Mon Sep 17 00:00:00 2001
|
2013-03-23 07:58:55 +08:00
|
|
|
From: md_5 <md_5@live.com.au>
|
2013-05-16 16:51:25 +08:00
|
|
|
Date: Thu, 16 May 2013 18:51:05 +1000
|
2013-05-16 16:10:23 +08:00
|
|
|
Subject: [PATCH] Orebfuscator
|
2013-01-21 14:00:31 +08:00
|
|
|
|
|
|
|
|
2013-02-20 08:58:31 +08:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
2013-05-16 16:16:30 +08:00
|
|
|
index 17d837d..d38eb4d 100644
|
2013-02-20 08:58:31 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
|
2013-03-16 05:35:56 +08:00
|
|
|
@@ -94,6 +94,7 @@ public class EntityFallingBlock extends Entity {
|
|
|
|
}
|
2013-02-20 08:58:31 +08:00
|
|
|
|
2013-03-16 05:35:56 +08:00
|
|
|
this.world.setAir(i, j, k);
|
2013-05-16 16:16:30 +08:00
|
|
|
+ org.spigotmc.OrebfuscatorManager.updateNearbyBlocks(world, i, j, k); // Spigot
|
2013-02-20 08:58:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.onGround) {
|
2013-01-21 14:00:31 +08:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
|
2013-05-16 16:16:30 +08:00
|
|
|
index ef220c1..ae1cee9 100644
|
2013-01-21 14:00:31 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/Explosion.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Explosion.java
|
|
|
|
@@ -240,6 +240,7 @@ public class Explosion {
|
|
|
|
j = chunkposition.y;
|
|
|
|
k = chunkposition.z;
|
|
|
|
l = this.world.getTypeId(i, j, k);
|
2013-05-16 16:16:30 +08:00
|
|
|
+ org.spigotmc.OrebfuscatorManager.updateNearbyBlocks(world, i, j, k); // Spigot
|
2013-01-21 14:00:31 +08:00
|
|
|
if (flag) {
|
|
|
|
double d0 = (double) ((float) i + this.world.random.nextFloat());
|
|
|
|
double d1 = (double) ((float) j + this.world.random.nextFloat());
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Packet51MapChunk.java b/src/main/java/net/minecraft/server/Packet51MapChunk.java
|
2013-05-16 16:16:30 +08:00
|
|
|
index d11c0ea..7711629 100644
|
2013-01-21 14:00:31 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/Packet51MapChunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Packet51MapChunk.java
|
2013-05-16 15:56:35 +08:00
|
|
|
@@ -46,6 +46,7 @@ public class Packet51MapChunk extends Packet {
|
2013-01-21 14:00:31 +08:00
|
|
|
|
|
|
|
this.d = chunkmap.c;
|
|
|
|
this.c = chunkmap.b;
|
2013-05-16 16:16:30 +08:00
|
|
|
+ org.spigotmc.OrebfuscatorManager.obfuscateSync(chunk.x, chunk.z, i, chunkmap.a, chunk.world); // Spigot
|
2013-05-16 15:56:35 +08:00
|
|
|
|
2013-01-21 14:00:31 +08:00
|
|
|
try {
|
|
|
|
this.inflatedBuffer = chunkmap.a;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java b/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
|
2013-05-16 16:51:25 +08:00
|
|
|
index 129dc4f..ce28495 100644
|
2013-01-21 14:00:31 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
|
|
|
|
@@ -28,6 +28,7 @@ public class Packet56MapChunkBulk extends Packet {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
// CraftBukkit end
|
2013-05-16 16:16:30 +08:00
|
|
|
+ private World world; // Spigot
|
2013-01-21 14:00:31 +08:00
|
|
|
|
|
|
|
public Packet56MapChunkBulk() {}
|
|
|
|
|
2013-05-16 16:51:25 +08:00
|
|
|
@@ -46,6 +47,9 @@ public class Packet56MapChunkBulk extends Packet {
|
2013-01-21 14:00:31 +08:00
|
|
|
Chunk chunk = (Chunk) list.get(k);
|
|
|
|
ChunkMap chunkmap = Packet51MapChunk.a(chunk, true, '\uffff');
|
|
|
|
|
2013-05-16 16:16:30 +08:00
|
|
|
+ // Spigot start
|
|
|
|
+ world = chunk.world;
|
|
|
|
+ /*
|
2013-01-21 14:00:31 +08:00
|
|
|
if (buildBuffer.length < j + chunkmap.a.length) {
|
|
|
|
byte[] abyte = new byte[j + chunkmap.a.length];
|
|
|
|
|
2013-05-16 16:51:25 +08:00
|
|
|
@@ -54,6 +58,8 @@ public class Packet56MapChunkBulk extends Packet {
|
2013-01-21 14:00:31 +08:00
|
|
|
}
|
|
|
|
|
2013-05-16 16:16:30 +08:00
|
|
|
System.arraycopy(chunkmap.a, 0, buildBuffer, j, chunkmap.a.length);
|
2013-05-16 16:51:25 +08:00
|
|
|
+ */
|
|
|
|
+ // Spigot end
|
2013-01-21 14:00:31 +08:00
|
|
|
j += chunkmap.a.length;
|
2013-05-16 16:51:25 +08:00
|
|
|
this.c[k] = chunk.x;
|
|
|
|
this.d[k] = chunk.z;
|
2013-05-16 16:16:30 +08:00
|
|
|
@@ -81,6 +87,22 @@ public class Packet56MapChunkBulk extends Packet {
|
|
|
|
if (this.buffer != null) {
|
2013-01-21 14:00:31 +08:00
|
|
|
return;
|
|
|
|
}
|
2013-05-16 16:16:30 +08:00
|
|
|
+ // Spigot start
|
2013-01-21 14:00:31 +08:00
|
|
|
+ int finalBufferSize = 0;
|
2013-05-16 16:16:30 +08:00
|
|
|
+ // Obfuscate all sections
|
2013-01-21 14:00:31 +08:00
|
|
|
+ for (int i = 0; i < a.length; i++) {
|
2013-03-23 07:58:55 +08:00
|
|
|
+ org.spigotmc.OrebfuscatorManager.obfuscate(c[i], d[i], a[i], inflatedBuffers[i], world);
|
2013-01-21 14:00:31 +08:00
|
|
|
+ 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;
|
|
|
|
+ }
|
2013-05-16 16:16:30 +08:00
|
|
|
+ // Spigot end
|
|
|
|
|
2013-01-21 14:00:31 +08:00
|
|
|
Deflater deflater = localDeflater.get();
|
|
|
|
deflater.reset();
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
2013-05-16 16:10:23 +08:00
|
|
|
index 1243d1d..e45bcd2 100644
|
2013-01-21 14:00:31 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
2013-05-16 16:10:23 +08:00
|
|
|
@@ -184,6 +184,7 @@ public class PlayerInteractManager {
|
|
|
|
this.o = j1;
|
2013-01-21 14:00:31 +08:00
|
|
|
}
|
|
|
|
}
|
2013-05-16 16:10:23 +08:00
|
|
|
+ org.spigotmc.OrebfuscatorManager.updateNearbyBlocks(world, i, j, k); // Spigot
|
2013-01-21 14:00:31 +08:00
|
|
|
}
|
2013-05-16 16:10:23 +08:00
|
|
|
}
|
2013-01-21 14:00:31 +08:00
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2013-06-15 20:01:15 +08:00
|
|
|
index c234cac..82dfef1 100644
|
2013-01-21 14:00:31 +08:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2013-05-16 16:10:23 +08:00
|
|
|
@@ -163,6 +163,12 @@ public final class CraftServer implements Server {
|
2013-01-21 14:00:31 +08:00
|
|
|
private final BooleanWrapper online = new BooleanWrapper();
|
2013-04-04 19:08:00 +08:00
|
|
|
public CraftScoreboardManager scoreboardManager;
|
2013-01-21 14:00:31 +08:00
|
|
|
|
|
|
|
+ // Orebfuscator use
|
|
|
|
+ public boolean orebfuscatorEnabled = false;
|
2013-02-16 07:13:00 +08:00
|
|
|
+ public int orebfuscatorEngineMode = 1;
|
2013-01-21 14:00:31 +08:00
|
|
|
+ public List<String> orebfuscatorDisabledWorlds;
|
2013-03-23 07:58:55 +08:00
|
|
|
+ public List<Short> orebfuscatorBlocks;
|
2013-01-21 14:00:31 +08:00
|
|
|
+
|
|
|
|
private final class BooleanWrapper {
|
|
|
|
private boolean value = true;
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2013-06-15 20:01:15 +08:00
|
|
|
index 4d022bd..0a39ed3 100644
|
2013-01-21 14:00:31 +08:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2013-06-11 11:14:01 +08:00
|
|
|
@@ -84,6 +84,7 @@ public class CraftWorld implements World {
|
2013-03-23 06:48:22 +08:00
|
|
|
public double itemMergeRadius = 3.5;
|
|
|
|
public double expMergeRadius = 3.5;
|
2013-03-23 06:55:21 +08:00
|
|
|
public int viewDistance;
|
2013-01-21 14:00:31 +08:00
|
|
|
+ public boolean obfuscated = false;
|
2013-06-11 11:14:01 +08:00
|
|
|
// Spigot end
|
|
|
|
|
2013-06-15 20:01:15 +08:00
|
|
|
// Spigot start
|
|
|
|
@@ -139,6 +140,7 @@ public class CraftWorld implements World {
|
2013-06-11 11:14:01 +08:00
|
|
|
|
|
|
|
viewDistance = Bukkit.getServer().getViewDistance();
|
|
|
|
viewDistance = configuration.getInt( "world-settings." + name + ".view-distance", viewDistance );
|
|
|
|
+ obfuscated = world.getServer().orebfuscatorEnabled && !world.getServer().orebfuscatorDisabledWorlds.contains( name );
|
|
|
|
|
|
|
|
if ( info )
|
|
|
|
{
|
2013-06-15 20:01:15 +08:00
|
|
|
@@ -158,6 +160,7 @@ public class CraftWorld implements World {
|
2013-06-11 11:14:01 +08:00
|
|
|
server.getLogger().info( "Item Merge Radius: " + itemMergeRadius );
|
|
|
|
server.getLogger().info( "Exp Merge Radius: " + expMergeRadius );
|
|
|
|
server.getLogger().info( "View distance: " + viewDistance );
|
|
|
|
+ server.getLogger().info( "Orebfuscator: " + obfuscated );
|
|
|
|
server.getLogger().info( "-------------------------------------------------" );
|
|
|
|
}
|
|
|
|
// Spigot end
|
2013-03-23 07:58:55 +08:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
2013-05-16 16:10:23 +08:00
|
|
|
index 67477f4..e5004b3 100644
|
2013-03-23 07:58:55 +08:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
2013-05-16 16:10:23 +08:00
|
|
|
@@ -19,6 +19,14 @@ public class Spigot {
|
2013-03-23 07:58:55 +08:00
|
|
|
server.spamGuardExclusions = configuration.getStringList("settings.spam-exclusions");
|
2013-04-23 09:27:55 +08:00
|
|
|
filterIps = configuration.getBoolean("settings.filter-unsafe-ips", false);
|
2013-03-23 07:58:55 +08:00
|
|
|
|
|
|
|
+ server.orebfuscatorEnabled = configuration.getBoolean("orebfuscator.enable", false);
|
|
|
|
+ server.orebfuscatorEngineMode = configuration.getInt("orebfuscator.engine-mode", 1);
|
|
|
|
+ server.orebfuscatorDisabledWorlds = configuration.getStringList("orebfuscator.disabled-worlds");
|
|
|
|
+ server.orebfuscatorBlocks = configuration.getShortList("orebfuscator.blocks");
|
|
|
|
+ if (server.orebfuscatorEngineMode != 1 && server.orebfuscatorEngineMode != 2) {
|
|
|
|
+ server.orebfuscatorEngineMode = 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (server.chunkGCPeriod == 0) {
|
|
|
|
server.getLogger().severe("[Spigot] You should not disable chunk-gc, unexpected behaviour may occur!");
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/spigotmc/OrebfuscatorManager.java b/src/main/java/org/spigotmc/OrebfuscatorManager.java
|
2013-01-21 14:00:31 +08:00
|
|
|
new file mode 100644
|
2013-06-03 15:58:18 +08:00
|
|
|
index 0000000..aa1ddfc
|
2013-01-21 14:00:31 +08:00
|
|
|
--- /dev/null
|
2013-03-23 07:58:55 +08:00
|
|
|
+++ b/src/main/java/org/spigotmc/OrebfuscatorManager.java
|
2013-06-03 15:58:18 +08:00
|
|
|
@@ -0,0 +1,204 @@
|
2013-03-23 07:58:55 +08:00
|
|
|
+package org.spigotmc;
|
2013-01-21 14:00:31 +08:00
|
|
|
+
|
2013-05-16 16:51:25 +08:00
|
|
|
+import gnu.trove.set.TByteSet;
|
|
|
|
+import gnu.trove.set.hash.TByteHashSet;
|
2013-01-21 14:00:31 +08:00
|
|
|
+import net.minecraft.server.Block;
|
2013-03-23 07:58:55 +08:00
|
|
|
+import net.minecraft.server.MinecraftServer;
|
2013-01-21 14:00:31 +08:00
|
|
|
+import net.minecraft.server.World;
|
|
|
|
+
|
2013-05-16 17:21:46 +08:00
|
|
|
+public class OrebfuscatorManager
|
|
|
|
+{
|
2013-01-21 14:00:31 +08:00
|
|
|
+
|
2013-05-16 17:21:46 +08:00
|
|
|
+ private static final CustomTimingsHandler update = new CustomTimingsHandler( "xray - update" );
|
|
|
|
+ private static final CustomTimingsHandler obfuscate = new CustomTimingsHandler( "xray - obfuscate" );
|
2013-05-16 16:51:25 +08:00
|
|
|
+ /*========================================================================*/
|
2013-01-21 14:00:31 +08:00
|
|
|
+ // Used to keep track of which blocks to obfuscate
|
2013-05-16 17:21:46 +08:00
|
|
|
+ private static final boolean[] obfuscateBlocks = new boolean[ Short.MAX_VALUE ];
|
2013-05-16 16:51:25 +08:00
|
|
|
+ // Used to select a random replacement ore
|
|
|
|
+ private static byte[] replacementOres;
|
2013-01-21 14:00:31 +08:00
|
|
|
+
|
2013-05-16 17:21:46 +08:00
|
|
|
+ static
|
|
|
|
+ {
|
2013-05-16 16:51:25 +08:00
|
|
|
+ // Set all listed blocks as true to be obfuscated
|
2013-05-16 17:21:46 +08:00
|
|
|
+ for ( short id : MinecraftServer.getServer().server.orebfuscatorBlocks )
|
|
|
|
+ {
|
2013-03-23 07:58:55 +08:00
|
|
|
+ obfuscateBlocks[id] = true;
|
|
|
|
+ }
|
2013-02-16 07:13:00 +08:00
|
|
|
+
|
2013-05-16 16:51:25 +08:00
|
|
|
+ // For every block
|
|
|
|
+ TByteSet blocks = new TByteHashSet();
|
2013-05-16 17:21:46 +08:00
|
|
|
+ for ( int i = 0; i < obfuscateBlocks.length; i++ )
|
|
|
|
+ {
|
2013-05-16 16:51:25 +08:00
|
|
|
+ // If we are obfuscating it
|
2013-05-16 17:21:46 +08:00
|
|
|
+ if ( obfuscateBlocks[i] )
|
|
|
|
+ {
|
2013-05-16 16:10:23 +08:00
|
|
|
+ Block block = Block.byId[i];
|
2013-05-16 16:51:25 +08:00
|
|
|
+ // Check it exists and is not a tile entity
|
2013-05-16 17:21:46 +08:00
|
|
|
+ if ( block != null && !block.t() /* isTileEntity */ )
|
|
|
|
+ {
|
2013-05-16 16:51:25 +08:00
|
|
|
+ // Add it to the set of replacement blocks
|
2013-05-16 17:21:46 +08:00
|
|
|
+ blocks.add( (byte) i );
|
2013-02-16 07:19:31 +08:00
|
|
|
+ }
|
2013-02-16 07:13:00 +08:00
|
|
|
+ }
|
|
|
|
+ }
|
2013-05-16 16:51:25 +08:00
|
|
|
+ // Bake it to a flat array of replacements
|
|
|
|
+ replacementOres = blocks.toArray();
|
2013-01-21 14:00:31 +08:00
|
|
|
+ }
|
|
|
|
+
|
2013-05-16 16:51:25 +08: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-05-16 17:21:46 +08:00
|
|
|
+ public static void updateNearbyBlocks(World world, int x, int y, int z)
|
|
|
|
+ {
|
|
|
|
+ if ( world.getWorld().obfuscated )
|
|
|
|
+ {
|
2013-05-16 16:51:25 +08:00
|
|
|
+ update.startTiming();
|
2013-05-16 17:21:46 +08:00
|
|
|
+ updateNearbyBlocks( world, x, y, z, 2 ); // 2 is the radius, we shouldn't change it as that would make it exponentially slower
|
2013-05-16 16:51:25 +08:00
|
|
|
+ update.stopTiming();
|
|
|
|
+ }
|
2013-02-16 07:13:00 +08:00
|
|
|
+ }
|
|
|
|
+
|
2013-05-16 16:51:25 +08:00
|
|
|
+ /**
|
|
|
|
+ * Starts the timings handler, and then removes all non exposed ores from
|
|
|
|
+ * the chunk buffer.
|
|
|
|
+ */
|
2013-05-16 17:21:46 +08:00
|
|
|
+ public static void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
|
|
|
|
+ {
|
|
|
|
+ if ( world.getWorld().obfuscated )
|
|
|
|
+ {
|
2013-05-16 16:51:25 +08:00
|
|
|
+ obfuscate.startTiming();
|
2013-05-16 17:21:46 +08:00
|
|
|
+ obfuscate( chunkX, chunkY, bitmask, buffer, world );
|
2013-05-16 16:51:25 +08:00
|
|
|
+ obfuscate.stopTiming();
|
|
|
|
+ }
|
2013-01-21 14:00:31 +08:00
|
|
|
+ }
|
2013-04-04 06:10:41 +08:00
|
|
|
+
|
2013-05-16 16:51:25 +08:00
|
|
|
+ /**
|
|
|
|
+ * Removes all non exposed ores from the chunk buffer.
|
|
|
|
+ */
|
2013-05-16 17:21:46 +08:00
|
|
|
+ public static void obfuscate(int chunkX, int chunkY, int bitmask, byte[] buffer, World world)
|
|
|
|
+ {
|
2013-05-16 16:51:25 +08:00
|
|
|
+ // If the world is marked as obfuscated
|
2013-05-16 17:21:46 +08:00
|
|
|
+ if ( world.getWorld().obfuscated )
|
|
|
|
+ {
|
2013-06-03 15:51:31 +08:00
|
|
|
+ // Initial radius to search around for air
|
|
|
|
+ int initialRadius = 1;
|
2013-05-16 16:51:25 +08:00
|
|
|
+ // Which block in the buffer we are looking at, anywhere from 0 to 16^4
|
2013-01-21 14:00:31 +08:00
|
|
|
+ int index = 0;
|
2013-05-16 16:51:25 +08:00
|
|
|
+ // The iterator marking which random ore we should use next
|
|
|
|
+ int randomOre = 0;
|
|
|
|
+
|
|
|
|
+ // Chunk corner X and Z blocks
|
2013-01-21 14:00:31 +08:00
|
|
|
+ int startX = chunkX << 4;
|
|
|
|
+ int startZ = chunkY << 4;
|
2013-05-16 16:51:25 +08:00
|
|
|
+
|
|
|
|
+ // Chunks can have up to 16 sections
|
2013-05-16 17:21:46 +08:00
|
|
|
+ for ( int i = 0; i < 16; i++ )
|
|
|
|
+ {
|
2013-01-21 14:00:31 +08:00
|
|
|
+ // If the bitmask indicates this chunk is sent...
|
2013-05-16 17:21:46 +08:00
|
|
|
+ if ( ( bitmask & 1 << i ) != 0 )
|
|
|
|
+ {
|
2013-05-16 16:51:25 +08:00
|
|
|
+ // Work through all blocks in the chunk, y,z,x
|
2013-05-16 17:21:46 +08:00
|
|
|
+ for ( int y = 0; y < 16; y++ )
|
|
|
|
+ {
|
|
|
|
+ for ( int z = 0; z < 16; z++ )
|
|
|
|
+ {
|
|
|
|
+ for ( int x = 0; x < 16; x++ )
|
|
|
|
+ {
|
2013-05-16 16:51:25 +08: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-05-16 17:21:46 +08:00
|
|
|
+ if ( obfuscateBlocks[blockId] )
|
|
|
|
+ {
|
2013-06-03 15:51:31 +08:00
|
|
|
+ // TODO: Don't really understand this, but if radius is not 0 and the world isn't loaded, bail out
|
|
|
|
+ if ( initialRadius != 0 && !isLoaded( world, startX + x, ( i << 4 ) + y, startZ + z, initialRadius ) )
|
|
|
|
+ {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // On the otherhand, if radius is 0, or the nearby blocks are all non air, we can obfuscate
|
|
|
|
+ if ( initialRadius == 0 || !hasTransparentBlockAdjacent( world, startX + x, ( i << 4 ) + y, startZ + z, initialRadius ) )
|
2013-05-16 17:21:46 +08:00
|
|
|
+ {
|
|
|
|
+ switch ( world.getServer().orebfuscatorEngineMode )
|
|
|
|
+ {
|
2013-05-16 16:51:25 +08:00
|
|
|
+ case 1:
|
2013-02-16 07:13:00 +08:00
|
|
|
+ // Replace with stone
|
|
|
|
+ buffer[index] = (byte) Block.STONE.id;
|
2013-05-16 16:51:25 +08:00
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ // Replace with random ore.
|
2013-05-16 17:21:46 +08:00
|
|
|
+ if ( randomOre >= replacementOres.length )
|
|
|
|
+ {
|
2013-05-16 16:51:25 +08:00
|
|
|
+ randomOre = 0;
|
|
|
|
+ }
|
2013-05-16 17:21:46 +08:00
|
|
|
+ buffer[index] = replacementOres[randomOre++];
|
2013-05-16 16:51:25 +08:00
|
|
|
+ break;
|
2013-02-16 07:13:00 +08:00
|
|
|
+ }
|
2013-01-21 14:00:31 +08:00
|
|
|
+ }
|
|
|
|
+ }
|
2013-05-16 16:51:25 +08: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
|
2013-05-16 17:21:46 +08:00
|
|
|
+ if ( ++index >= buffer.length )
|
|
|
|
+ {
|
2013-01-24 06:13:53 +08:00
|
|
|
+ return;
|
|
|
|
+ }
|
2013-01-21 14:00:31 +08:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2013-05-16 17:21:46 +08:00
|
|
|
+ private static void updateNearbyBlocks(World world, int x, int y, int z, int radius)
|
|
|
|
+ {
|
2013-05-16 16:51:25 +08:00
|
|
|
+ // If the block in question is loaded
|
2013-05-16 17:21:46 +08:00
|
|
|
+ if ( world.isLoaded( x, y, z ) )
|
|
|
|
+ {
|
2013-01-21 14:00:31 +08:00
|
|
|
+ // Get block id
|
2013-05-16 17:21:46 +08:00
|
|
|
+ int id = world.getTypeId( x, y, z );
|
2013-01-21 14:00:31 +08:00
|
|
|
+
|
|
|
|
+ // See if it needs update
|
2013-05-16 17:21:46 +08:00
|
|
|
+ if ( obfuscateBlocks[id] )
|
|
|
|
+ {
|
2013-01-21 14:00:31 +08:00
|
|
|
+ // Send the update
|
2013-05-16 17:21:46 +08:00
|
|
|
+ world.notify( x, y, z );
|
2013-01-21 14:51:34 +08:00
|
|
|
+ }
|
2013-01-21 14:00:31 +08:00
|
|
|
+
|
2013-01-21 14:51:34 +08:00
|
|
|
+ // Check other blocks for updates
|
2013-05-16 17:34:00 +08:00
|
|
|
+ if ( radius > 0 )
|
2013-05-16 17:21:46 +08:00
|
|
|
+ {
|
|
|
|
+ updateNearbyBlocks( world, x + 1, y, z, radius - 1 );
|
|
|
|
+ updateNearbyBlocks( world, x - 1, y, z, radius - 1 );
|
|
|
|
+ updateNearbyBlocks( world, x, y + 1, z, radius - 1 );
|
|
|
|
+ updateNearbyBlocks( world, x, y - 1, z, radius - 1 );
|
|
|
|
+ updateNearbyBlocks( world, x, y, z + 1, radius - 1 );
|
|
|
|
+ updateNearbyBlocks( world, x, y, z - 1, radius - 1 );
|
2013-01-21 14:00:31 +08:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2013-05-16 16:10:23 +08:00
|
|
|
+
|
2013-06-03 15:51:31 +08:00
|
|
|
+ private static boolean isLoaded(World world, int x, int y, int z, int radius)
|
|
|
|
+ {
|
|
|
|
+ return world.isLoaded( x, y, z )
|
|
|
|
+ || ( 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-05-16 17:21:46 +08:00
|
|
|
+ private static boolean hasTransparentBlockAdjacent(World world, int x, int y, int z, int radius)
|
|
|
|
+ {
|
2013-06-03 15:51:31 +08:00
|
|
|
+ return !Block.l( world.getTypeId( x, y, z ) ) /* isSolidBlock */
|
2013-05-16 18:05:02 +08: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 14:00:31 +08:00
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
|
2013-06-11 10:10:31 +08:00
|
|
|
index fe257e2..7860ccc 100644
|
2013-01-21 14:00:31 +08:00
|
|
|
--- a/src/main/resources/configurations/bukkit.yml
|
|
|
|
+++ b/src/main/resources/configurations/bukkit.yml
|
2013-06-11 10:10:31 +08:00
|
|
|
@@ -81,3 +81,9 @@ database:
|
2013-01-21 14:00:31 +08:00
|
|
|
driver: org.sqlite.JDBC
|
|
|
|
password: walrus
|
|
|
|
url: jdbc:sqlite:{DIR}{NAME}.db
|
|
|
|
+orebfuscator:
|
|
|
|
+ enable: false
|
2013-02-16 07:13:00 +08:00
|
|
|
+ engine-mode: 1
|
2013-01-21 14:00:31 +08:00
|
|
|
+ disabled-worlds:
|
|
|
|
+ - world_the_end
|
2013-03-23 07:58:55 +08:00
|
|
|
+ blocks: [1, 5, 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
|
2013-01-21 14:00:31 +08:00
|
|
|
--
|
2013-06-01 14:13:33 +08:00
|
|
|
1.8.1.2
|
2013-01-21 14:00:31 +08:00
|
|
|
|