geforkt von Mirrors/Paper
90fe0d58a5
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 897a0a23 SPIGOT-5753: Back PotionType by a minecraft registry 255b2aa1 SPIGOT-7080: Add World#locateNearestBiome ff984826 Remove javadoc.io doc links CraftBukkit Changes: 71b0135cc SPIGOT-5753: Back PotionType by a minecraft registry a6bcb8489 SPIGOT-7080: Add World#locateNearestBiome ad0e57434 SPIGOT-7502: CraftMetaItem - cannot deserialize BlockStateTag b3efca57a SPIGOT-6400: Use Mockito instead of InvocationHandler 38c599f9d PR-1272: Only allow one entity in CraftItem instead of two f065271ac SPIGOT-7498: ChunkSnapshot.getBlockEmittedLight() gets 64 blocks upper in Overworld Spigot Changes: e0e223fe Remove javadoc.io doc links
119 Zeilen
6.7 KiB
Diff
119 Zeilen
6.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 18:23:26 -0800
|
|
Subject: [PATCH] Add cause to Weather/ThunderChangeEvents
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 0f59f5da41f3ab18148a7b44b0872632f03ad078..508b18f5e7dd6240a680e73be639d0cf9e4e5d07 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -666,8 +666,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
this.serverLevelData.setClearWeatherTime(clearDuration);
|
|
this.serverLevelData.setRainTime(rainDuration);
|
|
this.serverLevelData.setThunderTime(rainDuration);
|
|
- this.serverLevelData.setRaining(raining);
|
|
- this.serverLevelData.setThundering(thundering);
|
|
+ this.serverLevelData.setRaining(raining, org.bukkit.event.weather.WeatherChangeEvent.Cause.COMMAND); // Paper
|
|
+ this.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.COMMAND); // Paper
|
|
}
|
|
|
|
@Override
|
|
@@ -1087,8 +1087,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
this.serverLevelData.setThunderTime(j);
|
|
this.serverLevelData.setRainTime(k);
|
|
this.serverLevelData.setClearWeatherTime(i);
|
|
- this.serverLevelData.setThundering(flag1);
|
|
- this.serverLevelData.setRaining(flag2);
|
|
+ this.serverLevelData.setThundering(flag1, org.bukkit.event.weather.ThunderChangeEvent.Cause.NATURAL); // Paper
|
|
+ this.serverLevelData.setRaining(flag2, org.bukkit.event.weather.WeatherChangeEvent.Cause.NATURAL); // Paper
|
|
}
|
|
|
|
this.oThunderLevel = this.thunderLevel;
|
|
@@ -1154,14 +1154,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
|
|
private void resetWeatherCycle() {
|
|
// CraftBukkit start
|
|
- this.serverLevelData.setRaining(false);
|
|
+ this.serverLevelData.setRaining(false, org.bukkit.event.weather.WeatherChangeEvent.Cause.SLEEP); // Paper - when passing the night
|
|
// If we stop due to everyone sleeping we should reset the weather duration to some other random value.
|
|
// Not that everyone ever manages to get the whole server to sleep at the same time....
|
|
if (!this.serverLevelData.isRaining()) {
|
|
this.serverLevelData.setRainTime(0);
|
|
}
|
|
// CraftBukkit end
|
|
- this.serverLevelData.setThundering(false);
|
|
+ this.serverLevelData.setThundering(false, org.bukkit.event.weather.ThunderChangeEvent.Cause.SLEEP); // Paper - when passing the night
|
|
// CraftBukkit start
|
|
// If we stop due to everyone sleeping we should reset the weather duration to some other random value.
|
|
// Not that everyone ever manages to get the whole server to sleep at the same time....
|
|
diff --git a/src/main/java/net/minecraft/world/level/storage/PrimaryLevelData.java b/src/main/java/net/minecraft/world/level/storage/PrimaryLevelData.java
|
|
index 14b8011c8874e05647eb1636ee1eed5d90da8200..7bfc5bbfcf67e5bbf57e99e648ff5bed4d6b477f 100644
|
|
--- a/src/main/java/net/minecraft/world/level/storage/PrimaryLevelData.java
|
|
+++ b/src/main/java/net/minecraft/world/level/storage/PrimaryLevelData.java
|
|
@@ -394,6 +394,11 @@ public class PrimaryLevelData implements ServerLevelData, WorldData {
|
|
|
|
@Override
|
|
public void setThundering(boolean thundering) {
|
|
+ // Paper start
|
|
+ this.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.UNKNOWN);
|
|
+ }
|
|
+ public void setThundering(boolean thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause cause) {
|
|
+ // Paper end
|
|
// CraftBukkit start
|
|
if (this.thundering == thundering) {
|
|
return;
|
|
@@ -401,7 +406,7 @@ public class PrimaryLevelData implements ServerLevelData, WorldData {
|
|
|
|
org.bukkit.World world = Bukkit.getWorld(this.getLevelName());
|
|
if (world != null) {
|
|
- ThunderChangeEvent thunder = new ThunderChangeEvent(world, thundering);
|
|
+ ThunderChangeEvent thunder = new ThunderChangeEvent(world, thundering, cause); // Paper
|
|
Bukkit.getServer().getPluginManager().callEvent(thunder);
|
|
if (thunder.isCancelled()) {
|
|
return;
|
|
@@ -428,6 +433,12 @@ public class PrimaryLevelData implements ServerLevelData, WorldData {
|
|
|
|
@Override
|
|
public void setRaining(boolean raining) {
|
|
+ // Paper start
|
|
+ this.setRaining(raining, org.bukkit.event.weather.WeatherChangeEvent.Cause.UNKNOWN);
|
|
+ }
|
|
+
|
|
+ public void setRaining(boolean raining, org.bukkit.event.weather.WeatherChangeEvent.Cause cause) {
|
|
+ // Paper end
|
|
// CraftBukkit start
|
|
if (this.raining == raining) {
|
|
return;
|
|
@@ -435,7 +446,7 @@ public class PrimaryLevelData implements ServerLevelData, WorldData {
|
|
|
|
org.bukkit.World world = Bukkit.getWorld(this.getLevelName());
|
|
if (world != null) {
|
|
- WeatherChangeEvent weather = new WeatherChangeEvent(world, raining);
|
|
+ WeatherChangeEvent weather = new WeatherChangeEvent(world, raining, cause); // Paper
|
|
Bukkit.getServer().getPluginManager().callEvent(weather);
|
|
if (weather.isCancelled()) {
|
|
return;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
index 784001a514b2400b07f64f7d60ec0926891b7b51..a08d724c327b8f3eb819f72713b7fe4be18c1940 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
|
@@ -1187,7 +1187,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public void setStorm(boolean hasStorm) {
|
|
- world.levelData.setRaining(hasStorm);
|
|
+ world.serverLevelData.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper
|
|
this.setWeatherDuration(0); // Reset weather duration (legacy behaviour)
|
|
this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands)
|
|
}
|
|
@@ -1209,7 +1209,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
|
|
|
@Override
|
|
public void setThundering(boolean thundering) {
|
|
- world.serverLevelData.setThundering(thundering);
|
|
+ world.serverLevelData.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper
|
|
this.setThunderDuration(0); // Reset weather duration (legacy behaviour)
|
|
this.setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands)
|
|
}
|