Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
c5a10665b8
Spigot still maintains some partial implementation of "tick skipping", a practice in which the MinecraftServer.currentTick field is updated not by an increment of one per actual tick, but instead set to System.currentTimeMillis() / 50. This behaviour means that the tracked tick may "skip" a tick value in case a previous tick took more than the expected 50ms. To compensate for this in important paths, spigot/craftbukkit implements "wall-time". Instead of incrementing/decrementing ticks on block entities/entities by one for each call to their tick() method, they instead increment/decrement important values, like an ItemEntity's age or pickupDelay, by the difference of `currentTick - lastTick`, where `lastTick` is the value of `currentTick` during the last tick() call. These "fixes" however do not play nicely with minecraft's simulation distance as entities/block entities implementing the above behaviour would "catch up" their values when moving from a non-ticking chunk to a ticking one as their `lastTick` value remains stuck on the last tick in a ticking chunk and hence lead to a large "catch up" once ticked again. Paper completely removes the "tick skipping" behaviour (See patch "Further-improve-server-tick-loop"), making the above precautions completely unnecessary, which also rids paper of the previous described incompatibility with non-ticking chunks.
55 Zeilen
3.7 KiB
Diff
55 Zeilen
3.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Date: Wed, 2 Dec 2020 20:04:01 -0800
|
|
Subject: [PATCH] Add ServerResourcesReloadedEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 05aa3323e9ae971fba5ab8c6c319c7805a3808aa..39ce74bc3fbb282f56028273d53f980171bdb464 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -2114,7 +2114,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
return this.functionManager;
|
|
}
|
|
|
|
+ // Paper start - Add ServerResourcesReloadedEvent
|
|
+ @Deprecated @io.papermc.paper.annotation.DoNotUse
|
|
public CompletableFuture<Void> reloadResources(Collection<String> dataPacks) {
|
|
+ return this.reloadResources(dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.PLUGIN);
|
|
+ }
|
|
+ public CompletableFuture<Void> reloadResources(Collection<String> dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause cause) {
|
|
+ // Paper end - Add ServerResourcesReloadedEvent
|
|
CompletableFuture<Void> completablefuture = CompletableFuture.supplyAsync(() -> {
|
|
Stream<String> stream = dataPacks.stream(); // CraftBukkit - decompile error
|
|
PackRepository resourcepackrepository = this.packRepository;
|
|
@@ -2146,6 +2152,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary());
|
|
this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager);
|
|
org.bukkit.craftbukkit.block.data.CraftBlockData.reloadCache(); // Paper - cache block data strings; they can be defined by datapacks so refresh it here
|
|
+ new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper - Add ServerResourcesReloadedEvent; fire after everything has been reloaded
|
|
}, this);
|
|
|
|
if (this.isSameThread()) {
|
|
diff --git a/src/main/java/net/minecraft/server/commands/ReloadCommand.java b/src/main/java/net/minecraft/server/commands/ReloadCommand.java
|
|
index fa18d018a8458b30c0048f7e59aea39f928d974a..c020c86194723a5c89816f91e0b7c5eeaf132b7e 100644
|
|
--- a/src/main/java/net/minecraft/server/commands/ReloadCommand.java
|
|
+++ b/src/main/java/net/minecraft/server/commands/ReloadCommand.java
|
|
@@ -20,7 +20,7 @@ public class ReloadCommand {
|
|
public ReloadCommand() {}
|
|
|
|
public static void reloadPacks(Collection<String> dataPacks, CommandSourceStack source) {
|
|
- source.getServer().reloadResources(dataPacks).exceptionally((throwable) -> {
|
|
+ source.getServer().reloadResources(dataPacks, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.COMMAND).exceptionally((throwable) -> { // Paper - Add ServerResourcesReloadedEvent
|
|
ReloadCommand.LOGGER.warn("Failed to execute reload", throwable);
|
|
source.sendFailure(Component.translatable("commands.reload.failure"));
|
|
return null;
|
|
@@ -50,7 +50,7 @@ public class ReloadCommand {
|
|
WorldData savedata = minecraftserver.getWorldData();
|
|
Collection<String> collection = resourcepackrepository.getSelectedIds();
|
|
Collection<String> collection1 = ReloadCommand.discoverNewPacks(resourcepackrepository, savedata, collection);
|
|
- minecraftserver.reloadResources(collection1);
|
|
+ minecraftserver.reloadResources(collection1, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.PLUGIN); // Paper - Add ServerResourcesReloadedEvent
|
|
}
|
|
// CraftBukkit end
|
|
|