2021-06-11 14:02:28 +02:00
|
|
|
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
|
2024-07-17 19:24:53 +02:00
|
|
|
index 89e05d9316b012a5c8103682ff9dbeae757f4f57..9114ba1742a4fc8683848d431fa92046a85fe871 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
2024-06-13 22:57:13 +02:00
|
|
|
@@ -1666,7 +1666,9 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
2024-04-24 14:11:27 +02:00
|
|
|
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));
|
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2024-07-17 19:24:53 +02:00
|
|
|
index 6e01013228798f9682624e912618500f0d4fa485..5ae307f9343ffea39c286992459a6c8069d9fb86 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
2024-06-14 23:07:44 +02:00
|
|
|
@@ -246,12 +246,14 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
2023-03-04 23:42:10 +01:00
|
|
|
@Override
|
2021-06-11 14:02:28 +02:00
|
|
|
public boolean setSpawnLocation(int x, int y, int z, float angle) {
|
|
|
|
try {
|
2023-03-04 23:42:10 +01:00
|
|
|
- Location previousLocation = this.getSpawnLocation();
|
2023-10-27 01:34:58 +02:00
|
|
|
- this.world.levelData.setSpawn(new BlockPos(x, y, z), angle);
|
2024-01-20 23:13:41 +01:00
|
|
|
+ // Location previousLocation = this.getSpawnLocation(); // Paper - Call SpawnChangeEvent; moved to nms.ServerLevel
|
2023-10-27 01:34:58 +02:00
|
|
|
+ this.world.setDefaultSpawnPos(new BlockPos(x, y, z), angle); // Paper - use ServerLevel#setDefaultSpawnPos
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2024-01-20 23:13:41 +01:00
|
|
|
+ // Paper start - Call SpawnChangeEvent; move to nms.ServerLevel
|
2021-06-11 14:02:28 +02:00
|
|
|
// Notify anyone who's listening.
|
|
|
|
- SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
|
2021-06-14 12:42:08 +02:00
|
|
|
- this.server.getPluginManager().callEvent(event);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ // SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
|
|
|
|
+ // server.getPluginManager().callEvent(event);
|
2024-01-20 23:13:41 +01:00
|
|
|
+ // Paper end - Call SpawnChangeEvent
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
} catch (Exception e) {
|