Fixed Data Fixer injection
This commit is contained in:
parent
dceec8db85
commit
194e78c960
1 changed files with 27 additions and 7 deletions
|
@ -3,6 +3,7 @@ package org.betterx.worlds.together.mixin.client;
|
|||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
||||
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
|
@ -18,6 +19,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mixin(WorldOpenFlows.class)
|
||||
|
@ -27,23 +29,40 @@ public abstract class WorldOpenFlowsMixin {
|
|||
@Final
|
||||
private LevelStorageSource levelSource;
|
||||
|
||||
@Shadow
|
||||
protected abstract void doLoadLevel(Screen screen, String levelID, boolean safeMode, boolean canAskForBackup);
|
||||
|
||||
@Inject(method = "loadLevel", cancellable = true, at = @At("HEAD"))
|
||||
private void wt_callFixerOnLoad(Screen screen, String levelID, CallbackInfo ci) {
|
||||
@Shadow
|
||||
protected abstract void loadLevel(
|
||||
LevelStorageSource.LevelStorageAccess levelStorageAccess,
|
||||
Dynamic<?> dynamic,
|
||||
boolean bl,
|
||||
boolean bl2,
|
||||
Runnable runnable
|
||||
);
|
||||
|
||||
@Inject(
|
||||
method = "checkForBackupAndLoad(Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;Ljava/lang/Runnable;)V",
|
||||
cancellable = true,
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/worldselection/WorldOpenFlows;loadLevel(Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;Lcom/mojang/serialization/Dynamic;ZZLjava/lang/Runnable;)V")
|
||||
)
|
||||
private void wt_callFixerOnLoad(
|
||||
LevelStorageSource.LevelStorageAccess levelStorageAccess,
|
||||
Runnable runnable,
|
||||
CallbackInfo ci
|
||||
) throws IOException {
|
||||
final String levelID = levelStorageAccess.getLevelId();
|
||||
final var dynamic = levelStorageAccess.getDataTag();
|
||||
WorldBootstrap.InGUI.setupLoadedWorld(levelID, this.levelSource);
|
||||
|
||||
if (WorldBootstrap.InGUI.applyWorldPatches(levelSource, levelID, (appliedFixes) -> {
|
||||
WorldBootstrap.finishedWorldLoad();
|
||||
this.doLoadLevel(screen, levelID, false, false);
|
||||
this.loadLevel(levelStorageAccess, dynamic, false, false, runnable);
|
||||
})) {
|
||||
//cancel call when fix-screen is presented
|
||||
ci.cancel();
|
||||
} else {
|
||||
WorldBootstrap.finishedWorldLoad();
|
||||
if (WorldsTogether.SURPRESS_EXPERIMENTAL_DIALOG) {
|
||||
this.doLoadLevel(screen, levelID, false, false);
|
||||
this.loadLevel(levelStorageAccess, dynamic, false, false, runnable);
|
||||
//cancel call as we manually start the level load here
|
||||
ci.cancel();
|
||||
}
|
||||
|
@ -52,10 +71,11 @@ public abstract class WorldOpenFlowsMixin {
|
|||
|
||||
@Inject(method = "createFreshLevel", at = @At("HEAD"))
|
||||
public void wt_createFreshLevel(
|
||||
String levelID,
|
||||
String string,
|
||||
LevelSettings levelSettings,
|
||||
WorldOptions worldOptions,
|
||||
Function<RegistryAccess, WorldDimensions> function,
|
||||
Screen screen,
|
||||
CallbackInfo ci
|
||||
) {
|
||||
WorldsTogether.LOGGER.warning("called createFreshLevel...");
|
||||
|
|
Loading…
Reference in a new issue