Skip to content

Commit

Permalink
Update to 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Dec 9, 2023
1 parent d2bab0e commit 77ca459
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 34 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ java {
}

outlet.allowSnapshotsForProject = false
outlet.mcVersionRange = project.minecraft_version_range
outlet.mcVersionRange = ">=${project.minecraft_version}"

group = project.group
description = project.displayname
archivesBaseName = project.name

loom {
mixin.defaultRefmapName = 'kirin.mixin.refmap.json'
accessWidenerPath = file('src/main/resources/kirin.aw')
}

reckon {
Expand All @@ -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}"
}
Expand Down
11 changes: 5 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
21 changes: 19 additions & 2 deletions src/main/java/com/minelittlepony/common/client/gui/Tooltip.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,8 +48,20 @@ default Stream<Text> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, EntityRenderer<? extends PlayerEntity>> getPlayerRenderers();

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
],
"license": "MIT",
"icon": "kirin_logo.png",
"accessWidener": "kirin.aw",
"environment": "*",
"depends": {
"minecraft": "${minecraftVersion}",
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/kirin.aw
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
accessWidener v1 named
accessible method net/minecraft/client/gui/tooltip/Tooltip <init> (Lnet/minecraft/text/Text;Lnet/minecraft/text/Text;)V

0 comments on commit 77ca459

Please sign in to comment.