mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
137 lines
6.9 KiB
Diff
137 lines
6.9 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||
|
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||
|
this.worldDataServer.setClearWeatherTime(clearDuration);
|
||
|
this.worldDataServer.setRainTime(rainDuration);
|
||
|
this.worldDataServer.setThunderTime(rainDuration);
|
||
|
- this.worldDataServer.setRaining(raining);
|
||
|
- this.worldDataServer.setThundering(thundering);
|
||
|
+ this.worldDataServer.setRaining(raining, org.bukkit.event.weather.WeatherChangeEvent.Cause.COMMAND); // Paper
|
||
|
+ this.worldDataServer.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.COMMAND); // Paper
|
||
|
}
|
||
|
|
||
|
public Biome getBiomeBySeed(int i, int j, int k) { return getUncachedNoiseBiome(i, j, k); } // Paper - OBFHELPER
|
||
|
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||
|
this.worldDataServer.setThunderTime(j);
|
||
|
this.worldDataServer.setRainTime(k);
|
||
|
this.worldDataServer.setClearWeatherTime(i);
|
||
|
- this.worldDataServer.setThundering(flag1);
|
||
|
- this.worldDataServer.setRaining(flag2);
|
||
|
+ this.worldDataServer.setThundering(flag1, org.bukkit.event.weather.ThunderChangeEvent.Cause.NATURAL); // Paper
|
||
|
+ this.worldDataServer.setRaining(flag2, org.bukkit.event.weather.WeatherChangeEvent.Cause.NATURAL); // Paper
|
||
|
}
|
||
|
|
||
|
this.oThunderLevel = this.thunderLevel;
|
||
|
@@ -0,0 +0,0 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
|
||
|
|
||
|
private void stopWeather() {
|
||
|
// CraftBukkit start
|
||
|
- this.worldDataServer.setRaining(false);
|
||
|
+ this.worldDataServer.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.worldDataServer.isRaining()) {
|
||
|
this.worldDataServer.setRainTime(0);
|
||
|
}
|
||
|
// CraftBukkit end
|
||
|
- this.worldDataServer.setThundering(false);
|
||
|
+ this.worldDataServer.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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||
|
--- a/src/main/java/net/minecraft/world/level/storage/PrimaryLevelData.java
|
||
|
+++ b/src/main/java/net/minecraft/world/level/storage/PrimaryLevelData.java
|
||
|
@@ -0,0 +0,0 @@ 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 flag, org.bukkit.event.weather.ThunderChangeEvent.Cause cause) {
|
||
|
+ // Paper end
|
||
|
// CraftBukkit start
|
||
|
- if (this.thundering == thundering) {
|
||
|
+ if (this.thundering == flag) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
org.bukkit.World world = Bukkit.getWorld(getLevelName());
|
||
|
if (world != null) {
|
||
|
- ThunderChangeEvent thunder = new ThunderChangeEvent(world, thundering);
|
||
|
+ ThunderChangeEvent thunder = new ThunderChangeEvent(world, flag, cause); // Paper
|
||
|
Bukkit.getServer().getPluginManager().callEvent(thunder);
|
||
|
if (thunder.isCancelled()) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
// CraftBukkit end
|
||
|
- this.thundering = thundering;
|
||
|
+ this.thundering = flag;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
@@ -0,0 +0,0 @@ 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 setStorm(boolean flag, org.bukkit.event.weather.WeatherChangeEvent.Cause cause) {
|
||
|
+ // Paper end
|
||
|
// CraftBukkit start
|
||
|
- if (this.raining == raining) {
|
||
|
+ if (this.raining == flag) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
org.bukkit.World world = Bukkit.getWorld(getLevelName());
|
||
|
if (world != null) {
|
||
|
- WeatherChangeEvent weather = new WeatherChangeEvent(world, raining);
|
||
|
+ WeatherChangeEvent weather = new WeatherChangeEvent(world, flag, cause); // Paper
|
||
|
Bukkit.getServer().getPluginManager().callEvent(weather);
|
||
|
if (weather.isCancelled()) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
// CraftBukkit end
|
||
|
- this.raining = raining;
|
||
|
+ this.raining = flag;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||
|
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
|
||
|
|
||
|
@Override
|
||
|
public void setStorm(boolean hasStorm) {
|
||
|
- world.levelData.setRaining(hasStorm);
|
||
|
+ world.worldDataServer.setRaining(hasStorm, org.bukkit.event.weather.WeatherChangeEvent.Cause.PLUGIN); // Paper
|
||
|
setWeatherDuration(0); // Reset weather duration (legacy behaviour)
|
||
|
setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands)
|
||
|
}
|
||
|
@@ -0,0 +0,0 @@ public class CraftWorld implements World {
|
||
|
|
||
|
@Override
|
||
|
public void setThundering(boolean thundering) {
|
||
|
- world.worldDataServer.setThundering(thundering);
|
||
|
+ world.worldDataServer.setThundering(thundering, org.bukkit.event.weather.ThunderChangeEvent.Cause.PLUGIN); // Paper
|
||
|
setThunderDuration(0); // Reset weather duration (legacy behaviour)
|
||
|
setClearWeatherDuration(0); // Reset clear weather duration (reset "/weather clear" commands)
|
||
|
}
|