Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update for improved tooltip methods in Forge.
- Loading branch information
Showing
10 changed files
with
136 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
mcversion=1.8.9 | ||
forgeversion=11.15.1.1761 | ||
forgeversion=11.15.1.1808 | ||
mcp_mappings=snapshot_20160223 | ||
curse_project_id=238222 | ||
|
||
version_major=2 | ||
version_minor=28 | ||
version_patch=9 | ||
version_patch=10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,25 @@ | ||
package mezz.jei.gui; | ||
|
||
import mezz.jei.config.Constants; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.FontRenderer; | ||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraft.client.gui.ScaledResolution; | ||
import net.minecraftforge.fml.client.config.GuiUtils; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* Workaround for GuiScreen.drawHoveringText being protected instead of public. | ||
* (the method with FontRenderer is added by Forge and can't be AT'd). | ||
*/ | ||
public class TooltipRenderer { | ||
private static final TooltipGuiScreen tooltipScreen = new TooltipGuiScreen(); | ||
|
||
public static void drawHoveringText(@Nonnull Minecraft minecraft, @Nonnull String textLine, int x, int y) { | ||
List<String> textLines = minecraft.fontRendererObj.listFormattedStringToWidth(textLine, Constants.MAX_TOOLTIP_WIDTH); | ||
drawHoveringText(minecraft, textLines, x, y, minecraft.fontRendererObj); | ||
drawHoveringText(minecraft, Collections.singletonList(textLine), x, y, minecraft.fontRendererObj); | ||
} | ||
|
||
public static void drawHoveringText(@Nonnull Minecraft minecraft, @Nonnull List<String> textLines, int x, int y) { | ||
drawHoveringText(minecraft, textLines, x, y, minecraft.fontRendererObj); | ||
} | ||
|
||
public static void drawHoveringText(@Nonnull Minecraft minecraft, @Nonnull List<String> textLines, int x, int y, @Nonnull FontRenderer font) { | ||
tooltipScreen.set(minecraft); | ||
tooltipScreen.drawHoveringText(textLines, x, y, font); | ||
} | ||
|
||
private static class TooltipGuiScreen extends GuiScreen { | ||
public void set(@Nonnull Minecraft minecraft) { | ||
this.mc = minecraft; | ||
this.itemRender = minecraft.getRenderItem(); | ||
ScaledResolution scaledresolution = new ScaledResolution(minecraft); | ||
this.width = scaledresolution.getScaledWidth(); | ||
this.height = scaledresolution.getScaledHeight(); | ||
} | ||
|
||
@Override | ||
public void drawHoveringText(@Nonnull List<String> textLines, int x, int y, @Nonnull FontRenderer font) { | ||
super.drawHoveringText(textLines, x, y, font); | ||
} | ||
ScaledResolution scaledresolution = new ScaledResolution(minecraft); | ||
GuiUtils.drawHoveringText(textLines, x, y, scaledresolution.getScaledWidth(), scaledresolution.getScaledHeight(), -1, font); | ||
} | ||
} |
Oops, something went wrong.