package net.geforcemods.securitycraft.screen.components;

import java.util.Arrays;
import java.util.List;

import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.network.chat.Component;

public class TextHoverChecker extends HoverChecker
{
	private List<Component> lines;
	private final TogglePictureButton button;

	public TextHoverChecker(int top, int bottom, int left, int right, Component line)
	{
		this(top, bottom, left, right, Arrays.asList(line));
	}

	public TextHoverChecker(int top, int bottom, int left, int right, List<Component> lines)
	{
		super(top, bottom, left, right);
		this.lines = lines;
		button = null;
	}

	public TextHoverChecker(AbstractWidget button, Component line)
	{
		this(button, Arrays.asList(line));
	}

	public TextHoverChecker(AbstractWidget button, List<Component> lines)
	{
		super(button);
		this.lines = lines;
		this.button = button instanceof TogglePictureButton tpb ? tpb : null;
	}

	public Component getName()
	{
		return lines.get(button == null ? 0 : button.getCurrentIndex());
	}

	public List<Component> getLines()
	{
		return lines;
	}
}

@@ -203,16 +203,65 @@
 mponent;
+%0Aimport net.minecraft.network.chat.TextComponent;
 %0A%0Apublic
@@ -1033,25 +1033,16 @@
 %7B%0A%09%09
-return lines.get(
+int i = 
 butt
@@ -1082,16 +1082,95 @@
 tIndex()
+;%0A%0A%09%09if(i %3E= lines.size())%0A%09%09%09return TextComponent.EMPTY;%0A%0A%09%09return lines.get(i
 );%0A%09%7D%0A%0A%09

fix a crash