3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 02:50:09 +01:00

Add engine mode 2

Dieser Commit ist enthalten in:
SuPaH sPii 2013-02-16 10:13:00 +11:00 committet von md_5
Ursprung 5bfd44a991
Commit 41c3037566
8 geänderte Dateien mit 79 neuen und 101 gelöschten Zeilen

Datei anzeigen

@ -1,19 +1,19 @@
From fa1b9add0d25e2c4b9f7a096bea508c5da3b25c4 Mon Sep 17 00:00:00 2001
From 5357ce98746067c6d3ebcb4267b5722d5098a419 Mon Sep 17 00:00:00 2001
From: lishid <lishid@gmail.com>
Date: Mon, 21 Jan 2013 16:59:04 +1100
Date: Sat, 16 Feb 2013 10:05:25 +1100
Subject: [PATCH] Add oreobfuscator for Spigot.
---
src/main/java/net/minecraft/server/Explosion.java | 1 +
.../net/minecraft/server/Packet51MapChunk.java | 1 +
.../net/minecraft/server/Packet56MapChunkBulk.java | 21 ++++-
.../minecraft/server/PlayerInteractManager.java | 5 ++
.../java/org/bukkit/craftbukkit/CraftServer.java | 5 ++
.../java/org/bukkit/craftbukkit/CraftWorld.java | 4 +
.../bukkit/craftbukkit/OrebfuscatorManager.java | 95 ++++++++++++++++++++++
src/main/java/org/bukkit/craftbukkit/Spigot.java | 4 +
src/main/resources/configurations/bukkit.yml | 5 ++
9 files changed, 140 insertions(+), 1 deletion(-)
src/main/java/net/minecraft/server/Explosion.java | 1 +
.../net/minecraft/server/Packet51MapChunk.java | 1 +
.../net/minecraft/server/Packet56MapChunkBulk.java | 21 +++-
.../minecraft/server/PlayerInteractManager.java | 5 +
.../java/org/bukkit/craftbukkit/CraftServer.java | 6 +
.../java/org/bukkit/craftbukkit/CraftWorld.java | 4 +
.../bukkit/craftbukkit/OrebfuscatorManager.java | 128 +++++++++++++++++++++
src/main/java/org/bukkit/craftbukkit/Spigot.java | 8 ++
src/main/resources/configurations/bukkit.yml | 6 +
9 files changed, 179 insertions(+), 1 deletion(-)
create mode 100644 src/main/java/org/bukkit/craftbukkit/OrebfuscatorManager.java
diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java
@ -29,14 +29,14 @@ index ba2f88f..8d5b1d8 100644
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
index b51d90c..365116a 100644
index b51d90c..230dd62 100644
--- a/src/main/java/net/minecraft/server/Packet51MapChunk.java
+++ b/src/main/java/net/minecraft/server/Packet51MapChunk.java
@@ -46,6 +46,7 @@ public class Packet51MapChunk extends Packet {
this.d = chunkmap.c;
this.c = chunkmap.b;
+ org.bukkit.craftbukkit.OrebfuscatorManager.obfuscate(chunk.x, chunk.z, i, chunkmap.a, chunk.world); // Spigot (Orebfuscator)
+ org.bukkit.craftbukkit.OrebfuscatorManager.obfuscateSync(chunk.x, chunk.z, i, chunkmap.a, chunk.world); // Spigot (Orebfuscator)
try {
this.inflatedBuffer = chunkmap.a;
@ -110,15 +110,16 @@ index 5faee12..55f9ffa 100644
if (false) { // Never trigger
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index a7785b7..ef52f32 100644
index a7785b7..204af22 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -163,6 +163,11 @@ public final class CraftServer implements Server {
@@ -163,6 +163,12 @@ public final class CraftServer implements Server {
private WarningState warningState = WarningState.DEFAULT;
private final BooleanWrapper online = new BooleanWrapper();
+ // Orebfuscator use
+ public boolean orebfuscatorEnabled = false;
+ public int orebfuscatorEngineMode = 1;
+ public int orebfuscatorUpdateRadius = 2;
+ public List<String> orebfuscatorDisabledWorlds;
+
@ -156,19 +157,26 @@ index 94e07fe..21bd64a 100644
public int cactusGrowthModifier = 100;
diff --git a/src/main/java/org/bukkit/craftbukkit/OrebfuscatorManager.java b/src/main/java/org/bukkit/craftbukkit/OrebfuscatorManager.java
new file mode 100644
index 0000000..7178dfb
index 0000000..5bb743f
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/OrebfuscatorManager.java
@@ -0,0 +1,95 @@
@@ -0,0 +1,128 @@
+package org.bukkit.craftbukkit;
+
+import java.util.ArrayList;
+import java.util.List;
+import net.minecraft.server.Block;
+import net.minecraft.server.World;
+import org.bukkit.event.CustomTimingsHandler;
+
+public class OrebfuscatorManager {
+
+ // Used to keep track of which blocks to obfuscate
+ private static boolean[] obfuscateBlocks = new boolean[Short.MAX_VALUE];
+ 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;
+
+ // Default blocks
+ static {
@ -183,10 +191,26 @@ index 0000000..7178dfb
+ obfuscateBlocks[Block.GLOWING_REDSTONE_ORE.id] = true;
+ obfuscateBlocks[Block.EMERALD_ORE.id] = true;
+ obfuscateBlocks[Block.ENDER_CHEST.id] = true;
+
+ List<Byte> blocks = new ArrayList<Byte>();
+ for (int i = 0; i < obfuscateBlocks.length; i++) {
+ if (obfuscateBlocks[i]) {
+ blocks.add((byte) i);
+ }
+ }
+ ores = blocks.toArray(new Byte[blocks.size()]);
+ }
+
+ public static void updateNearbyBlocks(World world, int x, int y, int z) {
+ update.startTiming();
+ updateNearbyBlocks(world, x, y, z, world.getServer().orebfuscatorUpdateRadius);
+ update.stopTiming();
+ }
+
+ public static void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world) {
+ obfuscate.startTiming();
+ obfuscate(chunkX, chunkY, bitmask, buffer, world);
+ obfuscate.stopTiming();
+ }
+
+ public static void obfuscate(int chunkX, int chunkY, int bitmask, byte[] buffer, World world) {
@ -205,8 +229,18 @@ index 0000000..7178dfb
+ // Check if the block should be obfuscated for the default engine modes
+ if (obfuscateBlocks[data & 0xFF]) {
+ if (initialRadius == 0 || !areAjacentBlocksTransparent(world, startX + x, (i << 4) + y, startZ + z, initialRadius)) {
+ // Replace with stone
+ buffer[index] = (byte) Block.STONE.id;
+ 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;
+ }
+ }
+ }
+ }
+ if (++index >= buffer.length) {
@ -256,30 +290,35 @@ index 0000000..7178dfb
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index 30bc542..ccb1cc7 100644
index 30bc542..b124dab 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -23,6 +23,10 @@ public class Spigot {
@@ -23,6 +23,14 @@ 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");
+ if (server.orebfuscatorEngineMode != 1 && server.orebfuscatorEngineMode != 2) {
+ server.orebfuscatorEngineMode = 1;
+ }
+
if (server.chunkGCPeriod == 0) {
server.getLogger().severe("[Spigot] You should not disable chunk-gc. Resetting period-in-ticks to 600 ticks.");
server.chunkGCPeriod = 600;
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 9d6d613..6931712 100644
index 9d6d613..3228d17 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -84,3 +84,8 @@ database:
@@ -84,3 +84,9 @@ database:
driver: org.sqlite.JDBC
password: walrus
url: jdbc:sqlite:{DIR}{NAME}.db
+orebfuscator:
+ enable: false
+ engine-mode: 1
+ update-radius: 2
+ disabled-worlds:
+ - world_the_end

Datei anzeigen

@ -1,4 +1,4 @@
From 300dbbfcdb5a9b8c49d7ac421fba28eb0ac22170 Mon Sep 17 00:00:00 2001
From 1c18e9b73bc9b0bce7ee99f0abf89b34b454b806 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 29 Jan 2013 13:25:53 -0500
Subject: [PATCH] Only count entities in chunks being processed for the spawn

Datei anzeigen

@ -1,61 +0,0 @@
From 7b9729d3f63896d55a46055572f2f03e5b47695e Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 25 Jan 2013 13:15:42 +1100
Subject: [PATCH] Track Xray timings.
---
src/main/java/net/minecraft/server/Packet51MapChunk.java | 2 +-
src/main/java/org/bukkit/craftbukkit/OrebfuscatorManager.java | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/main/java/net/minecraft/server/Packet51MapChunk.java b/src/main/java/net/minecraft/server/Packet51MapChunk.java
index 365116a..230dd62 100644
--- a/src/main/java/net/minecraft/server/Packet51MapChunk.java
+++ b/src/main/java/net/minecraft/server/Packet51MapChunk.java
@@ -46,7 +46,7 @@ public class Packet51MapChunk extends Packet {
this.d = chunkmap.c;
this.c = chunkmap.b;
- org.bukkit.craftbukkit.OrebfuscatorManager.obfuscate(chunk.x, chunk.z, i, chunkmap.a, chunk.world); // Spigot (Orebfuscator)
+ org.bukkit.craftbukkit.OrebfuscatorManager.obfuscateSync(chunk.x, chunk.z, i, chunkmap.a, chunk.world); // Spigot (Orebfuscator)
try {
this.inflatedBuffer = chunkmap.a;
diff --git a/src/main/java/org/bukkit/craftbukkit/OrebfuscatorManager.java b/src/main/java/org/bukkit/craftbukkit/OrebfuscatorManager.java
index 7178dfb..c0ee505 100644
--- a/src/main/java/org/bukkit/craftbukkit/OrebfuscatorManager.java
+++ b/src/main/java/org/bukkit/craftbukkit/OrebfuscatorManager.java
@@ -2,11 +2,14 @@ package org.bukkit.craftbukkit;
import net.minecraft.server.Block;
import net.minecraft.server.World;
+import org.bukkit.event.CustomTimingsHandler;
public class OrebfuscatorManager {
// Used to keep track of which blocks to obfuscate
private static boolean[] obfuscateBlocks = new boolean[Short.MAX_VALUE];
+ private static final CustomTimingsHandler obfuscate = new CustomTimingsHandler("xray - obfuscate");
+ private static final CustomTimingsHandler update = new CustomTimingsHandler("xray - update");
// Default blocks
static {
@@ -24,7 +27,15 @@ public class OrebfuscatorManager {
}
public static void updateNearbyBlocks(World world, int x, int y, int z) {
+ update.startTiming();
updateNearbyBlocks(world, x, y, z, world.getServer().orebfuscatorUpdateRadius);
+ update.stopTiming();
+ }
+
+ public static void obfuscateSync(int chunkX, int chunkY, int bitmask, byte[] buffer, World world) {
+ obfuscate.startTiming();
+ obfuscate(chunkX, chunkY, bitmask, buffer, world);
+ obfuscate.stopTiming();
}
public static void obfuscate(int chunkX, int chunkY, int bitmask, byte[] buffer, World world) {
--
1.8.1-rc2

Datei anzeigen

@ -1,4 +1,4 @@
From e5df30285b9c210b6734435a8ff9286edeb009bf Mon Sep 17 00:00:00 2001
From c990d9e10a9a8285c8d408c6cb665c1f1e640545 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 2 Feb 2013 19:40:53 +1100
Subject: [PATCH] Send maps a lot less often to combat the lag they cause.
@ -24,10 +24,10 @@ index a026c4c..27a548f 100644
ItemStack i5 = i4.i();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index ef52f32..16d397e 100644
index 204af22..f00b28d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -178,6 +178,7 @@ public final class CraftServer implements Server {
@@ -179,6 +179,7 @@ public final class CraftServer implements Server {
public boolean ipFilter = false;
public boolean commandComplete = true;
public List<String> spamGuardExclusions;
@ -36,7 +36,7 @@ index ef52f32..16d397e 100644
static {
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index ccb1cc7..0fe463a 100644
index b124dab..c712b52 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -22,6 +22,7 @@ public class Spigot {
@ -46,9 +46,9 @@ index ccb1cc7..0fe463a 100644
+ server.mapSendInterval = configuration.getInt("settings.map-send-interval", server.mapSendInterval);
server.orebfuscatorEnabled = configuration.getBoolean("orebfuscator.enable", false);
server.orebfuscatorUpdateRadius = configuration.getInt("orebfuscator.update-radius", 2);
server.orebfuscatorEngineMode = configuration.getInt("orebfuscator.engine-mode", 1);
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 6931712..474ac54 100644
index 3228d17..3122a14 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -34,6 +34,7 @@ settings:

Datei anzeigen

@ -1,4 +1,4 @@
From a308c6b519ecd2e93036e1a16948d30a3648dd1b Mon Sep 17 00:00:00 2001
From c8578420f6c44d29e5f93dfbcee0b861c16794bd Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 3 Feb 2013 09:20:19 +1100
Subject: [PATCH] Detect, remove and warn about null tile entities.

Datei anzeigen

@ -1,4 +1,4 @@
From 603242f60a45c54c3d8b5ba3190bea68ac8bb53b Mon Sep 17 00:00:00 2001
From c7b127737d0df2cfbbae9fa5abe6bbb85312139a Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 3 Feb 2013 12:28:17 +1100
Subject: [PATCH] Tick loop optimization - sleep for as long as possible.
@ -82,7 +82,7 @@ index 955a3ac..99a6cf4 100644
this.a((CrashReport) null);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index ccb1cc7..83988c3 100644
index c712b52..582dbab 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -6,6 +6,7 @@ import org.bukkit.configuration.file.YamlConfiguration;

Datei anzeigen

@ -1,4 +1,4 @@
From 9e2340addda939c6025c98d09d1ce3ace1643352 Mon Sep 17 00:00:00 2001
From 4203ea2e84a0c75510a1acdcf8a9f914f1c9403c Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Thu, 14 Feb 2013 17:32:20 +1100
Subject: [PATCH] Netty

Datei anzeigen

@ -1,4 +1,4 @@
From 32e3f230b9ed3247dad944db0174da82e78b9522 Mon Sep 17 00:00:00 2001
From 21e9df28f07d8c883d274c1e7b57caa79488dc03 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 3 Feb 2013 05:10:21 -0500
Subject: [PATCH] Entity Activation Range# This feature gives 3 new
@ -137,7 +137,7 @@ index 21bd64a..a083ae4 100644
public Block getBlockAt(int x, int y, int z) {
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
index b422bcd..94536c2 100644
index 582dbab..04f8f56 100644
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
@@ -1,7 +1,9 @@
@ -150,7 +150,7 @@ index b422bcd..94536c2 100644
public class Spigot {
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
@@ -33,5 +35,151 @@ public class Spigot {
@@ -37,5 +39,151 @@ public class Spigot {
server.getLogger().severe("[Spigot] You should not disable chunk-gc. Resetting period-in-ticks to 600 ticks.");
server.chunkGCPeriod = 600;
}
@ -322,7 +322,7 @@ index bb0c191..6a4a05e 100644
}
}
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 474ac54..f36aab3 100644
index 3122a14..5933a88 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -50,6 +50,9 @@ world-settings: