本文整理汇总了Java中net.minecraftforge.event.entity.player.ItemTooltipEvent.getToolTip方法的典型用法代码示例。如果您正苦于以下问题:Java ItemTooltipEvent.getToolTip方法的具体用法?Java ItemTooltipEvent.getToolTip怎么用?Java ItemTooltipEvent.getToolTip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.player.ItemTooltipEvent
的用法示例。
在下文中一共展示了ItemTooltipEvent.getToolTip方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemTooltip
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onItemTooltip(ItemTooltipEvent event)
{
ArrayList<String> tooltip = (ArrayList<String>) event.getToolTip();
ItemStack stack = event.getItemStack();
NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
if (event.getEntityPlayer() != null)
{
PlayerInformation info = (PlayerInformation) event.getEntityPlayer().getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
if (info != null && (stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemLEMagical || stack.getItem() instanceof ItemLEBauble))
{
Rarity rarity = Rarity.getRarity(nbt);
if (rarity != Rarity.DEFAULT)
{
if (stack.getItem() instanceof ItemSword) drawMelee(tooltip, stack, nbt, event.getEntityPlayer(), info);
else if (stack.getItem() instanceof ItemArmor) drawArmor(tooltip, stack, nbt, event.getEntityPlayer(), info);
else if (stack.getItem() instanceof ItemLEMagical) drawMagical(tooltip, stack, nbt, event.getEntityPlayer(), info);
else if (stack.getItem() instanceof ItemLEBauble) drawBauble(tooltip, stack, nbt, event.getEntityPlayer(), info);
}
}
}
}
示例2: onTooltipShow
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
/** Show item damages in their tooltips */
@SubscribeEvent
public void onTooltipShow(ItemTooltipEvent e) {
if(ACConfig.durabilityTooltips && !e.getItemStack().isEmpty() && e.getItemStack().getItem().isDamageable()) {
String modid = e.getItemStack().getItem().getRegistryName().getResourceDomain();
if(!ACConfig.tooltipModBL.contains(modid)) {
int maxDamage = e.getItemStack().getMaxDamage();
int currentDamage = e.getItemStack().getItemDamage();
List<String> t = e.getToolTip();
if(e.getFlags().isAdvanced() && currentDamage > 0) { // remove the vanilla indicator
Iterator<String> it = t.iterator();
while(it.hasNext()) {
String str = it.next();
if(str.contains("Durability")) it.remove();
}
}
t.add(1, TextFormatting.DARK_GRAY + "Durability: " + (maxDamage - currentDamage) + " / " + maxDamage);
}
}
}
示例3: onTooltip
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onTooltip(ItemTooltipEvent event)
{
ArrayList<String> tooltip = (ArrayList<String>) event.getToolTip();
ItemStack stack = event.getItemStack();
NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
if (stack != null && nbt != null)
{
if (stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemBow || stack.getItem() instanceof ItemShield || stack.getItem() instanceof ItemTool)
{
Rarity rarity = Rarity.getRarity(nbt);
if (rarity != Rarity.DEFAULT)
{
addTooltips(tooltip, stack, nbt);
}
}
}
}
示例4: onItemTooltip
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
/**
* Change attribute format when displayed on item tooltip
*
* @param event
*/
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event) {
for (String txt : event.getToolTip()) {
if (txt.startsWith(TextFormatting.BLUE.toString())) {
if (txt.contains(attributeNames[0]) || txt.contains(attributeNames[2]))
event.getToolTip().set(event.getToolTip().indexOf(txt), TextFormatting.DARK_GREEN + TextFormatting.getTextWithoutFormattingCodes(txt));
else if (txt.contains(attributeNames[3]))
event.getToolTip().set(event.getToolTip().indexOf(txt), TextFormatting.DARK_GREEN + reformat(txt, 3));
else if (txt.contains(attributeNames[1]))
event.getToolTip().set(event.getToolTip().indexOf(txt), TextFormatting.GOLD + reformat(txt, 1));
}
}
if(event.getItemStack().getItem() instanceof IBackStabbable){
event.getToolTip().add(TextFormatting.GOLD + I18n.format("attribute.name.weapon.backstab"));
}
}
示例5: drawTooltips
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void drawTooltips(ItemTooltipEvent event) {
ItemStack stack = event.getItemStack();
if (stack.getItem() instanceof IUpgrade) {
IUpgrade upgrade = (IUpgrade) stack.getItem();
List<String> tooltips = event.getToolTip();
Collection<UpgradableBlockType> compatibleBlocks = upgrade.getCompatibleTypes(stack);
for (UpgradableBlockType type : compatibleBlocks) {
tooltips.add(LocalizationHelper.localize("betterchests:tooltip.compatible." + type.name().toLowerCase()));
}
int maxUpgrades = upgrade.getMaxAmountUpgrades(stack);
if (maxUpgrades > 0 && maxUpgrades < Integer.MAX_VALUE) {
tooltips.add(LocalizationHelper.localizeFormatted("betterchests:tooltip.maxUpgrades", maxUpgrades));
}
Collection<ItemStack> requiredUpgrades = upgrade.getRequiredUpgrades(stack);
if (!requiredUpgrades.isEmpty()) {
tooltips.add(LocalizationHelper.localize("betterchests:tooltip.requiredUpgrades"));
for (ItemStack req : requiredUpgrades) {
tooltips.add(" " + req.getDisplayName());
}
}
}
}
示例6: onToolTip
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent
void onToolTip(ItemTooltipEvent event)
{
if (isCorrectModeActive() && isCorrectItem(event.getItemStack()))
{
List<String> toolTip = event.getToolTip();
modifyToolTip(toolTip);
}
}
示例7: onRenderTooltips
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onRenderTooltips(ItemTooltipEvent event) {
EntityPlayer player = event.getEntityPlayer();
ItemStack stack = event.getItemStack();
List<String> tooltip = event.getToolTip();
if (stack == null) return;
handleITooltipHolders(player, stack, tooltip);
handleBaubleHolding(stack, tooltip);
}
示例8: onItemHover
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemHover(ItemTooltipEvent event) {
final ItemStack itemStack = event.getItemStack();
if (itemStack == null) return;
ITooltip<?> tooltip;
final Block block = BlockUtils.getBlockFromItem(itemStack.getItem());
if (block instanceof IBlockTooltip) tooltip = (IBlockTooltip) block;
else if (itemStack.getItem() instanceof ITooltip<?>) tooltip = (ITooltip<?>) itemStack.getItem();
else return;
// ITooltip<?> tooltip = (IBlockTooltip) block;
// final ITooltip<?> tooltip = (IBlockTooltip) itemStack.getItem();
final List<String> list = event.getToolTip();
final boolean hasShiftInfo = tooltip.hasShiftInformation();
final boolean hasControlInfo = tooltip.hasControlInformation();
tooltip.addInformation(list, itemStack);
if (hasShiftInfo) {
list.add("");
if (isShiftKeyDown()) tooltip.addShiftInformation(list, itemStack);
else list.add(shiftInfoTag);
}
if (hasControlInfo) {
if (!hasShiftInfo) list.add("");
if (isControlKeyDown()) tooltip.addControlInformation(list, itemStack);
else list.add(controlInfoTag);
}
}