2013-10-17 04:27:07 +02:00
|
|
|
package com.pahimar.ee3.core.handlers;
|
|
|
|
|
2013-10-18 07:23:11 +02:00
|
|
|
import net.minecraft.util.EnumChatFormatting;
|
2013-10-17 04:27:07 +02:00
|
|
|
import net.minecraftforge.event.ForgeSubscribe;
|
|
|
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
|
|
|
|
|
|
|
import com.pahimar.ee3.emc.EmcRegistry;
|
2013-10-20 08:32:32 +02:00
|
|
|
import com.pahimar.ee3.emc.EmcType;
|
2013-10-18 07:23:11 +02:00
|
|
|
import com.pahimar.ee3.emc.EmcValue;
|
2013-10-17 04:27:07 +02:00
|
|
|
import com.pahimar.ee3.item.CustomWrappedStack;
|
2013-10-18 07:23:11 +02:00
|
|
|
import com.pahimar.ee3.item.OreStack;
|
|
|
|
import com.pahimar.ee3.item.crafting.RecipeRegistry;
|
2013-10-17 04:27:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Equivalent-Exchange-3
|
|
|
|
*
|
|
|
|
* ItemTooltipEventHandler
|
|
|
|
*
|
|
|
|
* @author pahimar
|
|
|
|
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class ItemTooltipEventHandler {
|
2013-10-18 07:23:11 +02:00
|
|
|
|
|
|
|
private static boolean debug = true;
|
2013-10-17 04:27:07 +02:00
|
|
|
|
|
|
|
@ForgeSubscribe
|
|
|
|
public void handleItemTooltipEvent(ItemTooltipEvent event) {
|
|
|
|
|
2013-10-18 07:23:11 +02:00
|
|
|
CustomWrappedStack stack = new CustomWrappedStack(event.itemStack);
|
|
|
|
if (debug) {
|
|
|
|
event.toolTip.add(EnumChatFormatting.AQUA + "ID: " + event.itemStack.itemID + ", Meta: " + event.itemStack.getItemDamage());
|
|
|
|
if (stack.getWrappedStack() instanceof OreStack) {
|
|
|
|
event.toolTip.add(EnumChatFormatting.AQUA + "OreDictionary Item");
|
|
|
|
}
|
|
|
|
if (RecipeRegistry.getRecipeMappings().containsKey(stack)) {
|
|
|
|
event.toolTip.add(EnumChatFormatting.AQUA + "Made from a recipe");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EmcRegistry.hasEmcValue(stack)) {
|
|
|
|
EmcValue emcValue = EmcRegistry.getEmcValue(stack);
|
|
|
|
|
|
|
|
event.toolTip.add("");
|
2013-10-25 21:22:59 +02:00
|
|
|
if (emcValue != null) {
|
2013-10-26 02:40:13 +02:00
|
|
|
event.toolTip.add("EMC: " + stack.getStackSize() * emcValue.getValue());
|
2013-10-25 21:22:59 +02:00
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
for (EmcType emcType : EmcType.TYPES) {
|
|
|
|
if (emcValue.components[emcType.ordinal()] > 0) {
|
2013-10-26 02:40:13 +02:00
|
|
|
event.toolTip.add(" * " + emcType + ": " + stack.getStackSize() * emcValue.components[emcType.ordinal()]);
|
2013-10-25 21:22:59 +02:00
|
|
|
}
|
2013-10-20 08:32:32 +02:00
|
|
|
}
|
2013-10-18 07:23:11 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-17 04:27:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|