Fixes #212 now you need to hold shift to see our info

This commit is contained in:
modmuss50 2015-11-01 16:10:36 +00:00
parent 2f88e819a3
commit 12cfe38a50

View file

@ -16,35 +16,36 @@ public class StackToolTipEvent {
@SubscribeEvent
public void handleItemTooltipEvent(ItemTooltipEvent event) {
if(event.itemStack.getItem() instanceof IListInfoProvider){
if (event.itemStack.getItem() instanceof IListInfoProvider) {
((IListInfoProvider) event.itemStack.getItem()).addInfo(event.toolTip, false);
} else if (event.itemStack.getItem() instanceof IEnergyInterfaceItem){
int percentage = percentage((int)((IEnergyInterfaceItem) event.itemStack.getItem()).getMaxPower(event.itemStack), (int)((IEnergyInterfaceItem) event.itemStack.getItem()).getEnergy(event.itemStack));
ChatFormatting color;
if(percentage<= 10){
color = ChatFormatting.RED;
} else if(percentage >= 75){
color = ChatFormatting.GREEN;
} else {
color = ChatFormatting.YELLOW;
}
event.toolTip.add(color + "" + (int)((IEnergyInterfaceItem) event.itemStack.getItem()).getEnergy(event.itemStack) + ChatFormatting.LIGHT_PURPLE + " stored eu");
event.toolTip.add(Color.GREEN + "" + (int)((IEnergyInterfaceItem) event.itemStack.getItem()).getMaxPower(event.itemStack) + ChatFormatting.LIGHT_PURPLE + " max eu");
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)){
event.toolTip.add(ChatFormatting.GREEN +"" + percentage + "%" + ChatFormatting.LIGHT_PURPLE +" charged");
event.toolTip.add(Color.GREEN + "" + (int)((IEnergyInterfaceItem) event.itemStack.getItem()).getMaxTransfer(event.itemStack) + ChatFormatting.LIGHT_PURPLE + " eu/tick in/out");
} else if (event.itemStack.getItem() instanceof IEnergyInterfaceItem) {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
int percentage = percentage((int) ((IEnergyInterfaceItem) event.itemStack.getItem()).getMaxPower(event.itemStack), (int) ((IEnergyInterfaceItem) event.itemStack.getItem()).getEnergy(event.itemStack));
ChatFormatting color;
if (percentage <= 10) {
color = ChatFormatting.RED;
} else if (percentage >= 75) {
color = ChatFormatting.GREEN;
} else {
color = ChatFormatting.YELLOW;
}
event.toolTip.add(color + "" + (int) ((IEnergyInterfaceItem) event.itemStack.getItem()).getEnergy(event.itemStack) + ChatFormatting.LIGHT_PURPLE + " stored eu");
event.toolTip.add(Color.GREEN + "" + (int) ((IEnergyInterfaceItem) event.itemStack.getItem()).getMaxPower(event.itemStack) + ChatFormatting.LIGHT_PURPLE + " max eu");
event.toolTip.add(ChatFormatting.GREEN + "" + percentage + "%" + ChatFormatting.LIGHT_PURPLE + " charged");
event.toolTip.add(Color.GREEN + "" + (int) ((IEnergyInterfaceItem) event.itemStack.getItem()).getMaxTransfer(event.itemStack) + ChatFormatting.LIGHT_PURPLE + " eu/tick in/out");
}
} else {
Block block = Block.getBlockFromItem(event.itemStack.getItem());
if(block != null && block instanceof BlockContainer && block.getClass().getCanonicalName().startsWith("techreborn.")){
if (block != null && block instanceof BlockContainer && block.getClass().getCanonicalName().startsWith("techreborn.")) {
TileEntity tile = block.createTileEntity(Minecraft.getMinecraft().theWorld, event.itemStack.getItemDamage());
if(tile instanceof IListInfoProvider){
if (tile instanceof IListInfoProvider) {
((IListInfoProvider) tile).addInfo(event.toolTip, false);
}
}
}
}
public int percentage(int MaxValue, int CurrentValue) {
if (CurrentValue == 0)
return 0;