added deep frozen state where chunk tickets will not be expiring as well, preventing chunks from unloading. Fixes #204
This commit is contained in:
1 parent
07b3029820
commit
3e76adbdaa
5 files changed
+33
-4
No files matched your search
@@ -43,7 +43,8 @@ public class TickCommand
|
|||||||
c.getSource(),
|
c.getSource(),
|
||||||
getInteger(c,"ticks"),
|
getInteger(c,"ticks"),
|
||||||
getString(c, "tail command")))))).
|
getString(c, "tail command")))))).
|
||||||
then(literal("freeze").executes( (c)-> toggleFreeze(c.getSource()))).
|
then(literal("freeze").executes( (c)-> toggleFreeze(c.getSource(), false)).
|
||||||
|
then(literal("deep").executes( (c)-> toggleFreeze(c.getSource(), true)))).
|
||||||
then(literal("step").
|
then(literal("step").
|
||||||
executes((c) -> step(1)).
|
executes((c) -> step(1)).
|
||||||
then(argument("ticks", integer(1,72000)).
|
then(argument("ticks", integer(1,72000)).
|
||||||
@@ -95,15 +96,18 @@ public class TickCommand
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int toggleFreeze(ServerCommandSource source)
|
private static int toggleFreeze(ServerCommandSource source, boolean isDeep)
|
||||||
{
|
{
|
||||||
TickSpeed.is_paused = !TickSpeed.is_paused;
|
TickSpeed.is_paused = !TickSpeed.is_paused;
|
||||||
if (TickSpeed.is_paused)
|
if (TickSpeed.is_paused)
|
||||||
{
|
{
|
||||||
Messenger.m(source, "gi Game is paused");
|
TickSpeed.deepFreeze = isDeep;
|
||||||
|
Messenger.m(source, "gi Game is "+(isDeep?"deeply ":"")+"frozen");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
TickSpeed.deepFreeze = false;
|
||||||
Messenger.m(source, "gi Game runs normally");
|
Messenger.m(source, "gi Game runs normally");
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public class TickSpeed
|
|||||||
public static ServerCommandSource tick_warp_sender = null;
|
public static ServerCommandSource tick_warp_sender = null;
|
||||||
public static int player_active_timeout = 0;
|
public static int player_active_timeout = 0;
|
||||||
public static boolean process_entities = true;
|
public static boolean process_entities = true;
|
||||||
|
public static boolean deepFreeze = false;
|
||||||
public static boolean is_paused = false;
|
public static boolean is_paused = false;
|
||||||
public static boolean is_superHot = false;
|
public static boolean is_superHot = false;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package carpet.mixins;
|
||||||
|
|
||||||
|
import carpet.helpers.TickSpeed;
|
||||||
|
import net.minecraft.server.world.ChunkTicketManager;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(ChunkTicketManager.class)
|
||||||
|
public class ChunkTicketManager_tickMixin
|
||||||
|
{
|
||||||
|
@Shadow private long age;
|
||||||
|
|
||||||
|
@Inject(method = "purge", at = @At("HEAD"), cancellable = true)
|
||||||
|
private void pauseTicketSystem(CallbackInfo ci)
|
||||||
|
{
|
||||||
|
// pausing expiry of tickets
|
||||||
|
// that will prevent also chunks from unloading, so require a deep frozen state
|
||||||
|
if (!TickSpeed.process_entities && TickSpeed.deepFreeze) age--;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -120,7 +120,7 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
|||||||
|
|
||||||
this.profiler.startTick();
|
this.profiler.startTick();
|
||||||
this.profiler.push("tick");
|
this.profiler.push("tick");
|
||||||
this.tick(TickSpeed.time_warp_start_time != 0 ? ()->true : this::shouldKeepTicking);
|
this.tick(TickSpeed.time_warp_start_time != 0 ? ()->!hasRunningTasks() : this::shouldKeepTicking);
|
||||||
this.profiler.swap("nextTickWait");
|
this.profiler.swap("nextTickWait");
|
||||||
this.field_19249 = true;
|
this.field_19249 = true;
|
||||||
this.field_19248 = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference);
|
this.field_19248 = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
"ServerWorld_tickMixin",
|
"ServerWorld_tickMixin",
|
||||||
"ServerChunkManager_tickMixin",
|
"ServerChunkManager_tickMixin",
|
||||||
"ThreadedAnvilChunkStorage_tickMixin",
|
"ThreadedAnvilChunkStorage_tickMixin",
|
||||||
|
"ChunkTicketManager_tickMixin",
|
||||||
|
|
||||||
"ThreadedAnvilChunkStorage_scarpetChunkCreationMixin",
|
"ThreadedAnvilChunkStorage_scarpetChunkCreationMixin",
|
||||||
"ChunkHolder_scarpetChunkCreationMixin",
|
"ChunkHolder_scarpetChunkCreationMixin",
|
||||||
|
|||||||
Reference in new issue
Block a user