summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2015-01-05 09:50:48 +1100
committermd_5 <git@md-5.net>2015-01-05 09:50:48 +1100
commit07fcb493a96c789173f2995c4b91ffe496255486 (patch)
tree9da5a4ee76db660536bba30e6a6cc209b8017368 /nms-patches
parente5c51c790fad12b79e0b186fe34e38a10bd57110 (diff)
downloadcraftbukkit-07fcb493a96c789173f2995c4b91ffe496255486.tar
craftbukkit-07fcb493a96c789173f2995c4b91ffe496255486.tar.gz
craftbukkit-07fcb493a96c789173f2995c4b91ffe496255486.tar.lz
craftbukkit-07fcb493a96c789173f2995c4b91ffe496255486.tar.xz
craftbukkit-07fcb493a96c789173f2995c4b91ffe496255486.zip
Rewrite storm / thunder event handling to catch all cases. Fixes SPIGOT-335.
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/World.patch55
-rw-r--r--nms-patches/WorldData.patch50
-rw-r--r--nms-patches/WorldServer.patch81
3 files changed, 98 insertions, 88 deletions
diff --git a/nms-patches/World.patch b/nms-patches/World.patch
index 57e89847..b0a4b583 100644
--- a/nms-patches/World.patch
+++ b/nms-patches/World.patch
@@ -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;
diff --git a/nms-patches/WorldData.patch b/nms-patches/WorldData.patch
index 41e25097..877ae674 100644
--- a/nms-patches/WorldData.patch
+++ b/nms-patches/WorldData.patch
@@ -1,6 +1,50 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/WorldData.java Sat Nov 29 19:36:33 2014
-+++ src/main/java/net/minecraft/server/WorldData.java Sat Nov 29 19:35:56 2014
-@@ -645,4 +645,12 @@
+--- ../work/decompile-8eb82bde/net/minecraft/server/WorldData.java 2015-01-05 09:50:01.989188327 +1100
++++ src/main/java/net/minecraft/server/WorldData.java 2015-01-05 09:50:01.993188321 +1100
+@@ -1,6 +1,9 @@
+ package net.minecraft.server;
+
+ import java.util.concurrent.Callable;
++import org.bukkit.Bukkit;
++import org.bukkit.event.weather.ThunderChangeEvent;
++import org.bukkit.event.weather.WeatherChangeEvent;
+
+ public class WorldData {
+
+@@ -395,6 +398,16 @@
+ }
+
+ public void setThundering(boolean flag) {
++ // CraftBukkit start
++ org.bukkit.World world = Bukkit.getWorld(getName());
++ if (world != null) {
++ ThunderChangeEvent thunder = new ThunderChangeEvent(world, flag);
++ Bukkit.getServer().getPluginManager().callEvent(thunder);
++ if (thunder.isCancelled()) {
++ return;
++ }
++ }
++ // CraftBukkit end
+ this.s = flag;
+ }
+
+@@ -411,6 +424,16 @@
+ }
+
+ public void setStorm(boolean flag) {
++ // CraftBukkit start
++ org.bukkit.World world = Bukkit.getWorld(getName());
++ if (world != null) {
++ WeatherChangeEvent weather = new WeatherChangeEvent(world, flag);
++ Bukkit.getServer().getPluginManager().callEvent(weather);
++ if (weather.isCancelled()) {
++ return;
++ }
++ }
++ // CraftBukkit end
+ this.q = flag;
+ }
+
+@@ -645,4 +668,12 @@
static boolean q(WorldData worlddata) {
return worlddata.x;
}
diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch
index 91ae74b7..42ccea1c 100644
--- a/nms-patches/WorldServer.patch
+++ b/nms-patches/WorldServer.patch
@@ -1,6 +1,6 @@
---- ../work/decompile-8eb82bde//net/minecraft/server/WorldServer.java 2015-01-04 19:54:26.537675427 +0000
-+++ src/main/java/net/minecraft/server/WorldServer.java 2015-01-04 19:54:26.541675427 +0000
-@@ -16,6 +16,20 @@
+--- ../work/decompile-8eb82bde/net/minecraft/server/WorldServer.java 2015-01-05 09:50:02.053188213 +1100
++++ src/main/java/net/minecraft/server/WorldServer.java 2015-01-05 09:50:02.057188206 +1100
+@@ -16,6 +16,18 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -14,14 +14,12 @@
+
+import org.bukkit.event.block.BlockFormEvent;
+import org.bukkit.event.weather.LightningStrikeEvent;
-+import org.bukkit.event.weather.ThunderChangeEvent;
-+import org.bukkit.event.weather.WeatherChangeEvent;
+// CraftBukkit end
+
public class WorldServer extends World implements IAsyncTaskHandler {
private static final Logger a = LogManager.getLogger();
-@@ -37,14 +51,21 @@
+@@ -37,14 +49,21 @@
private static final List U = Lists.newArrayList(new StructurePieceTreasure[] { new StructurePieceTreasure(Items.STICK, 0, 1, 3, 10), new StructurePieceTreasure(Item.getItemOf(Blocks.PLANKS), 0, 1, 3, 10), new StructurePieceTreasure(Item.getItemOf(Blocks.LOG), 0, 1, 3, 10), new StructurePieceTreasure(Items.STONE_AXE, 0, 1, 1, 3), new StructurePieceTreasure(Items.WOODEN_AXE, 0, 1, 1, 5), new StructurePieceTreasure(Items.STONE_PICKAXE, 0, 1, 1, 3), new StructurePieceTreasure(Items.WOODEN_PICKAXE, 0, 1, 1, 5), new StructurePieceTreasure(Items.APPLE, 0, 2, 3, 5), new StructurePieceTreasure(Items.BREAD, 0, 2, 3, 3), new StructurePieceTreasure(Item.getItemOf(Blocks.LOG2), 0, 1, 3, 10)});
private List V = Lists.newArrayList();
@@ -46,7 +44,7 @@
this.B();
this.C();
this.af().a(minecraftserver.aG());
-@@ -86,6 +107,89 @@
+@@ -86,6 +105,89 @@
return this;
}
@@ -136,7 +134,7 @@
public void doTick() {
super.doTick();
-@@ -105,8 +209,11 @@
+@@ -105,8 +207,11 @@
}
this.methodProfiler.a("mobSpawner");
@@ -150,7 +148,7 @@
}
this.methodProfiler.c("chunkSource");
-@@ -135,6 +242,8 @@
+@@ -135,6 +240,8 @@
this.Q.a(this.getTime());
this.methodProfiler.b();
this.ak();
@@ -159,7 +157,7 @@
}
public BiomeMeta a(EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
-@@ -161,7 +270,7 @@
+@@ -161,7 +268,7 @@
if (entityhuman.v()) {
++i;
@@ -168,27 +166,26 @@
++j;
}
}
-@@ -187,26 +296,45 @@
+@@ -187,26 +294,46 @@
}
private void ag() {
- this.worldData.setWeatherDuration(0);
-- this.worldData.setStorm(false);
+ this.worldData.setStorm(false);
- this.worldData.setThunderDuration(0);
-- this.worldData.setThundering(false);
+ // CraftBukkit start
-+ WeatherChangeEvent weather = new WeatherChangeEvent(this.getWorld(), false);
-+ this.getServer().getPluginManager().callEvent(weather);
-+
-+ ThunderChangeEvent thunder = new ThunderChangeEvent(this.getWorld(), false);
-+ this.getServer().getPluginManager().callEvent(thunder);
-+ if (!weather.isCancelled()) {
++ // 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.worldData.hasStorm()) {
+ this.worldData.setWeatherDuration(0);
-+ this.worldData.setStorm(false);
+ }
-+ if (!thunder.isCancelled()) {
++ // CraftBukkit end
+ this.worldData.setThundering(false);
++ // 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....
++ if (!this.worldData.isThundering()) {
+ this.worldData.setThunderDuration(0);
-+ this.worldData.setThundering(false);
+ }
+ // CraftBukkit end
}
@@ -221,7 +218,7 @@
return false;
} else {
return false;
-@@ -227,15 +355,22 @@
+@@ -227,15 +354,22 @@
} else {
int i = 0;
int j = 0;
@@ -252,7 +249,7 @@
this.a(k, l, chunk);
this.methodProfiler.c("tickChunk");
chunk.b(false);
-@@ -260,11 +395,29 @@
+@@ -260,11 +394,29 @@
BlockPosition blockposition1 = blockposition.down();
if (this.w(blockposition1)) {
@@ -284,7 +281,7 @@
}
if (this.S() && this.getBiome(blockposition1).e()) {
-@@ -376,7 +529,7 @@
+@@ -376,7 +528,7 @@
}
public void tickEntities() {
@@ -293,7 +290,7 @@
if (this.emptyTime++ >= 1200) {
return;
}
-@@ -401,7 +554,13 @@
+@@ -401,7 +553,13 @@
throw new IllegalStateException("TickNextTick list out of synch");
} else {
if (i > 1000) {
@@ -308,7 +305,7 @@
}
this.methodProfiler.a("cleaning");
-@@ -501,6 +660,7 @@
+@@ -501,6 +659,7 @@
return arraylist;
}
@@ -316,7 +313,7 @@
public void entityJoinedWorld(Entity entity, boolean flag) {
if (!this.getSpawnAnimals() && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) {
entity.die();
-@@ -511,7 +671,9 @@
+@@ -511,7 +670,9 @@
}
super.entityJoinedWorld(entity, flag);
@@ -326,7 +323,7 @@
private boolean getSpawnNPCs() {
return this.server.getSpawnNPCs();
-@@ -523,14 +685,44 @@
+@@ -523,14 +684,44 @@
protected IChunkProvider k() {
IChunkLoader ichunkloader = this.dataManager.createChunkLoader(this.worldProvider);
@@ -373,7 +370,7 @@
for (int k1 = 0; k1 < this.h.size(); ++k1) {
TileEntity tileentity = (TileEntity) this.h.get(k1);
BlockPosition blockposition = tileentity.getPosition();
-@@ -539,6 +731,8 @@
+@@ -539,6 +730,8 @@
arraylist.add(tileentity);
}
}
@@ -382,7 +379,7 @@
return arraylist;
}
-@@ -601,6 +795,23 @@
+@@ -601,6 +794,23 @@
int i = 0;
int j = this.worldProvider.getSeaLevel();
int k = 0;
@@ -406,7 +403,7 @@
if (blockposition != null) {
i = blockposition.getX();
-@@ -611,7 +822,7 @@
+@@ -611,7 +821,7 @@
int l = 0;
@@ -415,7 +412,7 @@
i += random.nextInt(64) - random.nextInt(64);
k += random.nextInt(64) - random.nextInt(64);
++l;
-@@ -648,8 +859,9 @@
+@@ -648,8 +858,9 @@
return this.worldProvider.h();
}
@@ -426,7 +423,7 @@
if (iprogressupdate != null) {
iprogressupdate.a("Saving level");
}
-@@ -660,7 +872,8 @@
+@@ -660,7 +871,8 @@
}
this.chunkProvider.saveChunks(flag, iprogressupdate);
@@ -436,7 +433,7 @@
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
-@@ -680,7 +893,7 @@
+@@ -680,7 +892,7 @@
}
}
@@ -445,7 +442,7 @@
this.checkSession();
this.worldData.a(this.af().h());
this.worldData.d(this.af().f());
-@@ -691,8 +904,12 @@
+@@ -691,8 +903,12 @@
this.worldData.k(this.af().p());
this.worldData.b(this.af().j());
this.worldData.e(this.af().i());
@@ -459,7 +456,7 @@
}
protected void a(Entity entity) {
-@@ -724,8 +941,16 @@
+@@ -724,8 +940,16 @@
}
public boolean strikeLightning(Entity entity) {
@@ -477,7 +474,7 @@
return true;
} else {
return false;
-@@ -737,10 +962,20 @@
+@@ -737,10 +961,20 @@
}
public Explosion createExplosion(Entity entity, double d0, double d1, double d2, float f, boolean flag, boolean flag1) {
@@ -498,7 +495,7 @@
if (!flag1) {
explosion.clearBlocks();
}
-@@ -786,7 +1021,8 @@
+@@ -786,7 +1020,8 @@
BlockActionData blockactiondata = (BlockActionData) iterator.next();
if (this.a(blockactiondata)) {
@@ -508,7 +505,7 @@
}
}
-@@ -809,6 +1045,7 @@
+@@ -809,6 +1044,7 @@
boolean flag = this.S();
super.p();
@@ -516,7 +513,7 @@
if (this.o != this.p) {
this.server.getPlayerList().a(new PacketPlayOutGameStateChange(7, this.p), this.worldProvider.getDimension());
}
-@@ -827,7 +1064,21 @@
+@@ -827,7 +1063,21 @@
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.p));
this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.r));
}
@@ -539,7 +536,7 @@
}
protected int q() {
-@@ -855,10 +1106,17 @@
+@@ -855,10 +1105,17 @@
}
public void a(EnumParticle enumparticle, boolean flag, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, int... aint) {