2013-04-10 06:08:33 +02:00
|
|
|
From 50bc4517a46a353fdd95685653da987eece96a49 Mon Sep 17 00:00:00 2001
|
2013-03-23 00:58:55 +01:00
|
|
|
From: md_5 <md_5@live.com.au>
|
|
|
|
Date: Sat, 23 Mar 2013 10:58:17 +1100
|
2013-01-21 07:00:31 +01:00
|
|
|
Subject: [PATCH] Add oreobfuscator for Spigot.
|
|
|
|
|
|
|
|
|
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
|
2013-03-25 08:57:00 +01:00
|
|
|
index 17d837d..ecc52b9 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-03-15 22:35:56 +01:00
|
|
|
@@ -94,6 +94,7 @@ public class EntityFallingBlock extends Entity {
|
|
|
|
}
|
2013-02-20 01:58:31 +01:00
|
|
|
|
2013-03-15 22:35:56 +01:00
|
|
|
this.world.setAir(i, j, k);
|
2013-03-23 00:58:55 +01:00
|
|
|
+ org.spigotmc.OrebfuscatorManager.updateNearbyBlocks(world, i, j, k); // Spigot (Orebfuscator)
|
2013-02-20 01:58:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.onGround) {
|
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
|
2013-03-25 08:57:00 +01:00
|
|
|
index b43953a..b907562 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
|
|
|
|
@@ -240,6 +240,7 @@ public class Explosion {
|
|
|
|
j = chunkposition.y;
|
|
|
|
k = chunkposition.z;
|
|
|
|
l = this.world.getTypeId(i, j, k);
|
2013-03-23 00:58:55 +01:00
|
|
|
+ org.spigotmc.OrebfuscatorManager.updateNearbyBlocks(world, i, j, k); // Spigot (Orebfuscator)
|
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());
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Packet51MapChunk.java b/src/main/java/net/minecraft/server/Packet51MapChunk.java
|
2013-04-04 00:10:41 +02:00
|
|
|
index b51d90c..84dbb88 100644
|
2013-01-21 07:00:31 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/Packet51MapChunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Packet51MapChunk.java
|
2013-04-04 00:10:41 +02:00
|
|
|
@@ -36,7 +36,7 @@ public class Packet51MapChunk extends Packet {
|
|
|
|
}
|
|
|
|
// Spigot end
|
|
|
|
|
|
|
|
- public Packet51MapChunk(Chunk chunk, boolean flag, int i) {
|
|
|
|
+ public Packet51MapChunk(Chunk chunk, boolean flag, int i, int obfuscate) { // Spigot (Orebfuscator) - added argument
|
|
|
|
this.lowPriority = true;
|
|
|
|
this.a = chunk.x;
|
|
|
|
this.b = chunk.z;
|
|
|
|
@@ -46,7 +46,11 @@ public class Packet51MapChunk extends Packet {
|
2013-01-21 07:00:31 +01:00
|
|
|
|
|
|
|
this.d = chunkmap.c;
|
|
|
|
this.c = chunkmap.b;
|
2013-04-04 00:10:41 +02:00
|
|
|
-
|
|
|
|
+ // Spigot start - Orebfuscator
|
|
|
|
+ if (obfuscate > 0) {
|
|
|
|
+ org.spigotmc.OrebfuscatorManager.obfuscateSync(chunk.x, chunk.z, i, chunkmap.a, chunk.world, obfuscate);
|
|
|
|
+ }
|
|
|
|
+ // Spigot end
|
2013-01-21 07:00:31 +01:00
|
|
|
try {
|
|
|
|
this.inflatedBuffer = chunkmap.a;
|
2013-04-04 00:10:41 +02:00
|
|
|
deflater.setInput(chunkmap.a, 0, chunkmap.a.length);
|
|
|
|
@@ -57,6 +61,12 @@ public class Packet51MapChunk extends Packet {
|
|
|
|
deflater.end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Spigot start - add new default constructor to support new orebfuscator arg.
|
|
|
|
+ public Packet51MapChunk(Chunk chunk, boolean flag, int i) {
|
|
|
|
+ this(chunk, flag, i, 1);
|
|
|
|
+ }
|
|
|
|
+ // Spigot end
|
|
|
|
|
|
|
|
public void a(DataInputStream datainputstream) throws IOException { // CraftBukkit - throws IOException
|
|
|
|
this.a = datainputstream.readInt();
|
2013-01-21 07:00:31 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java b/src/main/java/net/minecraft/server/Packet56MapChunkBulk.java
|
2013-03-25 08:57:00 +01:00
|
|
|
index 129dc4f..9f8afe3 100644
|
2013-01-21 07:00:31 +01: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
|
|
|
|
+ private World world; // Spigot (Orebfuscator) Keep track of world
|
|
|
|
|
|
|
|
public Packet56MapChunkBulk() {}
|
|
|
|
|
|
|
|
@@ -46,6 +47,9 @@ public class Packet56MapChunkBulk extends Packet {
|
|
|
|
Chunk chunk = (Chunk) list.get(k);
|
|
|
|
ChunkMap chunkmap = Packet51MapChunk.a(chunk, true, '\uffff');
|
|
|
|
|
|
|
|
+ world = chunk.world; // Spigot (Orebfuscator)
|
|
|
|
+ /* Spigot (Orebfuscator) - Don't use the build buffer yet. Copy to it more efficiently once the chunk is obfuscated
|
|
|
|
+ // Moved to compress()
|
|
|
|
if (buildBuffer.length < j + chunkmap.a.length) {
|
|
|
|
byte[] abyte = new byte[j + chunkmap.a.length];
|
|
|
|
|
|
|
|
@@ -53,7 +57,7 @@ public class Packet56MapChunkBulk extends Packet {
|
|
|
|
buildBuffer = abyte;
|
|
|
|
}
|
|
|
|
|
|
|
|
- System.arraycopy(chunkmap.a, 0, buildBuffer, j, chunkmap.a.length);
|
|
|
|
+ System.arraycopy(chunkmap.a, 0, buildBuffer, j, chunkmap.a.length); */
|
|
|
|
j += chunkmap.a.length;
|
|
|
|
this.c[k] = chunk.x;
|
|
|
|
this.d[k] = chunk.z;
|
|
|
|
@@ -82,6 +86,21 @@ public class Packet56MapChunkBulk extends Packet {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Spigot (Orebfuscator) start - Obfuscate chunks
|
|
|
|
+ int finalBufferSize = 0;
|
|
|
|
+ for (int i = 0; i < a.length; i++) {
|
2013-03-23 00:58:55 +01:00
|
|
|
+ org.spigotmc.OrebfuscatorManager.obfuscate(c[i], d[i], a[i], inflatedBuffers[i], world);
|
2013-01-21 07:00:31 +01: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;
|
|
|
|
+ }
|
|
|
|
+ // Spigot (Orebfuscator) end
|
|
|
|
Deflater deflater = localDeflater.get();
|
|
|
|
deflater.reset();
|
|
|
|
deflater.setInput(this.buildBuffer);
|
2013-04-04 00:10:41 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerChunk.java b/src/main/java/net/minecraft/server/PlayerChunk.java
|
|
|
|
index 20f8e8a..3792638 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerChunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerChunk.java
|
|
|
|
@@ -117,7 +117,7 @@ class PlayerChunk {
|
|
|
|
if (this.dirtyCount == 64) {
|
|
|
|
i = this.location.x * 16;
|
|
|
|
j = this.location.z * 16;
|
|
|
|
- this.sendAll(new Packet51MapChunk(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z), (this.f == 0xFFFF), this.f)); // CraftBukkit - send everything (including biome) if all sections flagged
|
|
|
|
+ this.sendAll(new Packet51MapChunk(PlayerChunkMap.a(this.playerChunkMap).getChunkAt(this.location.x, this.location.z), (this.f == 0xFFFF), this.f, PlayerChunkMap.a(this.playerChunkMap).getServer().orebfuscatorUpdateRadius)); // Spigot (Orebfuscator) - CraftBukkit - send everything (including biome) if all sections flagged
|
|
|
|
|
|
|
|
for (k = 0; k < 16; ++k) {
|
|
|
|
if ((this.f & 1 << k) != 0) {
|
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
|
2013-03-25 08:57:00 +01:00
|
|
|
index 91bed16..8af36ca 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-03-25 08:57:00 +01:00
|
|
|
@@ -285,6 +285,11 @@ public class PlayerInteractManager {
|
2013-01-21 07:00:31 +01:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
+ // Spigot (Orebfuscator) start
|
|
|
|
+ else {
|
2013-03-23 00:58:55 +01:00
|
|
|
+ org.spigotmc.OrebfuscatorManager.updateNearbyBlocks(world, i, j, k);
|
2013-01-21 07:00:31 +01:00
|
|
|
+ }
|
|
|
|
+ // Spigot (Orebfuscator) end
|
|
|
|
}
|
|
|
|
|
|
|
|
if (false) { // Never trigger
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2013-04-10 06:06:41 +02:00
|
|
|
index e7c3a0c..9f2be37 100644
|
2013-01-21 07:00:31 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2013-03-23 00:58:55 +01:00
|
|
|
@@ -163,6 +163,13 @@ public final class CraftServer implements Server {
|
2013-01-21 07:00:31 +01:00
|
|
|
private final BooleanWrapper online = new BooleanWrapper();
|
2013-04-04 13:08:00 +02:00
|
|
|
public CraftScoreboardManager scoreboardManager;
|
2013-01-21 07:00:31 +01:00
|
|
|
|
|
|
|
+ // Orebfuscator use
|
|
|
|
+ public boolean orebfuscatorEnabled = false;
|
2013-02-16 00:13:00 +01:00
|
|
|
+ public int orebfuscatorEngineMode = 1;
|
2013-01-21 07:00:31 +01:00
|
|
|
+ public int orebfuscatorUpdateRadius = 2;
|
|
|
|
+ public List<String> orebfuscatorDisabledWorlds;
|
2013-03-23 00:58:55 +01:00
|
|
|
+ public List<Short> orebfuscatorBlocks;
|
2013-01-21 07:00:31 +01: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-03-25 08:57:00 +01:00
|
|
|
index 7c48dad..d30219d 100644
|
2013-01-21 07:00:31 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2013-03-23 10:15:20 +01:00
|
|
|
@@ -123,6 +123,8 @@ public class CraftWorld implements World {
|
2013-03-22 23:55:21 +01:00
|
|
|
viewDistance = Bukkit.getServer().getViewDistance();
|
|
|
|
viewDistance = configuration.getInt("world-settings." + name + ".view-distance", viewDistance);
|
2013-01-21 07:00:31 +01:00
|
|
|
|
|
|
|
+ obfuscated = !world.getServer().orebfuscatorDisabledWorlds.contains(name);
|
|
|
|
+
|
2013-03-23 10:15:20 +01:00
|
|
|
if (!info) return;
|
2013-01-21 07:00:31 +01:00
|
|
|
server.getLogger().info("-------------- Spigot ----------------");
|
|
|
|
server.getLogger().info("-------- World Settings For [" + name + "] --------");
|
2013-03-23 10:15:20 +01:00
|
|
|
@@ -138,6 +140,7 @@ public class CraftWorld implements World {
|
2013-01-21 07:00:31 +01:00
|
|
|
server.getLogger().info("Tree Growth Modifier: " + treeGrowthModifier);
|
|
|
|
server.getLogger().info("Mushroom Growth Modifier: " + mushroomGrowthModifier);
|
2013-03-22 23:55:21 +01:00
|
|
|
server.getLogger().info("View distance: " + viewDistance);
|
2013-01-21 07:00:31 +01:00
|
|
|
+ server.getLogger().info("Oreobfuscator: " + obfuscated);
|
|
|
|
server.getLogger().info("-------------------------------------------------");
|
|
|
|
// Spigot end
|
|
|
|
}
|
2013-03-23 10:15:20 +01:00
|
|
|
@@ -149,6 +152,7 @@ public class CraftWorld implements World {
|
2013-03-22 23:48:22 +01:00
|
|
|
public double itemMergeRadius = 3.5;
|
|
|
|
public double expMergeRadius = 3.5;
|
2013-03-22 23:55:21 +01:00
|
|
|
public int viewDistance;
|
2013-01-21 07:00:31 +01:00
|
|
|
+ public boolean obfuscated = false;
|
|
|
|
//Crop growth rates:
|
|
|
|
public int wheatGrowthModifier = 100;
|
|
|
|
public int cactusGrowthModifier = 100;
|
2013-03-23 00:58:55 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
|
|
|
index db46037..4097568 100644
|
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
|
|
|
@@ -15,6 +15,15 @@ public class Spigot {
|
|
|
|
server.commandComplete = configuration.getBoolean("settings.command-complete", true);
|
|
|
|
server.spamGuardExclusions = configuration.getStringList("settings.spam-exclusions");
|
|
|
|
|
|
|
|
+ server.orebfuscatorEnabled = configuration.getBoolean("orebfuscator.enable", false);
|
|
|
|
+ server.orebfuscatorEngineMode = configuration.getInt("orebfuscator.engine-mode", 1);
|
|
|
|
+ server.orebfuscatorUpdateRadius = configuration.getInt("orebfuscator.update-radius", 2);
|
|
|
|
+ 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 07:00:31 +01:00
|
|
|
new file mode 100644
|
2013-04-04 00:10:41 +02:00
|
|
|
index 0000000..d168c55
|
2013-01-21 07:00:31 +01:00
|
|
|
--- /dev/null
|
2013-03-23 00:58:55 +01:00
|
|
|
+++ b/src/main/java/org/spigotmc/OrebfuscatorManager.java
|
2013-04-04 00:10:41 +02:00
|
|
|
@@ -0,0 +1,146 @@
|
2013-03-23 00:58:55 +01:00
|
|
|
+package org.spigotmc;
|
2013-01-21 07:00:31 +01:00
|
|
|
+
|
2013-02-16 00:13:00 +01:00
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
2013-01-21 07:00:31 +01:00
|
|
|
+import net.minecraft.server.Block;
|
2013-03-23 00:58:55 +01:00
|
|
|
+import net.minecraft.server.MinecraftServer;
|
2013-01-21 07:00:31 +01:00
|
|
|
+import net.minecraft.server.World;
|
2013-02-26 18:21:40 +01:00
|
|
|
+import org.bukkit.CustomTimingsHandler;
|
2013-01-21 07:00:31 +01:00
|
|
|
+
|
|
|
|
+public class OrebfuscatorManager {
|
|
|
|
+
|
|
|
|
+ // Used to keep track of which blocks to obfuscate
|
2013-02-16 00:13:00 +01:00
|
|
|
+ private static final boolean[] obfuscateBlocks = new boolean[Short.MAX_VALUE];
|
|
|
|
+ private static Byte[] ores;
|
|
|
|
+ private static final CustomTimingsHandler obfuscate = new CustomTimingsHandler("xray - obfuscate");
|
|
|
|
+ private static final CustomTimingsHandler update = new CustomTimingsHandler("xray - update");
|
|
|
|
+ private static int ITERATOR = 0;
|
2013-01-21 07:00:31 +01:00
|
|
|
+
|
|
|
|
+ // Default blocks
|
|
|
|
+ static {
|
2013-03-23 00:58:55 +01:00
|
|
|
+ for (short id : MinecraftServer.getServer().server.orebfuscatorBlocks) {
|
|
|
|
+ obfuscateBlocks[id] = true;
|
|
|
|
+ }
|
2013-02-16 00:13:00 +01:00
|
|
|
+
|
|
|
|
+ List<Byte> blocks = new ArrayList<Byte>();
|
|
|
|
+ for (int i = 0; i < obfuscateBlocks.length; i++) {
|
|
|
|
+ if (obfuscateBlocks[i]) {
|
2013-02-16 00:24:25 +01:00
|
|
|
+ if (i != Block.STONE.id && i != Block.CHEST.id && i != Block.ENDER_CHEST.id) {
|
2013-02-16 00:19:31 +01:00
|
|
|
+ blocks.add((byte) i);
|
|
|
|
+ }
|
2013-02-16 00:13:00 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ores = blocks.toArray(new Byte[blocks.size()]);
|
2013-01-21 07:00:31 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void updateNearbyBlocks(World world, int x, int y, int z) {
|
2013-02-16 00:13:00 +01:00
|
|
|
+ update.startTiming();
|
2013-01-21 07:00:31 +01:00
|
|
|
+ updateNearbyBlocks(world, x, y, z, world.getServer().orebfuscatorUpdateRadius);
|
2013-02-16 00:13:00 +01:00
|
|
|
+ update.stopTiming();
|
|
|
|
+ }
|
|
|
|
+
|
2013-04-04 00:10:41 +02:00
|
|
|
+ public static void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world, int initRadius) {
|
2013-02-16 00:13:00 +01:00
|
|
|
+ obfuscate.startTiming();
|
2013-04-04 00:10:41 +02:00
|
|
|
+ obfuscate(chunkX, chunkY, bitmask, buffer, world, initRadius);
|
2013-02-16 00:13:00 +01:00
|
|
|
+ obfuscate.stopTiming();
|
2013-01-21 07:00:31 +01:00
|
|
|
+ }
|
2013-04-04 00:10:41 +02:00
|
|
|
+
|
|
|
|
+ public static void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world) {
|
|
|
|
+ obfuscateSync(chunkX, chunkY, bitmask, buffer, world, 1);
|
|
|
|
+ }
|
|
|
|
+
|
2013-01-21 07:00:31 +01:00
|
|
|
+ public static void obfuscate(int chunkX, int chunkY, int bitmask, byte[] buffer, World world) {
|
2013-04-04 00:10:41 +02:00
|
|
|
+ obfuscate(chunkX, chunkY, bitmask, buffer, world, 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void obfuscate(int chunkX, int chunkY, int bitmask, byte[] buffer, World world, int initialRadius) {
|
2013-01-21 07:00:31 +01:00
|
|
|
+ if (world.getServer().orebfuscatorEnabled && world.getWorld().obfuscated) {
|
|
|
|
+ int index = 0;
|
|
|
|
+ int startX = chunkX << 4;
|
|
|
|
+ int startZ = chunkY << 4;
|
|
|
|
+ for (int i = 0; i < 16; i++) {
|
|
|
|
+ // If the bitmask indicates this chunk is sent...
|
|
|
|
+ if ((bitmask & 1 << i) != 0) {
|
|
|
|
+ for (int y = 0; y < 16; y++) {
|
|
|
|
+ for (int z = 0; z < 16; z++) {
|
|
|
|
+ for (int x = 0; x < 16; x++) {
|
|
|
|
+ byte data = buffer[index];
|
|
|
|
+ // Check if the block should be obfuscated for the default engine modes
|
|
|
|
+ if (obfuscateBlocks[data & 0xFF]) {
|
2013-02-26 01:43:00 +01:00
|
|
|
+ if (initialRadius != 0 && !isWorldLoaded(world, startX + x, (i << 4) + y, startZ + z, initialRadius)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
2013-01-21 07:00:31 +01:00
|
|
|
+ if (initialRadius == 0 || !areAjacentBlocksTransparent(world, startX + x, (i << 4) + y, startZ + z, initialRadius)) {
|
2013-02-16 00:13:00 +01:00
|
|
|
+ if (world.getServer().orebfuscatorEngineMode == 2) {
|
|
|
|
+ // Replace with random ore.
|
|
|
|
+ if (ITERATOR >= ores.length) {
|
|
|
|
+ ITERATOR = 0;
|
|
|
|
+ }
|
|
|
|
+ buffer[index] = (byte) (int) ores[ITERATOR++];
|
|
|
|
+ } else {
|
|
|
|
+ if (world.getServer().orebfuscatorEngineMode == 1) {
|
|
|
|
+ // Replace with stone
|
|
|
|
+ buffer[index] = (byte) Block.STONE.id;
|
|
|
|
+ }
|
|
|
|
+ }
|
2013-01-21 07:00:31 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
2013-01-24 09:28:22 +01:00
|
|
|
+ if (++index >= buffer.length) {
|
2013-01-23 23:13:53 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
2013-01-21 07:00:31 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static void updateNearbyBlocks(World world, int x, int y, int z, int radius) {
|
|
|
|
+ if (world.getServer().orebfuscatorEnabled && world.getWorld().obfuscated && world.isLoaded(x, y, z)) {
|
|
|
|
+ // Get block id
|
|
|
|
+ int id = world.getTypeId(x, y, z);
|
|
|
|
+
|
|
|
|
+ // See if it needs update
|
|
|
|
+ if (obfuscateBlocks[id]) {
|
|
|
|
+ // Send the update
|
|
|
|
+ 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
|
|
|
|
+ if (radius != 0) {
|
|
|
|
+ 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 07:00:31 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2013-02-26 01:43:00 +01:00
|
|
|
+
|
|
|
|
+ private static boolean isWorldLoaded(World world, int x, int y, int z, int radius) {
|
|
|
|
+ boolean toret = (y > 0 && y <= world.getHeight() && world.isLoaded(x, y, z));
|
|
|
|
+ if (toret) {
|
|
|
|
+ return toret || (radius > 0 && (isWorldLoaded(world, x, y + 1, z, radius - 1)
|
|
|
|
+ || isWorldLoaded(world, x, y - 1, z, radius - 1)
|
|
|
|
+ || isWorldLoaded(world, x + 1, y, z, radius - 1)
|
|
|
|
+ || isWorldLoaded(world, x - 1, y, z, radius - 1)
|
|
|
|
+ || isWorldLoaded(world, x, y, z + 1, radius - 1)
|
|
|
|
+ || isWorldLoaded(world, x, y, z - 1, radius - 1)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ }
|
2013-01-21 07:00:31 +01:00
|
|
|
+
|
|
|
|
+ private static boolean areAjacentBlocksTransparent(World world, int x, int y, int z, int radius) {
|
2013-01-21 07:38:13 +01:00
|
|
|
+ return y > 0 && y <= world.getHeight()
|
2013-03-15 23:08:53 +01:00
|
|
|
+ && !Block.l(world.getTypeId(x, y, z))
|
2013-01-21 07:38:13 +01:00
|
|
|
+ || (radius > 0 && (areAjacentBlocksTransparent(world, x, y + 1, z, radius - 1)
|
2013-01-21 07:00:31 +01:00
|
|
|
+ || areAjacentBlocksTransparent(world, x, y - 1, z, radius - 1)
|
|
|
|
+ || areAjacentBlocksTransparent(world, x + 1, y, z, radius - 1)
|
|
|
|
+ || areAjacentBlocksTransparent(world, x - 1, y, z, radius - 1)
|
|
|
|
+ || areAjacentBlocksTransparent(world, x, y, z + 1, radius - 1)
|
2013-01-21 07:38:13 +01:00
|
|
|
+ || areAjacentBlocksTransparent(world, x, y, z - 1, radius - 1)));
|
2013-01-21 07:00:31 +01:00
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
|
2013-03-23 10:15:20 +01:00
|
|
|
index 9b85e13..a63dc22 100644
|
2013-01-21 07:00:31 +01:00
|
|
|
--- a/src/main/resources/configurations/bukkit.yml
|
|
|
|
+++ b/src/main/resources/configurations/bukkit.yml
|
2013-03-23 10:15:20 +01:00
|
|
|
@@ -82,3 +82,10 @@ database:
|
2013-01-21 07:00:31 +01:00
|
|
|
driver: org.sqlite.JDBC
|
|
|
|
password: walrus
|
|
|
|
url: jdbc:sqlite:{DIR}{NAME}.db
|
|
|
|
+orebfuscator:
|
|
|
|
+ enable: false
|
2013-02-16 00:13:00 +01:00
|
|
|
+ engine-mode: 1
|
2013-01-21 07:00:31 +01:00
|
|
|
+ update-radius: 2
|
|
|
|
+ disabled-worlds:
|
|
|
|
+ - world_the_end
|
2013-03-23 00:58:55 +01:00
|
|
|
+ blocks: [1, 5, 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
|
2013-01-21 07:00:31 +01:00
|
|
|
--
|
2013-04-10 06:06:41 +02:00
|
|
|
1.8.2.1
|
2013-01-21 07:00:31 +01:00
|
|
|
|