2018-09-05 00:23:45 +00:00
|
|
|
--- a/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/net/minecraft/server/MinecraftServer.java
|
2018-09-21 06:50:50 +00:00
|
|
|
@@ -148,7 +148,6 @@
|
2018-09-22 03:28:47 +00:00
|
|
|
private int field_71280_D;
|
|
|
|
private int field_143008_E;
|
|
|
|
public final long[] field_71311_j = new long[100];
|
|
|
|
- public long[][] field_71312_k;
|
|
|
|
private KeyPair field_71292_I;
|
|
|
|
private String field_71293_J;
|
|
|
|
private String field_71294_K;
|
2018-09-21 06:50:50 +00:00
|
|
|
@@ -287,8 +286,7 @@
|
2018-09-22 03:28:47 +00:00
|
|
|
public void func_71247_a(String p_71247_1_, String p_71247_2_, long p_71247_3_, WorldType p_71247_5_, JsonElement p_71247_6_) {
|
|
|
|
this.func_71237_c(p_71247_1_);
|
2018-09-18 04:04:02 +00:00
|
|
|
this.func_200245_b(new TextComponentTranslation("menu.loadingLevel", new Object[0]));
|
2018-09-22 03:28:47 +00:00
|
|
|
- this.field_71305_c = new WorldServer[3];
|
|
|
|
- this.field_71312_k = new long[this.field_71305_c.length][100];
|
|
|
|
+ this.field_71305_c = new WorldServer[1]; //Forge only initialize overworld, we will do the rest.
|
|
|
|
ISaveHandler isavehandler = this.field_71310_m.func_197715_a(p_71247_1_, this);
|
|
|
|
this.func_175584_a(this.func_71270_I(), isavehandler);
|
|
|
|
WorldInfo worldinfo = isavehandler.func_75757_d();
|
2018-09-21 06:50:50 +00:00
|
|
|
@@ -340,6 +338,18 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ for (int dim : net.minecraftforge.common.DimensionManager.getStaticDimensionIDs()) {
|
2018-09-22 03:28:47 +00:00
|
|
|
+ WorldServer world = this.field_71305_c[0];
|
2018-09-21 06:50:50 +00:00
|
|
|
+ if (dim != 0) {
|
2018-09-22 03:28:47 +00:00
|
|
|
+ world = (WorldServer)(new WorldServerMulti(this, isavehandler, dim, this.field_71305_c[0], this.field_71304_b).func_175643_b());
|
|
|
|
+ world.func_72954_a(new ServerWorldEventHandler(this, world));
|
|
|
|
+ if (!this.func_71264_H()) {
|
|
|
|
+ world.func_72912_H().func_76060_a(func_71265_f());
|
2018-09-21 06:50:50 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(world));
|
|
|
|
+ }
|
|
|
|
+
|
2018-09-22 03:28:47 +00:00
|
|
|
this.field_71318_t.func_72364_a(this.field_71305_c);
|
2018-09-21 06:50:50 +00:00
|
|
|
if (worldinfo.func_201357_P() != null) {
|
|
|
|
this.func_201300_aS().func_201381_a(worldinfo.func_201357_P());
|
|
|
|
@@ -378,7 +388,7 @@
|
|
|
|
this.func_200245_b(new TextComponentTranslation("menu.generatingTerrain", new Object[0]));
|
|
|
|
int j1 = 0;
|
2018-09-22 03:28:47 +00:00
|
|
|
field_147145_h.info("Preparing start region for level 0");
|
|
|
|
- WorldServer worldserver = this.field_71305_c[0];
|
|
|
|
+ WorldServer worldserver = func_71218_a(0);
|
|
|
|
BlockPos blockpos = worldserver.func_175694_M();
|
2018-09-21 06:50:50 +00:00
|
|
|
List<ChunkPos> list = Lists.<ChunkPos>newArrayList();
|
|
|
|
Set<ChunkPos> set = Sets.<ChunkPos>newConcurrentHashSet();
|
|
|
|
@@ -493,9 +503,14 @@
|
|
|
|
|
2018-09-22 03:28:47 +00:00
|
|
|
for(WorldServer worldserver1 : this.field_71305_c) {
|
2018-09-21 06:50:50 +00:00
|
|
|
if (worldserver1 != null) {
|
|
|
|
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(worldserver1));
|
|
|
|
worldserver1.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
2018-09-22 03:28:47 +00:00
|
|
|
+ WorldServer[] tmp = this.field_71305_c;
|
2018-09-21 06:50:50 +00:00
|
|
|
+ for (WorldServer world : tmp)
|
2018-09-22 03:28:47 +00:00
|
|
|
+ net.minecraftforge.common.DimensionManager.setWorld(world.field_73011_w.getId(), null, this);
|
2018-09-21 06:50:50 +00:00
|
|
|
}
|
|
|
|
|
2018-09-22 03:28:47 +00:00
|
|
|
if (this.field_71307_n.func_76468_d()) {
|
2018-09-21 06:50:50 +00:00
|
|
|
@@ -523,6 +538,7 @@
|
2018-09-05 00:23:45 +00:00
|
|
|
public void run() {
|
|
|
|
try {
|
2018-09-22 03:28:47 +00:00
|
|
|
if (this.func_71197_b()) {
|
2018-09-05 00:23:45 +00:00
|
|
|
+ net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerStarted(this);
|
|
|
|
this.field_211151_aa = Util.func_211177_b();
|
2018-09-22 03:28:47 +00:00
|
|
|
this.field_147147_p.func_151315_a(new TextComponentString(this.field_71286_C));
|
|
|
|
this.field_147147_p.func_151321_a(new ServerStatusResponse.Version("1.13", 393));
|
2018-09-21 06:50:50 +00:00
|
|
|
@@ -546,7 +562,10 @@
|
2018-09-05 00:23:45 +00:00
|
|
|
|
2018-09-22 03:28:47 +00:00
|
|
|
this.field_71296_Q = true;
|
2018-09-05 00:23:45 +00:00
|
|
|
}
|
|
|
|
+ net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerStopping(this);
|
|
|
|
+ net.minecraftforge.fml.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions
|
|
|
|
} else {
|
|
|
|
+ net.minecraftforge.fml.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions
|
2018-09-22 03:28:47 +00:00
|
|
|
this.func_71228_a((CrashReport)null);
|
2018-09-05 00:23:45 +00:00
|
|
|
}
|
|
|
|
} catch (Throwable throwable1) {
|
2018-09-21 06:50:50 +00:00
|
|
|
@@ -565,6 +584,7 @@
|
2018-09-22 03:28:47 +00:00
|
|
|
field_147145_h.error("We were unable to save this crash report to disk.");
|
2018-09-05 00:23:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ net.minecraftforge.fml.server.ServerLifecycleHooks.expectServerStopped(); // has to come before finalTick to avoid race conditions
|
2018-09-22 03:28:47 +00:00
|
|
|
this.func_71228_a(crashreport);
|
2018-09-05 00:23:45 +00:00
|
|
|
} finally {
|
|
|
|
try {
|
2018-09-21 06:50:50 +00:00
|
|
|
@@ -573,6 +593,7 @@
|
2018-09-05 00:23:45 +00:00
|
|
|
} catch (Throwable throwable) {
|
2018-09-22 03:28:47 +00:00
|
|
|
field_147145_h.error("Exception stopping the server", throwable);
|
2018-09-05 00:23:45 +00:00
|
|
|
} finally {
|
|
|
|
+ net.minecraftforge.fml.server.ServerLifecycleHooks.handleServerStopped(this);
|
2018-09-22 03:28:47 +00:00
|
|
|
this.func_71240_o();
|
2018-09-05 00:23:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-21 06:50:50 +00:00
|
|
|
@@ -648,6 +669,7 @@
|
|
|
|
|
|
|
|
Collections.shuffle(Arrays.asList(agameprofile));
|
2018-09-22 03:28:47 +00:00
|
|
|
this.field_147147_p.func_151318_b().func_151330_a(agameprofile);
|
|
|
|
+ this.field_147147_p.invalidateJson();
|
2018-09-21 06:50:50 +00:00
|
|
|
}
|
|
|
|
|
2018-09-22 03:28:47 +00:00
|
|
|
if (this.field_71315_w % 900 == 0) {
|
2018-09-21 06:50:50 +00:00
|
|
|
@@ -686,16 +708,18 @@
|
2018-09-22 03:28:47 +00:00
|
|
|
this.func_193030_aL().func_73660_a();
|
|
|
|
this.field_71304_b.func_76318_c("levels");
|
2018-09-18 04:04:02 +00:00
|
|
|
|
2018-09-22 03:28:47 +00:00
|
|
|
- for(int i = 0; i < this.field_71305_c.length; ++i) {
|
|
|
|
+ Integer[] ids = net.minecraftforge.common.DimensionManager.getIDs(this.field_71315_w % 200 == 0);
|
2018-09-18 04:04:02 +00:00
|
|
|
+ for(int x = 0; x < ids.length; ++x) {
|
|
|
|
+ int id = ids[x];
|
|
|
|
long j = Util.func_211178_c();
|
2018-09-22 03:28:47 +00:00
|
|
|
- if (i == 0 || this.func_71255_r()) {
|
|
|
|
- WorldServer worldserver = this.field_71305_c[i];
|
|
|
|
+ WorldServer worldserver = func_71218_a(id);
|
|
|
|
+ if (id == 0 || this.func_71255_r()) {
|
|
|
|
this.field_71304_b.func_194340_a(() -> {
|
|
|
|
return worldserver.func_72912_H().func_76065_j();
|
2018-09-18 04:04:02 +00:00
|
|
|
});
|
2018-09-22 03:28:47 +00:00
|
|
|
if (this.field_71315_w % 20 == 0) {
|
|
|
|
this.field_71304_b.func_76320_a("timeSync");
|
|
|
|
- this.field_71318_t.func_148537_a(new SPacketTimeUpdate(worldserver.func_82737_E(), worldserver.func_72820_D(), worldserver.func_82736_K().func_82766_b("doDaylightCycle")), worldserver.field_73011_w.func_186058_p().func_186068_a());
|
|
|
|
+ this.field_71318_t.func_148537_a(new SPacketTimeUpdate(worldserver.func_82737_E(), worldserver.func_72820_D(), worldserver.func_82736_K().func_82766_b("doDaylightCycle")), worldserver.field_73011_w.getId());
|
|
|
|
this.field_71304_b.func_76319_b();
|
2018-09-21 06:50:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@@ -724,9 +748,11 @@
|
2018-09-22 03:28:47 +00:00
|
|
|
this.field_71304_b.func_76319_b();
|
2018-09-18 04:04:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-22 03:28:47 +00:00
|
|
|
- this.field_71312_k[i][this.field_71315_w % 100] = Util.func_211178_c() - j;
|
|
|
|
+ worldserver.setTickTime(this.field_71315_w, Util.func_211178_c() - j);
|
2018-09-18 04:04:02 +00:00
|
|
|
}
|
|
|
|
|
2018-09-22 03:28:47 +00:00
|
|
|
+ this.field_71304_b.func_76318_c("dim_unloading");
|
2018-09-21 06:50:50 +00:00
|
|
|
+ net.minecraftforge.common.DimensionManager.unloadWorlds();
|
2018-09-22 03:28:47 +00:00
|
|
|
this.field_71304_b.func_76318_c("connection");
|
|
|
|
this.func_147137_ag().func_151269_c();
|
|
|
|
this.field_71304_b.func_76318_c("players");
|
2018-09-21 06:50:50 +00:00
|
|
|
@@ -749,6 +775,14 @@
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void main(String[] p_main_0_) {
|
|
|
|
+ //Forge: Copied from DedicatedServer.init as to run as early as possible, Old code left in place intentionally.
|
|
|
|
+ //Done in good faith with permission: https://github.com/MinecraftForge/MinecraftForge/issues/3659#issuecomment-390467028
|
|
|
|
+ ServerEula eula = new ServerEula(new File("eula.txt"));
|
2018-09-22 03:28:47 +00:00
|
|
|
+ if (!eula.func_154346_a()) {
|
|
|
|
+ field_147145_h.info("You need to agree to the EULA in order to run the server. Go to eula.txt for more info.");
|
|
|
|
+ eula.func_154348_b();
|
2018-09-21 06:50:50 +00:00
|
|
|
+ return;
|
|
|
|
+ }
|
2018-09-22 03:28:47 +00:00
|
|
|
Bootstrap.func_151354_b();
|
2018-09-21 06:50:50 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
@@ -851,7 +885,7 @@
|
|
|
|
}
|
|
|
|
|
2018-09-22 03:28:47 +00:00
|
|
|
public void func_71256_s() {
|
|
|
|
- this.field_175590_aa = new Thread(this, "Server thread");
|
|
|
|
+ this.field_175590_aa = new Thread(net.minecraftforge.fml.common.thread.SidedThreadGroups.SERVER, this, "Server thread");
|
|
|
|
this.field_175590_aa.setUncaughtExceptionHandler((p_195574_0_, p_195574_1_) -> {
|
|
|
|
field_147145_h.error(p_195574_1_);
|
2018-09-21 06:50:50 +00:00
|
|
|
});
|
|
|
|
@@ -871,11 +905,7 @@
|
|
|
|
}
|
|
|
|
|
2018-09-22 03:28:47 +00:00
|
|
|
public WorldServer func_71218_a(int p_71218_1_) {
|
|
|
|
- if (p_71218_1_ == -1) {
|
|
|
|
- return this.field_71305_c[1];
|
2018-09-21 06:50:50 +00:00
|
|
|
- } else {
|
2018-09-22 03:28:47 +00:00
|
|
|
- return p_71218_1_ == 1 ? this.field_71305_c[2] : this.field_71305_c[0];
|
2018-09-21 06:50:50 +00:00
|
|
|
- }
|
2018-09-22 03:28:47 +00:00
|
|
|
+ return net.minecraftforge.common.DimensionManager.getWorld(p_71218_1_, true, true);
|
2018-09-21 06:50:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public WorldServer func_200667_a(DimensionType p_200667_1_) {
|
|
|
|
@@ -918,7 +948,7 @@
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getServerModName() {
|
|
|
|
- return "vanilla";
|
2018-09-30 00:47:47 +00:00
|
|
|
+ return net.minecraftforge.fml.BrandingControl.getServerBranding();
|
2018-09-21 06:50:50 +00:00
|
|
|
}
|
|
|
|
|
2018-09-22 03:28:47 +00:00
|
|
|
public CrashReport func_71230_b(CrashReport p_71230_1_) {
|