aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorColen <54497873+GTNH-Colen@users.noreply.github.com>2022-01-28 20:14:17 +0000
committerGitHub <noreply@github.com>2022-01-28 21:14:17 +0100
commit3d2640eab73e1ecb17cff4700d8aa83fb324ee37 (patch)
tree8f357eef9d15f16ba54b9462eb53707055920d55 /src/main
parentbba8933048adf109d7b1f2bfa42517b2a9fbd5cf (diff)
downloadGT5-Unofficial-3d2640eab73e1ecb17cff4700d8aa83fb324ee37.tar.gz
GT5-Unofficial-3d2640eab73e1ecb17cff4700d8aa83fb324ee37.tar.bz2
GT5-Unofficial-3d2640eab73e1ecb17cff4700d8aa83fb324ee37.zip
Texture tooltips update (#903)
* New circuits * Fix last tier ore dict * Colorfull tier tooltips (#898) * Make Repellator stop slimes spawning (#896) * Add special tooltip handling, requested by Colen Co-authored-by: Alkalus <3060479+draknyte1@users.noreply.github.com> Co-authored-by: glowredman <fredcraft00@gmail.com> * Fixed github shenanigans with new tier colours. * Update A LOT of textures (mostly minor) * Remove extraneous comments. * Remove obsolete comments and update materials.java. * Add tooltips for all batteries in base GT. * Remove test case Co-authored-by: Alkalus <3060479+draknyte1@users.noreply.github.com> Co-authored-by: glowredman <fredcraft00@gmail.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gregtech/api/enums/Materials.java11
-rw-r--r--src/main/java/gregtech/client/GT_TooltipEventHandler.java192
-rw-r--r--src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java107
-rw-r--r--src/main/java/gregtech/common/items/GT_MetaGenerated_Item_03.java83
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/17.pngbin1689 -> 5324 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/19.pngbin1708 -> 1258 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/20.pngbin5247 -> 2838 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/20.png.mcmeta7
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/21.pngbin2109 -> 1308 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/22.pngbin2136 -> 1301 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/23.pngbin2128 -> 1289 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/24.pngbin5454 -> 2961 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/24.png.mcmeta7
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/25.pngbin1991 -> 5564 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/27.pngbin2015 -> 1378 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/28.pngbin5480 -> 2837 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/28.png.mcmeta7
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/29.pngbin1894 -> 5232 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/31.pngbin1909 -> 1194 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/32.pngbin5145 -> 2249 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/32.png.mcmeta7
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/33.pngbin2244 -> 1354 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/35.pngbin2233 -> 1327 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/36.pngbin5374 -> 2918 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/36.png.mcmeta7
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/37.pngbin2038 -> 1416 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/38.pngbin2050 -> 1448 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/39.pngbin2048 -> 1405 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/40.pngbin5790 -> 2972 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/40.png.mcmeta7
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/41.pngbin1962 -> 1384 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/42.pngbin2000 -> 3093 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/43.pngbin1993 -> 1335 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/44.pngbin5749 -> 3346 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/44.png.mcmeta7
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/45.pngbin1888 -> 1503 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/47.pngbin1902 -> 1493 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/48.pngbin6626 -> 2806 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/48.png.mcmeta7
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/640.pngbin413 -> 898 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/641.pngbin425 -> 906 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/642.pngbin410 -> 903 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/643.pngbin394 -> 886 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/644.pngbin411 -> 886 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/645.pngbin438 -> 926 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/646.pngbin435 -> 910 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/647.pngbin455 -> 931 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/648.pngbin457 -> 947 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/649.pngbin2168 -> 1809 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/651.pngbin483 -> 963 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/652.pngbin491 -> 1384 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/655.pngbin483 -> 967 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/656.pngbin485 -> 968 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/657.pngbin497 -> 981 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/658.pngbin493 -> 985 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/680.pngbin525 -> 1478 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/681.pngbin565 -> 1457 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/682.pngbin561 -> 1450 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/683.pngbin567 -> 1060 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/684.pngbin545 -> 1448 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/685.pngbin549 -> 1030 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/686.pngbin565 -> 1034 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/687.pngbin575 -> 1461 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/688.pngbin3219 -> 1432 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/689.pngbin2236 -> 1407 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/690.pngbin486 -> 1385 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/691.pngbin513 -> 1403 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/692.pngbin471 -> 1374 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/693.pngbin457 -> 1374 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/694.pngbin482 -> 1364 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/695.pngbin509 -> 1403 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/696.pngbin502 -> 1383 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/697.pngbin509 -> 1387 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/698.pngbin3164 -> 1389 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/699.pngbin2223 -> 1967 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/705.pngbin4051 -> 5088 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/706.pngbin4039 -> 5031 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/120.pngbin6682 -> 5070 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/174.pngbin815 -> 1706 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/174.png.mcmeta2
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/175.pngbin1005 -> 2050 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/175.png.mcmeta2
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/176.pngbin3331 -> 5365 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/176.png.mcmeta2
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/177.pngbin18422 -> 23976 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/177.png.mcmeta2
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/88.pngbin4062 -> 5092 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/91.pngbin4043 -> 5028 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/95.pngbin4059 -> 5044 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/98.pngbin3028 -> 1709 bytes
-rw-r--r--src/main/resources/assets/gregtech/textures/items/gt.metaitem.03/99.pngbin3732 -> 1995 bytes
91 files changed, 355 insertions, 102 deletions
diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java
index 0e270b1d44..60190431cb 100644
--- a/src/main/java/gregtech/api/enums/Materials.java
+++ b/src/main/java/gregtech/api/enums/Materials.java
@@ -9,7 +9,6 @@ import gregtech.api.interfaces.IMaterialHandler;
import gregtech.api.interfaces.ISubTagContainer;
import gregtech.api.objects.GT_FluidStack;
import gregtech.api.objects.MaterialStack;
-import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
import gregtech.loaders.materialprocessing.ProcessingConfig;
@@ -337,10 +336,12 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
public static Materials Nano = new Materials( -1, TextureSet.SET_NONE , 1.0F, 0, 0, 0 , 255, 255, 255, 0, "Nano" , "Bio" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 11)));
public static Materials Piko = new Materials( -1, TextureSet.SET_NONE , 1.0F, 0, 0, 0 , 255, 255, 255, 0, "Piko" , "Bio" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 12)));
public static Materials Quantum = new Materials( -1, TextureSet.SET_NONE , 1.0F, 0, 0, 0 , 255, 255, 255, 0, "Quantum" , "Bio" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 13)));
- public static Materials Optical = new Materials( -1, TextureSet.SET_NONE , 1.0F, 0, 0, 0 , 255, 255, 255, 0, "Optical" , "Optical" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 14)));
- public static Materials Exotic = new Materials( -1, TextureSet.SET_NONE , 1.0F, 0, 0, 0 , 255, 255, 255, 0, "Exotic" , "Exotic" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 13)));
- public static Materials Cosmic = new Materials( -1, TextureSet.SET_NONE , 1.0F, 0, 0, 0 , 255, 255, 255, 0, "Cosmic" , "Cosmic" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 14)));
- public static Materials Transcendental = new Materials( -1, TextureSet.SET_NONE , 1.0F, 0, 0, 0 , 255, 255, 255, 0, "Transcendental" , "Transcendental" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 15)));
+ public static Materials Optical = new Materials( -1, TextureSet.SET_NONE , 1.0F, 0, 0, 0 , 255, 255, 255, 0, "Optical" , "Optical" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 13)));
+ public static Materials Exotic = new Materials( -1, TextureSet.SET_NONE , 1.0F, 0, 0, 0 , 255, 255, 255, 0, "Exotic" , "Exotic" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 14)));
+ public static Materials Cosmic = new Materials( -1, TextureSet.SET_NONE , 1.0F, 0, 0, 0 , 255, 255, 255, 0, "Cosmic" , "Cosmic" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 15)));
+ public static Materials Transcendent = new Materials( -1, TextureSet.SET_NONE , 1.0F, 0, 0, 0 , 255, 255, 255, 0, "Transcendent" , "Transcendent" , 0, 0, -1, 0, false, false, 1, 1, 1, Dyes.dyeLightGray , Arrays.asList(new TC_AspectStack(TC_Aspects.ELECTRUM, 16)));
+
+
/**
* Not possible to determine exact Components
*/
diff --git a/src/main/java/gregtech/client/GT_TooltipEventHandler.java b/src/main/java/gregtech/client/GT_TooltipEventHandler.java
index 1fb4995025..30ef1a396d 100644
--- a/src/main/java/gregtech/client/GT_TooltipEventHandler.java
+++ b/src/main/java/gregtech/client/GT_TooltipEventHandler.java
@@ -1,7 +1,5 @@
package gregtech.client;
-import static net.minecraft.util.EnumChatFormatting.*;
-
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
@@ -15,52 +13,93 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.oredict.OreDictionary;
public class GT_TooltipEventHandler {
-
- private static final Map<String, Supplier<String>[]> tooltipMap = new HashMap<>();
-
+
+ private static final Map<String, Supplier<String>> tooltipMap = new HashMap<>();
+
+ private static final String BLACK, DARK_BLUE, DARK_GREEN, DARK_AQUA, DARK_RED, DARK_PURPLE, GOLD, GRAY, DARK_GRAY, BLUE, GREEN, AQUA, RED, LIGHT_PURPLE, YELLOW, WHITE, OBFUSCATED, BOLD, STRIKETHROUGH, UNDERLINE, ITALIC, RESET;
+
+ private static final Supplier<String> NEW_LINE;
+
+ /*
+ * What you can do:
+ * - add simple, unformated text
+ * - add formatted text
+ * Note: you can chain formatting codes but the color must be used first:
+ * e.g. BLACK + ITALIC will create black, italic text but ITALIC + BLACK will only create black text.
+ * - add animated text
+ * - chain multiple static and/or animated text together using chain()
+ * (Although chaining only static text together is pointless, text() is already able to to that)
+ * - add multiple lines by using NEW_LINE (either as String or as Supplier<String>)
+ * Note: formatting only applies for one line
+ * Note: having a NEW_LINE in animated text results in "skipping" of one formatting since NEW_LINE
+ * counts as character but is not displayed
+ *
+ * Note: adding a tooltip to an item multiple times also creates multiple lines (in the same order they were added)
+ *
+ * What you cannot do:
+ * - add a tooltip depending on NBT, tooltips are only mapped to name and meta
+ *
+ * This method is executed on postInit
+ */
public static void init() {
- addOredictTooltip("circuitPrimitive", formattedText("ULV-Tier", RED));
- addOredictTooltip("circuitBasic", formattedText("LV-Tier", DARK_BLUE));
- addOredictTooltip("circuitGood", formattedText("MV-Tier", GRAY));
- addOredictTooltip("circuitAdvanced", formattedText("HV-Tier", GOLD));
- addOredictTooltip("circuitData", formattedText("EV-Tier", DARK_PURPLE));
- addOredictTooltip("circuitElite", formattedText("IV-Tier", DARK_BLUE));
- addOredictTooltip("circuitMaster", formattedText("LuV-Tier", LIGHT_PURPLE));
- addOredictTooltip("circuitUltimate", formattedText("ZPM-Tier", WHITE));
- addOredictTooltip("circuitSuperconductor", formattedText("UV-Tier", AQUA));
- addOredictTooltip("circuitInfinite", formattedText("UHV-Tier", DARK_RED));
- addOredictTooltip("circuitBio", formattedText("UEV-Tier", GREEN));
- //addOredictTooltip("circuitOptical", formattedText("UIV-Tier", DARK_GREEN));
- //addOredictTooltip("circuitExotic", formattedText("UV-Tier", DARK_AQUA));
- //addOredictTooltip("circuitCosmic", animatedString("UXV-Tier", 8, 500, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, BLACK, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE, WHITE));
- //addOredictTooltip("circuitTranscendental", animatedString("MAX-Tier", 1, 80, RED, GOLD, YELLOW, GREEN, AQUA, BLUE, LIGHT_PURPLE));
+
+ // Tooltip tiers for ALL items given the appropriate tier oredict tag.
+ addOredictTooltip("ULV", text(WHITE + "ULV-Tier"));
+ addOredictTooltip("LV" , text(GRAY + "LV-Tier"));
+ addOredictTooltip("MV" , text(GOLD + "MV-Tier"));
+ addOredictTooltip("HV" , text(YELLOW + "HV-Tier"));
+ addOredictTooltip("EV" , text(DARK_GRAY + "EV-Tier"));
+ addOredictTooltip("IV" , text(GREEN + "IV-Tier"));
+ addOredictTooltip("LuV", text(LIGHT_PURPLE + "LuV-Tier"));
+ addOredictTooltip("ZPM", text(AQUA + "ZPM-Tier"));
+ addOredictTooltip("UV" , text(DARK_GREEN + "UV-Tier"));
+ addOredictTooltip("UHV", text(DARK_RED + "UHV-Tier"));
+ addOredictTooltip("UEV", text(DARK_PURPLE + "UEV-Tier"));
+ addOredictTooltip("UIV", text(DARK_BLUE + BOLD + "UIV-Tier"));
+ addOredictTooltip("UMV", text(RED + BOLD + UNDERLINE + "UMV-Tier"));
+ addOredictTooltip("UXV", animatedText("UXV-Tier", 1, 100, DARK_PURPLE + BOLD + UNDERLINE, DARK_RED + UNDERLINE + BOLD));
+ addOredictTooltip("MAX", chain(
+ animatedText("X", 1, 100, LIGHT_PURPLE + BOLD + OBFUSCATED + UNDERLINE, RED + BOLD + OBFUSCATED + UNDERLINE, GOLD + OBFUSCATED + BOLD + UNDERLINE, YELLOW + OBFUSCATED + BOLD + UNDERLINE, GREEN + OBFUSCATED + BOLD + UNDERLINE, AQUA + OBFUSCATED + BOLD + UNDERLINE, BLUE + OBFUSCATED + BOLD + UNDERLINE),
+ animatedText("MAX-Tier", 1, 100, RED + BOLD + UNDERLINE, GOLD + BOLD + UNDERLINE, YELLOW + BOLD + UNDERLINE, GREEN + BOLD + UNDERLINE, AQUA + BOLD + UNDERLINE, BLUE + BOLD + UNDERLINE, LIGHT_PURPLE + BOLD + UNDERLINE),
+ animatedText("X", 1, 100, GOLD + OBFUSCATED + BOLD + UNDERLINE, YELLOW + OBFUSCATED + BOLD + UNDERLINE, GREEN + OBFUSCATED + BOLD + UNDERLINE, AQUA + OBFUSCATED + BOLD + UNDERLINE, BLUE + OBFUSCATED + BOLD + UNDERLINE, LIGHT_PURPLE + OBFUSCATED + BOLD + UNDERLINE, RED + OBFUSCATED + BOLD + UNDERLINE)
+ ));
+
}
-
+
@SubscribeEvent
public void renderTooltip(ItemTooltipEvent event) {
- Supplier<String>[] texts = tooltipMap.get(getStackIdentifier(event.itemStack));
- if(texts == null) return;
- String s = "";
- for(Supplier<String> snippet : texts) {
- s += snippet.get();
+ Supplier<String> tooltip = tooltipMap.get(getStackIdentifier(event.itemStack));
+ if(tooltip != null) {
+ String text = tooltip.get();
+ if(!text.isEmpty()) {
+ for(String line : text.split("\n")) {
+ event.toolTip.add(line);
+ }
+ }
}
- event.toolTip.add(s);
}
-
+
+ @SafeVarargs
+ private static Supplier<String> chain(Supplier<String>... parts) {
+ return () -> {
+ String s = "";
+ for(Supplier<String> text : parts) {
+ s += text.get();
+ }
+ return s;
+ };
+ }
+
private static Supplier<String> text(String text) {
return () -> text;
}
-
- private static Supplier<String> formattedText(String text, EnumChatFormatting formatting){
- return () -> formatting + text;
- }
-
+
/** Taken and adapted from <a href=https://github.com/GTNewHorizons/Avaritia/blob/7b7eaed652f6be320b10f33d8f8e6a04e66ca14f/src/main/java/fox/spiteful/avaritia/LudicrousText.java#L19>Avaritia</a>, licensed under MIT */
- private static Supplier<String> animatedString(String text, int posstep, int delay, EnumChatFormatting... formattingArray) {
- if(text.isEmpty()) return () -> "";
-
+ private static Supplier<String> animatedText(String text, int posstep, int delay, String... formattingArray) {
+ if(text == null || text.isEmpty() || formattingArray == null || formattingArray.length == 0) return () -> "";
+
final int finalDelay = delay = delay <= 0 ? delay = 1 : delay;
-
+
return () -> {
StringBuilder sb = new StringBuilder(text.length() * 3);
int offset = (int) ((System.currentTimeMillis() / finalDelay) % formattingArray.length);
@@ -73,29 +112,76 @@ public class GT_TooltipEventHandler {
return sb.toString();
};
}
-
- @SafeVarargs
- private static void addOredictTooltip(String oredictName, Supplier<String>... tooltips) {
+
+ private static void addOredictTooltip(String oredictName, Supplier<String> tooltip) {
for(ItemStack item : OreDictionary.getOres(oredictName)) {
- addItemTooltip(item, tooltips);
+ addItemTooltip(item, tooltip);
}
}
-
- @SafeVarargs
- private static void addItemTooltip(String modID, String registryName, int meta, Supplier<String>... tooltips) {
+
+ private static void addItemTooltip(String modID, String registryName, int meta, Supplier<String> tooltip) {
Item item = GameRegistry.findItem(modID, registryName);
- if(item == null || meta < 0 || meta >= OreDictionary.WILDCARD_VALUE || tooltips == null) return;
- tooltipMap.put(item.getUnlocalizedName() + "@" + meta, tooltips);
+ if(item == null || meta < 0 || meta >= OreDictionary.WILDCARD_VALUE || tooltip == null) return;
+ String identifier = item.getUnlocalizedName() + "@" + meta;
+ Supplier<String> previous = tooltipMap.get(identifier);
+ if(previous == null) {
+ tooltipMap.put(identifier, tooltip);
+ } else {
+ tooltipMap.put(identifier, chain(previous, NEW_LINE, tooltip));
+ }
}
-
- @SafeVarargs
- private static void addItemTooltip(ItemStack item, Supplier<String>... tooltips) {
- if(item == null || tooltips == null) return;
- tooltipMap.put(getStackIdentifier(item), tooltips);
+
+ private static void addItemTooltip(ItemStack item, Supplier<String> tooltip) {
+ if(item == null || tooltip == null) return;
+ String identifier = getStackIdentifier(item);
+ Supplier<String> previous = tooltipMap.get(identifier);
+ if(previous == null) {
+ tooltipMap.put(identifier, tooltip);
+ } else {
+ tooltipMap.put(identifier, chain(previous, NEW_LINE, tooltip));
+ }
}
-
+
private static String getStackIdentifier(ItemStack stack) {
return stack == null ? "" : stack.getItem().getUnlocalizedName() + "@" + stack.getItemDamage();
}
-}
+ static {
+ AQUA = EnumChatFormatting.AQUA.toString();
+ BLACK = EnumChatFormatting.BLACK.toString();
+ BLUE = EnumChatFormatting.BLUE.toString();
+ BOLD = EnumChatFormatting.BOLD.toString();
+ DARK_AQUA = EnumChatFormatting.DARK_AQUA.toString();
+ DARK_BLUE = EnumChatFormatting.DARK_BLUE.toString();
+ DARK_GRAY = EnumChatFormatting.DARK_GRAY.toString();
+ DARK_GREEN = EnumChatFormatting.DARK_GREEN.toString();
+ DARK_PURPLE = EnumChatFormatting.DARK_PURPLE.toString();
+ DARK_RED = EnumChatFormatting.DARK_RED.toString();
+ GOLD = EnumChatFormatting.GOLD.toString();
+ GRAY = EnumChatFormatting.GRAY.toString();
+ GREEN = EnumChatFormatting.GREEN.toString();
+ ITALIC = EnumChatFormatting.ITALIC.toString();
+ LIGHT_PURPLE = EnumChatFormatting.LIGHT_PURPLE.toString();
+ OBFUSCATED = EnumChatFormatting.OBFUSCATED.toString();
+ RED = EnumChatFormatting.RED.toString();
+ RESET = EnumChatFormatting.RESET.toString();
+ STRIKETHROUGH = EnumChatFormatting.STRIKETHROUGH.toString();
+ UNDERLINE = EnumChatFormatting.UNDERLINE.toString();
+ WHITE = EnumChatFormatting.WHITE.toString();
+ YELLOW = EnumChatFormatting.YELLOW.toString();
+
+ NEW_LINE = new Supplier<String>() {
+
+ @Override
+ public String get() {
+ return "\n";
+ }
+
+ @Override
+ public String toString() {
+ return "\n";
+ }
+ };
+ }
+
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java
index 9b679c1ff4..625b8fc206 100644
--- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java
+++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Item_01.java
@@ -34,6 +34,7 @@ import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.util.MathHelper;
+import net.minecraftforge.oredict.OreDictionary;