Compare commits

..
4 Commits
Author SHA1 Message Date
Martin Robertz c4e3537957 update 2025-10-01 17:23:42 +02:00
EmperorSuper 9bc1e79f64 Add Gadomancy support (Thaumic Sight enchant) (#40) 2025-10-01 08:12:13 +02:00
Martin Robertz bdebd737d6 update 2025-09-21 17:20:45 +02:00
WoriveandMartin Robertz 9f04d3d029 feat(api): Add support for advanced tooltip body (#38)
Co-authored-by: Martin Robertz <[email protected]>
2025-09-21 17:19:57 +02:00
19 changed files with 133 additions and 3 deletions

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
// Add your dependencies here
dependencies {
implementation('com.github.GTNewHorizons:NotEnoughItems:2.7.85-GTNH:dev')
implementation('com.github.GTNewHorizons:NotEnoughItems:2.7.91-GTNH:dev')
shadowImplementation('au.com.bytecode:opencsv:2.4')
}
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.42'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.43'
}
@@ -97,7 +97,7 @@ public class HUDHandlerIAspectContainer implements IWailaDataProvider {
ItemStack headSlot = player.inventory.armorInventory[3];
if (headSlot == null) return tag;
boolean hasReveal = ThaumcraftModule.IGoggles.isInstance(headSlot.getItem());
boolean hasReveal = ThaumcraftModule.isGoggles.apply(headSlot);
if (!hasReveal) return tag;
Map<String, ?> knownAspects = (Map<String, ?>) ThaumcraftModule.CommonProxy_getKnownAspects
@@ -2,7 +2,9 @@ package mcp.mobius.waila.addons.thaumcraft;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.function.Function;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import org.apache.logging.log4j.Level;
@@ -34,6 +36,8 @@ public class ThaumcraftModule {
public static Class<?> IGoggles = null;
public static Function<ItemStack, Boolean> isGoggles = stack -> IGoggles.isInstance(stack.getItem());
public static void register() {
try {
Thaumcraft = Class.forName("thaumcraft.common.Thaumcraft");
@@ -0,0 +1,41 @@
package mcp.mobius.waila.addons.thaumcraftGadomancy;
import java.lang.reflect.Field;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import org.apache.logging.log4j.Level;
import mcp.mobius.waila.Waila;
import mcp.mobius.waila.addons.thaumcraft.ThaumcraftModule;
public class GadomancyModule {
public static Class<?> RegisteredEnchantments = null;
public static Field RegisteredEnchantments_revealer = null;
public static int revealerEffectId;
public static void register() {
try {
RegisteredEnchantments = Class.forName("makeo.gadomancy.common.registration.RegisteredEnchantments");
RegisteredEnchantments_revealer = RegisteredEnchantments.getDeclaredField("revealer");
Object revealer = RegisteredEnchantments_revealer.get(null);
revealerEffectId = ((Enchantment) revealer).effectId;
ThaumcraftModule.isGoggles = stack -> ThaumcraftModule.IGoggles.isInstance(stack.getItem())
|| EnchantmentHelper.getEnchantmentLevel(revealerEffectId, stack) > 0;
} catch (ClassNotFoundException e) {
Waila.log.log(Level.INFO, "[Thaumcraft Gadomancy] Gadomancy mod not found.");
return;
} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thaumcraft Gadomancy] Unhandled exception. {}", e);
return;
}
Waila.log.log(Level.INFO, "Gadomancy mod found.");
}
}
@@ -62,6 +62,35 @@ public interface IWailaDataProvider {
List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config);
/**
* Callback used to determine if there is extended information to display for the Body section. If this returns
* true, Waila will either display the "Hold <KEY> for more info" prompt or call getWailaAdvancedBody if the key is
* being held.
*
* @param itemStack Current block scanned, in ItemStack form.
* @param accessor Contains most of the relevant information about the current environment.
* @param config Current configuration of Waila.
* @return True if advanced body information is available, false otherwise.
*/
default boolean hasAdvancedBody(ItemStack itemStack, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return false; // Default to false for backward compatibility
}
/**
* Callback used to add the extended lines to the Body section of the tooltip. This method is ONLY called if
* hasAdvancedBody returns true AND the player is holding the configured key for advanced tooltips.
*
* @param itemStack Current block scanned, in ItemStack form.
* @param currenttip The current list of tooltip lines, including the normal body.
* @param accessor Contains most of the relevant information about the current environment.
* @param config Current configuration of Waila.
* @return Modified input currenttip with advanced information appended.
*/
default List<String> getWailaAdvancedBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
IWailaConfigHandler config) {
return currenttip; // Default to returning the unmodified list
}
/**
* Callback used to add lines to one of the three sections of the tooltip (Head, Body, Tail).</br>
* Will be used if the implementing class is registered via {@link IWailaRegistrar}.{@link registerTailProvider}
@@ -6,6 +6,7 @@ import java.util.Map;
import java.util.TreeMap;
import net.minecraft.block.Block;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@@ -17,7 +18,9 @@ import mcp.mobius.waila.Waila;
import mcp.mobius.waila.api.IWailaBlock;
import mcp.mobius.waila.api.IWailaDataProvider;
import mcp.mobius.waila.api.IWailaEntityProvider;
import mcp.mobius.waila.cbcore.LangUtil;
import mcp.mobius.waila.cbcore.Layout;
import mcp.mobius.waila.client.KeyEvent;
import mcp.mobius.waila.network.Message0x01TERequest;
import mcp.mobius.waila.network.Message0x03EntRequest;
import mcp.mobius.waila.network.WailaPacketHandler;
@@ -146,11 +149,29 @@ public class MetaDataProvider {
}
if (layout == Layout.BODY) for (List<IWailaDataProvider> providersList : bodyBlockProviders.values()) {
boolean hasAdvancedBodyAvailable = false;
final boolean isAdvancedKeyDown = KeyEvent.key_show_advanced.getIsKeyPressed();
for (IWailaDataProvider dataProvider : providersList) try {
currenttip = dataProvider.getWailaBody(itemStack, currenttip, accessor, ConfigHandler.instance());
if (dataProvider.hasAdvancedBody(itemStack, accessor, ConfigHandler.instance())) {
hasAdvancedBodyAvailable = true;
if (isAdvancedKeyDown) {
currenttip = dataProvider
.getWailaAdvancedBody(itemStack, currenttip, accessor, ConfigHandler.instance());
}
}
} catch (Throwable e) {
currenttip = WailaExceptionHandler.handleErr(e, dataProvider.getClass().toString(), currenttip);
}
if (hasAdvancedBodyAvailable && !isAdvancedKeyDown) {
String keyName = GameSettings.getKeyDisplayString(KeyEvent.key_show_advanced.getKeyCode());
currenttip.add(LangUtil.translateG("hud.msg.holdkeymoreinfo", keyName));
}
}
if (layout == Layout.FOOTER) for (List<IWailaDataProvider> providersList : tailBlockProviders.values()) {
for (IWailaDataProvider dataProvider : providersList) try {
@@ -23,6 +23,7 @@ public class KeyEvent {
public static KeyBinding key_liquid;
public static KeyBinding key_recipe;
public static KeyBinding key_usage;
public static KeyBinding key_show_advanced;
public KeyEvent() {
ClientRegistry
@@ -35,6 +36,8 @@ public class KeyEvent {
key_recipe = new KeyBinding(Constants.BIND_WAILA_RECIPE, Keyboard.KEY_NUMPAD3, "Waila"));
ClientRegistry.registerKeyBinding(
key_usage = new KeyBinding(Constants.BIND_WAILA_USAGE, Keyboard.KEY_NUMPAD4, "Waila"));
ClientRegistry.registerKeyBinding(
key_show_advanced = new KeyBinding(Constants.BIND_WAILA_SHOW_ADVANCED, Keyboard.KEY_LSHIFT, "Waila"));
}
@SubscribeEvent
@@ -20,6 +20,7 @@ import mcp.mobius.waila.addons.railcraft.RailcraftModule;
import mcp.mobius.waila.addons.statues.StatuesModule;
import mcp.mobius.waila.addons.stevescarts.StevesCartsModule;
import mcp.mobius.waila.addons.thaumcraft.ThaumcraftModule;
import mcp.mobius.waila.addons.thaumcraftGadomancy.GadomancyModule;
import mcp.mobius.waila.addons.thermaldynamics.ThermalDynamicsModule;
import mcp.mobius.waila.addons.thermalexpansion.ThermalExpansionModule;
import mcp.mobius.waila.addons.twilightforest.TwilightForestModule;
@@ -50,6 +51,9 @@ public class ProxyServer {
/* Thaumcraft */
ThaumcraftModule.register();
/* Gadomancy */
GadomancyModule.register();
/* EnderStorage */
EnderStorageModule.register();
@@ -6,6 +6,7 @@ public final class Constants {
public static String BIND_WAILA_CFG = "waila.keybind.wailaconfig";
public static String BIND_WAILA_SHOW = "waila.keybind.wailadisplay";
public static String BIND_WAILA_SHOW_ADVANCED = "waila.keybind.showadvanced";
public static String BIND_WAILA_LIQUID = "waila.keybind.liquid";
public static String BIND_WAILA_RECIPE = "waila.keybind.recipe";
public static String BIND_WAILA_USAGE = "waila.keybind.usage";
@@ -30,6 +30,7 @@ enchant.label.enchantability=Oèarovatelnost
waila.keybind.wailaconfig=[Waila] Nastavení obrazu
waila.keybind.wailadisplay=[Waila] Zobrazit/Skrýt
waila.keybind.showadvanced=[Waila] Rozšířit popisek
waila.keybind.liquid=[Waila] Zobrazit tekutiny
waila.keybind.recipe=[Waila] Zobrazit recept
waila.keybind.usage=[Waila] Zobrazit použití
@@ -38,6 +39,8 @@ waila.keybind.testing=[Waila] Testování
client.msg.norecipe=Nenalezen žádný recept.
client.msg.nousage=Nenalezeno žádné využití.
hud.msg.holdkeymoreinfo=Držte %s pro více informací
hud.msg.none=<Nic>
hud.msg.empty=<Prázdný>
hud.msg.output=Výstup
@@ -30,6 +30,7 @@ enchant.label.enchantability=Verzauberbarkeit
waila.keybind.wailaconfig=[Waila] Config-Bildschirm
waila.keybind.wailadisplay=[Waila] Zeigen/Verstecken
waila.keybind.showadvanced=[Waila] Tooltip erweitern
waila.keybind.liquid=[Waila] Zeige Flüssigkeiten
waila.keybind.recipe=[Waila] Zeige Rezept
waila.keybind.usage=[Waila] Zeige Nutzung
@@ -38,6 +39,8 @@ waila.keybind.testing=[Waila] Testen
client.msg.norecipe=Kein Rezept gefunden.
client.msg.nousage=Keine Nutzung gefunden.
hud.msg.holdkeymoreinfo=Halte %s für mehr Infos
hud.msg.none=<Nichts>
hud.msg.empty=<Leer>
hud.msg.output=Output
@@ -31,6 +31,7 @@ enchant.label.enchantability=Enchantability
waila.keybind.wailaconfig=[Waila] Config screen
waila.keybind.wailadisplay=[Waila] Show/Hide
waila.keybind.showadvanced=[Waila] Expand Tooltip
waila.keybind.liquid=[Waila] Show liquids
waila.keybind.recipe=[Waila] Show recipe
waila.keybind.usage=[Waila] Show usage
@@ -39,6 +40,8 @@ waila.keybind.testing=[Waila] Testing
client.msg.norecipe=No recipe found.
client.msg.nousage=No usage found.
hud.msg.holdkeymoreinfo=Hold %s for more info
hud.msg.none=<None>
hud.msg.empty=<Empty>
hud.msg.output=Output
@@ -30,6 +30,7 @@ enchant.label.enchantability=Loitsitav
waila.keybind.wailaconfig=[Waila] Konfiguratsiooni ekraan
waila.keybind.wailadisplay=[Waila] Näita/Peida
waila.keybind.showadvanced=[Waila] Laienda kohtspikrit
waila.keybind.liquid=[Waila] Näita vedelikke
waila.keybind.recipe=[Waila] Näita retsepti
waila.keybind.usage=[Waila] Näita kasutamist
@@ -38,6 +39,8 @@ waila.keybind.testing=[Waila] Testimine
client.msg.norecipe=Ühtegi retsepti ei leitud.
client.msg.nousage=Ühtegi kasutust ei leitud.
hud.msg.holdkeymoreinfo=Hoia %s lisainfo saamiseks
hud.msg.none=<Mitte Ükski>
hud.msg.empty=<Tühi>
hud.msg.output=Väljund
@@ -28,6 +28,7 @@ enchant.label.enchantability=Enchantabilitée
waila.keybind.wailaconfig=[Waila] Ecran de config
waila.keybind.wailadisplay=[Waila] Afficher/Masquer
waila.keybind.showadvanced=[Waila] Développer l'info-bulle
waila.keybind.liquid=[Waila] Afficher les liquides
waila.keybind.recipe=[Waila] Afficher les recettes
waila.keybind.usage=[Waila] Afficher l'utilisation
@@ -36,6 +37,8 @@ waila.keybind.testing=[Waila] Test
client.msg.norecipe=Pas de recette trouvée.
client.msg.nousage=Pas d'utilisation trouvée.
hud.msg.holdkeymoreinfo=Maintenez %s pour plus d'infos
hud.msg.none=<Aucun>
hud.msg.empty=<Vide>
hud.msg.output=Sortie
@@ -30,6 +30,7 @@ enchant.label.enchantability=Incantabilità
waila.keybind.wailaconfig=[Waila] Config menù
waila.keybind.wailadisplay=[Waila] Mostra/Nascondi
waila.keybind.showadvanced=[Waila] Espandi tooltip
waila.keybind.liquid=[Waila] Mostra liquidi
waila.keybind.recipe=[Waila] Mostra ricetta
waila.keybind.usage=[Waila] Mostra uso
@@ -38,6 +39,8 @@ waila.keybind.testing=[Waila] Provare
client.msg.norecipe=Nessuna ricetta trovata.
client.msg.nousage=Nessun uso trovato.
hud.msg.holdkeymoreinfo=Tieni premuto %s per più info
hud.msg.none=<Niente>
hud.msg.empty=<Vuoto>
hud.msg.output=Uscita
@@ -28,6 +28,7 @@ enchant.label.enchantability=Enchantbaarheid
waila.keybind.wailaconfig=[Waila] Configuratiescherm
waila.keybind.wailadisplay=[Waila] Toon/Verberg
waila.keybind.showadvanced=[Waila] Tooltip uitvouwen
waila.keybind.liquid=[Waila] Toon vloeistoffen
waila.keybind.recipe=[Waila] Toon recepten
waila.keybind.usage=[Waila] Toon gebruik
@@ -36,6 +37,8 @@ waila.keybind.testing=[Waila] Testen
client.msg.norecipe=Geen recept gevonden.
client.msg.nousage=Geen gebruik gevonden.
hud.msg.holdkeymoreinfo=Houd %s ingedrukt voor meer info
hud.msg.none=<Geen>
hud.msg.empty=<Leeg>
hud.msg.output=Uitvoer
@@ -30,6 +30,7 @@ enchant.label.enchantability=Зачарование
waila.keybind.wailaconfig=[Waila] Меню настроек
waila.keybind.wailadisplay=[Waila] Показать/Скрыть
waila.keybind.showadvanced=[Waila] Развернуть подсказку
waila.keybind.liquid=[Waila] Показать жидкости
waila.keybind.recipe=[Waila] Показать рецепт
waila.keybind.usage=[Waila] Показать применение
@@ -38,6 +39,8 @@ waila.keybind.testing=[Waila] Тестировать
client.msg.norecipe=Рецептов не найдено.
client.msg.nousage=Применений не найдено.
hud.msg.holdkeymoreinfo=Удерживайте %s для подробностей
hud.msg.none=<Ничего>
hud.msg.empty=<Пусто>
hud.msg.output=Вывод
@@ -30,6 +30,7 @@ enchant.label.enchantability=附魔能力
waila.keybind.wailaconfig=[Waila]配置屏幕
waila.keybind.wailadisplay=[Waila]显示/隐藏
waila.keybind.showadvanced=[Waila]展开工具提示
waila.keybind.liquid=[Waila]显示流体
waila.keybind.recipe=[Waila]显示合成
waila.keybind.usage=[Waila]显示可参与合成
@@ -38,6 +39,8 @@ waila.keybind.testing=[Waila]测试中
client.msg.norecipe=未发现合成表.
client.msg.nousage=未发现可参与合成.
hud.msg.holdkeymoreinfo=按住 %s 查看更多信息
hud.msg.none=<无>
hud.msg.empty=<空>
hud.msg.output=输出