当前位置: 首页>>代码示例>>Java>>正文


Java ItemTooltipEvent类代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.player.ItemTooltipEvent的典型用法代码示例。如果您正苦于以下问题:Java ItemTooltipEvent类的具体用法?Java ItemTooltipEvent怎么用?Java ItemTooltipEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ItemTooltipEvent类属于net.minecraftforge.event.entity.player包,在下文中一共展示了ItemTooltipEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:26,代码来源:EventItemTooltip.java

示例2: handleFluidContainerTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
private void handleFluidContainerTooltip(ItemTooltipEvent event) {
    FluidStack fluidStack = FluidUtil.getFluidContained(event.getItemStack());
    if (fluidStack != null && fluidStack.amount > 0) {
        String key = "gui.tooltip.item." + fluidStack.getFluid().getName() + "_bucket";
        if (I18n.hasKey(key)) {
            if (event.getToolTip().get(event.getToolTip().size() - 1).contains("Minecraft Forge")) {
                // bit of a kludge!  otherwise the blue "Minecraft Forge" string gets shown twice
                event.getToolTip().remove(event.getToolTip().size() - 1);
            }
            String prefix = "";
            if (!FluidRegistry.getDefaultFluidName(fluidStack.getFluid()).startsWith(Names.MOD_ID)) {
                // fluid is owned by another mod; let's make it clear that this tooltip applies to PneumaticCraft
                prefix = TextFormatting.DARK_AQUA + "" + TextFormatting.ITALIC + "[" + Names.MOD_NAME + "] ";
            }
            if (PneumaticCraftRepressurized.proxy.isSneakingInGui()) {
                String translatedInfo = TextFormatting.AQUA + I18n.format(key);
                event.getToolTip().addAll(PneumaticCraftUtils.convertStringIntoList(prefix + translatedInfo, 40));
            } else {
                event.getToolTip().add(TextFormatting.AQUA + I18n.format("gui.tooltip.sneakForInfo"));
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:24,代码来源:ClientEventHandler.java

示例3: handleTooltipEvent

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleTooltipEvent(ItemTooltipEvent event)
{
	NBTTagCompound baseTag = event.getItemStack().getTagCompound();
	if (baseTag != null &&  baseTag.hasKey("sockets"))
	{
		NBTTagCompound tag = (NBTTagCompound) event.getItemStack().getTagCompound().getTag("sockets");
		
		for (int i = 0 ; i < tag.getInteger("number") ; i++)
		{
			if (tag.getString("socket-"+i)=="none")
			{
				event.getToolTip().add("Socket "+(i+1)+": Empty");
			}
			if (tag.getString("socket-"+i)=="diamond")
			{
				event.getToolTip().add("Socket "+(i+1)+": diamond");
			}
		}
	}
}
 
开发者ID:MikeLydeamore,项目名称:Jewelcrafting,代码行数:23,代码来源:TooltipHandler.java

示例4: onItemTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent ev)
{
	ItemStack itemStack = ev.getItemStack();

	if (itemStack.getItem() instanceof IClassifiedItem)
	{
		IClassifiedItem classifiedItem = (IClassifiedItem)itemStack.getItem();
		String transItemClass = I18n.translateToLocal("compositegear.itemclass");

		ev.getToolTip().add(1, transItemClass + ": " + classifiedItem.getItemClass().getLocalized());
		
		if (itemStack.getItem() instanceof ItemCGArmor) {
			String transItemDesc = I18n.translateToLocal("compositegear.itemdesc");
			
			
			if (((ItemCGArmor)itemStack.getItem()).hasDescription()) {
				String descriptionString = I18n.translateToLocal(itemStack.getItem().getUnlocalizedName() + ".description");
				ev.getToolTip().add(2, transItemDesc + ": " + descriptionString);
			}
		}
	}
}
 
开发者ID:TwilightWingsStudio,项目名称:CompositeGear,代码行数:25,代码来源:ClientEventHandler.java

示例5: addTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
@SubscribeEvent
public void addTooltip(ItemTooltipEvent event) {
	
	if (event.getItemStack().hasTagCompound() && event.getItemStack().getTagCompound().getBoolean("Australium") && !(event.getItemStack().getItem() instanceof ItemFromData)
			&& !event.getItemStack().hasDisplayName()) {
		event.getToolTip().set(0, "Australium " + event.getToolTip().get(0));
	}
	if (event.getItemStack().hasTagCompound() && event.getItemStack().getTagCompound().getBoolean("Strange")) {
		if (!(event.getItemStack().getItem() instanceof ItemFromData) && !event.getItemStack().hasDisplayName()) {
			event.getToolTip().set(0, TF2EventsCommon.STRANGE_TITLES[event.getItemStack().getTagCompound().getInteger("StrangeLevel")] + " " + event.getToolTip().get(0));
		}

		event.getToolTip().add("");
		if (event.getItemStack().getItem() instanceof ItemMedigun) {
			event.getToolTip().add("Ubercharges: " + event.getItemStack().getTagCompound().getInteger("Ubercharges"));
		} else if (event.getItemStack().getItem() instanceof ItemCloak) {
			event.getToolTip().add("Seconds cloaked: " + event.getItemStack().getTagCompound().getInteger("CloakTicks") / 20);
		} else {
			event.getToolTip().add("Mob kills: " + event.getItemStack().getTagCompound().getInteger("Kills"));
			event.getToolTip().add("Player kills: " + event.getItemStack().getTagCompound().getShort("PlayerKills"));
		}
	}
	
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:25,代码来源:TF2EventsClient.java

示例6: 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);
		}
	}
}
 
