diff options
author | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
---|---|---|
committer | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
commit | bee74680e607c2e29b038329f62181238911cd83 (patch) | |
tree | 708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/mache-vineflower/net/minecraft/server/ServerTickRateManager.java.patch | |
parent | 0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff) | |
download | Paper-softspoon.tar.gz Paper-softspoon.zip |
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/server/ServerTickRateManager.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/server/ServerTickRateManager.java.patch | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/server/ServerTickRateManager.java.patch b/patch-remap/mache-vineflower/net/minecraft/server/ServerTickRateManager.java.patch new file mode 100644 index 0000000000..4cbcec6fa8 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/server/ServerTickRateManager.java.patch @@ -0,0 +1,108 @@ +--- a/net/minecraft/server/ServerTickRateManager.java ++++ b/net/minecraft/server/ServerTickRateManager.java +@@ -8,6 +8,7 @@ + import net.minecraft.world.TickRateManager; + + public class ServerTickRateManager extends TickRateManager { ++ + private long remainingSprintTicks = 0L; + private long sprintTickStartTime = 0L; + private long sprintTimeSpend = 0L; +@@ -15,8 +16,8 @@ + private boolean previousIsFrozen = false; + private final MinecraftServer server; + +- public ServerTickRateManager(MinecraftServer minecraftServer) { +- this.server = minecraftServer; ++ public ServerTickRateManager(MinecraftServer minecraftserver) { ++ this.server = minecraftserver; + } + + public boolean isSprinting() { +@@ -58,8 +59,14 @@ + } + + public boolean stopSprinting() { ++ // CraftBukkit start, add sendLog parameter ++ return stopSprinting(true); ++ } ++ ++ public boolean stopSprinting(boolean sendLog) { ++ // CraftBukkit end + if (this.remainingSprintTicks > 0L) { +- this.finishTickSprint(); ++ this.finishTickSprint(sendLog); // CraftBukkit - add sendLog parameter + return true; + } else { + return false; +@@ -68,22 +75,30 @@ + + public boolean requestGameToSprint(int i) { + boolean flag = this.remainingSprintTicks > 0L; ++ + this.sprintTimeSpend = 0L; +- this.scheduledCurrentSprintTicks = (long)i; +- this.remainingSprintTicks = (long)i; ++ this.scheduledCurrentSprintTicks = (long) i; ++ this.remainingSprintTicks = (long) i; + this.previousIsFrozen = this.isFrozen(); + this.setFrozen(false); + return flag; + } + +- private void finishTickSprint() { +- long l = this.scheduledCurrentSprintTicks - this.remainingSprintTicks; +- double d = Math.max(1.0, (double)this.sprintTimeSpend) / (double)TimeUtil.NANOSECONDS_PER_MILLISECOND; +- int i = (int)((double)(TimeUtil.MILLISECONDS_PER_SECOND * l) / d); +- String string = String.format("%.2f", l == 0L ? (double)this.millisecondsPerTick() : d / (double)l); ++ private void finishTickSprint(boolean sendLog) { // CraftBukkit - add sendLog parameter ++ long i = this.scheduledCurrentSprintTicks - this.remainingSprintTicks; ++ double d0 = Math.max(1.0D, (double) this.sprintTimeSpend) / (double) TimeUtil.NANOSECONDS_PER_MILLISECOND; ++ int j = (int) ((double) (TimeUtil.MILLISECONDS_PER_SECOND * i) / d0); ++ String s = String.format("%.2f", i == 0L ? (double) this.millisecondsPerTick() : d0 / (double) i); ++ + this.scheduledCurrentSprintTicks = 0L; + this.sprintTimeSpend = 0L; +- this.server.createCommandSourceStack().sendSuccess(() -> Component.translatable("commands.tick.sprint.report", i, string), true); ++ // CraftBukkit start - add sendLog parameter ++ if (sendLog) { ++ this.server.createCommandSourceStack().sendSuccess(() -> { ++ return Component.translatable("commands.tick.sprint.report", j, s); ++ }, true); ++ } ++ // CraftBukkit end + this.remainingSprintTicks = 0L; + this.setFrozen(this.previousIsFrozen); + this.server.onTickRateChanged(); +@@ -94,16 +109,16 @@ + return false; + } else if (this.remainingSprintTicks > 0L) { + this.sprintTickStartTime = System.nanoTime(); +- this.remainingSprintTicks--; ++ --this.remainingSprintTicks; + return true; + } else { +- this.finishTickSprint(); ++ this.finishTickSprint(true); // CraftBukkit - add sendLog parameter + return false; + } + } + + public void endTickWork() { +- this.sprintTimeSpend = this.sprintTimeSpend + (System.nanoTime() - this.sprintTickStartTime); ++ this.sprintTimeSpend += System.nanoTime() - this.sprintTickStartTime; + } + + @Override +@@ -113,8 +128,8 @@ + this.updateStateToClients(); + } + +- public void updateJoiningPlayer(ServerPlayer serverPlayer) { +- serverPlayer.connection.send(ClientboundTickingStatePacket.from(this)); +- serverPlayer.connection.send(ClientboundTickingStepPacket.from(this)); ++ public void updateJoiningPlayer(ServerPlayer entityplayer) { ++ entityplayer.connection.send(ClientboundTickingStatePacket.from(this)); ++ entityplayer.connection.send(ClientboundTickingStepPacket.from(this)); + } + } |