I'm currently working on GUIScreens in minecraft modding and I am trying to detect when a certain button is pressed. I could do that with the click event and the mouseX and mouseY but there is apparently a onPress event, which is required in order to create a button. For a method to fulfill the requirements for onPress it has to have a button as a parameter, so it seems. However when I do just that, I can't use the button that I'm creating, since it's not a valid variable yet and could be null... How am I supposed to do this?
```java
private void addButtons() {
// Has to be executed when one Entry layout is changes
for(int i = 0; i < entries.size(); i++) {
int y = i * 12 + 20;
int x = 40;
if(i > 5) {
x = 80;
}
if (entries.get(i).getCurrentLayout().equals("default")) {
Button button = new Button(x, y, 143, 28, Component.literal("Entry" + i), buttonPressed(button));
entries.get(i).addButton(button);
this.addWidget(button);
}
}
}
protected void buttonPressed(Button button) {
}