Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 1 addition & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import dev.lambdaurora.mcdev.api.McVersionLookup
import dev.lambdaurora.mcdev.task.ConvertAccessWidenerToTransformer

plugins {
alias(libs.plugins.loom)
Expand Down Expand Up @@ -59,7 +58,6 @@ lambdamcdev {
withDepend("fabric-resource-loader-v1", ">=2.0.5")
withDepend("java", ">=${project.property("java_version")}")
withDepend("yumi_mc_core", "^${libs.versions.yumi.mc.foundation.get()}")
withAccessWidener("spruceui.accesswidener")
withMixins("spruceui.mixins.json")

withModMenu {
Expand All @@ -82,7 +80,6 @@ lambdamcdev {
}

loom {
accessWidenerPath = file("src/main/resources/spruceui.accesswidener")
mixin {
useLegacyMixinAp = false
}
Expand All @@ -106,7 +103,7 @@ repositories {
}
maven {
name = "NeoForge"
url = uri("https://maven.neoforged.net/")
url = uri("https://maven.neoforged.net/releases/")
content {
includeGroupByRegex("net\\.neoforged.*")
includeGroupByRegex("cpw\\.mods.*")
Expand Down Expand Up @@ -140,21 +137,12 @@ tasks.withType<JavaCompile>().configureEach {
options.isIncremental = true
}

val convertAWtoAT by tasks.registering(ConvertAccessWidenerToTransformer::class) {
this.group = "generation"
this.input = loom.accessWidenerPath
this.output = project.layout.buildDirectory.get().file("generated/accesstransformer.cfg")
}

tasks.jar {
inputs.property("archivesName", base.archivesName)

from("LICENSE") {
rename { "${it}_${inputs.properties["archivesName"]}" }
}
from(convertAWtoAT) {
into("META-INF")
}
}

tasks.named<Jar>("sourcesJar") {
Expand All @@ -163,9 +151,6 @@ tasks.named<Jar>("sourcesJar") {
from("LICENSE") {
rename { "${it}_${inputs.properties["archivesName"]}" }
}
from(convertAWtoAT) {
into("META-INF")
}
}

val testmodJar = tasks.register<Jar>("testmodJar") {
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[versions]
minecraft = "26.1-snapshot-6"
minecraft = "26.1-pre-1"
fabric-loader = "0.18.4"
neoforge-loader = "10.0.10"
fabric-api = "0.143.2+26.1"
modmenu = "15.0.0-beta.1"
fabric-api = "0.143.12+26.1"
modmenu = "18.0.0-alpha.5"

yumi-mc-foundation = "1.0.0-beta.2+26.1-snapshot-6"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
* @since 2.0.0
*/
public interface Background {
void render(SpruceGuiGraphics graphics, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta);
void extractRenderState(SpruceGuiGraphics graphics, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public record DirtTexturedBackground(int red, int green, int blue, int alpha) im
public static final Background DARKENED = new DirtTexturedBackground(32, 32, 32, 255);

@Override
public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta) {
RenderUtil.renderBackgroundTexture(graphics,
public void extractRenderState(SpruceGuiGraphics graphics, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta) {
RenderUtil.extractBackgroundTexture(graphics,
widget.getX(), widget.getY(), widget.getWidth(), widget.getHeight(),
vOffset / 32.f, this.red, this.green, this.blue, this.alpha
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private EmptyBackground() {
}

@Override
public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta) {
public void extractRenderState(SpruceGuiGraphics graphics, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta) {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public record MenuBackground(Identifier texture, Identifier inWorldTexture) impl
);

@Override
public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta) {
public void extractRenderState(SpruceGuiGraphics graphics, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta) {
int x = widget.getX();
int y = widget.getY();
int width = widget.getWidth();
Expand All @@ -52,7 +52,7 @@ public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int vOffset,
}

Identifier identifier = CLIENT.level == null ? this.inWorldTexture : this.texture;
graphics.drawTexture(
graphics.blit(
RenderPipelines.GUI_TEXTURED, identifier,
x, y,
0, 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public SimpleColorBackground(int red, int green, int blue, int alpha) {
}

@Override
public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta) {
public void extractRenderState(SpruceGuiGraphics graphics, SpruceWidget widget, int vOffset, int mouseX, int mouseY, float delta) {
int x = widget.getX();
int y = widget.getY();
graphics.fill(x, y, x + widget.getWidth(), y + widget.getHeight(), this.color);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/lambdaurora/spruceui/border/Border.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* @since 2.0.0
*/
public interface Border {
void render(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX, int mouseY, float delta);
void extractRenderState(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX, int mouseY, float delta);

/**
* Returns the thickness of the top border.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private EmptyBorder() {
}

@Override
public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX, int mouseY, float delta) {
public void extractRenderState(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX, int mouseY, float delta) {
}

@Override
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/dev/lambdaurora/spruceui/border/MenuBorder.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public record MenuBorder(boolean top, boolean right, boolean bottom, boolean lef
public static final MenuBorder TAB_LIST = new MenuBorder(true, true, true, false);

@Override
public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX, int mouseY, float delta) {
public void extractRenderState(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX, int mouseY, float delta) {
if (this.top) {
Identifier topTexture = CLIENT.level == null
? SpruceTextures.MENU_TOP_BORDER
Expand All @@ -47,7 +47,7 @@ public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX,
width -= THICKNESS;
}

graphics.drawTexture(
graphics.blit(
RenderPipelines.GUI_TEXTURED,
topTexture,
widget.getX(), widget.getY(),
Expand All @@ -61,7 +61,7 @@ public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX,
Identifier cornerTexture = CLIENT.level == null
? SpruceTextures.MENU_TOP_RIGHT_BORDER
: SpruceTextures.INWORLD_MENU_TOP_RIGHT_BORDER;
graphics.drawTexture(
graphics.blit(
RenderPipelines.GUI_TEXTURED,
cornerTexture,
widget.getEndX() - THICKNESS, widget.getY(),
Expand All @@ -88,7 +88,7 @@ public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX,
height -= THICKNESS;
}

graphics.drawTexture(
graphics.blit(
RenderPipelines.GUI_TEXTURED, rightTexture,
widget.getEndX() - THICKNESS, y,
0, 0,
Expand All @@ -100,7 +100,7 @@ public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX,
if (this.bottom && this.right) {
Identifier cornerTexture = CLIENT.level == null
? SpruceTextures.MENU_BOTTOM_RIGHT_BORDER : SpruceTextures.INWORLD_MENU_BOTTOM_RIGHT_BORDER;
graphics.drawTexture(
graphics.blit(
RenderPipelines.GUI_TEXTURED,
cornerTexture,
widget.getEndX() - THICKNESS, widget.getEndY() - THICKNESS,
Expand All @@ -121,7 +121,7 @@ public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX,
width -= THICKNESS;
}

graphics.drawTexture(
graphics.blit(
RenderPipelines.GUI_TEXTURED,
bottomTexture,
widget.getX(), widget.getEndY() - THICKNESS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public SimpleBorder(int thickness, int red, int green, int blue, int alpha, int
}

@Override
public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX, int mouseY, float delta) {
public void extractRenderState(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX, int mouseY, float delta) {
int x = widget.getX();
int y = widget.getY();
int right = x + widget.getWidth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public record TexturedBorder(WidgetSprites sprites) implements Border {
));

@Override
public void render(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX, int mouseY, float delta) {
graphics.drawSprite(
public void extractRenderState(SpruceGuiGraphics graphics, SpruceWidget widget, int mouseX, int mouseY, float delta) {
graphics.blitSprite(
RenderPipelines.GUI_TEXTURED, this.sprites.get(widget.isActive(), widget.isFocusedOrHovered()),
widget.getX(), widget.getY(),
widget.getWidth(), widget.getHeight()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
package dev.lambdaurora.spruceui.impl;

import dev.lambdaurora.spruceui.render.SpruceGuiGraphics;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.render.state.GuiRenderState;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.renderer.state.gui.GuiRenderState;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.Internal
public interface GuiGraphicsAccessor {
SpruceGuiGraphics spruceui$spruced();

GuiGraphics.ScissorStack spruceui$getScissorStack();
GuiGraphicsExtractor.ScissorStack spruceui$getScissorStack();

GuiRenderState spruceui$getGuiRenderState();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import dev.lambdaurora.spruceui.event.ScreenEvents;
import dev.lambdaurora.spruceui.render.SpruceGuiGraphics;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
import org.spongepowered.asm.mixin.Dynamic;
Expand All @@ -25,23 +25,26 @@ public class GameRendererMixin {
@SuppressWarnings({"MixinAnnotationTarget"})
@Dynamic
@WrapOperation(
method = "render",
method = "extractGui",
at = {
@At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/screens/Screen;renderWithTooltipAndSubtitles(Lnet/minecraft/client/gui/GuiGraphics;IIF)V"
target = "Lnet/minecraft/client/gui/screens/Screen;extractRenderStateWithTooltipAndSubtitles(Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V"
),
// FIXME: see what Neoforge names this hook.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the NeoForge signature is still the same.

https://github.com/neoforged/NeoForge/blob/7e61b8a35f1c0087ee07ca1d09db0c8452a6521a/patches/net/minecraft/client/renderer/GameRenderer.java.patch#L50

Though, it may still change which puts us in a delicate spot for now.
Arguably, it'd be much nicer if they used mixins for this. >:(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave it as-is in the meantime. Tho, saying that, the vanilla call is missing in NeoForge, so; it'll, break either way of: it's left commented out, always causing a mixin error on startup, or it's active but they changed the name mid-way through, causing a mixin error on startup then.

/*
@At(
value = "INVOKE",
target = "Lnet/neoforged/neoforge/client/ClientHooks;drawScreen(Lnet/minecraft/client/gui/screens/Screen;Lnet/minecraft/client/gui/GuiGraphics;IIF)V",
target = "Lnet/neoforged/neoforge/client/ClientHooks;drawScreen(Lnet/minecraft/client/gui/screens/Screen;Lnet/minecraft/client/gui/GuiGraphicsExtractor;IIF)V",
remap = false
),
*/
},
require = 1,
allow = 1
)
private void spruceui$onRenderScreen(
Screen currentScreen, GuiGraphics graphics, int mouseX, int mouseY, float tickDelta, Operation<Void> operation
Screen currentScreen, GuiGraphicsExtractor graphics, int mouseX, int mouseY, float tickDelta, Operation<Void> operation
) {
var sprucedGraphics = SpruceGuiGraphics.of(graphics);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
import dev.lambdaurora.spruceui.render.SpruceGuiGraphics;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.render.state.GuiRenderState;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.renderer.state.gui.GuiRenderState;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;

@Environment(EnvType.CLIENT)
@Mixin(GuiGraphics.class)
public class GuiGraphicsMixin implements GuiGraphicsAccessor {
@Mixin(GuiGraphicsExtractor.class)
public class GuiGraphicsExtractorMixin implements GuiGraphicsAccessor {
@Unique
private final SpruceGuiGraphics spruce$graphics = new SpruceGuiGraphics((GuiGraphics) (Object) this);
private final SpruceGuiGraphics spruce$graphics = new SpruceGuiGraphics((GuiGraphicsExtractor) (Object) this);

@Shadow
@Final
public GuiGraphics.ScissorStack scissorStack;
public GuiGraphicsExtractor.ScissorStack scissorStack;
@Shadow
@Final
public GuiRenderState guiRenderState;
Expand All @@ -39,7 +39,7 @@ public class GuiGraphicsMixin implements GuiGraphicsAccessor {
}

@Override
public GuiGraphics.ScissorStack spruceui$getScissorStack() {
public GuiGraphicsExtractor.ScissorStack spruceui$getScissorStack() {
return this.scissorStack;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class MinecraftClientMixin {
@Unique
private Screen tickingScreen;

@Inject(method = "resizeDisplay", at = @At("RETURN"))
@Inject(method = "resizeGui", at = @At("RETURN"))
private void onResolutionChanged(CallbackInfo ci) {
ResolutionChangeCallback.EVENT.invoker().apply((Minecraft) (Object) this);
}
Expand Down
Loading
Loading