Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b99415c
Allow drawing non-`LivingEntity` entities with `EntityDrawable` & por…
screret Oct 12, 2025
96dbf12
remove unnecessary `RenderSystem.disableBlend` from text rendering ca…
screret Oct 12, 2025
c711a11
change the first parameter of `GuiDraw#drawAmountText` to `GuiContext…
screret Oct 12, 2025
154f20c
use lombok `@Accessors` for StyledText/AnimatedText setter methods
screret Oct 12, 2025
32c9966
make the test gui fox follow the mouse cursor
screret Oct 12, 2025
66e88be
formatting tweaks, mainly in TestMuiMachine
screret Oct 12, 2025
b479caf
force gradle to download FastUtil and GL11 from the central maven rep…
screret Oct 12, 2025
aa90af2
Merge branch 'mui2-refactor' into sc/mui/entity-render-things
screret Oct 13, 2025
cce819a
make compile agian
screret Oct 13, 2025
e792a66
gradle please give me my sources
screret Oct 13, 2025
1f84893
fix the test fop tweaking like hell
screret Oct 13, 2025
0af1135
fix odd spotless line spits in GuiDraw method parameters
screret Oct 13, 2025
96566dd
Merge branch 'mui2-refactor' into sc/mui/entity-render-things
screret Nov 15, 2025
1ab7f9c
make this compile again (oops bad merge)
screret Nov 15, 2025
f7939be
Merge branch 'mui2-refactor' into sc/mui/entity-render-things
screret Jan 5, 2026
2d50911
Merge branch 'mui2-refactor' into sc/mui/entity-render-things
screret Jan 20, 2026
8b6ec87
Merge branch 'mui2-refactor' of https://github.com/GregTechCEu/GregTe…
YoungOnionMC Feb 3, 2026
a60fd05
get stuff working
YoungOnionMC Feb 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions gradle/scripts/repositories.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
repositories {
mavenLocal()
mavenCentral()
// force gradle to download FastUtil and LWJGL from the central maven so we can get source artifacts
exclusiveContent { // Force
forRepository { mavenCentral() }
filter {
includeGroup("it.unimi.dsi")
includeGroup("org.lwjgl")
includeGroupAndSubgroups("io.netty")
}
}

maven { // JEI
name = "Jared's Maven"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ default StyledText alignment(Alignment alignment) {
return withStyle().alignment(alignment);
}

default StyledText color(int color) {
default @NotNull StyledText color(int color) {
return color(() -> color);
}

Expand Down Expand Up @@ -322,7 +322,7 @@ default void loadFromJson(JsonObject json) {
}
styledText.shadow(JsonHelper.getBoolean(json, false, "shadow"));
styledText.alignment(
JsonHelper.deserialize(json, Alignment.class, styledText.getAlignment(), "align", "alignment"));
JsonHelper.deserialize(json, Alignment.class, styledText.alignment(), "align", "alignment"));
styledText.scale(JsonHelper.getFloat(json, 1, "scale"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,64 @@
import com.gregtechceu.gtceu.api.mui.theme.WidgetTheme;
import com.gregtechceu.gtceu.client.mui.screen.viewport.GuiContext;

import net.minecraft.world.entity.LivingEntity;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.world.entity.Entity;

public class EntityDrawable implements IDrawable {
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.jetbrains.annotations.Nullable;

private LivingEntity entity;
import java.util.function.BiConsumer;

public EntityDrawable(LivingEntity entity) {
@Accessors(fluent = true, chain = true)
public class EntityDrawable<T extends Entity> implements IDrawable {

@Getter
protected final T entity;
@Setter
protected @Nullable BiConsumer<GuiGraphics, T> preDraw;
@Setter
protected @Nullable BiConsumer<GuiGraphics, T> postDraw;

@Setter
private boolean followMouse;
private float lookTargetX = 0.0f;
private float lookTargetY = 0.0f;

public EntityDrawable(T entity) {
this(entity, null, null);
}

public EntityDrawable(T entity, @Nullable BiConsumer<GuiGraphics, T> preDraw,
@Nullable BiConsumer<GuiGraphics, T> postDraw) {
this.entity = entity;
this.preDraw = preDraw;
this.postDraw = postDraw;
}

public EntityDrawable<T> followMouse() {
return followMouse(true);
}

public EntityDrawable<T> lookTowardAngle(float xAngle, float yAngle) {
this.followMouse = false;
this.lookTargetX = xAngle;
this.lookTargetY = yAngle;

return this;
}

@Override
public void draw(GuiContext context, int x, int y, int width, int height, WidgetTheme widgetTheme) {
GuiDraw.drawLivingEntity(context.getGraphics(), this.entity, x, y, width, height, context.getCurrentDrawingZ());
if (this.followMouse) {
GuiDraw.drawEntityLookingAtMouse(context.getGraphics(), this.entity, x, y, width, height,
context.getCurrentDrawingZ(), context.getMouseX(), context.getMouseY(),
this.preDraw, this.postDraw);
} else {
GuiDraw.drawEntityLookingAtAngle(context.getGraphics(), this.entity, x, y, width, height,
context.getCurrentDrawingZ(), this.lookTargetX, this.lookTargetY,
this.preDraw, this.postDraw);
}
}
}
404 changes: 277 additions & 127 deletions src/main/java/com/gregtechceu/gtceu/api/mui/drawable/GuiDraw.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public List<IIcon> measureLines(List<IDrawable> lines) {
float scale = this.scale;
Alignment alignment1 = this.alignment;
if (element instanceof StyledText styledText) {
scale = styledText.getScale();
alignment1 = styledText.getAlignment();
scale = styledText.scale();
alignment1 = styledText.alignment();
}
Component text = key.get();
int width = (int) (getFont().width(text) * scale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,27 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import lombok.Setter;
import lombok.experimental.Accessors;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.function.IntSupplier;

@Accessors(fluent = true, chain = true)
public class AnimatedText extends StyledText {

private MutableComponent full;
private String fullString;
private String currentString = "";
private int currentIndex;
/**
* How fast the characters appear
*/
@Setter
private int speed = 40; // ms per char
private long timeLastDraw;
@Setter
private boolean forward = true;

private boolean isAnimating = false;
Expand Down Expand Up @@ -104,48 +113,33 @@ public AnimatedText stopAnimation() {
return this;
}

public AnimatedText forward(boolean forward) {
this.forward = forward;
return this;
}

@Override
public AnimatedText style(ChatFormatting formatting) {
public @NotNull AnimatedText style(ChatFormatting formatting) {
return (AnimatedText) super.style(formatting);
}

@Override
public AnimatedText alignment(Alignment alignment) {
public @NotNull AnimatedText alignment(Alignment alignment) {
return (AnimatedText) super.alignment(alignment);
}

@Override
public AnimatedText color(int color) {
public @NotNull AnimatedText color(int color) {
return color(() -> color);
}

@Override
public AnimatedText color(@Nullable IntSupplier color) {
public @NotNull AnimatedText color(@Nullable IntSupplier color) {
return (AnimatedText) super.color(color);
}

@Override
public AnimatedText scale(float scale) {
public @NotNull AnimatedText scale(float scale) {
return (AnimatedText) super.scale(scale);
}

@Override
public AnimatedText shadow(@Nullable Boolean shadow) {
public @NotNull AnimatedText shadow(@Nullable Boolean shadow) {
return (AnimatedText) super.shadow(shadow);
}

/**
* How fast the characters appear
*
* @param speed in ms per character
*/
public AnimatedText speed(int speed) {
this.speed = speed;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,27 @@
import net.minecraftforge.api.distmarker.OnlyIn;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.function.IntSupplier;

@Accessors(fluent = true, chain = true)
public class StyledText extends BaseKey {

private final IKey key;
@Getter
@Setter
private Alignment alignment = Alignment.Center;
@Getter
@Setter
private IntSupplier color = null;
@Setter
private @Nullable Boolean shadow = null;
@Getter
@Setter
private float scale = 1f;

public StyledText(IKey key) {
Expand Down Expand Up @@ -57,40 +65,11 @@ public void draw(GuiContext context, int x, int y, int width, int height, Widget
}

@Override
public BaseKey style(ChatFormatting formatting) {
public @NotNull BaseKey style(ChatFormatting formatting) {
this.key.style(formatting);
return this;
}

@Override
public StyledText alignment(Alignment alignment) {
this.alignment = alignment;
return this;
}

@Override
public StyledText color(int color) {
return color(() -> color);
}

@Override
public StyledText color(@Nullable IntSupplier color) {
this.color = color;
return this;
}

@Override
public StyledText scale(float scale) {
this.scale = scale;
return this;
}

@Override
public StyledText shadow(@Nullable Boolean shadow) {
this.shadow = shadow;
return this;
}

@Override
public TextWidget<?> asWidget() {
return new TextWidget<>(this.key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import com.mojang.blaze3d.systems.RenderSystem;
import lombok.Getter;
import lombok.Setter;

Expand Down Expand Up @@ -263,12 +262,10 @@ protected int getStartX(float maxWidth, float lineWidth) {

protected void draw(GuiGraphics graphics, FormattedCharSequence text, float x, float y) {
if (this.simulate || graphics == null) return;
RenderSystem.disableBlend();
graphics.pose().pushPose();
graphics.pose().scale(this.scale, this.scale, 0f);
graphics.drawString(getFont(), text, (int) (x / this.scale), (int) (y / this.scale), this.color, this.shadow);
graphics.pose().popPose();
RenderSystem.enableBlend();
}

public float getFontHeight() {
Expand Down
Loading
Loading