305 lines
16 KiB
Diff
305 lines
16 KiB
Diff
--- ../src-base/minecraft/net/minecraft/world/WorldServer.java
|
|
+++ ../src-work/minecraft/net/minecraft/world/WorldServer.java
|
|
@@ -101,30 +101,39 @@
|
|
private int field_147489_T;
|
|
private final List<NextTickListEntry> field_94579_S = Lists.<NextTickListEntry>newArrayList();
|
|
|
|
+ /** Stores the recently processed (lighting) chunks */
|
|
+ protected Set<ChunkPos> doneChunks = new java.util.HashSet<ChunkPos>();
|
|
+ public List<Teleporter> customTeleporters = new ArrayList<Teleporter>();
|
|
+
|
|
public WorldServer(MinecraftServer p_i45921_1_, ISaveHandler p_i45921_2_, WorldInfo p_i45921_3_, int p_i45921_4_, Profiler p_i45921_5_)
|
|
{
|
|
- super(p_i45921_2_, p_i45921_3_, DimensionType.func_186069_a(p_i45921_4_).func_186070_d(), p_i45921_5_, false);
|
|
+ super(p_i45921_2_, p_i45921_3_, net.minecraftforge.common.DimensionManager.createProviderFor(p_i45921_4_), p_i45921_5_, false);
|
|
this.field_73061_a = p_i45921_1_;
|
|
this.field_73062_L = new EntityTracker(this);
|
|
this.field_73063_M = new PlayerChunkMap(this);
|
|
+ // Guarantee the dimension ID was not reset by the provider
|
|
+ int providerDim = this.field_73011_w.getDimension();
|
|
this.field_73011_w.func_76558_a(this);
|
|
+ this.field_73011_w.setDimension(providerDim);
|
|
this.field_73020_y = this.func_72970_h();
|
|
+ perWorldStorage = new MapStorage(new net.minecraftforge.common.WorldSpecificSaveHandler((WorldServer)this, p_i45921_2_));
|
|
this.field_85177_Q = new Teleporter(this);
|
|
this.func_72966_v();
|
|
this.func_72947_a();
|
|
this.func_175723_af().func_177725_a(p_i45921_1_.func_175580_aG());
|
|
+ net.minecraftforge.common.DimensionManager.setWorld(p_i45921_4_, this, field_73061_a);
|
|
}
|
|
|
|
public World func_175643_b()
|
|
{
|
|
this.field_72988_C = new MapStorage(this.field_73019_z);
|
|
String s = VillageCollection.func_176062_a(this.field_73011_w);
|
|
- VillageCollection villagecollection = (VillageCollection)this.field_72988_C.func_75742_a(VillageCollection.class, s);
|
|
+ VillageCollection villagecollection = (VillageCollection)this.perWorldStorage.func_75742_a(VillageCollection.class, s);
|
|
|
|
if (villagecollection == null)
|
|
{
|
|
this.field_72982_D = new VillageCollection(this);
|
|
- this.field_72988_C.func_75745_a(s, this.field_72982_D);
|
|
+ this.perWorldStorage.func_75745_a(s, this.field_72982_D);
|
|
}
|
|
else
|
|
{
|
|
@@ -161,6 +170,7 @@
|
|
this.func_175723_af().func_177750_a(this.field_72986_A.func_176137_E());
|
|
}
|
|
|
|
+ this.initCapabilities();
|
|
return this;
|
|
}
|
|
|
|
@@ -179,8 +189,8 @@
|
|
{
|
|
if (this.func_82736_K().func_82766_b("doDaylightCycle"))
|
|
{
|
|
- long i = this.field_72986_A.func_76073_f() + 24000L;
|
|
- this.field_72986_A.func_76068_b(i - i % 24000L);
|
|
+ long i = this.func_72820_D() + 24000L;
|
|
+ this.func_72877_b(i - i % 24000L);
|
|
}
|
|
|
|
this.func_73053_d();
|
|
@@ -206,7 +216,7 @@
|
|
|
|
if (this.func_82736_K().func_82766_b("doDaylightCycle"))
|
|
{
|
|
- this.field_72986_A.func_76068_b(this.field_72986_A.func_76073_f() + 1L);
|
|
+ this.func_72877_b(this.func_72820_D() + 1L);
|
|
}
|
|
|
|
this.field_72984_F.func_76318_c("tickPending");
|
|
@@ -220,6 +230,10 @@
|
|
this.field_175740_d.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();
|
|
}
|
|
@@ -228,12 +242,14 @@
|
|
public Biome.SpawnListEntry func_175734_a(EnumCreatureType p_175734_1_, BlockPos p_175734_2_)
|
|
{
|
|
List<Biome.SpawnListEntry> list = this.func_72863_F().func_177458_a(p_175734_1_, p_175734_2_);
|
|
+ list = net.minecraftforge.event.ForgeEventFactory.getPotentialSpawns(this, p_175734_1_, p_175734_2_, list);
|
|
return list != null && !list.isEmpty() ? (Biome.SpawnListEntry)WeightedRandom.func_76271_a(this.field_73012_v, list) : null;
|
|
}
|
|
|
|
public boolean func_175732_a(EnumCreatureType p_175732_1_, Biome.SpawnListEntry p_175732_2_, BlockPos p_175732_3_)
|
|
{
|
|
List<Biome.SpawnListEntry> list = this.func_72863_F().func_177458_a(p_175732_1_, p_175732_3_);
|
|
+ list = net.minecraftforge.event.ForgeEventFactory.getPotentialSpawns(this, p_175732_1_, p_175732_3_, list);
|
|
return list != null && !list.isEmpty() ? list.contains(p_175732_2_) : false;
|
|
}
|
|
|
|
@@ -279,10 +295,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);
|
|
+ this.field_73011_w.resetRainAndThunder();
|
|
}
|
|
|
|
public boolean func_73056_e()
|
|
@@ -375,7 +388,7 @@
|
|
boolean flag1 = this.func_72911_I();
|
|
this.field_72984_F.func_76320_a("pollingChunks");
|
|
|
|
- for (Iterator<Chunk> iterator = this.field_73063_M.func_187300_b(); iterator.hasNext(); this.field_72984_F.func_76319_b())
|
|
+ for (Iterator<Chunk> iterator = getPersistentChunkIterable(this.field_73063_M.func_187300_b()); iterator.hasNext(); this.field_72984_F.func_76319_b())
|
|
{
|
|
this.field_72984_F.func_76320_a("getChunk");
|
|
Chunk chunk = iterator.next();
|
|
@@ -387,7 +400,7 @@
|
|
chunk.func_150804_b(false);
|
|
this.field_72984_F.func_76318_c("thunder");
|
|
|
|
- if (flag && flag1 && this.field_73012_v.nextInt(100000) == 0)
|
|
+ if (this.field_73011_w.canDoLightning(chunk) && flag && flag1 && this.field_73012_v.nextInt(100000) == 0)
|
|
{
|
|
this.field_73005_l = this.field_73005_l * 3 + 1013904223;
|
|
int l = this.field_73005_l >> 2;
|
|
@@ -415,13 +428,14 @@
|
|
|
|
this.field_72984_F.func_76318_c("iceandsnow");
|
|
|
|
- if (this.field_73012_v.nextInt(16) == 0)
|
|
+ if (this.field_73011_w.canDoRainSnowIce(chunk) && this.field_73012_v.nextInt(16) == 0)
|
|
{
|
|
this.field_73005_l = this.field_73005_l * 3 + 1013904223;
|
|
int j2 = this.field_73005_l >> 2;
|
|
BlockPos blockpos1 = this.func_175725_q(new BlockPos(j + (j2 & 15), 0, k + (j2 >> 8 & 15)));
|
|
BlockPos blockpos2 = blockpos1.func_177977_b();
|
|
|
|
+ if (this.func_175697_a(blockpos2, 1)) // Forge: check area to avoid loading neighbors in unloaded chunks
|
|
if (this.func_175662_w(blockpos2))
|
|
{
|
|
this.func_175656_a(blockpos2, Blocks.field_150432_aD.func_176223_P());
|
|
@@ -525,7 +539,10 @@
|
|
{
|
|
if (p_175654_2_.func_149698_L())
|
|
{
|
|
- if (this.func_175707_a(p_175654_1_.func_177982_a(-8, -8, -8), p_175654_1_.func_177982_a(8, 8, 8)))
|
|
+ //Keeping here as a note for future when it may be restored.
|
|
+ boolean isForced = getPersistentChunks().containsKey(new ChunkPos(p_175654_1_));
|
|
+ int range = isForced ? 0 : 8;
|
|
+ if (this.func_175707_a(p_175654_1_.func_177982_a(-range, -range, -range), p_175654_1_.func_177982_a(range, range, range)))
|
|
{
|
|
IBlockState iblockstate = this.func_180495_p(p_175654_1_);
|
|
|
|
@@ -561,6 +578,7 @@
|
|
|
|
public void func_180497_b(BlockPos p_180497_1_, Block p_180497_2_, int p_180497_3_, int p_180497_4_)
|
|
{
|
|
+ if (p_180497_2_ == null) return; //Forge: Prevent null blocks from ticking, can happen if blocks are removed in old worlds. TODO: Fix real issue causing block to be null.
|
|
NextTickListEntry nextticklistentry = new NextTickListEntry(p_180497_1_, p_180497_2_);
|
|
nextticklistentry.func_82753_a(p_180497_4_);
|
|
Material material = p_180497_2_.func_176223_P().func_185904_a();
|
|
@@ -579,7 +597,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++ >= 300)
|
|
{
|
|
@@ -703,6 +721,9 @@
|
|
{
|
|
NextTickListEntry nextticklistentry1 = iterator.next();
|
|
iterator.remove();
|
|
+ //Keeping here as a note for future when it may be restored.
|
|
+ //boolean isForced = getPersistentChunks().containsKey(new ChunkPos(nextticklistentry.xCoord >> 4, nextticklistentry.zCoord >> 4));
|
|
+ //byte b0 = isForced ? 0 : 8;
|
|
int k = 0;
|
|
|
|
if (this.func_175707_a(nextticklistentry1.field_180282_a.func_177982_a(0, 0, 0), nextticklistentry1.field_180282_a.func_177982_a(0, 0, 0)))
|
|
@@ -829,6 +850,10 @@
|
|
|
|
public boolean func_175660_a(EntityPlayer p_175660_1_, BlockPos p_175660_2_)
|
|
{
|
|
+ return super.func_175660_a(p_175660_1_, p_175660_2_);
|
|
+ }
|
|
+ public boolean canMineBlockBody(EntityPlayer p_175660_1_, BlockPos p_175660_2_)
|
|
+ {
|
|
return !this.field_73061_a.func_175579_a(this, p_175660_2_, p_175660_1_) && this.func_175723_af().func_177746_a(p_175660_2_);
|
|
}
|
|
|
|
@@ -894,6 +919,7 @@
|
|
}
|
|
else
|
|
{
|
|
+ if (net.minecraftforge.event.ForgeEventFactory.onCreateWorldSpawn(this, p_73052_1_)) return;
|
|
this.field_72987_B = true;
|
|
BiomeProvider biomeprovider = this.field_73011_w.func_177499_m();
|
|
List<Biome> list = biomeprovider.func_76932_a();
|
|
@@ -979,6 +1005,7 @@
|
|
}
|
|
|
|
chunkproviderserver.func_186027_a(p_73044_1_);
|
|
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Save(this));
|
|
|
|
for (Chunk chunk : Lists.newArrayList(chunkproviderserver.func_189548_a()))
|
|
{
|
|
@@ -1023,6 +1050,7 @@
|
|
this.field_72986_A.func_176135_e(this.func_175723_af().func_177732_i());
|
|
this.field_73019_z.func_75755_a(this.field_72986_A, this.field_73061_a.func_184103_al().func_72378_q());
|
|
this.field_72988_C.func_75744_a();
|
|
+ this.perWorldStorage.func_75744_a();
|
|
}
|
|
|
|
public boolean func_72838_d(Entity p_72838_1_)
|
|
@@ -1034,7 +1062,7 @@
|
|
{
|
|
for (Entity entity : Lists.newArrayList(p_175650_1_))
|
|
{
|
|
- if (this.func_184165_i(entity))
|
|
+ if (this.func_184165_i(entity) && !net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(entity, this)))
|
|
{
|
|
this.field_72996_f.add(entity);
|
|
this.func_72923_a(entity);
|
|
@@ -1115,7 +1143,7 @@
|
|
{
|
|
if (super.func_72942_c(p_72942_1_))
|
|
{
|
|
- this.field_73061_a.func_184103_al().func_148543_a((EntityPlayer)null, p_72942_1_.field_70165_t, p_72942_1_.field_70163_u, p_72942_1_.field_70161_v, 512.0D, this.field_73011_w.func_186058_p().func_186068_a(), new SPacketSpawnGlobalEntity(p_72942_1_));
|
|
+ this.field_73061_a.func_184103_al().func_148543_a((EntityPlayer)null, p_72942_1_.field_70165_t, p_72942_1_.field_70163_u, p_72942_1_.field_70161_v, 512.0D, this.field_73011_w.getDimension(), new SPacketSpawnGlobalEntity(p_72942_1_));
|
|
return true;
|
|
}
|
|
else
|
|
@@ -1137,6 +1165,7 @@
|
|
public Explosion func_72885_a(@Nullable Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_)
|
|
{
|
|
Explosion explosion = new Explosion(this, p_72885_1_, p_72885_2_, p_72885_4_, p_72885_6_, p_72885_8_, p_72885_9_, p_72885_10_);
|
|
+ if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this, explosion)) return explosion;
|
|
explosion.func_77278_a();
|
|
explosion.func_77279_a(false);
|
|
|
|
@@ -1182,7 +1211,7 @@
|
|
{
|
|
if (this.func_147485_a(blockeventdata))
|
|
{
|
|
- this.field_73061_a.func_184103_al().func_148543_a((EntityPlayer)null, (double)blockeventdata.func_180328_a().func_177958_n(), (double)blockeventdata.func_180328_a().func_177956_o(), (double)blockeventdata.func_180328_a().func_177952_p(), 64.0D, this.field_73011_w.func_186058_p().func_186068_a(), new SPacketBlockAction(blockeventdata.func_180328_a(), blockeventdata.func_151337_f(), blockeventdata.func_151339_d(), blockeventdata.func_151338_e()));
|
|
+ this.field_73061_a.func_184103_al().func_148543_a((EntityPlayer)null, (double)blockeventdata.func_180328_a().func_177958_n(), (double)blockeventdata.func_180328_a().func_177956_o(), (double)blockeventdata.func_180328_a().func_177952_p(), 64.0D, this.field_73011_w.getDimension(), new SPacketBlockAction(blockeventdata.func_180328_a(), blockeventdata.func_151337_f(), blockeventdata.func_151339_d(), blockeventdata.func_151338_e()));
|
|
}
|
|
}
|
|
|
|
@@ -1208,27 +1237,31 @@
|
|
|
|
if (this.field_73003_n != this.field_73004_o)
|
|
{
|
|
- this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(7, this.field_73004_o), this.field_73011_w.func_186058_p().func_186068_a());
|
|
+ this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(7, this.field_73004_o), this.field_73011_w.getDimension());
|
|
}
|
|
|
|
if (this.field_73018_p != this.field_73017_q)
|
|
{
|
|
- this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(8, this.field_73017_q), this.field_73011_w.func_186058_p().func_186068_a());
|
|
+ this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(8, this.field_73017_q), this.field_73011_w.getDimension());
|
|
}
|
|
|
|
+ /* 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_184103_al().func_148540_a(new SPacketChangeGameState(2, 0.0F));
|
|
+ this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(2, 0.0F), this.field_73011_w.getDimension());
|
|
}
|
|
else
|
|
{
|
|
- this.field_73061_a.func_184103_al().func_148540_a(new SPacketChangeGameState(1, 0.0F));
|
|
+ this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(1, 0.0F), this.field_73011_w.getDimension());
|
|
}
|
|
|
|
- this.field_73061_a.func_184103_al().func_148540_a(new SPacketChangeGameState(7, this.field_73004_o));
|
|
- this.field_73061_a.func_184103_al().func_148540_a(new SPacketChangeGameState(8, this.field_73017_q));
|
|
+ this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(7, this.field_73004_o), this.field_73011_w.getDimension());
|
|
+ this.field_73061_a.func_184103_al().func_148537_a(new SPacketChangeGameState(8, this.field_73017_q), this.field_73011_w.getDimension());
|
|
}
|
|
}
|
|
|
|
@@ -1323,6 +1356,11 @@
|
|
return this.field_193036_D;
|
|
}
|
|
|
|
+ public java.io.File getChunkSaveLocation()
|
|
+ {
|
|
+ return ((net.minecraft.world.chunk.storage.AnvilChunkLoader)func_72863_F().field_73247_e).field_75825_d;
|
|
+ }
|
|
+
|
|
static class ServerBlockEventList extends ArrayList<BlockEventData>
|
|
{
|
|
private ServerBlockEventList()
|