mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-22 12:59:49 +00:00
Tooltip utils
This commit is contained in:
1 parent
bcc4586d5d
commit
69ffb6314e
3 files changed
+57
-14
No files matched your search
@@ -0,0 +1,21 @@
|
||||
package slimeknights.mantle.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemArmorTooltip extends ItemArmor {
|
||||
|
||||
public ItemArmorTooltip(ArmorMaterial armorMaterial, int renderIndex, EntityEquipmentSlot equipmentSlot) {
|
||||
super(armorMaterial, renderIndex, equipmentSlot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack p_addInformation_1_, EntityPlayer p_addInformation_2_, List<String> p_addInformation_3_, boolean p_addInformation_4_) {
|
||||
ItemTooltip.addOptionalTooltip(p_addInformation_1_, p_addInformation_3_);
|
||||
super.addInformation(p_addInformation_1_, p_addInformation_2_, p_addInformation_3_, p_addInformation_4_);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ import slimeknights.mantle.util.LocUtils;
|
||||
* Only returns valid metadatas. The validity is determined by a bitmask.
|
||||
* Current maximum is 64 metas - that should suffice for most applications.
|
||||
*/
|
||||
public class ItemMetaDynamic extends Item {
|
||||
public class ItemMetaDynamic extends ItemTooltip {
|
||||
|
||||
private static int MAX = (2 << 16) - 1;
|
||||
|
||||
@@ -122,17 +122,4 @@ public class ItemMetaDynamic extends Item {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
if(I18n.canTranslate(this.getUnlocalizedName(stack) + ".tooltip")) {
|
||||
tooltip.addAll(LocUtils.getTooltips(TextFormatting.GRAY.toString() +
|
||||
LocUtils.translateRecursive(this.getUnlocalizedName(stack) + ".tooltip")));
|
||||
}
|
||||
else if(I18n.canTranslate(super.getUnlocalizedName(stack) + ".tooltip")) {
|
||||
tooltip.addAll(LocUtils.getTooltips(
|
||||
TextFormatting.GRAY.toString() + LocUtils.translateRecursive(super.getUnlocalizedName(stack) + ".tooltip")));
|
||||
}
|
||||
super.addInformation(stack, playerIn, tooltip, advanced);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package slimeknights.mantle.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import slimeknights.mantle.util.LocUtils;
|
||||
|
||||
// Item with automatic tooltip support
|
||||
public class ItemTooltip extends Item {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
addOptionalTooltip(stack, tooltip);
|
||||
super.addInformation(stack, playerIn, tooltip, advanced);
|
||||
}
|
||||
|
||||
public static void addOptionalTooltip(ItemStack stack, List<String> tooltip) {
|
||||
if(I18n.canTranslate(stack.getUnlocalizedName() + ".tooltip")) {
|
||||
tooltip.addAll(LocUtils.getTooltips(TextFormatting.GRAY.toString() +
|
||||
LocUtils.translateRecursive(stack.getUnlocalizedName() + ".tooltip")));
|
||||
}
|
||||
else if(I18n.canTranslate(stack.getUnlocalizedName() + ".tooltip")) {
|
||||
tooltip.addAll(LocUtils.getTooltips(
|
||||
TextFormatting.GRAY.toString() + LocUtils.translateRecursive(stack.getUnlocalizedName() + ".tooltip")));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user