From 0976e9a02ae2d7d0064ecaae698d570b793ab52e Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Sat, 5 Jul 2014 22:55:30 -0500 Subject: [PATCH] Make players tick in main loop "feature" configurable Defaults to false, servers thant additional security and peace of mind can turn it back on but doing so may cause gameplay abnormalities --- .../0002-PaperSpigot-config-files.patch | 8 +- ...urable-interaction-limit-restriction.patch | 6 +- ...-main-tick-loop-feature-configurable.patch | 160 ++++++++++++++++++ 3 files changed, 167 insertions(+), 7 deletions(-) create mode 100644 CraftBukkit-Patches/0025-Make-players-in-main-tick-loop-feature-configurable.patch diff --git a/CraftBukkit-Patches/0002-PaperSpigot-config-files.patch b/CraftBukkit-Patches/0002-PaperSpigot-config-files.patch index 5758e2329..b09776ffc 100644 --- a/CraftBukkit-Patches/0002-PaperSpigot-config-files.patch +++ b/CraftBukkit-Patches/0002-PaperSpigot-config-files.patch @@ -1,4 +1,4 @@ -From 00702f0bae4a4aa9e7cec4bc18346646a5be8477 Mon Sep 17 00:00:00 2001 +From d95bbdf079e933361de7873e910f52520b57e66d Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 2 Jul 2014 22:26:16 -0500 Subject: [PATCH] PaperSpigot config files @@ -40,10 +40,10 @@ index cb6efc0..a0a1dd1 100644 this.world = new CraftWorld((WorldServer) this, gen, env); this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 40a9eb3..db7484a 100644 +index 8ad5b89..95d30e8 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -815,6 +815,7 @@ public final class CraftServer implements Server { +@@ -813,6 +813,7 @@ public final class CraftServer implements Server { } org.spigotmc.SpigotConfig.init(); // Spigot @@ -51,7 +51,7 @@ index 40a9eb3..db7484a 100644 for (WorldServer world : console.worlds) { world.difficulty = difficulty; world.setSpawnFlags(monsters, animals); -@@ -830,12 +831,14 @@ public final class CraftServer implements Server { +@@ -828,12 +829,14 @@ public final class CraftServer implements Server { world.ticksPerMonsterSpawns = this.getTicksPerMonsterSpawns(); } world.spigotConfig.init(); // Spigot diff --git a/CraftBukkit-Patches/0022-Configurable-interaction-limit-restriction.patch b/CraftBukkit-Patches/0022-Configurable-interaction-limit-restriction.patch index 2288e50ae..23ae5d000 100644 --- a/CraftBukkit-Patches/0022-Configurable-interaction-limit-restriction.patch +++ b/CraftBukkit-Patches/0022-Configurable-interaction-limit-restriction.patch @@ -1,11 +1,11 @@ -From 2e5f51f1a7378429dd6855c63c2fa59224a48a7e Mon Sep 17 00:00:00 2001 +From 93a0fc4b68a3803e2206b098f81b7d183c1e4e44 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 3 Jul 2014 00:53:47 -0500 Subject: [PATCH] Configurable interaction limit restriction diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index afafd62..71878e9 100644 +index baa89ef..d5f3b7b 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -59,6 +59,8 @@ import org.bukkit.inventory.InventoryView; @@ -17,7 +17,7 @@ index afafd62..71878e9 100644 public class PlayerConnection implements PacketPlayInListener { private static final Logger c = LogManager.getLogger(); -@@ -588,7 +590,7 @@ public class PlayerConnection implements PacketPlayInListener { +@@ -570,7 +572,7 @@ public class PlayerConnection implements PacketPlayInListener { public void a(PacketPlayInBlockPlace packetplayinblockplace) { boolean throttled = false; diff --git a/CraftBukkit-Patches/0025-Make-players-in-main-tick-loop-feature-configurable.patch b/CraftBukkit-Patches/0025-Make-players-in-main-tick-loop-feature-configurable.patch new file mode 100644 index 000000000..f10437703 --- /dev/null +++ b/CraftBukkit-Patches/0025-Make-players-in-main-tick-loop-feature-configurable.patch @@ -0,0 +1,160 @@ +From bcc9626b269c27b7c3b72cc6d1ee56793f517305 Mon Sep 17 00:00:00 2001 +From: Zach Brown +Date: Sat, 5 Jul 2014 22:54:54 -0500 +Subject: [PATCH] Make players in main tick loop feature configurable + + +diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java +index 93b974a..ffd0549 100644 +--- a/src/main/java/net/minecraft/server/EntityPlayer.java ++++ b/src/main/java/net/minecraft/server/EntityPlayer.java +@@ -27,6 +27,8 @@ import org.bukkit.event.inventory.InventoryType; + import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; + // CraftBukkit end + ++import org.github.paperspigot.PaperSpigotConfig; // PaperSpigot ++ + public class EntityPlayer extends EntityHuman implements ICrafting { + + private static final Logger bL = LogManager.getLogger(); +@@ -175,13 +177,16 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + return 1.62F; + } + +- // Spigot start +- private AxisAlignedBB groundCheck = AxisAlignedBB.a( 0, 0, 0, 0, 0, 0 ); +- + public void h() { +- groundCheck.b( locX - 0.3, locY - 0.1, locZ - 0.3, locX + 0.3, locY, locZ + 0.3 ); +- onGround = world.c(groundCheck); +- // Spigot end ++ // PaperSpigot start - Make player tick in main loop configurable ++ if (PaperSpigotConfig.playerTickMainLoop) { ++ // Spigot start ++ AxisAlignedBB groundCheck = AxisAlignedBB.a( 0, 0, 0, 0, 0, 0 ); ++ groundCheck.b( locX - 0.3, locY - 0.1, locZ - 0.3, locX + 0.3, locY, locZ + 0.3 ); ++ onGround = world.c(groundCheck); ++ // Spigot end ++ } ++ // PaperSpigot end + + // CraftBukkit start + if (this.joining) { +@@ -261,14 +266,19 @@ public class EntityPlayer extends EntityHuman implements ICrafting { + if (this.bX > 0L && this.server.getIdleTimeout() > 0 && MinecraftServer.ar() - this.bX > (long) (this.server.getIdleTimeout() * 1000 * 60)) { + this.playerConnection.disconnect("You have been idle for too long!"); + } +- // Spigot start +- this.i(); +- if ( Double.isNaN( previousY ) ) +- { ++ ++ // PaperSpigot start - Make player tick in main loop configurable ++ if (PaperSpigotConfig.playerTickMainLoop) { ++ // Spigot start ++ this.i(); ++ if ( Double.isNaN( previousY ) ) ++ { ++ previousY = locY; ++ } ++ this.b(locY - previousY, onGround); + previousY = locY; + } +- this.b(locY - previousY, onGround); +- previousY = locY; ++ // PaperSpigot end + } + + private double previousY = Double.NaN; +diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java +index d5f3b7b..d8dd9af 100644 +--- a/src/main/java/net/minecraft/server/PlayerConnection.java ++++ b/src/main/java/net/minecraft/server/PlayerConnection.java +@@ -291,6 +291,12 @@ public class PlayerConnection implements PacketPlayInListener { + f1 = packetplayinflying.h(); + } + ++ // PaperSpigot start - Make player tick in main loop configurable ++ if (!PaperSpigotConfig.playerTickMainLoop) { ++ this.player.onGround = packetplayinflying.i(); ++ this.player.i(); ++ } ++ // PaperSpigot end; + this.player.V = 0.0F; + this.player.setLocation(d1, d2, d3, f, f1); + if (this.player.vehicle != null) { +@@ -309,6 +315,11 @@ public class PlayerConnection implements PacketPlayInListener { + } + + if (this.player.isSleeping()) { ++ // PaperSpigot start - Make player tick in main loop configurable ++ if (!PaperSpigotConfig.playerTickMainLoop) { ++ this.player.i(); ++ } ++ // PaperSpigot end + this.player.setLocation(this.y, this.z, this.q, this.player.yaw, this.player.pitch); + worldserver.playerJoinedWorld(this.player); + return; +@@ -352,6 +363,11 @@ public class PlayerConnection implements PacketPlayInListener { + f3 = packetplayinflying.h(); + } + ++ // PaperSpigot start - Make player tick in main loop configurable ++ if (!PaperSpigotConfig.playerTickMainLoop) { ++ this.player.i(); ++ } ++ // PaperSpigot end + this.player.V = 0.0F; + this.player.setLocation(this.y, this.z, this.q, f2, f3); + if (!this.checkMovement) { +@@ -382,6 +398,11 @@ public class PlayerConnection implements PacketPlayInListener { + } + + this.player.move(d4, d5, d6); ++ // PaperSpigot start - Make player tick in main loop configurable ++ if (!PaperSpigotConfig.playerTickMainLoop) { ++ this.player.onGround = packetplayinflying.i(); ++ } ++ // PaperSpigot end + this.player.checkMovement(d4, d5, d6); + double d11 = d5; + +@@ -423,7 +444,17 @@ public class PlayerConnection implements PacketPlayInListener { + this.f = 0; + } + ++ // PaperSpigot start - Make player tick in main loop configurable ++ if (!PaperSpigotConfig.playerTickMainLoop) { ++ this.player.onGround = packetplayinflying.i(); ++ } ++ // PaperSpigot end + this.minecraftServer.getPlayerList().d(this.player); ++ // PaperSpigot start - Make player tick in main loop configurable ++ if (!PaperSpigotConfig.playerTickMainLoop) { ++ this.player.b(this.player.locY - d0, packetplayinflying.i()); ++ } ++ // PaperSpigot end + } else if (this.e % 20 == 0) { + this.a(this.y, this.z, this.q, this.player.yaw, this.player.pitch); + } +diff --git a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java +index 7bda065..4f9f660 100644 +--- a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java ++++ b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java +@@ -135,4 +135,13 @@ public class PaperSpigotConfig + { + interactLimit = getInt( "settings.player-interaction-limit", 2 ); + } ++ ++ public static boolean playerTickMainLoop; ++ private static void playerTickMainLoop() ++ { ++ playerTickMainLoop = getBoolean( "settings.player-tick-in-main-loop", false ); ++ if ( playerTickMainLoop ) { ++ Bukkit.getLogger().log( Level.INFO, "Ticking players in the main loop. This may cause gameplay abnormalities" ); ++ } ++ } + } +-- +1.9.1 +