Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-15 02:50:09 +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.
44 Zeilen
2.6 KiB
Diff
44 Zeilen
2.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Sat, 22 Aug 2020 23:36:21 +0200
|
|
Subject: [PATCH] Fix SpawnChangeEvent not firing for all use-cases
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 89e05d9316b012a5c8103682ff9dbeae757f4f57..9114ba1742a4fc8683848d431fa92046a85fe871 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1666,7 +1666,9 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
float f1 = this.levelData.getSpawnAngle();
|
|
|
|
if (!blockposition1.equals(pos) || f1 != angle) {
|
|
+ org.bukkit.Location prevSpawnLoc = this.getWorld().getSpawnLocation(); // Paper - Call SpawnChangeEvent
|
|
this.levelData.setSpawn(pos, angle);
|
|
+ new org.bukkit.event.world.SpawnChangeEvent(this.getWorld(), prevSpawnLoc).callEvent(); // Paper - Call SpawnChangeEvent
|
|
this.getServer().getPlayerList().broadcastAll(new ClientboundSetDefaultSpawnPositionPacket(pos, angle));
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index 6e01013228798f9682624e912618500f0d4fa485..5ae307f9343ffea39c286992459a6c8069d9fb86 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -246,12 +246,14 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
@Override
|
|
public boolean setSpawnLocation(int x, int y, int z, float angle) {
|
|
try {
|
|
- Location previousLocation = this.getSpawnLocation();
|
|
- this.world.levelData.setSpawn(new BlockPos(x, y, z), angle);
|
|
+ // Location previousLocation = this.getSpawnLocation(); // Paper - Call SpawnChangeEvent; moved to nms.ServerLevel
|
|
+ this.world.setDefaultSpawnPos(new BlockPos(x, y, z), angle); // Paper - use ServerLevel#setDefaultSpawnPos
|
|
|
|
+ // Paper start - Call SpawnChangeEvent; move to nms.ServerLevel
|
|
// Notify anyone who's listening.
|
|
- SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
|
|
- this.server.getPluginManager().callEvent(event);
|
|
+ // SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
|
|
+ // server.getPluginManager().callEvent(event);
|
|
+ // Paper end - Call SpawnChangeEvent
|
|
|
|
return true;
|
|
} catch (Exception e) {
|