开发者ID:sblectric,项目名称:AdvancedCombat,代码行数:21,代码来源:InformationHandler.java

示例7: renderQuartzTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGH)
@SideOnly(Side.CLIENT)
public void renderQuartzTooltip(ItemTooltipEvent event)
{
    ItemStack stack = event.getItemStack();
    if(stack == null)
        return;
    NBTTagCompound compound = stack.getTagCompound();

    if(!stack.isEmpty() && compound != null && compound.hasKey("QuartzCrystal"))
    {
        int growth = compound.getInteger("QuartzCrystalGrowth");
        int souls = compound.getInteger("QuartzSouls");
        event.getToolTip().add(TextFormatting.LIGHT_PURPLE+getSaturationString(growth,false));
        if(souls > 0)
            event.getToolTip().add(TextFormatting.DARK_RED+getSoulString(souls,27,false));
    }
}
 
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:19,代码来源:RenewablesHandler.java

示例8: onToolTip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
@SideOnly(Side.CLIENT)
public void onToolTip(ItemTooltipEvent event)
{
    ItemStack stack = event.getItemStack();

    if(isRottingItem(stack))
    {
        long timeOfCreation = getCreationDate(stack);
        if(timeOfCreation == -1)
            return;

        for(RotInfo info : rottingItems.get(stack.getItem())) {
            if(info.matches(stack)) {
                String prefix =  I18n.format(info.getUnlocalizedName(stack, timeOfCreation));
                if(prefix.length() > 0)
                    prefix = prefix + " ";

                event.getToolTip().set(0,prefix + event.getToolTip().get(0));
                break;
            }
        }
    }
}
 
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:25,代码来源:RotHandler.java

示例9: onTooltipEvent

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
@SubscribeEvent
public void onTooltipEvent(ItemTooltipEvent event) {
    ItemStack stack = event.getItemStack();
    if (stack.getItem() == Items.extractor) {
        event.getToolTip().subList(1, event.getToolTip().size()).clear();
        int malgra = 0;
        int maxMalgra = 0;
        if (stack.hasTagCompound()) {
            malgra = stack.getTagCompound().getInteger("malgra");
            ExtractorContainer container = (ExtractorContainer) (ForgeRegistries.ITEMS.getValue(new ResourceLocation(stack.getTagCompound().getString("container"))));
            maxMalgra = container.getStorage();
        } else {
            stack.setTagCompound(new NBTTagCompound());
            stack.getTagCompound().setInteger("malgra", malgra);
            stack.getTagCompound().setString("container", Items.tinyContainer.getUnlocalizedName().substring(5));
        }
        event.getToolTip().add(Utils.translateToLocal("item.manaExtractor.malgraStored") + ": " + malgra + "/" + maxMalgra);
        if (stack.hasTagCompound()) {
            ExtractorTip tip = (ExtractorTip) (ForgeRegistries.ITEMS.getValue(new ResourceLocation(stack.getTagCompound().getString("tip"))));
            if (tip != null)
                event.getToolTip().add((tip.getMaterial().getDamageVsEntity() + 4) + " " + Utils.translateToLocal("attribute.name.generic.attackDamage"));
        }
    }
}
 
开发者ID:Ohrm,项目名称:Malgra,代码行数:25,代码来源:Extractor.java

