package net.minecraft.client.gui.screens;

import net.minecraft.client.gui.components.AbstractWidget;
import java.util.Iterator;
import com.mojang.blaze3d.vertex.PoseStack;
import java.util.Collection;
import net.minecraft.client.gui.components.Button;
import com.google.common.collect.Lists;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.FormattedText;
import java.util.List;
import net.minecraft.network.chat.Component;

public class AlertScreen extends Screen {
    private final Runnable callback;
    protected final Component text;
    private final List<FormattedText> lines;
    protected final Component okButton;
    private int delayTicker;
    
    public AlertScreen(final Runnable runnable, final Component mr2, final Component mr3) {
        this(runnable, mr2, mr3, CommonComponents.GUI_BACK);
    }
    
    public AlertScreen(final Runnable runnable, final Component mr2, final Component mr3, final Component mr4) {
        super(mr2);
        this.lines = Lists.newArrayList();
        this.callback = runnable;
        this.text = mr3;
        this.okButton = mr4;
    }
    
    @Override
    protected void init() {
        super.init();
        this.<Button>addButton(new Button(this.width / 2 - 100, this.height / 6 + 168, 200, 20, this.okButton, dni -> this.callback.run()));
        this.lines.clear();
        this.lines.addAll(this.font.split(this.text, this.width - 50));
    }
    
    @Override
    public void render(final PoseStack dhl, final int integer2, final int integer3, final float float4) {
        this.renderBackground(dhl);
        this.drawCenteredString(dhl, this.font, this.title, this.width / 2, 70, 16777215);
        int integer4 = 90;
        for (final FormattedText mu8 : this.lines) {
            this.drawCenteredString(dhl, this.font, mu8, this.width / 2, integer4, 16777215);
            final int n = integer4;
            this.font.getClass();
            integer4 = n + 9;
        }
        super.render(dhl, integer2, integer3, float4);
    }
    
    @Override
    public void tick() {
        super.tick();
        final int delayTicker = this.delayTicker - 1;
        this.delayTicker = delayTicker;
        if (delayTicker == 0) {
            for (final AbstractWidget dng3 : this.buttons) {
                dng3.active = true;
            }
        }
    }
}
