package com.mojang.realmsclient.gui.screens;

import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.TranslatableComponent;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.realms.RealmsScreen;

public class RealmsClientOutdatedScreen extends RealmsScreen {
    private final Screen lastScreen;
    private final boolean outdated;
    
    public RealmsClientOutdatedScreen(final Screen dqs, final boolean boolean2) {
        this.lastScreen = dqs;
        this.outdated = boolean2;
    }
    
    public void init() {
        this.<Button>addButton(new Button(this.width / 2 - 100, RealmsScreen.row(12), 200, 20, CommonComponents.GUI_BACK, dni -> this.minecraft.setScreen(this.lastScreen)));
    }
    
    @Override
    public void render(final PoseStack dhl, final int integer2, final int integer3, final float float4) {
        this.renderBackground(dhl);
        final Component mr6 = new TranslatableComponent(this.outdated ? "mco.client.outdated.title" : "mco.client.incompatible.title");
        this.drawCenteredString(dhl, this.font, mr6, this.width / 2, RealmsScreen.row(3), 16711680);
        for (int integer4 = this.outdated ? 2 : 3, integer5 = 0; integer5 < integer4; ++integer5) {
            final String string9 = (this.outdated ? "mco.client.outdated.msg.line" : "mco.client.incompatible.msg.line") + (integer5 + 1);
            this.drawCenteredString(dhl, this.font, new TranslatableComponent(string9), this.width / 2, RealmsScreen.row(5) + integer5 * 12, 16777215);
        }
        super.render(dhl, integer2, integer3, float4);
    }
    
    @Override
    public boolean keyPressed(final int integer1, final int integer2, final int integer3) {
        if (integer1 == 257 || integer1 == 335 || integer1 == 256) {
            this.minecraft.setScreen(this.lastScreen);
            return true;
        }
        return super.keyPressed(integer1, integer2, integer3);
    }
}
