Skip to content

Commit

Permalink
[sq] Migrate global config to world config
Browse files Browse the repository at this point in the history
  • Loading branch information
zachbr committed Oct 28, 2018
1 parent 5fb524b commit cd732d7
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions Spigot-Server-Patches/0402-Optimize-redstone-algorithm.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From 94f51edf7e90da572fe0ea6cd2b3081e0577584c Mon Sep 17 00:00:00 2001
From f0da7b76d53ee19746c7658c29587c5788d5a866 Mon Sep 17 00:00:00 2001
From: theosib <millerti@172.16.221.1>
Date: Thu, 27 Sep 2018 01:43:35 -0600
Subject: [PATCH] Optimize redstone algorithm
Expand All @@ -18,18 +18,18 @@ A lot of this code is self-contained in a helper class.
Aside from making the obvious class/function renames and obfhelpers I didn't need to modify much.
Just added Bukkit's event system and took a few liberties with dead code and comment misspellings.

diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 70f650bb2..65e596340 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -458,4 +458,14 @@ public class PaperConfig {
velocitySecretKey = secret.getBytes(StandardCharsets.UTF_8);
}
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index eabb2c1ba..45ea9203b 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -569,4 +569,14 @@ public class PaperWorldConfig {
private void preventMovingIntoUnloadedChunks() {
preventMovingIntoUnloadedChunks = getBoolean("prevent-moving-into-unloaded-chunks", false);
}
+
+ public static boolean useEigencraftRedstone = false;
+ private static void useNewRedstone() {
+ useEigencraftRedstone = config.getBoolean("settings.use-faster-eigencraft-redstone", false);
+ public boolean useEigencraftRedstone = false;
+ private void useNewRedstone() {
+ useEigencraftRedstone = this.getBoolean("use-faster-eigencraft-redstone", false);
+ if (useEigencraftRedstone) {
+ log("Using new redstone algorithm by theosib.");
+ } else {
Expand Down Expand Up @@ -954,7 +954,7 @@ index 000000000..74d4dfedb
+ }
+}
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneWire.java b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
index 80bad6755..e2b225312 100644
index 80bad6755..67699a9e2 100644
--- a/src/main/java/net/minecraft/server/BlockRedstoneWire.java
+++ b/src/main/java/net/minecraft/server/BlockRedstoneWire.java
@@ -1,5 +1,7 @@
Expand Down Expand Up @@ -992,7 +992,7 @@ index 80bad6755..e2b225312 100644
+ * Note: Added 'source' argument so as to help determine direction of information flow
+ */
+ private IBlockData updateSurroundingRedstone(World worldIn, BlockPosition pos, IBlockData state, BlockPosition source) {
+ if (PaperConfig.useEigencraftRedstone) {
+ if (worldIn.paperConfig.useEigencraftRedstone) {
+ return turbo.updateSurroundingRedstone(worldIn, pos, state, source);
+ }
+ return a(worldIn, pos, state);
Expand All @@ -1015,7 +1015,7 @@ index 80bad6755..e2b225312 100644
+ int k = worldIn.isBlockIndirectlyGettingPowered(pos1);
+ this.setCanProvidePower(true);
+
+ if (!PaperConfig.useEigencraftRedstone) {
+ if (!worldIn.paperConfig.useEigencraftRedstone) {
+ // This code is totally redundant to if statements just below the loop.
+ if (k > 0 && k > j - 1) {
+ j = k;
Expand All @@ -1029,7 +1029,7 @@ index 80bad6755..e2b225312 100644
+ // redstone wire will be set to 'k'. If 'k' is already 15, then nothing inside the
+ // following loop can affect the power level of the wire. Therefore, the loop is
+ // skipped if k is already 15.
+ if (!PaperConfig.useEigencraftRedstone || k < 15) {
+ if (!worldIn.paperConfig.useEigencraftRedstone || k < 15) {
+ for (EnumDirection enumfacing : EnumDirection.EnumDirectionLimit.HORIZONTAL) {
+ BlockPosition blockpos = pos1.shift(enumfacing);
+ boolean flag = blockpos.getX() != pos2.getX() || blockpos.getZ() != pos2.getZ();
Expand All @@ -1048,7 +1048,7 @@ index 80bad6755..e2b225312 100644
+ }
+ }
+
+ if (!PaperConfig.useEigencraftRedstone) {
+ if (!worldIn.paperConfig.useEigencraftRedstone) {
+ // The old code would decrement the wire value only by 1 at a time.
+ if (l > j) {
+ j = l - 1;
Expand Down Expand Up @@ -1079,7 +1079,7 @@ index 80bad6755..e2b225312 100644
+ worldIn.setTypeAndData(pos1, state, 2);
+ }
+
+ if (!PaperConfig.useEigencraftRedstone) {
+ if (!worldIn.paperConfig.useEigencraftRedstone) {
+ // The new search algorithm keeps track of blocks needing updates in its own data structures,
+ // so only add anything to blocksNeedingUpdate if we're using the vanilla update algorithm.
+ this.getBlocksNeedingUpdate().add(pos1);
Expand Down

0 comments on commit cd732d7

Please sign in to comment.