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.WorldsTogether;
|
||||||
import org.betterx.worlds.together.world.event.WorldBootstrap;
|
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.Screen;
|
||||||
import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows;
|
import net.minecraft.client.gui.screens.worldselection.WorldOpenFlows;
|
||||||
import net.minecraft.core.RegistryAccess;
|
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.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@Mixin(WorldOpenFlows.class)
|
@Mixin(WorldOpenFlows.class)
|
||||||
|
@ -27,23 +29,40 @@ public abstract class WorldOpenFlowsMixin {
|
||||||
@Final
|
@Final
|
||||||
private LevelStorageSource levelSource;
|
private LevelStorageSource levelSource;
|
||||||
|
|
||||||
@Shadow
|
|
||||||
protected abstract void doLoadLevel(Screen screen, String levelID, boolean safeMode, boolean canAskForBackup);
|
|
||||||
|
|
||||||
@Inject(method = "loadLevel", cancellable = true, at = @At("HEAD"))
|
@Shadow
|
||||||
private void wt_callFixerOnLoad(Screen screen, String levelID, CallbackInfo ci) {
|
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);
|
WorldBootstrap.InGUI.setupLoadedWorld(levelID, this.levelSource);
|
||||||
|
|
||||||
if (WorldBootstrap.InGUI.applyWorldPatches(levelSource, levelID, (appliedFixes) -> {
|
if (WorldBootstrap.InGUI.applyWorldPatches(levelSource, levelID, (appliedFixes) -> {
|
||||||
WorldBootstrap.finishedWorldLoad();
|
WorldBootstrap.finishedWorldLoad();
|
||||||
this.doLoadLevel(screen, levelID, false, false);
|
this.loadLevel(levelStorageAccess, dynamic, false, false, runnable);
|
||||||
})) {
|
})) {
|
||||||
//cancel call when fix-screen is presented
|
//cancel call when fix-screen is presented
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
} else {
|
} else {
|
||||||
WorldBootstrap.finishedWorldLoad();
|
WorldBootstrap.finishedWorldLoad();
|
||||||
if (WorldsTogether.SURPRESS_EXPERIMENTAL_DIALOG) {
|
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
|
//cancel call as we manually start the level load here
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
@ -52,10 +71,11 @@ public abstract class WorldOpenFlowsMixin {
|
||||||
|
|
||||||
@Inject(method = "createFreshLevel", at = @At("HEAD"))
|
@Inject(method = "createFreshLevel", at = @At("HEAD"))
|
||||||
public void wt_createFreshLevel(
|
public void wt_createFreshLevel(
|
||||||
String levelID,
|
String string,
|
||||||
LevelSettings levelSettings,
|
LevelSettings levelSettings,
|
||||||
WorldOptions worldOptions,
|
WorldOptions worldOptions,
|
||||||
Function<RegistryAccess, WorldDimensions> function,
|
Function<RegistryAccess, WorldDimensions> function,
|
||||||
|
Screen screen,
|
||||||
CallbackInfo ci
|
CallbackInfo ci
|
||||||
) {
|
) {
|
||||||
WorldsTogether.LOGGER.warning("called createFreshLevel...");
|
WorldsTogether.LOGGER.warning("called createFreshLevel...");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue