Tic Tooltips support for the leveling tooltips

This commit is contained in:
Bernhard Bonigl committed 2014-07-17 20:58:40 +02:00
1 parent 54b95dc228
commit 183d9f132a
1 file changed
+35 -4
@@ -1,9 +1,11 @@
package iguanaman.iguanatweakstconstruct.leveling.handlers;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import iguanaman.iguanatweakstconstruct.leveling.LevelingLogic;
import iguanaman.iguanatweakstconstruct.leveling.LevelingTooltips;
import iguanaman.iguanatweakstconstruct.reference.IguanaConfig;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
@@ -29,11 +31,15 @@ public class ToolTipHandler {
if(!(event.itemStack.getItem() instanceof ToolCore))
return;
// don't display tooltip when CTRL is held (also tic tooltips compatibility)
if(ctrlHeld())
return;
ItemStack stack = event.itemStack;
// find spot to insert our tooltip data
ListIterator<String> inserter = findInsertSpot(event.toolTip);
// does the user hold shift?
boolean advanced = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
boolean advanced = shiftHeld();
// only allow advanced (xp) tooltip if config option is set
advanced &= IguanaConfig.showTooltipXP;
@@ -81,7 +87,7 @@ public class ToolTipHandler {
inserter.add("");
// add info that you can hold shift for more details
if(!advanced && IguanaConfig.showTooltipXP)
if(!advanced && IguanaConfig.showTooltipXP && !Loader.isModLoaded("TiCTooltips")) // don't display if TicToolTips is installed
event.toolTip.add(EnumChatFormatting.GRAY.toString() + EnumChatFormatting.ITALIC.toString() + "Hold SHIFT for XP");
}
@@ -91,14 +97,39 @@ public class ToolTipHandler {
// progress to the end, check if there's a "+ damage" stuff
while(iterator.hasNext())
if(iterator.next().startsWith(plusPrefix))
{
{
String str = iterator.next();
if (str.isEmpty() || str.startsWith(plusPrefix)) {
iterator.previous();
break;
}
else if(Loader.isModLoaded("TiCTooltips") && str.contains("Shift")) {
iterator.previous();
break;
}
}
// iterator.previous();
// we're either directly before the "+ damage" or at the end now
return iterator;
}
// all hail ticTooltips for that information ;)
private boolean shiftHeld()
{
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
}
private boolean ctrlHeld()
{
// prioritize CONTROL, but allow OPTION as well on Mac (note: GuiScreen's isCtrlKeyDown only checks for the OPTION key on Mac)
boolean isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
if (!isCtrlKeyDown && Minecraft.isRunningOnMac)
isCtrlKeyDown = Keyboard.isKeyDown(Keyboard.KEY_LMETA) || Keyboard.isKeyDown(Keyboard.KEY_RMETA);
return isCtrlKeyDown;
}
}