|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Wed, 7 Aug 2024 22:16:50 -0300 |
| 4 | +Subject: [PATCH] Remove unused code from Spigot tick limiters |
| 5 | + |
| 6 | +Paper removed this feature from Spigot, but forgot to remove some parts of the code/config |
| 7 | + |
| 8 | +diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java |
| 9 | +index 38ebe35f6fa434103b52e86262c7f4cc32d486e3..1a1b1e0cb30f294c3485da0f18ac71993b5779cc 100644 |
| 10 | +--- a/src/main/java/net/minecraft/server/World.java |
| 11 | ++++ b/src/main/java/net/minecraft/server/World.java |
| 12 | +@@ -135,8 +135,12 @@ public abstract class World implements IBlockAccess { |
| 13 | + private final byte chunkTickRadius; |
| 14 | + public static boolean haveWeSilencedAPhysicsCrash; |
| 15 | + public static String blockLocation; |
| 16 | ++ // PandaSpigot start - Remove unused code |
| 17 | ++ /* |
| 18 | + private org.spigotmc.TickLimiter entityLimiter; |
| 19 | + private org.spigotmc.TickLimiter tileLimiter; |
| 20 | ++ */ |
| 21 | ++ // PandaSpigot end |
| 22 | + private int tileTickPosition; |
| 23 | + public ExecutorService lightingExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("PaperSpigot - Lighting Thread").build()); // PaperSpigot - Asynchronous lighting updates |
| 24 | + public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<Explosion.CacheKey, Float>(); // PaperSpigot - Optimize explosions |
| 25 | +@@ -241,8 +245,12 @@ public abstract class World implements IBlockAccess { |
| 26 | + // CraftBukkit end |
| 27 | + this.keepSpawnInMemory = this.paperSpigotConfig.keepSpawnInMemory; // PaperSpigot |
| 28 | + timings = new co.aikar.timings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings |
| 29 | ++ // PandaSpigot start - Remove unused code |
| 30 | ++ /* |
| 31 | + this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime); |
| 32 | + this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime); |
| 33 | ++ */ |
| 34 | ++ // PandaSpigot end |
| 35 | + } |
| 36 | + |
| 37 | + public World b() { |
| 38 | +@@ -1552,7 +1560,7 @@ public abstract class World implements IBlockAccess { |
| 39 | + guardEntityList = true; // Spigot |
| 40 | + // CraftBukkit start - Use field for loop variable |
| 41 | + co.aikar.timings.TimingHistory.entityTicks += this.entityList.size(); // Spigot |
| 42 | +- int entitiesThisCycle = 0; |
| 43 | ++ // int entitiesThisCycle = 0; // PandaSpigot - Remove unused code |
| 44 | + // PaperSpigot start - Disable tick limiters |
| 45 | + //if (tickPosition < 0) tickPosition = 0; |
| 46 | + for (tickPosition = 0; tickPosition < entityList.size(); tickPosition++) { |
| 47 | +@@ -1624,14 +1632,14 @@ public abstract class World implements IBlockAccess { |
| 48 | + // CraftBukkit end |
| 49 | + |
| 50 | + // Spigot start |
| 51 | +- int tilesThisCycle = 0; |
| 52 | +- for (tileTickPosition = 0; tileTickPosition < tileEntityList.size(); tileTickPosition++) { // PaperSpigot - Disable tick limiters |
| 53 | ++ // int tilesThisCycle = 0; // PandaSpigot - Remove unused code |
| 54 | ++ for (tileTickPosition = 0; tileTickPosition < tileEntityList.size(); tileTickPosition++) { // PaperSpigot - Disable tick limiters // PandaSpigot - TODO: This is really necessary? I think we can go back to vanilla handling |
| 55 | + tileTickPosition = (tileTickPosition < tileEntityList.size()) ? tileTickPosition : 0; |
| 56 | + TileEntity tileentity = (TileEntity) this.tileEntityList.get(tileTickPosition); |
| 57 | + // Spigot start |
| 58 | + if (tileentity == null) { |
| 59 | + getServer().getLogger().severe("Spigot has detected a null entity and has removed it, preventing a crash"); |
| 60 | +- tilesThisCycle--; |
| 61 | ++ // tilesThisCycle--; // PandaSpigot - Remove unused code |
| 62 | + this.tileEntityList.remove(tileTickPosition--); |
| 63 | + continue; |
| 64 | + } |
| 65 | +@@ -1651,7 +1659,7 @@ public abstract class World implements IBlockAccess { |
| 66 | + System.err.println(msg); |
| 67 | + throwable2.printStackTrace(); |
| 68 | + getServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable2))); |
| 69 | +- tilesThisCycle--; |
| 70 | ++ // tilesThisCycle--; // PandaSpigot - Remove unused code |
| 71 | + this.tileEntityList.remove(tileTickPosition--); |
| 72 | + continue; |
| 73 | + // PaperSpigot end |
| 74 | +@@ -1665,7 +1673,7 @@ public abstract class World implements IBlockAccess { |
| 75 | + } |
| 76 | + |
| 77 | + if (tileentity.x()) { |
| 78 | +- tilesThisCycle--; |
| 79 | ++ // tilesThisCycle--; // PandaSpigot - Remove unused code |
| 80 | + this.tileEntityList.remove(tileTickPosition--); |
| 81 | + //this.h.remove(tileentity); // PaperSpigot - Remove unused list |
| 82 | + if (this.isLoaded(tileentity.getPosition())) { |
| 83 | +diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java |
| 84 | +index 8e86212aa5deae00c55cacc7207525df67a1868e..c028e9ff37e37f08f7c764a59cf77f5b447b0655 100644 |
| 85 | +--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java |
| 86 | ++++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java |
| 87 | +@@ -333,6 +333,8 @@ public class SpigotWorldConfig |
| 88 | + hangingTickFrequency = getInt( "hanging-tick-frequency", 100 ); |
| 89 | + } |
| 90 | + |
| 91 | ++ // PandaSpigot start - Remove unused config |
| 92 | ++ /* |
| 93 | + public int tileMaxTickTime; |
| 94 | + public int entityMaxTickTime; |
| 95 | + private void maxTickTimes() |
| 96 | +@@ -341,4 +343,6 @@ public class SpigotWorldConfig |
| 97 | + entityMaxTickTime = getInt("max-tick-time.entity", 50); |
| 98 | + log("Tile Max Tick Time: " + tileMaxTickTime + "ms Entity max Tick Time: " + entityMaxTickTime + "ms"); |
| 99 | + } |
| 100 | ++ */ |
| 101 | ++ // PandaSpigot end |
| 102 | + } |
| 103 | +diff --git a/src/main/java/org/spigotmc/TickLimiter.java b/src/main/java/org/spigotmc/TickLimiter.java |
| 104 | +deleted file mode 100644 |
| 105 | +index 23a39382be1541d31713a587a60079d0754c908b..0000000000000000000000000000000000000000 |
| 106 | +--- a/src/main/java/org/spigotmc/TickLimiter.java |
| 107 | ++++ /dev/null |
| 108 | +@@ -1,20 +0,0 @@ |
| 109 | +-package org.spigotmc; |
| 110 | +- |
| 111 | +-public class TickLimiter { |
| 112 | +- |
| 113 | +- private final int maxTime; |
| 114 | +- private long startTime; |
| 115 | +- |
| 116 | +- public TickLimiter(int maxtime) { |
| 117 | +- this.maxTime = maxtime; |
| 118 | +- } |
| 119 | +- |
| 120 | +- public void initTick() { |
| 121 | +- startTime = System.currentTimeMillis(); |
| 122 | +- } |
| 123 | +- |
| 124 | +- public boolean shouldContinue() { |
| 125 | +- long remaining = System.currentTimeMillis() - startTime; |
| 126 | +- return remaining < maxTime; |
| 127 | +- } |
| 128 | +-} |
0 commit comments