Compare commits

..
Author SHA1 Message Date
Ranzu c71c62daf0 wrap
- I would love to eat come quesadilla actrually mm
2026-11-03 12:17:42 +01:00
Ranzu 9900cdb1db compat 2026-11-03 12:13:44 +01:00
Ranzu 2655f15c31 Register 2026-11-03 11:43:48 +01:00
8 changed files with 204 additions and 4 deletions

No files matched your search

+1
View File
@@ -19,6 +19,7 @@ dependencies {
compileOnly("com.github.GTNewHorizons:GT5-Unofficial:5.09.54.242:dev") {exclude group: 'com.github.GTNewHorizons', module: 'ThaumicTinkerer'}
compileOnly('curse.maven:computercraft-67504:2269339')
compileOnly('curse.maven:cofh-core-69162:2388751')
compileOnly('com.github.GTNewHorizons:Dashboard:1.0.11:api')
// For testing purposes
//runtimeOnlyNonPublishable("com.github.GTNewHorizons:Electro-Magic-Tools:1.7.25:dev")
@@ -0,0 +1,169 @@
package thaumic.tinkerer.client.core.handler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.gtnewhorizons.dashboard.api.HudBounds;
import com.gtnewhorizons.dashboard.api.HudElement;
import com.gtnewhorizons.dashboard.api.HudRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import thaumcraft.common.config.Config;
import thaumic.tinkerer.client.core.handler.kami.SoulHeartClientHandler;
import thaumic.tinkerer.client.core.handler.kami.ToolModeHUDHandler;
import thaumic.tinkerer.common.core.handler.ConfigHandler;
/**
* Lets players move, resize and hide the Dislocation focus box, the Kami tool mode text and the soul hearts in
* Dashboard's HUD editor. The only class using Dashboard, so only call it while Dashboard is loaded.
*/
@SideOnly(Side.CLIENT)
public final class DashboardHud {
private static final int ITEM_SIZE = 18;
private static final int TEXT_PADDING = 4;
private static final int TOOL_MODE_OFFSET = 72;
private static final int SOUL_HEARTS_WIDTH = 81;
private static final int SOUL_HEARTS_HEIGHT = 9;
private static final int SAMPLE_SOUL_HP = 20;
private static final int BOX_COLOR = 0x66000000;
private static final int TEXT_COLOR = 0xFFAA00;
private static final HudElement DISLOCATION_FOCUS = new HudElement(
"thaumictinkerer:dislocation_focus",
DashboardHud::getDislocationBounds);
private static final HudElement TOOL_MODE = new HudElement(
"thaumictinkerer:tool_mode",
DashboardHud::getToolModeBounds);
private static final HudElement SOUL_HEARTS = new HudElement(
"thaumictinkerer:soul_hearts",
DashboardHud::getSoulHeartsBounds);
private static final RenderItem RENDER_ITEM = new RenderItem();
private DashboardHud() {}
/** The tool mode text and soul hearts only exist with Kami turned on. */
public static void register(boolean kami) {
DISLOCATION_FOCUS.setPreview(
(screenWidth, screenHeight) -> HudRegistry
.render(DISLOCATION_FOCUS, () -> drawDislocationPreview(screenWidth, screenHeight)));
HudRegistry.register(DISLOCATION_FOCUS);
if (!kami) {
return;
}
TOOL_MODE.setPreview(
(screenWidth, screenHeight) -> HudRegistry
.render(TOOL_MODE, () -> drawToolModePreview(screenWidth, screenHeight)));
SOUL_HEARTS.setPreview(
(screenWidth, screenHeight) -> HudRegistry.render(SOUL_HEARTS, DashboardHud::drawSoulHeartsPreview));
HudRegistry.register(TOOL_MODE);
HudRegistry.register(SOUL_HEARTS);
}
// False means the player hid the element, so skip drawing it and do not call endRender()
public static boolean beginDislocationFocus(ScaledResolution resolution) {
return HudRegistry.beginRender(DISLOCATION_FOCUS, resolution);
}
public static boolean beginToolMode(ScaledResolution resolution) {
return HudRegistry.beginRender(TOOL_MODE, resolution);
}
public static boolean beginSoulHearts(ScaledResolution resolution) {
return HudRegistry.beginRender(SOUL_HEARTS, resolution);
}
public static void endRender() {
HudRegistry.endRender();
}
/** Next to Thaumcraft's wand dial: the block's icon, with the text in the small font beside it. */
private static HudBounds getDislocationBounds(int screenWidth, int screenHeight) {
int y = Config.dialBottom ? screenHeight - 70 : 50;
int textWidth = getSmallTextWidth(StatCollector.translateToLocal("ttmisc.focusDislocation.tooltip"));
return new HudBounds(TEXT_PADDING - 1, y - 1, ITEM_SIZE + 1 + textWidth + TEXT_PADDING, ITEM_SIZE + 1);
}
/** Centered above the hotbar, a little above the held item's name. */
private static HudBounds getToolModeBounds(int screenWidth, int screenHeight) {
int width = Minecraft.getMinecraft().fontRenderer.getStringWidth(getToolModeText());
return new HudBounds((screenWidth - width) / 2, screenHeight - TOOL_MODE_OFFSET, width, 9);
}
/** Above the food bar, at soulHeart.height, higher while the air bubbles show. */
private static HudBounds getSoulHeartsBounds(int screenWidth, int screenHeight) {
int y = screenHeight - ConfigHandler.soulHeartHeight;
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (player != null && player.getAir() < 300) {
y -= 10;
}
return new HudBounds(screenWidth / 2 + 10, y, SOUL_HEARTS_WIDTH, SOUL_HEARTS_HEIGHT);
}
private static String getToolModeText() {
String text = ToolModeHUDHandler.getTooltip();
return text == null || text.isEmpty() ? StatCollector.translateToLocal("ttmisc.mode.pick.1") : text;
}
private static int getSmallTextWidth(String text) {
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
boolean unicode = font.getUnicodeFlag();
font.setUnicodeFlag(true);
int width = font.getStringWidth(text);
font.setUnicodeFlag(unicode);
return width;
}
/** Like the real one: a chest in the box, the text in the small font beside it. */
private static void drawDislocationPreview(int screenWidth, int screenHeight) {
HudBounds bounds = getDislocationBounds(screenWidth, screenHeight);
Minecraft mc = Minecraft.getMinecraft();
FontRenderer font = mc.fontRenderer;
String text = StatCollector.translateToLocal("ttmisc.focusDislocation.tooltip");
int x = bounds.x + 1;
int y = bounds.y + 1;
Gui.drawRect(bounds.x, bounds.y, x + ITEM_SIZE, y + ITEM_SIZE, BOX_COLOR);
Gui.drawRect(x + ITEM_SIZE, y, bounds.getRight(), y + 9, BOX_COLOR);
boolean unicode = font.getUnicodeFlag();
font.setUnicodeFlag(true);
font.drawStringWithShadow(text, x + ITEM_SIZE + 2, y, TEXT_COLOR);
font.setUnicodeFlag(unicode);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
RENDER_ITEM.renderItemIntoGUI(font, mc.renderEngine, new ItemStack(Blocks.chest), x, y);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
}
private static void drawToolModePreview(int screenWidth, int screenHeight) {
HudBounds bounds = getToolModeBounds(screenWidth, screenHeight);
Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(getToolModeText(), bounds.x, bounds.y, TEXT_COLOR);
}
/** The real drawing, with sample soul hearts for the moment. */
private static void drawSoulHeartsPreview() {
int realHp = SoulHeartClientHandler.clientPlayerHP;
SoulHeartClientHandler.clientPlayerHP = SAMPLE_SOUL_HP;
try {
SoulHeartClientHandler.renderHUD(HudRegistry.getResolution(), Minecraft.getMinecraft().thePlayer, null);
} finally {
SoulHeartClientHandler.clientPlayerHP = realHp;
}
}
}
@@ -28,6 +28,7 @@ import thaumcraft.api.wands.ItemFocusBasic;
import thaumcraft.common.config.Config;
import thaumcraft.common.items.wands.ItemWandCasting;
import thaumic.tinkerer.client.core.helper.ClientHelper;
import thaumic.tinkerer.common.compat.LoadedMods;
import thaumic.tinkerer.common.item.foci.ItemFocusDislocation;
public final class HUDHandler {
@@ -49,7 +50,8 @@ public final class HUDHandler {
if (focus != null && focus instanceof ItemFocusDislocation) {
ItemStack pickedBlock = ((ItemFocusDislocation) focus).getPickedBlock(item);
if (pickedBlock != null) {
if (pickedBlock != null
&& (!LoadedMods.dashboardLoaded || DashboardHud.beginDislocationFocus(event.resolution))) {
Gui.drawRect(xpos - 1, ypos - 1, xpos + 18, ypos + 18, 0x66000000);
FontRenderer font = ClientHelper.fontRenderer();
@@ -87,6 +89,7 @@ public final class HUDHandler {
ypos);
}
font.setUnicodeFlag(unicode);
if (LoadedMods.dashboardLoaded) DashboardHud.endRender();
}
}
}
@@ -24,7 +24,9 @@ import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import thaumic.tinkerer.client.core.handler.DashboardHud;
import thaumic.tinkerer.client.lib.LibResources;
import thaumic.tinkerer.common.compat.LoadedMods;
import thaumic.tinkerer.common.core.handler.ConfigHandler;
public final class SoulHeartClientHandler {
@@ -69,11 +71,25 @@ public final class SoulHeartClientHandler {
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDrawScreenPre(RenderGameOverlayEvent.Pre event) {
Minecraft mc = Minecraft.getMinecraft();
if (event.type == RenderGameOverlayEvent.ElementType.HEALTH) {
if (event.type == RenderGameOverlayEvent.ElementType.HEALTH && !LoadedMods.dashboardLoaded) {
renderHUD(event.resolution, mc.thePlayer, null);
}
}
/**
* With Dashboard, the soul hearts are drawn here instead of with the health bar, so they do not move or hide with
* it.
*/
@SubscribeEvent
public void onDrawScreenPost(RenderGameOverlayEvent.Post event) {
if (event.type == RenderGameOverlayEvent.ElementType.ALL && LoadedMods.dashboardLoaded
&& clientPlayerHP > 0
&& DashboardHud.beginSoulHearts(event.resolution)) {
renderHUD(event.resolution, Minecraft.getMinecraft().thePlayer, null);
DashboardHud.endRender();
}
}
@SideOnly(Side.CLIENT)
public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) {
@@ -26,6 +26,8 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import thaumic.tinkerer.client.core.handler.ClientTickHandler;
import thaumic.tinkerer.client.core.handler.DashboardHud;
import thaumic.tinkerer.common.compat.LoadedMods;
public final class ToolModeHUDHandler {
@@ -39,6 +41,10 @@ public final class ToolModeHUDHandler {
}
}
public static String getTooltip() {
return currentTooltip;
}
@SideOnly(Side.CLIENT)
public static void clientTick() {
if (tooltipDisplayTicks > 0) --tooltipDisplayTicks;
@@ -62,7 +68,7 @@ public final class ToolModeHUDHandler {
if (opacity > 160) opacity = 160;
if (opacity > 0) {
if (opacity > 0 && (!LoadedMods.dashboardLoaded || DashboardHud.beginToolMode(var5))) {
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
@@ -71,6 +77,7 @@ public final class ToolModeHUDHandler {
var8.drawStringWithShadow(currentTooltip, tooltipStartX, tooltipStartY, color + (opacity << 24));
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
if (LoadedMods.dashboardLoaded) DashboardHud.endRender();
}
}
}
@@ -30,6 +30,7 @@ import cpw.mods.fml.common.network.FMLNetworkEvent;
import cpw.mods.fml.relauncher.Side;
import thaumcraft.client.fx.ParticleEngine;
import thaumic.tinkerer.client.core.handler.ClientTickHandler;
import thaumic.tinkerer.client.core.handler.DashboardHud;
import thaumic.tinkerer.client.core.handler.GemArmorKeyHandler;
import thaumic.tinkerer.client.core.handler.HUDHandler;
import thaumic.tinkerer.client.core.handler.kami.KamiArmorClientHandler;
@@ -114,6 +115,8 @@ public final class TTClientProxy extends TTCommonProxy {
if (ConfigHandler.showPlacementMirrorBlocks)
MinecraftForge.EVENT_BUS.register(new PlacementMirrorPredictionRenderer());
}
if (LoadedMods.dashboardLoaded) DashboardHud.register(ConfigHandler.enableKami);
}
@SubscribeEvent
@@ -13,6 +13,7 @@ public class LoadedMods {
public static final boolean bloodMagicLoaded = Loader.isModLoaded("BloodMagic");
public static final boolean botaniaLoaded = Loader.isModLoaded("Botania");
public static final boolean computerCraftLoaded = Loader.isModLoaded("ComputerCraft");
public static final boolean dashboardLoaded = Loader.isModLoaded("dashboard");
public static final boolean enderIOLoaded = Loader.isModLoaded("EnderIO");
public static final boolean enderStorageLoaded = Loader.isModLoaded("EnderStorage");
public static final boolean forgeMultipartLoaded = Loader.isModLoaded("ForgeMultipart");
@@ -21,7 +21,7 @@ public final class LibMisc {
public static final String NETWORK_CHANNEL = MOD_ID;
public static final String DEPENDENCIES = "required-after:Forge@[10.12.1.1112,);required-after:Thaumcraft;before:advthaum;after:IC2;after:Waila;after:ForgeMultipart;after:ComputerCraft";
public static final String DEPENDENCIES = "required-after:Forge@[10.12.1.1112,);required-after:Thaumcraft;before:advthaum;after:IC2;after:Waila;after:ForgeMultipart;after:ComputerCraft;after:dashboard@[1.0.11,)";
public static final String COMMON_PROXY = "thaumic.tinkerer.common.core.proxy.TTCommonProxy";
public static final String CLIENT_PROXY = "thaumic.tinkerer.client.core.proxy.TTClientProxy";