mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-26 06:53:20 +00:00
Changes the updateWeather function in WorldServer to only send the weather info to players in the correct dimension, rather than all players on the server. This is what causes the client-side rain, as the client believes that it has started raining locally, rather than in another dimension.
247 lines
11 KiB
Diff
247 lines
11 KiB
Diff
--- ../src-base/minecraft/net/minecraft/world/WorldServer.java
|
|
+++ ../src-work/minecraft/net/minecraft/world/WorldServer.java
|
|
@@ -3,6 +3,7 @@
|
|
import com.google.common.collect.Lists;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
+import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
@@ -50,11 +51,19 @@
|
|
import net.minecraft.world.biome.WorldChunkManager;
|
|
import net.minecraft.world.chunk.Chunk;
|
|
import net.minecraft.world.chunk.IChunkProvider;
|
|
+import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
|
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
|
import net.minecraft.world.chunk.storage.IChunkLoader;
|
|
import net.minecraft.world.gen.ChunkProviderServer;
|
|
import net.minecraft.world.gen.feature.WorldGeneratorBonusChest;
|
|
import net.minecraft.world.storage.ISaveHandler;
|
|
+import net.minecraftforge.common.ChestGenHooks;
|
|
+import static net.minecraftforge.common.ChestGenHooks.BONUS_CHEST;
|
|
+import net.minecraftforge.common.DimensionManager;
|
|
+import net.minecraftforge.common.MinecraftForge;
|
|
+import net.minecraftforge.event.ForgeEventFactory;
|
|
+import net.minecraftforge.event.world.WorldEvent;
|
|
+
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
@@ -79,6 +88,10 @@
|
|
private IntHashMap field_73066_T;
|
|
private static final String __OBFID = "CL_00001437";
|
|
|
|
+ /** Stores the recently processed (lighting) chunks */
|
|
+ protected Set<ChunkCoordIntPair> doneChunks = new HashSet<ChunkCoordIntPair>();
|
|
+ public List<Teleporter> customTeleporters = new ArrayList<Teleporter>();
|
|
+
|
|
public WorldServer(MinecraftServer p_i45284_1_, ISaveHandler p_i45284_2_, String p_i45284_3_, int p_i45284_4_, WorldSettings p_i45284_5_, Profiler p_i45284_6_)
|
|
{
|
|
super(p_i45284_2_, p_i45284_3_, p_i45284_5_, WorldProvider.func_76570_a(p_i45284_4_), p_i45284_6_);
|
|
@@ -111,8 +124,12 @@
|
|
this.field_72988_C.func_75745_a("scoreboard", scoreboardsavedata);
|
|
}
|
|
|
|
- scoreboardsavedata.func_96499_a(this.field_96442_D);
|
|
+ if (!(this instanceof WorldServerMulti)) //Forge: We fix the global mapStorage, which causes us to share scoreboards early. So don't associate the save data with the temporary scoreboard
|
|
+ {
|
|
+ scoreboardsavedata.func_96499_a(this.field_96442_D);
|
|
+ }
|
|
((ServerScoreboard)this.field_96442_D).func_96547_a(scoreboardsavedata);
|
|
+ DimensionManager.setWorld(p_i45284_4_, this);
|
|
}
|
|
|
|
public void func_72835_b()
|
|
@@ -171,6 +188,10 @@
|
|
this.field_72983_E.func_75528_a();
|
|
this.field_72984_F.func_76318_c("portalForcer");
|
|
this.field_85177_Q.func_85189_a(this.func_82737_E());
|
|
+ for (Teleporter tele : customTeleporters)
|
|
+ {
|
|
+ tele.func_85189_a(func_82737_E());
|
|
+ }
|
|
this.field_72984_F.func_76319_b();
|
|
this.func_147488_Z();
|
|
}
|
|
@@ -178,6 +199,7 @@
|
|
public BiomeGenBase.SpawnListEntry func_73057_a(EnumCreatureType p_73057_1_, int p_73057_2_, int p_73057_3_, int p_73057_4_)
|
|
{
|
|
List list = this.func_72863_F().func_73155_a(p_73057_1_, p_73057_2_, p_73057_3_, p_73057_4_);
|
|
+ list = ForgeEventFactory.getPotentialSpawns(this, p_73057_1_, p_73057_2_, p_73057_3_, p_73057_4_, list);
|
|
return list != null && !list.isEmpty() ? (BiomeGenBase.SpawnListEntry)WeightedRandom.func_76271_a(this.field_73012_v, list) : null;
|
|
}
|
|
|
|
@@ -218,10 +240,7 @@
|
|
|
|
private void func_73051_P()
|
|
{
|
|
- this.field_72986_A.func_76080_g(0);
|
|
- this.field_72986_A.func_76084_b(false);
|
|
- this.field_72986_A.func_76090_f(0);
|
|
- this.field_72986_A.func_76069_a(false);
|
|
+ field_73011_w.resetRainAndThunder();
|
|
}
|
|
|
|
public boolean func_73056_e()
|
|
@@ -301,7 +320,7 @@
|
|
int k1;
|
|
int l1;
|
|
|
|
- if (this.field_73012_v.nextInt(100000) == 0 && this.func_72896_J() && this.func_72911_I())
|
|
+ if (field_73011_w.canDoLightning(chunk) && this.field_73012_v.nextInt(100000) == 0 && this.func_72896_J() && this.func_72911_I())
|
|
{
|
|
this.field_73005_l = this.field_73005_l * 3 + 1013904223;
|
|
i1 = this.field_73005_l >> 2;
|
|
@@ -317,7 +336,7 @@
|
|
|
|
this.field_72984_F.func_76318_c("iceandsnow");
|
|
|
|
- if (this.field_73012_v.nextInt(16) == 0)
|
|
+ if (field_73011_w.canDoRainSnowIce(chunk) && this.field_73012_v.nextInt(16) == 0)
|
|
{
|
|
this.field_73005_l = this.field_73005_l * 3 + 1013904223;
|
|
i1 = this.field_73005_l >> 2;
|
|
@@ -393,6 +412,9 @@
|
|
public void func_147454_a(int p_147454_1_, int p_147454_2_, int p_147454_3_, Block p_147454_4_, int p_147454_5_, int p_147454_6_)
|
|
{
|
|
NextTickListEntry nextticklistentry = new NextTickListEntry(p_147454_1_, p_147454_2_, p_147454_3_, p_147454_4_);
|
|
+ //Keeping here as a note for future when it may be restored.
|
|
+ //boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(nextticklistentry.xCoord >> 4, nextticklistentry.zCoord >> 4));
|
|
+ //byte b0 = isForced ? 0 : 8;
|
|
byte b0 = 0;
|
|
|
|
if (this.field_72999_e && p_147454_4_.func_149688_o() != Material.field_151579_a)
|
|
@@ -452,7 +474,7 @@
|
|
|
|
public void func_72939_s()
|
|
{
|
|
- if (this.field_73010_i.isEmpty())
|
|
+ if (this.field_73010_i.isEmpty() && getPersistentChunks().isEmpty())
|
|
{
|
|
if (this.field_80004_Q++ >= 1200)
|
|
{
|
|
@@ -512,6 +534,9 @@
|
|
{
|
|
nextticklistentry = (NextTickListEntry)iterator.next();
|
|
iterator.remove();
|
|
+ //Keeping here as a note for future when it may be restored.
|
|
+ //boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(nextticklistentry.xCoord >> 4, nextticklistentry.zCoord >> 4));
|
|
+ //byte b0 = isForced ? 0 : 8;
|
|
byte b0 = 0;
|
|
|
|
if (this.func_72904_c(nextticklistentry.field_77183_a - b0, nextticklistentry.field_77181_b - b0, nextticklistentry.field_77182_c - b0, nextticklistentry.field_77183_a + b0, nextticklistentry.field_77181_b + b0, nextticklistentry.field_77182_c + b0))
|
|
@@ -634,13 +659,26 @@
|
|
{
|
|
ArrayList arraylist = new ArrayList();
|
|
|
|
- for (int k1 = 0; k1 < this.field_147482_g.size(); ++k1)
|
|
+ for(int x = (p_147486_1_ >> 4); x <= (p_147486_4_ >> 4); x++)
|
|
{
|
|
- TileEntity tileentity = (TileEntity)this.field_147482_g.get(k1);
|
|
-
|
|
- if (tileentity.field_145851_c >= p_147486_1_ && tileentity.field_145848_d >= p_147486_2_ && tileentity.field_145849_e >= p_147486_3_ && tileentity.field_145851_c < p_147486_4_ && tileentity.field_145848_d < p_147486_5_ && tileentity.field_145849_e < p_147486_6_)
|
|
+ for(int z = (p_147486_3_ >> 4); z <= (p_147486_6_ >> 4); z++)
|
|
{
|
|
- arraylist.add(tileentity);
|
|
+ Chunk chunk = func_72964_e(x, z);
|
|
+ if (chunk != null)
|
|
+ {
|
|
+ for(Object obj : chunk.field_150816_i.values())
|
|
+ {
|
|
+ TileEntity entity = (TileEntity)obj;
|
|
+ if (!entity.func_145837_r())
|
|
+ {
|
|
+ if (entity.field_145851_c >= p_147486_1_ && entity.field_145848_d >= p_147486_2_ && entity.field_145849_e >= p_147486_3_ &&
|
|
+ entity.field_145851_c <= p_147486_4_ && entity.field_145848_d <= p_147486_5_ && entity.field_145849_e <= p_147486_6_)
|
|
+ {
|
|
+ arraylist.add(entity);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
}
|
|
}
|
|
|
|
@@ -649,9 +687,14 @@
|
|
|
|
public boolean func_72962_a(EntityPlayer p_72962_1_, int p_72962_2_, int p_72962_3_, int p_72962_4_)
|
|
{
|
|
- return !this.field_73061_a.func_96290_a(this, p_72962_2_, p_72962_3_, p_72962_4_, p_72962_1_);
|
|
+ return super.func_72962_a(p_72962_1_, p_72962_2_, p_72962_3_, p_72962_4_);
|
|
}
|
|
|
|
+ public boolean canMineBlockBody(EntityPlayer par1EntityPlayer, int par2, int par3, int par4)
|
|
+ {
|
|
+ return !this.field_73061_a.func_96290_a(this, par2, par3, par4, par1EntityPlayer);
|
|
+ }
|
|
+
|
|
protected void func_72963_a(WorldSettings p_72963_1_)
|
|
{
|
|
if (this.field_73066_T == null)
|
|
@@ -726,7 +769,7 @@
|
|
|
|
protected void func_73047_i()
|
|
{
|
|
- WorldGeneratorBonusChest worldgeneratorbonuschest = new WorldGeneratorBonusChest(field_73069_S, 10);
|
|
+ WorldGeneratorBonusChest worldgeneratorbonuschest = new WorldGeneratorBonusChest(ChestGenHooks.getItems(BONUS_CHEST, field_73012_v), ChestGenHooks.getCount(BONUS_CHEST, field_73012_v));
|
|
|
|
for (int i = 0; i < 10; ++i)
|
|
{
|
|
@@ -763,6 +806,7 @@
|
|
}
|
|
|
|
this.field_73020_y.func_73151_a(p_73044_1_, p_73044_2_);
|
|
+ MinecraftForge.EVENT_BUS.post(new WorldEvent.Save(this));
|
|
ArrayList arraylist = Lists.newArrayList(this.field_73059_b.func_152380_a());
|
|
Iterator iterator = arraylist.iterator();
|
|
|
|
@@ -791,6 +835,7 @@
|
|
this.func_72906_B();
|
|
this.field_73019_z.func_75755_a(this.field_72986_A, this.field_73061_a.func_71203_ab().func_72378_q());
|
|
this.field_72988_C.func_75744_a();
|
|
+ this.perWorldStorage.func_75744_a();
|
|
}
|
|
|
|
public void func_72923_a(Entity p_72923_1_)
|
|
@@ -941,19 +986,23 @@
|
|
this.field_73061_a.func_71203_ab().func_148537_a(new S2BPacketChangeGameState(8, this.field_73017_q), this.field_73011_w.field_76574_g);
|
|
}
|
|
|
|
+ /*The function in use here has been replaced in order to only send the weather info to players in the correct dimension,
|
|
+ rather than to all players on the server. This is what causes the client-side rain, as the
|
|
+ client believes that it has started raining locally, rather than in another dimension.
|
|
+ */
|
|
if (flag != this.func_72896_J())
|
|
{
|
|
if (flag)
|
|
{
|
|
- this.field_73061_a.func_71203_ab().func_148540_a(new S2BPacketChangeGameState(2, 0.0F));
|
|
+ this.field_73061_a.func_71203_ab().func_148537_a(new S2BPacketChangeGameState(2, 0.0F), this.field_73011_w.field_76574_g);
|
|
}
|
|
else
|
|
{
|
|
- this.field_73061_a.func_71203_ab().func_148540_a(new S2BPacketChangeGameState(1, 0.0F));
|
|
+ this.field_73061_a.func_71203_ab().func_148537_a(new S2BPacketChangeGameState(1, 0.0F), this.field_73011_w.field_76574_g);
|
|
}
|
|
|
|
- this.field_73061_a.func_71203_ab().func_148540_a(new S2BPacketChangeGameState(7, this.field_73004_o));
|
|
- this.field_73061_a.func_71203_ab().func_148540_a(new S2BPacketChangeGameState(8, this.field_73017_q));
|
|
+ this.field_73061_a.func_71203_ab().func_148537_a(new S2BPacketChangeGameState(7, this.field_73004_o), this.field_73011_w.field_76574_g);
|
|
+ this.field_73061_a.func_71203_ab().func_148537_a(new S2BPacketChangeGameState(8, this.field_73017_q), this.field_73011_w.field_76574_g);
|
|
}
|
|
}
|
|
|
|
@@ -1002,6 +1051,11 @@
|
|
}
|
|
}
|
|
|
|
+ public File getChunkSaveLocation()
|
|
+ {
|
|
+ return ((AnvilChunkLoader)field_73059_b.field_73247_e).field_75825_d;
|
|
+ }
|
|
+
|
|
static class ServerBlockEventList extends ArrayList
|
|
{
|
|
private static final String __OBFID = "CL_00001439";
|