ForgePatch/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch

153 lines
6.6 KiB
Diff
Raw Normal View History

2018-09-05 00:23:45 +00:00
--- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java
2019-05-23 23:02:15 +00:00
@@ -182,7 +182,7 @@
private final GameProfileRepository field_152365_W;
private final PlayerProfileCache field_152366_X;
private long field_147142_T;
- protected final Thread field_175590_aa = Util.func_200696_a(new Thread(this, "Server thread"), (p_213187_0_) -> {
+ protected final Thread field_175590_aa = Util.func_200696_a(new Thread(net.minecraftforge.fml.common.thread.SidedThreadGroups.SERVER, this, "Server thread"), (p_213187_0_) -> {
p_213187_0_.setUncaughtExceptionHandler((p_213206_0_, p_213206_1_) -> {
field_147145_h.error(p_213206_1_);
});
@@ -386,6 +386,7 @@
if (dimensiontype != DimensionType.OVERWORLD) {
this.field_71305_c.put(dimensiontype, new ServerMultiWorld(serverworld1, this, this.field_213217_au, p_213194_1_, dimensiontype, this.field_71304_b, p_213194_4_));
}
2019-05-23 23:02:15 +00:00
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Load(field_71305_c.get(dimensiontype)));
}
2019-05-23 23:02:15 +00:00
}
@@ -541,6 +542,7 @@
for(ServerWorld serverworld1 : this.func_212370_w()) {
if (serverworld1 != null) {
try {
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.WorldEvent.Unload(serverworld1));
serverworld1.close();
} catch (IOException ioexception) {
field_147145_h.error("Exception closing the level", (Throwable)ioexception);
@@ -581,6 +583,7 @@
2018-09-05 00:23:45 +00:00
public void run() {
try {
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();
2019-05-23 23:02:15 +00:00
this.field_147147_p.func_151315_a(new StringTextComponent(this.field_71286_C));
this.field_147147_p.func_151321_a(new ServerStatusResponse.Version(SharedConstants.func_215069_a().getName(), SharedConstants.func_215069_a().getProtocolVersion()));
@@ -612,7 +615,10 @@
this.field_71304_b.func_219897_b();
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
this.func_71228_a((CrashReport)null);
2018-09-05 00:23:45 +00:00
}
} catch (Throwable throwable1) {
2019-05-23 23:02:15 +00:00
@@ -631,6 +637,7 @@
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
this.func_71228_a(crashreport);
2018-09-05 00:23:45 +00:00
} finally {
try {
2019-05-23 23:02:15 +00:00
@@ -639,6 +646,7 @@
2018-09-05 00:23:45 +00:00
} catch (Throwable throwable) {
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);
this.func_71240_o();
2018-09-05 00:23:45 +00:00
}
2019-05-23 23:02:15 +00:00
@@ -735,6 +743,7 @@
2019-05-23 23:02:15 +00:00
protected void func_71217_p(BooleanSupplier p_71217_1_) {
long i = Util.func_211178_c();
+ net.minecraftforge.fml.hooks.BasicEventHooks.onPreServerTick();
++this.field_71315_w;
2019-05-23 23:02:15 +00:00
this.func_71190_q(p_71217_1_);
if (i - this.field_147142_T >= 5000000000L) {
@@ -749,6 +758,7 @@
Collections.shuffle(Arrays.asList(agameprofile));
this.field_147147_p.func_151318_b().func_151330_a(agameprofile);
+ this.field_147147_p.invalidateJson();
}
2019-05-23 23:02:15 +00:00
if (this.field_71315_w % 6000 == 0) {
@@ -776,6 +786,7 @@
long i1 = Util.func_211178_c();
this.field_213215_ap.func_181747_a(i1 - i);
this.field_71304_b.func_76319_b();
+ net.minecraftforge.fml.hooks.BasicEventHooks.onPostServerTick();
}
2019-05-23 23:02:15 +00:00
protected void func_71190_q(BooleanSupplier p_71190_1_) {
@@ -796,6 +807,7 @@
}
this.field_71304_b.func_76320_a("tick");
2019-05-23 23:02:15 +00:00
+ net.minecraftforge.fml.hooks.BasicEventHooks.onPreWorldTick(serverworld);
try {
2019-05-23 23:02:15 +00:00
serverworld.func_72835_b(p_71190_1_);
@@ -804,6 +816,7 @@
serverworld.func_72914_a(crashreport);
throw new ReportedException(crashreport);
}
2019-05-23 23:02:15 +00:00
+ net.minecraftforge.fml.hooks.BasicEventHooks.onPostWorldTick(serverworld);
this.field_71304_b.func_76319_b();
2019-05-23 23:02:15 +00:00
this.field_71304_b.func_76319_b();
@@ -814,6 +827,8 @@
}))[this.field_71315_w % 100] = Util.func_211178_c() - i;
}
2019-05-23 23:02:15 +00:00
+ this.field_71304_b.func_219895_b("dim_unloading");
+ net.minecraftforge.common.DimensionManager.unloadWorlds(this, this.field_71315_w % 200 == 0);
2019-05-23 23:02:15 +00:00
this.field_71304_b.func_219895_b("connection");
this.func_147137_ag().func_151269_c();
2019-05-23 23:02:15 +00:00
this.field_71304_b.func_219895_b("players");
@@ -850,6 +865,7 @@
OptionSpec<Integer> optionspec10 = optionparser.accepts("port").withRequiredArg().ofType(Integer.class).defaultsTo(-1);
OptionSpec<String> optionspec11 = optionparser.accepts("serverId").withRequiredArg();
OptionSpec<String> optionspec12 = optionparser.nonOptions();
+ optionparser.accepts("gameDir").withRequiredArg().ofType(File.class).defaultsTo(new File(".")); //Forge: Consume this argument, we use it in the launcher, and the client side.
try {
OptionSet optionset = optionparser.parse(p_main_0_);
@@ -942,7 +958,7 @@
}
2019-05-23 23:02:15 +00:00
public ServerWorld func_71218_a(DimensionType p_71218_1_) {
- return this.field_71305_c.get(p_71218_1_);
+ return net.minecraftforge.common.DimensionManager.getWorld(this, p_71218_1_, true, true);
}
2019-05-23 23:02:15 +00:00
public Iterable<ServerWorld> func_212370_w() {
@@ -981,7 +997,7 @@
}
public String getServerModName() {
- return "vanilla";
2018-09-30 00:47:47 +00:00
+ return net.minecraftforge.fml.BrandingControl.getServerBranding();
}
public CrashReport func_71230_b(CrashReport p_71230_1_) {
@@ -1516,4 +1532,14 @@
}
2019-05-23 23:02:15 +00:00
public abstract boolean func_213199_b(GameProfile p_213199_1_);
+
+ @Nullable
+ public long[] getTickTime(DimensionType dim) {
+ return field_71312_k.get(dim);
+ }
+
+ @Deprecated //Forge Internal use Only, You can screw up a lot of things if you mess with this map.
2019-05-23 23:02:15 +00:00
+ public synchronized Map<DimensionType, ServerWorld> forgeGetWorldMap() {
+ return this.field_71305_c;
+ }
}