Rewrite storm / thunder event handling to catch all cases. Fixes SPIGOT-335.

This commit is contained in:
md_5
2015-01-05 09:50:48 +11:00
parent e5c51c790f
commit 07fcb493a9
3 changed files with 98 additions and 88 deletions

View File

@@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde/net/minecraft/server/World.java 2014-12-10 19:16:20.916465384 +0000
+++ src/main/java/net/minecraft/server/World.java 2014-12-10 19:11:37.648468459 +0000
--- ../work/decompile-8eb82bde/net/minecraft/server/World.java 2015-01-05 09:42:04.285856834 +1100
+++ src/main/java/net/minecraft/server/World.java 2015-01-05 09:42:04.293856810 +1100
@@ -13,6 +13,22 @@
import java.util.UUID;
import java.util.concurrent.Callable;
@@ -412,38 +412,7 @@
entity.P = entity.locX;
entity.Q = entity.locY;
entity.R = entity.locZ;
@@ -1615,7 +1834,13 @@
--j;
this.worldData.setThunderDuration(j);
if (j <= 0) {
- this.worldData.setThundering(!this.worldData.isThundering());
+ // CraftBukkit start
+ ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), !this.worldData.isThundering());
+ this.getServer().getPluginManager().callEvent(thunder);
+ if (!thunder.isCancelled()) {
+ this.worldData.setThundering(!this.worldData.isThundering());
+ }
+ // CraftBukkit end
}
}
@@ -1639,7 +1864,14 @@
--k;
this.worldData.setWeatherDuration(k);
if (k <= 0) {
- this.worldData.setStorm(!this.worldData.hasStorm());
+ // CraftBukkit start
+ WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), !this.worldData.hasStorm());
+ this.getServer().getPluginManager().callEvent(weather);
+
+ if (!weather.isCancelled()) {
+ this.worldData.setStorm(!this.worldData.hasStorm());
+ }
+ // CraftBukkit end
}
}
@@ -1651,12 +1883,18 @@
@@ -1651,12 +1870,18 @@
}
this.p = MathHelper.a(this.p, 0.0F, 1.0F);
@@ -463,7 +432,7 @@
this.methodProfiler.a("buildList");
int i;
@@ -1673,7 +1911,7 @@
@@ -1673,7 +1898,7 @@
for (int i1 = -l; i1 <= l; ++i1) {
for (int j1 = -l; j1 <= l; ++j1) {
@@ -472,7 +441,7 @@
}
}
}
@@ -1851,7 +2089,10 @@
@@ -1851,7 +2076,10 @@
}
public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) {
@@ -484,7 +453,7 @@
return false;
} else {
int i = 0;
@@ -2095,8 +2336,17 @@
@@ -2095,8 +2323,17 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -503,7 +472,7 @@
++i;
}
}
@@ -2105,12 +2355,17 @@
@@ -2105,12 +2342,17 @@
}
public void b(Collection collection) {
@@ -523,7 +492,7 @@
this.a(entity);
}
@@ -2124,7 +2379,13 @@
@@ -2124,7 +2366,13 @@
Block block1 = this.getType(blockposition).getBlock();
AxisAlignedBB axisalignedbb = flag ? null : block.a(this, blockposition, block.getBlockData());
@@ -538,7 +507,7 @@
}
public int getBlockPower(BlockPosition blockposition, EnumDirection enumdirection) {
@@ -2215,6 +2476,11 @@
@@ -2215,6 +2463,11 @@
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
@@ -550,7 +519,7 @@
if (IEntitySelector.d.apply(entityhuman1)) {
double d5 = entityhuman1.e(d0, d1, d2);
@@ -2269,7 +2535,7 @@
@@ -2269,7 +2522,7 @@
return null;
}
@@ -559,7 +528,7 @@
this.dataManager.checkSession();
}
@@ -2331,6 +2597,16 @@
@@ -2331,6 +2584,16 @@
public void everyoneSleeping() {}
@@ -576,7 +545,7 @@
public float h(float f) {
return (this.q + (this.r - this.q) * f) * this.j(f);
}
@@ -2538,6 +2814,6 @@
@@ -2538,6 +2801,6 @@
int l = j * 16 + 8 - blockposition.getZ();
short short0 = 128;