package net.minecraft.client.gui.screens;

import java.util.Iterator;
import net.minecraft.client.gui.Font;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.TranslatableComponent;
import javax.annotation.Nullable;
import net.minecraft.network.chat.FormattedText;
import java.util.List;
import net.minecraft.network.chat.Component;

public class DisconnectedScreen extends Screen {
    private final Component reason;
    @Nullable
    private List<FormattedText> lines;
    private final Screen parent;
    private int textHeight;
    
    public DisconnectedScreen(final Screen dqs, final String string, final Component mr) {
        super(new TranslatableComponent(string));
        this.parent = dqs;
        this.reason = mr;
    }
    
    @Override
    public boolean shouldCloseOnEsc() {
        return false;
    }
    
    @Override
    protected void init() {
        this.lines = this.font.split(this.reason, this.width - 50);
        final int size = this.lines.size();
        this.font.getClass();
        this.textHeight = size * 9;
        final int integer1 = this.width / 2 - 100;
        final int n = this.height / 2 + this.textHeight / 2;
        this.font.getClass();
        this.<Button>addButton(new Button(integer1, Math.min(n + 9, this.height - 30), 200, 20, new TranslatableComponent("gui.toMenu"), dni -> this.minecraft.setScreen(this.parent)));
    }
    
    @Override
    public void render(final PoseStack dhl, final int integer2, final int integer3, final float float4) {
        this.renderBackground(dhl);
        final Font font = this.font;
        final Component title = this.title;
        final int integer5 = this.width / 2;
        final int n = this.height / 2 - this.textHeight / 2;
        this.font.getClass();
        this.drawCenteredString(dhl, font, title, integer5, n - 9 * 2, 11184810);
        int integer4 = this.height / 2 - this.textHeight / 2;
        if (this.lines != null) {
            for (final FormattedText mu8 : this.lines) {
                this.drawCenteredString(dhl, this.font, mu8, this.width / 2, integer4, 16777215);
                final int n2 = integer4;
                this.font.getClass();
                integer4 = n2 + 9;
            }
        }
        super.render(dhl, integer2, integer3, float4);
    }
}
