Fixed Welcome- and UpdateScreen

This commit is contained in:
Frank 2023-12-19 20:58:37 +01:00
parent 277fd0c8fd
commit 0de74f96ea
7 changed files with 40 additions and 11 deletions

View file

@ -35,4 +35,21 @@ public abstract class BCLibLayoutScreen extends LayoutScreenWithIcon {
) {
super(parent, BCLIB_LOGO_LOCATION, component, topPadding, bottomPadding, sidePadding);
}
public BCLibLayoutScreen(
@Nullable Runnable onClose,
Component component
) {
super(onClose, BCLIB_LOGO_LOCATION, component);
}
public BCLibLayoutScreen(
@Nullable Runnable onClose,
Component component,
int topPadding,
int bottomPadding,
int sidePadding
) {
super(onClose, BCLIB_LOGO_LOCATION, component, topPadding, bottomPadding, sidePadding);
}
}

View file

@ -30,6 +30,10 @@ public class UpdatesScreen extends BCLibLayoutScreen {
public static final String DONATION_URL = "https://www.buymeacoffee.com/quiqueck";
static final ResourceLocation UPDATE_LOGO_LOCATION = new ResourceLocation(BCLib.MOD_ID, "icon_updater.png");
public UpdatesScreen(Runnable onClose) {
super(onClose, Component.translatable("bclib.updates.title"), 10, 10, 10);
}
public UpdatesScreen(Screen parent) {
super(parent, Component.translatable("bclib.updates.title"), 10, 10, 10);
}

View file

@ -11,7 +11,6 @@ import org.betterx.worlds.together.WorldsTogether;
import org.betterx.worlds.together.worldPreset.WorldPresets;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
@ -19,11 +18,11 @@ import net.minecraft.resources.ResourceLocation;
public class WelcomeScreen extends BCLibLayoutScreen {
static final ResourceLocation BETTERX_LOCATION = new ResourceLocation(BCLib.MOD_ID, "betterx.png");
static final ResourceLocation BACKGROUND = new ResourceLocation(BCLib.MOD_ID, "header.jpg");
static final ResourceLocation BACKGROUND = new ResourceLocation(BCLib.MOD_ID, "header.png");
static final ResourceLocation ICON_BETTERNETHER = new ResourceLocation(BCLib.MOD_ID, "icon_betternether.png");
static final ResourceLocation ICON_BETTEREND = new ResourceLocation(BCLib.MOD_ID, "icon_betterend.png");
public WelcomeScreen(Screen parent) {
public WelcomeScreen(Runnable parent) {
super(parent, translatable("bclib.welcome.title"));
}

View file

@ -17,6 +17,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
import java.util.function.Function;
import org.jetbrains.annotations.Nullable;
@Mixin(Minecraft.class)
@ -34,6 +36,14 @@ public abstract class MinecraftMixin {
@Nullable
public Screen screen;
@Inject(
method = "addInitialScreens",
at = @At("TAIL")
)
private void bclib_onScreenInit(List<Function<Runnable, Screen>> list, CallbackInfo ci) {
VersionCheckerClient.presentUpdateScreen(list);
}
@Inject(method = "<init>*", at = @At("TAIL"))
private void bclib_onMCInit(GameConfig args, CallbackInfo info) {
BuiltInRegistries.BLOCK.forEach(block -> {
@ -42,7 +52,5 @@ public abstract class MinecraftMixin {
itemColors.register(provider.getItemProvider(), block.asItem());
}
});
VersionCheckerClient.presentUpdateScreen(screen);
}
}

View file

@ -4,21 +4,22 @@ import org.betterx.bclib.client.gui.screens.UpdatesScreen;
import org.betterx.bclib.client.gui.screens.WelcomeScreen;
import org.betterx.bclib.config.Configs;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import java.util.List;
import java.util.function.Function;
@Environment(EnvType.CLIENT)
public class VersionCheckerClient extends VersionChecker {
public static void presentUpdateScreen(Screen parent) {
public static void presentUpdateScreen(List<Function<Runnable, Screen>> screens) {
if (!Configs.CLIENT_CONFIG.didShowWelcomeScreen()) {
Minecraft.getInstance().setScreen(new WelcomeScreen(parent));
screens.add(WelcomeScreen::new);
} else if (Configs.CLIENT_CONFIG.showUpdateInfo() && !VersionChecker.isEmpty()) {
Minecraft.getInstance().setScreen(new UpdatesScreen(parent));
screens.add(UpdatesScreen::new);
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 KiB