Created
December 7, 2015 00:01
-
-
Save Vazkii/2608fe308a46a16172e0 to your computer and use it in GitHub Desktop.
LiMI - Lightweight Mod Indicator
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
package vazkii.limi; | |
import net.minecraftforge.common.MinecraftForge; | |
import net.minecraftforge.common.config.Configuration; | |
import net.minecraftforge.event.entity.player.ItemTooltipEvent; | |
import cpw.mods.fml.common.Loader; | |
import cpw.mods.fml.common.Mod; | |
import cpw.mods.fml.common.Mod.EventHandler; | |
import cpw.mods.fml.common.ModContainer; | |
import cpw.mods.fml.common.event.FMLPreInitializationEvent; | |
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | |
import cpw.mods.fml.common.registry.GameData; | |
@Mod(modid = "LiMI", name = "LiMI", version = "1.0") | |
public class LiMI { | |
String formatting; | |
@EventHandler | |
public void preInit(FMLPreInitializationEvent event) { | |
MinecraftForge.EVENT_BUS.register(this); | |
Configuration config = new Configuration(event.getSuggestedConfigurationFile()); | |
config.load(); | |
formatting = config.getString("formatting", Configuration.CATEGORY_GENERAL, "&e&o", "The formatting codes to use in the tooltip. Use & to substitute for the control character."); | |
if(config.hasChanged()) | |
config.save(); | |
} | |
@SubscribeEvent | |
public void onTooltip(ItemTooltipEvent event) { | |
String itemName = GameData.getItemRegistry().getNameForObject(event.itemStack.getItem()); | |
ModContainer mod = Loader.instance().getIndexedModList().get(itemName.split(":")[0]); | |
String name = mod == null ? "Minecraft" : mod.getName(); | |
event.toolTip.add(formatting.replaceAll("&", "\u00a7") + name); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got this crash with this when I opened up the creative menu on the search tab. http://pastebin.com/ymq0AtgL