package info.u_team.u_team_core.gui.elements;

import java.util.*;

import com.mojang.blaze3d.matrix.MatrixStack;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.widget.Widget;
import net.minecraft.client.gui.widget.list.ExtendedList;

public abstract class ScrollableListEntry<T extends ScrollableListEntry<T>> extends ExtendedList.AbstractListEntry<T> {
	
	protected final Minecraft minecraft;
	
	private final List<Widget> widget;
	
	public ScrollableListEntry() {
		minecraft = Minecraft.getInstance();
		widget = new ArrayList<>();
	}
	
	protected <B extends Widget> B addButton(B button) {
		widget.add(button);
		return button;
	}
	
	@Override
	public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_) {
		widget.forEach(button -> button.mouseClicked(p_mouseClicked_1_, p_mouseClicked_3_, p_mouseClicked_5_));
		return true;
	}
	
	@Override
	public boolean mouseReleased(double p_mouseReleased_1_, double p_mouseReleased_3_, int p_mouseReleased_5_) {
		for (final Widget button : widget) {
			if (button.mouseReleased(p_mouseReleased_1_, p_mouseReleased_3_, p_mouseReleased_5_)) {
				return true;
			}
		}
		return false;
	}
	
	@Override
	public boolean mouseDragged(double p_mouseDragged_1_, double p_mouseDragged_3_, int p_mouseDragged_5_, double p_mouseDragged_6_, double p_mouseDragged_8_) {
		for (final Widget button : widget) {
			if (button.mouseDragged(p_mouseDragged_1_, p_mouseDragged_3_, p_mouseDragged_5_, p_mouseDragged_6_, p_mouseDragged_8_)) {
				return true;
			}
		}
		return false;
	}
	
	@Override
	public abstract void render(MatrixStack matrixStack, int slotIndex, int entryY, int entryX, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float partialTicks);
}

@@ -449,16 +449,17 @@
 %3E widget
+s
 ;%0A%09%0A%09pub
@@ -533,16 +533,17 @@
 %09%09widget
+s
  = new A
@@ -623,16 +623,17 @@
 %09%09widget
+s
 .add(but
@@ -707,33 +707,22 @@
 (double 
-p_
 mouse
-Clicked_1_
+X
 , double
@@ -726,48 +726,26 @@
 ble 
-p_
 mouse
-Clicked_3_, int p_mouseClicked_5_
+Y, int button
 ) %7B%0A
@@ -752,16 +752,17 @@
 %09%09widget
+s
 .forEach
@@ -766,24 +766,24 @@
 ach(
-button -%3E button
+widget -%3E widget
 .mou
@@ -796,63 +796,30 @@
 ked(
-p_
 mouse
-Clicked_1_, p_mouseClicked_3_, p_mouseClicked_5_
+X, mouseY, button
 ));%0A
@@ -886,34 +886,22 @@
 (double 
-p_
 mouse
-Released_1_
+X
 , double
@@ -905,50 +905,26 @@
 ble 
-p_
 mouse
-Released_3_, int p_mouseReleased_5_
+Y, int button
 ) %7B%0A
@@ -935,38 +935,38 @@
 r (final Widget 
-button
+widget
  : widget) %7B%0A%09%09%09
@@ -950,32 +950,33 @@
  widget : widget
+s
 ) %7B%0A%09%09%09if (butto
@@ -966,30 +966,30 @@
 s) %7B%0A%09%09%09if (
-button
+widget
 .mouseReleas
@@ -995,66 +995,30 @@
 sed(
-p_
 mouse
-Released_1_, p_mouseReleased_3_, p_mouseReleased_5_
+X, mouseY, button
 )) %7B
@@ -1112,33 +1112,22 @@
 (double 
-p_
 mouse
-Dragged_1_
+X
 , double
@@ -1131,100 +1131,54 @@
 ble 
-p_
 mouse
-Dragged_3_, int p_mouseDragged_5_, double p_mouseDragged_6_, double p_mouseDragged_8_
+Y, int button, double dragX, double dragY
 ) %7B%0A
@@ -1197,22 +1197,22 @@
  Widget 
-button
+widget
  : widge
@@ -1212,16 +1212,17 @@
 : widget
+s
 ) %7B%0A%09%09%09i
@@ -1224,22 +1224,22 @@
 %0A%09%09%09if (
-button
+widget
 .mouseDr
@@ -1248,101 +1248,44 @@
 ged(
-p_
 mouse
-Dragged_1_, p_mouseDragged_3_, p_mouseDragged_5_, p_mouseDragged_6_, p_mouseDragged_8_
+X, mouseY, button, dragX, dragY
 )) %7B

Update param names