diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 9a4a60a7..ef634389 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -23,3 +23,10 @@ jobs: uses: eskatos/gradle-command-action@v1 with: arguments: build publish + - name: Publish Modrinth Jar + env: + MODRINTH_KEY: ${{ secrets.MODRINTH_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: eskatos/gradle-command-action@v1 + with: + arguments: modrinth diff --git a/build.gradle b/build.gradle index d6bcfc3e..5e979aaf 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ java { } outlet.allowSnapshotsForProject = false -outlet.mcVersionRange = project.minecraft_version_range +outlet.mcVersionRange = ">=${project.minecraft_version}" group = project.group description = project.displayname @@ -27,6 +27,7 @@ archivesBaseName = project.name loom { mixin.defaultRefmapName = 'kirin.mixin.refmap.json' + accessWidenerPath = file('src/main/resources/kirin.aw') } reckon { @@ -50,7 +51,7 @@ processResources { filesMatching("fabric.mod.json") { expand "version": project.version.toString(), - "minecraftVersion": project.minecraft_version_range, + "minecraftVersion": ">=${project.minecraft_version}", "loaderVersion": ">=${project.loader_version}", "fabricVersion": ">=${project.fabric_version}" } diff --git a/gradle.properties b/gradle.properties index b7a45ac3..c7af9009 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.daemon=false # Fabric Properties # check these on https://fabricmc.net/develop - minecraft_version=1.20.2-rc1 - yarn_mappings=1.20.2-rc1+build.2 - loader_version=0.14.22 - fabric_version=0.88.5+1.20.2 + minecraft_version=1.20.4 + yarn_mappings=1.20.4+build.1 + loader_version=0.15.1 + fabric_version=0.91.2+1.20.4 # Mod Properties group=com.minelittlepony @@ -15,6 +15,5 @@ org.gradle.daemon=false description=Embedded common code used across several Mine Little Pony projects to create their GUIs. # Publishing - minecraft_version_range=>=1.20.2 modrinth_loader_type=fabric - modrinth_project_id= + modrinth_project_id=9aNz8Zqn diff --git a/src/main/java/com/minelittlepony/common/client/gui/Tooltip.java b/src/main/java/com/minelittlepony/common/client/gui/Tooltip.java index be940f59..3a71f411 100644 --- a/src/main/java/com/minelittlepony/common/client/gui/Tooltip.java +++ b/src/main/java/com/minelittlepony/common/client/gui/Tooltip.java @@ -6,13 +6,18 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.joml.Vector2i; import com.google.common.base.Splitter; +import com.minelittlepony.common.client.gui.style.IStyled; import com.minelittlepony.common.mixin.MixinTooltip; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.Narratable; +import net.minecraft.client.gui.ScreenRect; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; import net.minecraft.client.gui.screen.narration.NarrationPart; +import net.minecraft.client.gui.tooltip.TooltipPositioner; +import net.minecraft.client.gui.tooltip.WidgetTooltipPositioner; import net.minecraft.text.MutableText; import net.minecraft.text.StringVisitable; import net.minecraft.text.Style; @@ -43,8 +48,20 @@ default Stream stream() { return getLines().stream(); } - default net.minecraft.client.gui.tooltip.Tooltip toTooltip() { - var tooltip = net.minecraft.client.gui.tooltip.Tooltip.of(Text.empty()); + default net.minecraft.client.gui.tooltip.Tooltip toTooltip(IStyled element) { + var tooltip = new net.minecraft.client.gui.tooltip.Tooltip(Text.empty(), Text.literal(getString().toString())) { + @Override + protected TooltipPositioner createPositioner(boolean hovered, boolean focused, ScreenRect focus) { + TooltipPositioner original = super.createPositioner(hovered, focused, focus); + if (!(original instanceof WidgetTooltipPositioner)) { + return original; + } + return (int screenWidth, int screenHeight, int x, int y, int width, int height) -> { + return original.getPosition(screenWidth, screenHeight, x, y, width, height) + .add(element.getStyle().toolTipX, element.getStyle().toolTipY, new Vector2i()); + }; + } + }; ((MixinTooltip)tooltip).setLines(stream().map(Text::asOrderedText).toList()); return tooltip; } diff --git a/src/main/java/com/minelittlepony/common/client/gui/element/Button.java b/src/main/java/com/minelittlepony/common/client/gui/element/Button.java index 1ddf090d..d877438b 100644 --- a/src/main/java/com/minelittlepony/common/client/gui/element/Button.java +++ b/src/main/java/com/minelittlepony/common/client/gui/element/Button.java @@ -5,9 +5,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.joml.Vector2i; -import org.joml.Vector2ic; - import com.minelittlepony.common.client.gui.ITextContext; import com.minelittlepony.common.client.gui.ITickableElement; import com.minelittlepony.common.client.gui.Tooltip; @@ -22,7 +19,6 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ButtonTextures; import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder; -import net.minecraft.client.gui.tooltip.TooltipPositioner; import net.minecraft.client.gui.widget.PressableWidget; import net.minecraft.screen.ScreenTexts; import net.minecraft.util.Identifier; @@ -191,21 +187,14 @@ public boolean isMouseOver(double mouseX, double mouseY) { } @Override - public void render(DrawContext context, int mouseX, int mouseY, float tickDelta) { - if (!visible) { - return; - } + public void renderWidget(DrawContext context, int mouseX, int mouseY, float tickDelta) { getStyle().getTooltip().ifPresentOrElse(tooltip -> { if (tooltip != prevTooltip) { prevTooltip = tooltip; - setTooltip(tooltip.toTooltip()); + setTooltip(tooltip.toTooltip(this)); } }, () -> setTooltip(null)); - super.render(context, mouseX, mouseY, tickDelta); - } - @Override - public void renderButton(DrawContext context, int mouseX, int mouseY, float tickDelta) { MinecraftClient mc = MinecraftClient.getInstance(); context.setShaderColor(1, 1, 1, alpha); RenderSystem.enableBlend(); @@ -226,15 +215,6 @@ public void renderButton(DrawContext context, int mouseX, int mouseY, float tick renderForeground(context, mc, mouseX, mouseY, foreColor | MathHelper.ceil(alpha * 255F) << 24); } - @Override - protected TooltipPositioner getTooltipPositioner() { - TooltipPositioner original = super.getTooltipPositioner(); - return (int screenWidth, int screenHeight, int x, int y, int width, int height) -> { - Vector2ic pos = original.getPosition(screenWidth, screenHeight, x, y, width, height); - return new Vector2i(pos.x() + getStyle().toolTipX, pos.y() + getStyle().toolTipY); - }; - } - protected void renderBackground(DrawContext context, MinecraftClient mc, int mouseX, int mouseY) { context.drawGuiTexture(TEXTURES.get(active, this.isSelected()), getX(), getY(), getWidth(), getHeight()); } diff --git a/src/main/java/com/minelittlepony/common/client/gui/element/Label.java b/src/main/java/com/minelittlepony/common/client/gui/element/Label.java index e1bdc305..d3e96b91 100644 --- a/src/main/java/com/minelittlepony/common/client/gui/element/Label.java +++ b/src/main/java/com/minelittlepony/common/client/gui/element/Label.java @@ -57,7 +57,7 @@ public ScreenRect getNavigationFocus() { } @Override - public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) { + public void renderWidget(DrawContext context, int mouseX, int mouseY, float partialTicks) { int textY = (int)(getY() + MinecraftClient.getInstance().textRenderer.fontHeight/1.5F); if (center) { diff --git a/src/main/java/com/minelittlepony/common/mixin/MixinEntityRenderDispatcher.java b/src/main/java/com/minelittlepony/common/mixin/MixinEntityRenderDispatcher.java index 952392a9..4f8bbeae 100644 --- a/src/main/java/com/minelittlepony/common/mixin/MixinEntityRenderDispatcher.java +++ b/src/main/java/com/minelittlepony/common/mixin/MixinEntityRenderDispatcher.java @@ -10,9 +10,12 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; +/** + * @deprecated Rather use EntityRendererRegistry or replace with the APIs provided by Mson to set player renderers + */ +@Deprecated @Mixin(EntityRenderDispatcher.class) public interface MixinEntityRenderDispatcher { - @Accessor("modelRenderers") Map> getPlayerRenderers(); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 5e0b3754..b21d1365 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -15,6 +15,7 @@ ], "license": "MIT", "icon": "kirin_logo.png", + "accessWidener": "kirin.aw", "environment": "*", "depends": { "minecraft": "${minecraftVersion}", diff --git a/src/main/resources/kirin.aw b/src/main/resources/kirin.aw new file mode 100644 index 00000000..6b2e5ffd --- /dev/null +++ b/src/main/resources/kirin.aw @@ -0,0 +1,2 @@ +accessWidener v1 named +accessible method net/minecraft/client/gui/tooltip/Tooltip (Lnet/minecraft/text/Text;Lnet/minecraft/text/Text;)V