This commit is contained in:
Moulberry committed 2024-09-15 11:35:31 +08:00
1 parent 7f1d199704
commit be99313e81
47 files changed
+1247 -337

No files matched your search

@@ -4,9 +4,11 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalIntRef;
import com.moulberry.flashback.Flashback;
import com.moulberry.flashback.screen.FlashbackButton;
import com.moulberry.flashback.screen.SelectReplayScreen;
import net.fabricmc.fabric.api.client.screen.v1.Screens;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.AbstractButton;
import net.minecraft.client.gui.components.AbstractWidget;
@@ -14,10 +16,13 @@ import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.AlertScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.client.gui.screens.worldselection.SelectWorldScreen;
import net.minecraft.network.chat.Component;
import net.minecraft.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
@@ -87,7 +92,21 @@ public class MixinTitleScreen extends Screen {
if (!overlapsWithExistingButton) {
this.openSelectReplayScreenButton = new FlashbackButton(x, y, size, size, Component.literal("Open Replays"), button -> {
this.minecraft.setScreen(new SelectReplayScreen(this));
List<String> incompatibleMods = Screen.hasShiftDown() ? List.of() : Flashback.getReplayIncompatibleMods();
if (incompatibleMods.isEmpty()) {
this.minecraft.setScreen(new SelectReplayScreen(this));
} else {
String mods = StringUtils.join(incompatibleMods, ", ");
String description = """
You have mods which are known to cause crashes when loading replays
Please remove the following mods in order to be able to load replays:
""";
this.minecraft.setScreen(new AlertScreen(() -> Minecraft.getInstance().setScreen(this),
Component.literal("Incompatible Mods"), Component.literal(description).append(Component.literal(mods).withStyle(ChatFormatting.RED))));
}
});
this.addRenderableWidget(this.openSelectReplayScreenButton);
return;