Move difficulty lock w/ sleep time to off-main thread
This commit is contained in:
@@ -10,10 +10,12 @@ import com.google.common.collect.Iterables;
|
||||
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.EnumDifficulty;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.NetworkManager;
|
||||
import net.minecraft.server.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.PacketPlayOutUpdateTime;
|
||||
import net.minecraft.server.World;
|
||||
import net.minecraft.server.WorldServer;
|
||||
|
||||
public class AkarinAsyncScheduler extends Thread {
|
||||
@@ -55,10 +57,10 @@ public class AkarinAsyncScheduler extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
// Send time updates to everyone, it will get the right time from the world the player is in.
|
||||
for (final WorldServer world : server.getWorlds()) {
|
||||
final boolean doDaylight = world.getGameRules().getBoolean("doDaylightCycle");
|
||||
final long dayTime = world.getDayTime();
|
||||
for (WorldServer world : server.getWorlds()) {
|
||||
// Send time updates to everyone, it will get the right time from the world the player is in.
|
||||
boolean doDaylight = world.getGameRules().getBoolean("doDaylightCycle");
|
||||
long dayTime = world.getDayTime();
|
||||
long worldTime = world.getTime();
|
||||
final PacketPlayOutUpdateTime worldPacket = new PacketPlayOutUpdateTime(worldTime, dayTime, doDaylight);
|
||||
for (EntityHuman entityhuman : world.players) {
|
||||
@@ -71,6 +73,20 @@ public class AkarinAsyncScheduler extends Thread {
|
||||
new PacketPlayOutUpdateTime(worldTime, playerTime, doDaylight);
|
||||
entityplayer.playerConnection.sendPacket(packet); // Add support for per player time
|
||||
}
|
||||
|
||||
// Hardcore difficulty lock
|
||||
if (world.getWorldData().isHardcore() && world.getDifficulty() != EnumDifficulty.HARD) {
|
||||
world.getWorldData().setDifficulty(EnumDifficulty.HARD);
|
||||
}
|
||||
|
||||
// Sleeping time management
|
||||
if (world.everyoneDeeplySleeping()) {
|
||||
if (world.getGameRules().getBoolean("doDaylightCycle")) {
|
||||
long i = world.worldData.getDayTime() + 24000L;
|
||||
|
||||
world.worldData.setDayTime(i - i % 24000L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send player latency update packets
|
||||
|
||||
@@ -254,17 +254,25 @@ public class WorldServer extends World implements IAsyncTaskHandler {
|
||||
public void doTick(BooleanSupplier booleansupplier) {
|
||||
this.P = true;
|
||||
super.doTick(booleansupplier);
|
||||
// Akarin start
|
||||
/*
|
||||
if (this.getWorldData().isHardcore() && this.getDifficulty() != EnumDifficulty.HARD) {
|
||||
this.getWorldData().setDifficulty(EnumDifficulty.HARD);
|
||||
}
|
||||
*/
|
||||
// Akarin end
|
||||
|
||||
this.chunkProvider.getChunkGenerator().getWorldChunkManager().tick();
|
||||
if (this.everyoneDeeplySleeping()) {
|
||||
// Akarin start
|
||||
/*
|
||||
if (this.getGameRules().getBoolean("doDaylightCycle")) {
|
||||
long i = this.worldData.getDayTime() + 24000L;
|
||||
|
||||
this.worldData.setDayTime(i - i % 24000L);
|
||||
}
|
||||
*/
|
||||
// Akarin end
|
||||
|
||||
this.i();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user