示例10: addTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@SubscribeEvent
public void addTooltip(ItemTooltipEvent e) {
	if (!e.getItemStack().isEmpty()) {
		Minecraft mc = Minecraft.getMinecraft();
		if (mc.currentScreen instanceof GuiContainer) {
			GuiContainer c = (GuiContainer) mc.currentScreen;
			if (c.inventorySlots != null) {
				for (int i = 0;i < c.inventorySlots.inventorySlots.size();i++) {
					Slot s = c.inventorySlots.inventorySlots.get(i);
					if (s instanceof ITooltipSlot && e.getItemStack() == s.getStack() && ((ITooltipSlot) s).showTooltip()) {
						ITooltipSlot t = (ITooltipSlot) s;
						t.getTooltip(e.getToolTip());
					}
				}
			}
		}
		if (tooltipOverrideFast.containsKey(e.getItemStack().getItem())) {
			Entry<String, String> entry = tooltipOverrideFast.get(e.getItemStack().getItem());
			e.getToolTip().addAll((Collection<? extends String>) Arrays.asList((I18n.format(entry.getValue())).split("/n")).stream().map(s -> entry.getKey() + s).collect(Collectors.<String>toList()));
		}
	}
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:24,代码来源:EventHandlerClient.java

示例11: addTooltips

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
/** Adds block weight to non BlockBuildingAbstract tooltips if config. */
@SubscribeEvent
public void addTooltips(ItemTooltipEvent event) {
    
    if (GeoConfig.textVisual.buildTooltips) {
        
        Item item = event.getItemStack().getItem();
        Block block = Block.getBlockFromItem(item);
        
        if (item instanceof ItemBlock) {
        
            event.getToolTip().add(I18n.format(EBlockWeight
                    .getWeight(block.getDefaultState()).supports()));
        }
    }
}
 
开发者ID:JayAvery,项目名称:geomastery,代码行数:17,代码来源:ClientEvents.java

示例12: onToolTipEvent

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
@SubscribeEvent(priority = LOWEST)
@SuppressWarnings("unused")
public void onToolTipEvent(ItemTooltipEvent event) {
    if(event.getItemStack() ==null) {
        return;
    }
    if(ConfigurationHandler.getInstance().tooltipOnLinkItems && BoatLinker.getInstance().isValidLinkKey(event.getItemStack())) {
        this.addBoatLinkTooltip(event.getToolTip());
    }
    if(ConfigurationHandler.getInstance().tooltipOnChests && event.getItemStack().getItem() == Item.getItemFromBlock(Blocks.CHEST)) {
        this.addChestBoatTooltip(event.getToolTip());
    }
    if(ConfigurationHandler.getInstance().tooltipOnBoats && event.getItemStack().getItem() instanceof ItemBoat) {
        this.addBoatTooltip(event.getToolTip());
    }
}
 
开发者ID:InfinityRaider,项目名称:Boatifull,代码行数:17,代码来源:TooltipHandler.java

示例13: itemTooltipEvent

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
@SubscribeEvent
public void itemTooltipEvent(ItemTooltipEvent event) {

    if (instanceTooltipHandlers != null && Minecraft.getMinecraft().currentScreen != null) {
        GuiScreen screen = Minecraft.getMinecraft().currentScreen;

        Point mousePos = GuiDraw.getMousePosition();

        instanceTooltipHandlers.forEach(handler -> handler.handleTooltip(screen, mousePos.x, mousePos.y, event.getToolTip()));

        if (screen instanceof GuiContainer) {
            GuiContainer container = ((GuiContainer) screen);
            instanceTooltipHandlers.forEach(handler -> handler.handleItemDisplayName(screen, GuiHelper.getStackMouseOver(container, true), event.getToolTip()));
        }
    }
}
 
开发者ID:TheCBProject,项目名称:NotEnoughItems,代码行数:17,代码来源:NEIClientEventHandler.java

示例14: onToolTip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
@SubscribeEvent
public void onToolTip( ItemTooltipEvent pEvent )
{
  if( pEvent.entity == null ) {
    return;
  }
  CustomToolTips.ItemToolTip itt = _mCustomToolTips.FindItemToolTip( pEvent.itemStack );
  if( itt != null )
  {
      String[] tToolTips = itt.getToolTip().split("\\\\n");

    for( String tPartTip : tToolTips ) {
      pEvent.toolTip.add(tPartTip.replace("&", "§"));
    }
  }
}
 
开发者ID:GTNewHorizons,项目名称:NewHorizonsCoreMod,代码行数:17,代码来源:CustomToolTipsHandler.java

示例15: onTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入依赖的package包/类
@SubscribeEvent
public void onTooltip(ItemTooltipEvent event) {
    NBTTagCompound tag = event.itemStack.getTagCompound();
    if(tag != null) {
        if(tag.hasKey("CanDestroy", Constants.NBT.TAG_LIST)) {
            event.toolTip.add("");
            event.toolTip.add("Can break:");
            addBlockList(tag.getTagList("CanDestroy", Constants.NBT.TAG_STRING), event.toolTip);
        }
        if(tag.hasKey("CanPlaceOn", Constants.NBT.TAG_LIST)) {
            event.toolTip.add("");
            event.toolTip.add("Can be placed on:");
            addBlockList(tag.getTagList("CanPlaceOn", Constants.NBT.TAG_STRING), event.toolTip);
        }
    }
}
 
开发者ID:ljfa-ag,项目名称:Adventure-Backport,代码行数:17,代码来源:TooltipHandler.java


注:本文中的net.minecraftforge.event.entity.player.ItemTooltipEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。