mirror of
https://github.com/GTNewHorizons/Baubles-Expanded.git
synced 2026-10-26 14:23:55 +00:00
Added a tooltip helper function
This commit is contained in:
1 parent
ec95fb65ee
commit
fed6530d9d
3 files changed
+44
-17
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package baubles.api.expanded;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BaubleItemHelper {
|
||||
|
||||
/**
|
||||
* Adds compatible slot information to an item's tooltip, but only when shift is held.
|
||||
*
|
||||
* @param tooltip The tooltip list.
|
||||
* @param types The item's types.
|
||||
* @return If shift was held.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static boolean addSlotInformation(List tooltip, String[] types) {
|
||||
boolean shiftHeld = GuiScreen.isShiftKeyDown();
|
||||
if(shiftHeld) {
|
||||
tooltip.add(StatCollector.translateToLocal("tooltip.compatibleslots"));
|
||||
for(int i = 0; i < types.length; i++) {
|
||||
String type = StatCollector.translateToLocal("slot." + types[i]);
|
||||
if(i < types.length - 1) type += ",";
|
||||
tooltip.add(type);
|
||||
}
|
||||
} else {
|
||||
tooltip.add(StatCollector.translateToLocal("tooltip.shiftprompt"));
|
||||
}
|
||||
return shiftHeld;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,10 +4,10 @@ import java.util.List;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.expanded.BaubleExpandedSlots;
|
||||
import baubles.api.expanded.BaubleItemHelper;
|
||||
import baubles.api.expanded.IBaubleExpanded;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -15,7 +15,6 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
public class ItemDebugger extends Item implements IBaubleExpanded {
|
||||
|
||||
@@ -28,7 +27,7 @@ public class ItemDebugger extends Item implements IBaubleExpanded {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon[] icons;
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerIcons(IIconRegister ir) {
|
||||
@@ -72,18 +71,7 @@ public class ItemDebugger extends Item implements IBaubleExpanded {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean debug) {
|
||||
if(GuiScreen.isShiftKeyDown()) {
|
||||
tooltip.add(StatCollector.translateToLocal("tooltip.compatibleslots"));
|
||||
|
||||
String[] types = getBaubleTypes(stack);
|
||||
for(int i = 0; i < types.length; i++) {
|
||||
String type = StatCollector.translateToLocal("slot." + types[i]);
|
||||
if(i < types.length - 1) type += ",";
|
||||
tooltip.add(type);
|
||||
}
|
||||
} else {
|
||||
tooltip.add(StatCollector.translateToLocal("tooltip.shiftprompt"));
|
||||
}
|
||||
BaubleItemHelper.addSlotInformation(tooltip, getBaubleTypes(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,7 +105,7 @@ public class ItemDebugger extends Item implements IBaubleExpanded {
|
||||
public boolean canUnequip(ItemStack itemStack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getBackgroundIconForSlotType(String type) {
|
||||
if(type != null && BaubleExpandedSlots.isTypeRegistered(type)) {
|
||||
|
||||
@@ -10,18 +10,22 @@ button.normal=Normal
|
||||
keybind.baublesinventory=Baubles Inventory
|
||||
#
|
||||
# Tooltips
|
||||
tooltip.compatibleslots=Equippable in the following Bauble slots:
|
||||
tooltip.compatibleslots=Equippable in the following slots:
|
||||
tooltip.shiftprompt=Hold §bSHIFT§7 for more info.
|
||||
#
|
||||
# Slots
|
||||
slot.amulet=§aAmulet§7
|
||||
slot.belt=§aBelt§7
|
||||
slot.body=§aBody§7
|
||||
slot.boots=§aBoots§7
|
||||
slot.cape=§aCape§7
|
||||
slot.charm=§aCharm§7
|
||||
slot.chestplate=§aChestplate§7
|
||||
slot.earring=§aEarring§7
|
||||
slot.gauntlet=§aGauntlet§7
|
||||
slot.head=§aHead§7
|
||||
slot.helmet=§aHelmet§7
|
||||
slot.leggings=§aLeggings§7
|
||||
slot.quiver=§aQuiver§7
|
||||
slot.ring=§aRing§7
|
||||
slot.shield=§aShield§7
|
||||
|
||||
Reference in new issue
Block a user