-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a405056
commit 36a8272
Showing
20 changed files
with
264 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...iwells/replay/mixin/ChunkHolderMixin.java → .../replay/mixin/chunk/ChunkHolderMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/main/java/me/senseiwells/replay/mixin/chunk/ChunkMapMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package me.senseiwells.replay.mixin.chunk; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import me.senseiwells.replay.chunk.ChunkRecorder; | ||
import me.senseiwells.replay.chunk.ChunkRecorders; | ||
import me.senseiwells.replay.config.ReplayConfig; | ||
import net.minecraft.server.level.ChunkHolder; | ||
import net.minecraft.server.level.ChunkMap; | ||
import net.minecraft.world.level.ChunkPos; | ||
import org.spongepowered.asm.mixin.Debug; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.util.function.BooleanSupplier; | ||
|
||
@Debug(export = true) | ||
@Mixin(ChunkMap.class) | ||
public class ChunkMapMixin { | ||
@Inject( | ||
method = "updateChunkScheduling", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lit/unimi/dsi/fastutil/longs/Long2ObjectLinkedOpenHashMap;put(JLjava/lang/Object;)Ljava/lang/Object;", | ||
remap = false | ||
) | ||
) | ||
private void onUpdateChunkMap( | ||
long chunkPos, | ||
int newLevel, | ||
ChunkHolder holder, | ||
int oldLevel, | ||
CallbackInfoReturnable<ChunkHolder> cir | ||
) { | ||
ChunkPos pos = new ChunkPos(chunkPos); | ||
for (ChunkRecorder recorder : ChunkRecorders.all()) { | ||
if (recorder.getChunks().contains(pos)) { | ||
recorder.unpause(pos); | ||
} | ||
} | ||
} | ||
|
||
@Inject( | ||
method = "processUnloads", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lit/unimi/dsi/fastutil/longs/Long2ObjectLinkedOpenHashMap;put(JLjava/lang/Object;)Ljava/lang/Object;", | ||
remap = false | ||
) | ||
) | ||
private void onUnloadChunk( | ||
BooleanSupplier hasMoreTime, | ||
CallbackInfo ci, | ||
@Local ChunkHolder holder | ||
) { | ||
if (ReplayConfig.getSkipWhenChunksUnloaded()) { | ||
for (ChunkRecorder recorder : ChunkRecorders.all()) { | ||
recorder.pause(holder.getPos()); | ||
} | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...eiwells/replay/mixin/PlayerListMixin.java → ...s/replay/mixin/chunk/PlayerListMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/me/senseiwells/replay/mixin/chunk/ServerChunkCacheInvoker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package me.senseiwells.replay.mixin.chunk; | ||
|
||
import com.mojang.datafixers.util.Either; | ||
import net.minecraft.server.level.ChunkHolder; | ||
import net.minecraft.server.level.ServerChunkCache; | ||
import net.minecraft.world.level.chunk.ChunkAccess; | ||
import net.minecraft.world.level.chunk.ChunkStatus; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Invoker; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
@Mixin(ServerChunkCache.class) | ||
public interface ServerChunkCacheInvoker { | ||
@Invoker("getChunkFutureMainThread") | ||
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> getChunkAsync( | ||
int x, | ||
int y, | ||
ChunkStatus status, | ||
boolean load | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.