aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/anthonyhilyard
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/anthonyhilyard')
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipExtEvent.java57
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java16
2 files changed, 69 insertions, 4 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipExtEvent.java b/src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipExtEvent.java
new file mode 100644
index 0000000..dfb1364
--- /dev/null
+++ b/src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipExtEvent.java
@@ -0,0 +1,57 @@
+package com.anthonyhilyard.iceberg.events;
+
+import java.util.List;
+
+import com.mojang.blaze3d.matrix.MatrixStack;
+
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.text.ITextProperties;
+import net.minecraftforge.client.event.RenderTooltipEvent;
+
+public class RenderTooltipExtEvent
+{
+ public static class Pre extends RenderTooltipEvent.Pre
+ {
+ private boolean comparisonTooltip = false;
+ public Pre(ItemStack stack, List<? extends ITextProperties> lines, MatrixStack matrixStack, int x, int y, int screenWidth, int screenHeight, int maxWidth, FontRenderer font, boolean comparison)
+ {
+ super(stack, lines, matrixStack, x, y, screenWidth, screenHeight, maxWidth, font);
+ comparisonTooltip = comparison;
+ }
+ public boolean isComparison() { return comparisonTooltip; }
+ }
+
+ public static class PostBackground extends RenderTooltipEvent.PostBackground
+ {
+ private boolean comparisonTooltip = false;
+ public PostBackground(ItemStack stack, List<? extends ITextProperties> textLines, MatrixStack matrixStack, int x, int y, FontRenderer font, int width, int height, boolean comparison)
+ {
+ super(stack, textLines, matrixStack, x, y, font, width, height);
+ comparisonTooltip = comparison;
+ }
+ public boolean isComparison() { return comparisonTooltip; }
+ }
+
+ public static class PostText extends RenderTooltipEvent.PostText
+ {
+ private boolean comparisonTooltip = false;
+ public PostText(ItemStack stack, List<? extends ITextProperties> textLines, MatrixStack matrixStack, int x, int y, FontRenderer font, int width, int height, boolean comparison)
+ {
+ super(stack, textLines, matrixStack, x, y, font, width, height);
+ comparisonTooltip = comparison;
+ }
+ public boolean isComparison() { return comparisonTooltip; }
+ }
+
+ public static class Color extends RenderTooltipEvent.Color
+ {
+ private boolean comparisonTooltip = false;
+ public Color(ItemStack stack, List<? extends ITextProperties> textLines, MatrixStack matrixStack, int x, int y, FontRenderer font, int background, int borderStart, int borderEnd, boolean comparison)
+ {
+ super(stack, textLines, matrixStack, x, y, font, background, borderStart, borderEnd);
+ comparisonTooltip = comparison;
+ }
+ public boolean isComparison() { return comparisonTooltip; }
+ }
+}
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java b/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java
index 69039db..bc5f081 100644
--- a/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java
+++ b/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java
@@ -5,6 +5,7 @@ import java.util.List;
import javax.annotation.Nonnull;
+import com.anthonyhilyard.iceberg.events.RenderTooltipExtEvent;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
@@ -85,11 +86,18 @@ public class Tooltips
}
}
- @SuppressWarnings("deprecation")
public static void renderItemTooltip(@Nonnull final ItemStack stack, MatrixStack mStack, TooltipInfo info,
Rectangle2d rect, int screenWidth, int screenHeight,
int backgroundColor, int borderColorStart, int borderColorEnd)
{
+ renderItemTooltip(stack, mStack, info, rect, screenWidth, screenHeight, backgroundColor, borderColorStart, borderColorEnd, false);
+ }
+
+ @SuppressWarnings("deprecation")
+ public static void renderItemTooltip(@Nonnull final ItemStack stack, MatrixStack mStack, TooltipInfo info,
+ Rectangle2d rect, int screenWidth, int screenHeight,
+ int backgroundColor, int borderColorStart, int borderColorEnd, boolean comparison)
+ {
if (info.getLines().isEmpty())
{
return;
@@ -99,7 +107,7 @@ public class Tooltips
int rectY = rect.getY() + 18;
int maxTextWidth = rect.getWidth() - 8;
- RenderTooltipEvent.Pre event = new RenderTooltipEvent.Pre(stack, info.getLines(), mStack, rectX, rectY, screenWidth, screenHeight, maxTextWidth, info.getFont());
+ RenderTooltipExtEvent.Pre event = new RenderTooltipExtEvent.Pre(stack, info.getLines(), mStack, rectX, rectY, screenWidth, screenHeight, maxTextWidth, info.getFont(), comparison);
if (MinecraftForge.EVENT_BUS.post(event))
{
return;
@@ -171,7 +179,7 @@ public class Tooltips
}
final int zLevel = 400;
- RenderTooltipEvent.Color colorEvent = new RenderTooltipEvent.Color(stack, info.getLines(), mStack, tooltipX, tooltipY, info.getFont(), backgroundColor, borderColorStart, borderColorEnd);
+ RenderTooltipExtEvent.Color colorEvent = new RenderTooltipExtEvent.Color(stack, info.getLines(), mStack, tooltipX, tooltipY, info.getFont(), backgroundColor, borderColorStart, borderColorEnd, comparison);
MinecraftForge.EVENT_BUS.post(colorEvent);
backgroundColor = colorEvent.getBackground();
borderColorStart = colorEvent.getBorderStart();
@@ -216,7 +224,7 @@ public class Tooltips
renderType.endBatch();
mStack.popPose();
- MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostText(stack, info.getLines(), mStack, tooltipX, tooltipTop, info.getFont(), tooltipTextWidth, tooltipHeight));
+ MinecraftForge.EVENT_BUS.post(new RenderTooltipExtEvent.PostText(stack, info.getLines(), mStack, tooltipX, tooltipTop, info.getFont(), tooltipTextWidth, tooltipHeight, comparison));
RenderSystem.enableDepthTest();
RenderSystem.enableRescaleNormal();