2013-10-28 20:22:23 +01:00
|
|
|
package com.pahimar.ee3.core.handler;
|
2013-10-17 04:27:07 +02:00
|
|
|
|
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-11-27 04:23:36 +01:00
|
|
|
import com.pahimar.ee3.item.WrappedStack;
|
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-11-27 04:23:36 +01:00
|
|
|
WrappedStack stack = new WrappedStack(event.itemStack);
|
2013-10-18 07:23:11 +02:00
|
|
|
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-27 22:42:29 +01:00
|
|
|
event.toolTip.add("EMC: " + String.format("%.3f", 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-27 22:42:29 +01:00
|
|
|
event.toolTip.add(" * " + emcType + ": " + String.format("%.3f", 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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|