forked from Creators-of-Create/Create
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cycling to the manual item application EMI display
- Loading branch information
Showing
3 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/simibubi/create/compat/emi/CyclingDrawable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.simibubi.create.compat.emi; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
|
||
import dev.emi.emi.api.widget.DrawableWidget.DrawableWidgetConsumer; | ||
|
||
import java.util.List; | ||
|
||
public record CyclingDrawable(List<? extends DrawableWidgetConsumer> children) implements DrawableWidgetConsumer { | ||
@Override | ||
public void render(PoseStack matrices, int x, int y, float delta) { | ||
this.choose().render(matrices, x, y, delta); | ||
} | ||
|
||
private DrawableWidgetConsumer choose() { | ||
// ticks are not available, use system time. | ||
long millis = System.currentTimeMillis(); | ||
long seconds = millis / 1000; | ||
int index = (int) (seconds % this.children.size()); | ||
return this.children.get(index); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters