From b6cff41473b8715e1ef72be473b55f39cccfbd2a Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Tue, 2 Dec 2014 15:13:07 +0000 Subject: SPIGOT-96/BUKKIT-5016: Fix thunder storms not darkening the sky and transitions being broken. --- nms-patches/EntityPlayer.patch | 79 +++++++++++++++++++++++++++++++----------- nms-patches/World.patch | 35 ++++++++++++------- nms-patches/WorldServer.patch | 18 ++++++---- 3 files changed, 93 insertions(+), 39 deletions(-) diff --git a/nms-patches/EntityPlayer.patch b/nms-patches/EntityPlayer.patch index d8fc2f5d..777bd5b7 100644 --- a/nms-patches/EntityPlayer.patch +++ b/nms-patches/EntityPlayer.patch @@ -1,5 +1,5 @@ ---- ../work/decompile-8eb82bde//net/minecraft/server/EntityPlayer.java Sun Nov 30 12:33:51 2014 -+++ src/main/java/net/minecraft/server/EntityPlayer.java Sun Nov 30 12:31:53 2014 +--- ../work/decompile-8eb82bde//net/minecraft/server/EntityPlayer.java 2014-12-02 15:12:17.558036243 +0000 ++++ src/main/java/net/minecraft/server/EntityPlayer.java 2014-12-02 15:08:46.878040919 +0000 @@ -13,6 +13,17 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -50,7 +50,7 @@ } public void a(NBTTagCompound nbttagcompound) { -@@ -81,13 +108,39 @@ +@@ -81,14 +108,40 @@ this.playerInteractManager.setGameMode(EnumGamemode.getById(nbttagcompound.getInt("playerGameType"))); } } @@ -62,8 +62,8 @@ super.b(nbttagcompound); nbttagcompound.setInt("playerGameType", this.playerInteractManager.getGameMode().getId()); + this.getBukkitEntity().setExtraData(nbttagcompound); // CraftBukkit -+ } -+ + } + + // CraftBukkit start - World fallback code, either respawn location or global spawn + public void spawnIn(World world) { + super.spawnIn(world); @@ -86,11 +86,12 @@ + } + this.dimension = ((WorldServer) this.world).dimension; + this.playerInteractManager.a((WorldServer) world); - } ++ } + // CraftBukkit end - ++ public void levelDown(int i) { super.levelDown(i); + this.lastSentExp = -1; @@ -114,6 +167,11 @@ } @@ -174,7 +175,12 @@ + if (this.dead) { + return; + } -+ + +- if (scoreboardteambase != null && scoreboardteambase.j() != EnumNameTagVisibility.ALWAYS) { +- if (scoreboardteambase.j() == EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) { +- this.server.getPlayerList().a((EntityHuman) this, this.br().b()); +- } else if (scoreboardteambase.j() == EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) { +- this.server.getPlayerList().b((EntityHuman) this, this.br().b()); + java.util.List loot = new java.util.ArrayList(); + boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory"); + @@ -182,18 +188,13 @@ + for (int i = 0; i < this.inventory.items.length; ++i) { + if (this.inventory.items[i] != null) { + loot.add(CraftItemStack.asCraftMirror(this.inventory.items[i])); -+ } + } + } - -- if (scoreboardteambase != null && scoreboardteambase.j() != EnumNameTagVisibility.ALWAYS) { -- if (scoreboardteambase.j() == EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS) { -- this.server.getPlayerList().a((EntityHuman) this, this.br().b()); -- } else if (scoreboardteambase.j() == EnumNameTagVisibility.HIDE_FOR_OWN_TEAM) { -- this.server.getPlayerList().b((EntityHuman) this, this.br().b()); ++ + for (int i = 0; i < this.inventory.armor.length; ++i) { + if (this.inventory.armor[i] != null) { + loot.add(CraftItemStack.asCraftMirror(this.inventory.armor[i])); - } ++ } + } + } + @@ -433,19 +434,19 @@ public void triggerHealthUpdate() { this.bK = -1.0E8F; + this.lastSentExp = -1; // CraftBukkit - Added to reset -+ } + } + + // CraftBukkit start - Support multi-line messages + public void sendMessage(IChatBaseComponent[] ichatbasecomponent) { + for (IChatBaseComponent component : ichatbasecomponent) { + this.sendMessage(component); + } - } ++ } + // CraftBukkit end public void b(IChatBaseComponent ichatbasecomponent) { this.playerConnection.sendPacket(new PacketPlayOutChat(ichatbasecomponent)); -@@ -867,6 +1035,93 @@ +@@ -867,6 +1035,129 @@ } public IChatBaseComponent getPlayerListName() { @@ -484,12 +485,48 @@ + + if (type == WeatherType.DOWNFALL) { + this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(2, 0)); -+ // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, this.world.j(1.0F))); -+ // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, this.world.h(1.0F))); + } else { + this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0)); + } + } ++ ++ private float pluginRainPosition; ++ private float pluginRainPositionPrevious; ++ ++ public void updateWeather(float oldRain, float newRain, float oldThunder, float newThunder) { ++ if (this.weather == null) { ++ // Vanilla ++ if (oldRain != newRain) { ++ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, newRain)); ++ } ++ } else { ++ // Plugin ++ if (pluginRainPositionPrevious != pluginRainPosition) { ++ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, pluginRainPosition)); ++ } ++ } ++ ++ if (oldThunder != newThunder) { ++ if (weather == WeatherType.DOWNFALL || weather == null) { ++ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, newThunder)); ++ } else { ++ this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, 0)); ++ } ++ } ++ } ++ ++ public void tickWeather() { ++ if (this.weather == null) return; ++ ++ pluginRainPositionPrevious = pluginRainPosition; ++ if (weather == WeatherType.DOWNFALL) { ++ pluginRainPosition += 0.01; ++ } else { ++ pluginRainPosition -= 0.01; ++ } ++ ++ pluginRainPosition = MathHelper.a(pluginRainPosition, 0.0F, 1.0F); ++ } + + public void resetPlayerWeather() { + this.weather = null; diff --git a/nms-patches/World.patch b/nms-patches/World.patch index 57db4a9e..3131a603 100644 --- a/nms-patches/World.patch +++ b/nms-patches/World.patch @@ -1,5 +1,5 @@ ---- ../work/decompile-8eb82bde//net/minecraft/server/World.java 2014-11-29 21:17:20.461017061 +0000 -+++ src/main/java/net/minecraft/server/World.java 2014-11-29 21:17:07.617017346 +0000 +--- ../work/decompile-8eb82bde//net/minecraft/server/World.java 2014-12-02 15:12:18.222036228 +0000 ++++ src/main/java/net/minecraft/server/World.java 2014-12-02 15:04:12.678047004 +0000 @@ -13,6 +13,22 @@ import java.util.UUID; import java.util.concurrent.Callable; @@ -441,7 +441,18 @@ } } -@@ -1656,7 +1886,7 @@ +@@ -1651,12 +1881,18 @@ + } + + this.p = MathHelper.a(this.p, 0.0F, 1.0F); ++ ++ for (int idx = 0; idx < this.players.size(); ++idx) { ++ if (((EntityPlayer) this.players.get(idx)).world == this) { ++ ((EntityPlayer) this.players.get(idx)).tickWeather(); ++ } ++ } + } + } } protected void D() { @@ -450,7 +461,7 @@ this.methodProfiler.a("buildList"); int i; -@@ -1673,7 +1903,7 @@ +@@ -1673,7 +1909,7 @@ for (int i1 = -l; i1 <= l; ++i1) { for (int j1 = -l; j1 <= l; ++j1) { @@ -459,7 +470,7 @@ } } } -@@ -1851,7 +2081,10 @@ +@@ -1851,7 +2087,10 @@ } public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) { @@ -471,7 +482,7 @@ return false; } else { int i = 0; -@@ -2095,8 +2328,17 @@ +@@ -2095,8 +2334,17 @@ while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); @@ -490,7 +501,7 @@ ++i; } } -@@ -2105,12 +2347,17 @@ +@@ -2105,12 +2353,17 @@ } public void b(Collection collection) { @@ -510,7 +521,7 @@ this.a(entity); } -@@ -2124,7 +2371,13 @@ +@@ -2124,7 +2377,13 @@ Block block1 = this.getType(blockposition).getBlock(); AxisAlignedBB axisalignedbb = flag ? null : block.a(this, blockposition, block.getBlockData()); @@ -525,7 +536,7 @@ } public int getBlockPower(BlockPosition blockposition, EnumDirection enumdirection) { -@@ -2215,6 +2468,11 @@ +@@ -2215,6 +2474,11 @@ for (int i = 0; i < this.players.size(); ++i) { EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); @@ -537,7 +548,7 @@ if (IEntitySelector.d.apply(entityhuman1)) { double d5 = entityhuman1.e(d0, d1, d2); -@@ -2269,7 +2527,7 @@ +@@ -2269,7 +2533,7 @@ return null; } @@ -546,7 +557,7 @@ this.dataManager.checkSession(); } -@@ -2331,6 +2589,16 @@ +@@ -2331,6 +2595,16 @@ public void everyoneSleeping() {} @@ -563,7 +574,7 @@ public float h(float f) { return (this.q + (this.r - this.q) * f) * this.j(f); } -@@ -2538,6 +2806,6 @@ +@@ -2538,6 +2812,6 @@ int l = j * 16 + 8 - blockposition.getZ(); short short0 = 128; diff --git a/nms-patches/WorldServer.patch b/nms-patches/WorldServer.patch index a8557e42..d7463e8a 100644 --- a/nms-patches/WorldServer.patch +++ b/nms-patches/WorldServer.patch @@ -1,5 +1,5 @@ ---- ../work/decompile-8eb82bde//net/minecraft/server/WorldServer.java 2014-11-28 17:43:43.445707427 +0000 -+++ src/main/java/net/minecraft/server/WorldServer.java 2014-11-28 17:38:23.000000000 +0000 +--- ../work/decompile-8eb82bde//net/minecraft/server/WorldServer.java 2014-12-02 15:12:18.246036227 +0000 ++++ src/main/java/net/minecraft/server/WorldServer.java 2014-12-02 15:02:48.310048877 +0000 @@ -16,6 +16,20 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -513,10 +513,11 @@ if (this.o != this.p) { this.server.getPlayerList().a(new PacketPlayOutGameStateChange(7, this.p), this.worldProvider.getDimension()); } -@@ -827,6 +1063,16 @@ +@@ -827,7 +1063,21 @@ this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(7, this.p)); this.server.getPlayerList().sendAll(new PacketPlayOutGameStateChange(8, this.r)); } +- + // */ + if (flag != this.S()) { + // Only send weather packets to those affected @@ -525,12 +526,17 @@ + ((EntityPlayer) this.players.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); + } + } -+ // CraftBukkit end + } - ++ for (int i = 0; i < this.players.size(); ++i) { ++ if (((EntityPlayer) this.players.get(i)).world == this) { ++ ((EntityPlayer) this.players.get(i)).updateWeather(this.o, this.p, this.q, this.r); ++ } ++ } ++ // CraftBukkit end } -@@ -855,10 +1101,17 @@ + protected int q() { +@@ -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) { -- cgit v1.2.3