2013-12-21 23:16:55 +01:00
|
|
|
package com.pahimar.ee3.client.handler;
|
2013-10-17 04:27:07 +02:00
|
|
|
|
2013-12-20 00:41:22 +01:00
|
|
|
import com.pahimar.ee3.api.WrappedStack;
|
2013-10-17 04:27:07 +02:00
|
|
|
import com.pahimar.ee3.emc.EmcRegistry;
|
2013-10-18 07:23:11 +02:00
|
|
|
import com.pahimar.ee3.emc.EmcValue;
|
2013-12-21 23:16:55 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-12-16 02:26:42 +01:00
|
|
|
import net.minecraftforge.event.ForgeSubscribe;
|
|
|
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
2014-01-03 02:54:54 +01:00
|
|
|
import org.lwjgl.input.Keyboard;
|
2013-10-17 04:27:07 +02:00
|
|
|
|
2013-12-21 23:16:55 +01:00
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
2013-10-17 04:27:07 +02:00
|
|
|
/**
|
|
|
|
* Equivalent-Exchange-3
|
2013-12-16 02:26:42 +01:00
|
|
|
* <p/>
|
2013-10-17 04:27:07 +02:00
|
|
|
* ItemTooltipEventHandler
|
2013-12-16 02:26:42 +01:00
|
|
|
*
|
2013-10-17 04:27:07 +02:00
|
|
|
* @author pahimar
|
|
|
|
*/
|
2013-12-21 23:16:55 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-16 02:26:42 +01:00
|
|
|
public class ItemTooltipEventHandler
|
|
|
|
{
|
2014-01-02 00:18:59 +01:00
|
|
|
private static boolean debug = true;
|
2013-12-21 23:16:55 +01:00
|
|
|
private static DecimalFormat emcDecimalFormat = new DecimalFormat("#.###");
|
2013-10-17 04:27:07 +02:00
|
|
|
|
|
|
|
@ForgeSubscribe
|
2013-12-16 02:26:42 +01:00
|
|
|
public void handleItemTooltipEvent(ItemTooltipEvent event)
|
|
|
|
{
|
2014-01-03 02:54:54 +01:00
|
|
|
if (Keyboard.isKeyDown(29))
|
2013-12-16 02:26:42 +01:00
|
|
|
{
|
2013-12-31 04:58:17 +01:00
|
|
|
WrappedStack stack = new WrappedStack(event.itemStack);
|
2013-10-18 07:23:11 +02:00
|
|
|
|
2013-12-31 04:58:17 +01:00
|
|
|
if (EmcRegistry.getInstance().hasEmcValue(stack))
|
2013-12-16 02:26:42 +01:00
|
|
|
{
|
2013-12-31 04:58:17 +01:00
|
|
|
EmcValue emcValue = EmcRegistry.getInstance().getEmcValue(stack);
|
2014-01-03 02:54:54 +01:00
|
|
|
event.toolTip.add("EMC: " + String.format("%s", emcDecimalFormat.format(stack.getStackSize() * emcValue.getValue())));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
event.toolTip.add("No EMC value");
|
2013-10-18 07:23:11 +02:00
|
|
|
}
|
2013-10-17 04:27:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|