Skip to content

Commit

Permalink
change: check current thread before resetting settings
Browse files Browse the repository at this point in the history
makes seedqueue compat require less brittle mixinsquared injections
  • Loading branch information
KingContaria committed Jul 18, 2024
1 parent 53bc678 commit ebd61b0
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public abstract class MinecraftClientMixin {

@Inject(method = "createWorld", at = @At("HEAD"))
private void reset(String worldName, LevelInfo levelInfo, RegistryTracker.Modifiable registryTracker, GeneratorOptions generatorOptions, CallbackInfo ci) {
if (!MinecraftClient.getInstance().isOnThread()) {
return;
}
StandardSettings.createCache();
if (StandardSettings.isEnabled()) {
StandardSettings.reset();
Expand All @@ -51,6 +54,9 @@ private void reset(String worldName, LevelInfo levelInfo, RegistryTracker.Modifi

@Inject(method = "createWorld", at = @At("TAIL"))
private void onWorldJoin(String worldName, LevelInfo levelInfo, RegistryTracker.Modifiable registryTracker, GeneratorOptions generatorOptions, CallbackInfo ci) {
if (!MinecraftClient.getInstance().isOnThread()) {
return;
}
StandardSettings.saveToWorldFile(worldName);
if (StandardSettings.isEnabled()) {
if (this.isWindowFocused()) {
Expand Down Expand Up @@ -78,17 +84,23 @@ private void onWorldJoin_onResize(CallbackInfo ci) {

@Inject(method = "startIntegratedServer(Ljava/lang/String;Lnet/minecraft/util/registry/RegistryTracker$Modifiable;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function4;ZLnet/minecraft/client/MinecraftClient$WorldLoadAction;)V", at = @At("HEAD"))
private void resetPendingActions(CallbackInfo ci) {
StandardSettings.resetPendingActions();
if (MinecraftClient.getInstance().isOnThread()) {
StandardSettings.resetPendingActions();
}
}

@Inject(method = "startIntegratedServer(Ljava/lang/String;)V", at = @At("HEAD"))
private void loadCache(String worldName, CallbackInfo ci) {
StandardSettings.loadCache(worldName);
if (MinecraftClient.getInstance().isOnThread()) {
StandardSettings.loadCache(worldName);
}
}

@Inject(method = "startIntegratedServer(Ljava/lang/String;Lnet/minecraft/util/registry/RegistryTracker$Modifiable;Ljava/util/function/Function;Lcom/mojang/datafixers/util/Function4;ZLnet/minecraft/client/MinecraftClient$WorldLoadAction;)V", at = @At("TAIL"))
private void setLastWorld(String worldName, RegistryTracker.Modifiable registryTracker, Function<LevelStorage.Session, DataPackSettings> function, Function4<LevelStorage.Session, RegistryTracker.Modifiable, ResourceManager, DataPackSettings, SaveProperties> function4, boolean safeMode, @Coerce Object worldLoadAction, CallbackInfo ci) {
StandardSettings.lastWorld = worldName;
if (MinecraftClient.getInstance().isOnThread()) {
StandardSettings.lastWorld = worldName;
}
}

@Inject(method = "tick", at = @At("HEAD"))
Expand Down

0 comments on commit ebd61b0

Please sign in to comment.