2015-05-04 17:26:50 +02:00
|
|
|
package ellpeck.actuallyadditions.event;
|
|
|
|
|
|
|
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
2015-08-01 00:30:56 +02:00
|
|
|
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
|
2015-05-04 17:26:50 +02:00
|
|
|
import ellpeck.actuallyadditions.util.KeyUtil;
|
|
|
|
import ellpeck.actuallyadditions.util.ModUtil;
|
|
|
|
import ellpeck.actuallyadditions.util.StringUtil;
|
2015-08-01 00:30:56 +02:00
|
|
|
import net.minecraft.item.Item;
|
2015-05-04 17:26:50 +02:00
|
|
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
|
|
|
import net.minecraftforge.oredict.OreDictionary;
|
|
|
|
|
|
|
|
public class TooltipEvent{
|
|
|
|
|
2015-08-01 00:30:56 +02:00
|
|
|
private static final String TEXT_PRE = StringUtil.GRAY+" ";
|
|
|
|
private static final String HEADER_PRE = StringUtil.LIGHT_GRAY+" -";
|
|
|
|
|
2015-08-01 01:30:50 +02:00
|
|
|
@SubscribeEvent
|
2015-05-04 17:26:50 +02:00
|
|
|
public void onTooltipEvent(ItemTooltipEvent event){
|
2015-08-01 00:30:56 +02:00
|
|
|
if(event.itemStack.getItem() != null){
|
2015-08-02 09:58:36 +02:00
|
|
|
if(ConfigBoolValues.CTRL_EXTRA_INFO.isEnabled()){
|
|
|
|
if(KeyUtil.isControlPressed()){
|
2015-08-01 00:40:29 +02:00
|
|
|
event.toolTip.add(StringUtil.GRAY+StringUtil.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".extraInfo.desc")+":");
|
2015-08-01 00:30:56 +02:00
|
|
|
|
|
|
|
//OreDict Names
|
|
|
|
int[] oreIDs = OreDictionary.getOreIDs(event.itemStack);
|
2015-08-01 00:40:29 +02:00
|
|
|
event.toolTip.add(HEADER_PRE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".oredictName.desc")+":");
|
2015-08-01 00:30:56 +02:00
|
|
|
if(oreIDs.length > 0){
|
|
|
|
for(int oreID : oreIDs){
|
|
|
|
event.toolTip.add(TEXT_PRE+OreDictionary.getOreName(oreID));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
2015-08-01 00:40:29 +02:00
|
|
|
event.toolTip.add(TEXT_PRE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".noOredictNameAvail.desc"));
|
2015-08-01 00:30:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Code Name
|
2015-08-01 00:40:29 +02:00
|
|
|
event.toolTip.add(HEADER_PRE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".codeName.desc")+":");
|
2015-08-01 00:30:56 +02:00
|
|
|
event.toolTip.add(TEXT_PRE+Item.itemRegistry.getNameForObject(event.itemStack.getItem()));
|
|
|
|
|
|
|
|
//Base Item's Unlocalized Name
|
|
|
|
String baseName = event.itemStack.getItem().getUnlocalizedName();
|
2015-08-02 01:52:12 +02:00
|
|
|
if(baseName != null){
|
|
|
|
event.toolTip.add(HEADER_PRE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".baseUnlocName.desc")+":");
|
|
|
|
event.toolTip.add(TEXT_PRE+baseName);
|
|
|
|
}
|
2015-08-01 00:30:56 +02:00
|
|
|
|
|
|
|
//Unlocalized Name
|
|
|
|
String metaName = event.itemStack.getItem().getUnlocalizedName(event.itemStack);
|
2015-08-02 01:52:12 +02:00
|
|
|
if(metaName != null && baseName != null && !metaName.equals(baseName)){
|
2015-08-01 00:40:29 +02:00
|
|
|
event.toolTip.add(HEADER_PRE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".unlocName.desc")+":");
|
2015-08-01 00:30:56 +02:00
|
|
|
event.toolTip.add(TEXT_PRE+metaName);
|
|
|
|
}
|
|
|
|
}
|
2015-08-02 09:58:36 +02:00
|
|
|
else{
|
|
|
|
if(ConfigBoolValues.CTRL_INFO_FOR_EXTRA_INFO.isEnabled()){
|
|
|
|
event.toolTip.add(StringUtil.GRAY+StringUtil.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".ctrlForMoreInfo.desc"));
|
|
|
|
}
|
2015-05-04 17:26:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|