aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Hilyard <anthony.hilyard@gmail.com>2022-11-04 23:15:54 -0700
committerAnthony Hilyard <anthony.hilyard@gmail.com>2022-11-04 23:15:54 -0700
commit379e47c13645498bc9fe3c810bef4bba5994504b (patch)
tree1dd63744699f9f0fc7929f835765084494537410
parent20077907084aa2167ba5e66ae974c69121366b47 (diff)
downloadIceberg-379e47c13645498bc9fe3c810bef4bba5994504b.tar.gz
Iceberg-379e47c13645498bc9fe3c810bef4bba5994504b.tar.bz2
Iceberg-379e47c13645498bc9fe3c810bef4bba5994504b.zip
Ported 1.0.49 changes.
-rw-r--r--CHANGELOG.md3
-rw-r--r--build.gradle2
-rw-r--r--gradle.properties2
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/events/NewItemPickupEvent.java1
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java31
5 files changed, 33 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 988daca..8c1c88a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
# Changelog
+### 1.0.49
+- Added support for tooltips with non-text components placed above the title.
+
### 1.0.48
- Removed explicit Configured version requirement.
diff --git a/build.gradle b/build.gradle
index 6a8004c..e26621b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -52,7 +52,7 @@ dependencies {
minecraft "net.minecraftforge:forge:${project.mcVersion}-${project.forgeVersion}"
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
compileClasspath fg.deobf('curse.maven:configmenusforge-544048:3570070')
- compileClasspath fg.deobf(files('lib/configured-2.0.0-1.19.2.jar'))
+ compileClasspath fg.deobf('curse.maven:configured-457570:4011355')
}
jar {
diff --git a/gradle.properties b/gradle.properties
index 54a8fa4..a3f6675 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,6 +6,6 @@ org.gradle.daemon=false
name=${rootProject.name}
group=com.anthonyhilyard.${name.toLowerCase()}
author=anthonyhilyard
-version=1.0.48
+version=1.0.49
mcVersion=1.19.2
forgeVersion=43.1.27 \ No newline at end of file
diff --git a/src/main/java/com/anthonyhilyard/iceberg/events/NewItemPickupEvent.java b/src/main/java/com/anthonyhilyard/iceberg/events/NewItemPickupEvent.java
index 48f2faf..8b583cb 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/events/NewItemPickupEvent.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/events/NewItemPickupEvent.java
@@ -18,6 +18,7 @@ import net.minecraftforge.common.MinecraftForge;
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
*/
+@SuppressWarnings("null")
public class NewItemPickupEvent extends PlayerEvent
{
private final ItemStack itemStack;
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java b/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java
index 6bcb2b0..db952f8 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java
@@ -16,6 +16,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
+import net.minecraft.client.gui.screens.inventory.tooltip.ClientTextTooltip;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.Rect2i;
@@ -171,12 +172,18 @@ public class Tooltips
poseStack.translate(0.0D, 0.0D, zLevel);
int tooltipTop = rectY;
+ boolean titleRendered = false;
for (int componentNumber = 0; componentNumber < info.getComponents().size(); ++componentNumber)
{
ClientTooltipComponent textComponent = info.getComponents().get(componentNumber);
textComponent.renderText(preEvent.getFont(), rectX, tooltipTop, mat, renderType);
- tooltipTop += textComponent.getHeight() + (componentNumber == 0 ? 2 : 0);
+ tooltipTop += textComponent.getHeight();
+ if (!titleRendered && textComponent instanceof ClientTextTooltip)
+ {
+ tooltipTop += 2;
+ titleRendered = true;
+ }
}
renderType.endBatch();
@@ -345,8 +352,23 @@ public class Tooltips
}
// TODO: If the title is multiple lines, we need to extend this for each one.
+ // Find the title component, which is the first text component.
+ int titleIndex = 0;
+ for (ClientTooltipComponent clienttooltipcomponent : components)
+ {
+ if (clienttooltipcomponent instanceof ClientTextTooltip)
+ {
+ break;
+ }
+ titleIndex++;
+ }
+
+ if (titleIndex >= components.size())
+ {
+ titleIndex = 0;
+ }
- List<FormattedText> recomposedLines = StringRecomposer.recompose(List.of(components.get(0)));
+ List<FormattedText> recomposedLines = StringRecomposer.recompose(List.of(components.get(titleIndex)));
if (recomposedLines.isEmpty())
{
return components;
@@ -355,14 +377,15 @@ public class Tooltips
List<ClientTooltipComponent> result = new ArrayList<>(components);
FormattedCharSequence title = Language.getInstance().getVisualOrder(recomposedLines.get(0));
- while (result.get(0).getWidth(font) < tooltipWidth)
+ while (result.get(titleIndex).getWidth(font) < tooltipWidth)
{
title = FormattedCharSequence.fromList(List.of(SPACE, title, SPACE));
if (title == null)
{
break;
}
- result.set(0, ClientTooltipComponent.create(title));
+
+ result.set(titleIndex, ClientTooltipComponent.create(title));
}
return result;
}