Skip to content

Commit

Permalink
Make sure list widgets are ticked properly
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Jul 9, 2023
1 parent c54aa59 commit b921e9d
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@
import java.util.stream.Collectors;

@Environment(EnvType.CLIENT)
public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.Entry<E>> extends AbstractContainerEventHandler implements TickableWidget, Widget {
public abstract class DynamicEntryListWidget<E extends DynamicEntryListWidget.Entry<E>> extends AbstractContainerEventHandler implements Widget {
protected static final int DRAG_OUTSIDE = -2;
protected final Minecraft client;
private final List<E> entries = new Entries();
private float totalTicks = 1.0f;
private List<E> visibleEntries = Collections.emptyList();
public int width;
public int height;
Expand Down Expand Up @@ -213,8 +214,7 @@ protected int getMaxScrollPosition() {
protected void clickedHeader(int int_1, int int_2) {
}

@Override
public void tick() {
public void tickList() {
this.updateVisibleChildren();
for (E child : this.children()) {
child.tick();
Expand Down Expand Up @@ -247,6 +247,12 @@ protected void renderBackBackground(PoseStack matrices, BufferBuilder buffer, Te
@SuppressWarnings("deprecation")
@Override
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
this.totalTicks += delta;
if (this.totalTicks >= 1.0f) {
this.totalTicks = this.totalTicks % 1.0f;
this.tickList();
}

this.drawBackground();
int scrollbarPosition = this.getScrollbarPosition();
int int_4 = scrollbarPosition + 6;
Expand Down

0 comments on commit b921e9d

Please sign in to comment.