Sigh. Back to good old fashioned whatever we had before. Can anyone recommend some xray client I can actually use to test this stuff?
By: md_5 <md_5@live.com.au>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
From 08ff6f95339bf788c1d8a79c53642cdab3b72c2f Mon Sep 17 00:00:00 2001
|
||||
From 3c7f43e649d3e15939a321426a27eb5dbabddfea Mon Sep 17 00:00:00 2001
|
||||
From: md_5 <md_5@live.com.au>
|
||||
Date: Thu, 16 May 2013 18:51:05 +1000
|
||||
Subject: [PATCH] Orebfuscator
|
||||
@@ -108,12 +108,14 @@ index a7afa55..1a60229 100644
|
||||
|
||||
diff --git a/src/main/java/org/spigotmc/AntiXray.java b/src/main/java/org/spigotmc/AntiXray.java
|
||||
new file mode 100644
|
||||
index 0000000..59bae3b
|
||||
index 0000000..c165304
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/spigotmc/AntiXray.java
|
||||
@@ -0,0 +1,186 @@
|
||||
@@ -0,0 +1,204 @@
|
||||
+package org.spigotmc;
|
||||
+
|
||||
+import gnu.trove.set.TByteSet;
|
||||
+import gnu.trove.set.hash.TByteHashSet;
|
||||
+import net.minecraft.server.Block;
|
||||
+import net.minecraft.server.World;
|
||||
+
|
||||
@@ -125,7 +127,8 @@ index 0000000..59bae3b
|
||||
+ /*========================================================================*/
|
||||
+ // Used to keep track of which blocks to obfuscate
|
||||
+ private final boolean[] obfuscateBlocks = new boolean[ Short.MAX_VALUE ];
|
||||
+ private final boolean[] replaceBlocks = new boolean[ Short.MAX_VALUE ];
|
||||
+ // Used to select a random replacement ore
|
||||
+ private byte[] replacementOres;
|
||||
+
|
||||
+ public AntiXray(SpigotWorldConfig config)
|
||||
+ {
|
||||
@@ -134,10 +137,25 @@ index 0000000..59bae3b
|
||||
+ {
|
||||
+ obfuscateBlocks[id] = true;
|
||||
+ }
|
||||
+ for ( int id : config.xRayReplacements )
|
||||
+
|
||||
+ // For every block
|
||||
+ TByteSet blocks = new TByteHashSet();
|
||||
+ for ( int i = 0; i < obfuscateBlocks.length; i++ )
|
||||
+ {
|
||||
+ replaceBlocks[id] = true;
|
||||
+ // If we are obfuscating it
|
||||
+ if ( obfuscateBlocks[i] )
|
||||
+ {
|
||||
+ Block block = Block.byId[i];
|
||||
+ // Check it exists and is not a tile entity
|
||||
+ if ( block != null && !block.t() /* isTileEntity */ )
|
||||
+ {
|
||||
+ // Add it to the set of replacement blocks
|
||||
+ blocks.add( (byte) i );
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Bake it to a flat array of replacements
|
||||
+ replacementOres = blocks.toArray();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
@@ -209,7 +227,7 @@ index 0000000..59bae3b
|
||||
+ // TODO: extended IDs are not yet supported
|
||||
+ int blockId = buffer[index] & 0xFF;
|
||||
+ // Check if the block should be obfuscated
|
||||
+ if ( obfuscateBlocks[blockId] || replaceBlocks[blockId] )
|
||||
+ if ( obfuscateBlocks[blockId] )
|
||||
+ {
|
||||
+ // 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 ) )
|
||||
@@ -226,12 +244,12 @@ index 0000000..59bae3b
|
||||
+ buffer[index] = (byte) Block.STONE.id;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ if ( randomOre >= world.spigotConfig.xRayReplacements.size() )
|
||||
+ // Replace with random ore.
|
||||
+ if ( randomOre >= replacementOres.length )
|
||||
+ {
|
||||
+ randomOre = 0;
|
||||
+ }
|
||||
+ // Replace with random ore.
|
||||
+ buffer[index] = world.spigotConfig.xRayReplacements.get( randomOre++ ).byteValue();
|
||||
+ buffer[index] = replacementOres[randomOre++];
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
@@ -255,7 +273,7 @@ index 0000000..59bae3b
|
||||
+ int id = world.getTypeId( x, y, z );
|
||||
+
|
||||
+ // See if it needs update
|
||||
+ if ( updateSelf && ( obfuscateBlocks[id] || replaceBlocks[id] ) )
|
||||
+ if ( updateSelf && obfuscateBlocks[id] )
|
||||
+ {
|
||||
+ // Send the update
|
||||
+ world.notify( x, y, z );
|
||||
@@ -299,51 +317,43 @@ index 0000000..59bae3b
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index 3e66d79..c70055b 100644
|
||||
index 3e66d79..bab9d8f 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -1,5 +1,8 @@
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.spigotmc;
|
||||
|
||||
+import gnu.trove.set.TIntSet;
|
||||
+import gnu.trove.set.hash.TIntHashSet;
|
||||
+import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -128,4 +131,35 @@ public class SpigotWorldConfig
|
||||
@@ -128,4 +129,29 @@ public class SpigotWorldConfig
|
||||
viewDistance = getInt( "view-distance", Bukkit.getViewDistance() );
|
||||
log( "View Distance: " + viewDistance );
|
||||
}
|
||||
+
|
||||
+ public boolean antiXray;
|
||||
+ public int engineMode;
|
||||
+ public List<Integer> blocks;
|
||||
+ public List<Integer> xRayReplacements;
|
||||
+ public boolean antiXray = true;
|
||||
+ public int engineMode = 1;
|
||||
+ public List<Integer> blocks = Arrays.asList( new Integer[]
|
||||
+ {
|
||||
+ 1, 5, 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130
|
||||
+ } );
|
||||
+ public AntiXray antiXrayInstance;
|
||||
+ private void antiXray()
|
||||
+ {
|
||||
+ antiXray = getBoolean( "anti-xray.enabled", true );
|
||||
+ antiXray = getBoolean( "anti-xray.enabled", antiXray );
|
||||
+ log( "Anti X-Ray: " + antiXray );
|
||||
+
|
||||
+ engineMode = getInt( "anti-xray.engine-mode", 1 );
|
||||
+ engineMode = getInt( "anti-xray.engine-mode", engineMode );
|
||||
+ log( "\tEngine Mode: " + engineMode );
|
||||
+
|
||||
+ if ( SpigotConfig.version < 2 )
|
||||
+ if ( SpigotConfig.version < 3 )
|
||||
+ {
|
||||
+ set( "anti-xray.blocks", blocks );
|
||||
+ }
|
||||
+ blocks = getList( "anti-xray.blocks", Arrays.asList( new Integer[]
|
||||
+ {
|
||||
+ 14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130
|
||||
+ } ) ) ;
|
||||
+ blocks = getList( "anti-xray.blocks", blocks );
|
||||
+ log( "\tBlocks: " + blocks );
|
||||
+
|
||||
+ xRayReplacements = getList( "anti-xray.replacements", Arrays.asList( new Integer[]
|
||||
+ {
|
||||
+ 1, 3
|
||||
+ } ) );
|
||||
+
|
||||
+ antiXrayInstance = new AntiXray( this );
|
||||
+ }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user