Skip to content

Commit

Permalink
Update Tab.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Thutmose committed Oct 10, 2022
1 parent c307f14 commit abdfd04
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/java/pokecube/core/client/gui/pokemob/tabs/Tab.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pokecube.core.client.gui.pokemob.tabs;

import java.util.Collections;
import java.util.List;

import com.google.common.collect.Lists;
Expand Down Expand Up @@ -53,6 +54,7 @@ public void setEnabled(boolean active)
if (this.active)
{
this.init();
this.postInit();
}
ours.forEach(widget -> {
widget.visible = active;
Expand All @@ -62,11 +64,6 @@ public void setEnabled(boolean active)
public <T extends AbstractWidget> T addRenderableWidget(T widget)
{
parent.addRenderableWidget(widget);

// Add ours behind other things, this mimics ours being added first.
parent.renderables.remove(widget);
parent.renderables.add(0, widget);

this.ours.add(widget);
return widget;
}
Expand All @@ -92,6 +89,18 @@ public final void clear()

public abstract void init();

public final void postInit()
{
// Add ours behind other things, this mimics ours being added first.
// This is reversed first, so that they end up in the order that we add
// them originally.
Collections.reverse(ours);
ours.forEach(widget -> {
parent.renderables.remove(widget);
parent.renderables.add(0, widget);
});
}

public void renderBg(final PoseStack mat, final float partialTicks, final int mouseX, final int mouseY)
{

Expand Down

0 comments on commit abdfd04

Please sign in to comment.