本文整理汇总了Java中net.minecraftforge.event.entity.player.ItemTooltipEvent.getItemStack方法的典型用法代码示例。如果您正苦于以下问题:Java ItemTooltipEvent.getItemStack方法的具体用法?Java ItemTooltipEvent.getItemStack怎么用?Java ItemTooltipEvent.getItemStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.player.ItemTooltipEvent
的用法示例。
在下文中一共展示了ItemTooltipEvent.getItemStack方法的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);
}
}
}
}
示例2: 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);
}
}
}
}
示例3: 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));
}
}
示例4: 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());
}
}
示例5: 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"));
}
}
}
示例6: 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()));
}
}
}
示例7: onItemTooltipEvent
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onItemTooltipEvent(ItemTooltipEvent event) {
if (Keyboard.isCreated()
&& (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))) {
// https://www.reddit.com/r/minecraftsuggestions/comments/3brh7v/when_hovering_over_a_food_it_shows_how_many_food/
ItemStack itemStack = event.getItemStack();
if (itemStack == null || itemStack.getItem() == null) {
return;
}
if (foodDetails && itemStack.getItem() instanceof ItemFood) {
ItemFood food = (ItemFood) itemStack.getItem();
int hunger = food.getHealAmount(itemStack);
float satur = food.getSaturationModifier(itemStack);
if (hunger > 0 || satur > 0) {
event.getToolTip().add(hunger + " (" + satur + ")");
}
}
if (fuelDetails) {
int burnTime = TileEntityFurnace.getItemBurnTime(itemStack);
if (burnTime > 0) {
event.getToolTip().add(UtilChat.lang("tooltip.burntime") + burnTime);
}
}
}
}
示例8: 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);
}
}
}
}
示例9: addSeedStatsTooltip
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
/**
* Adds tooltips for SEED stats.
*
* @param event
*/
@SubscribeEvent
public void addSeedStatsTooltip(ItemTooltipEvent event) {
ItemStack stack = event.getItemStack();
// Add Seed Information.
if (stack != null) {
AgriSeed seed = AgriApi.getSeedRegistry().valueOf(stack).orElse(null);
if (seed != null) {
if (seed.getStat().isAnalyzed()) {
seed.getStat().addStats(event.getToolTip()::add);
} else {
event.getToolTip().add(" " + AgriCore.getTranslator().translate("agricraft_tooltip.unidentified"));
}
}
}
}
示例10: onItemHover
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
/**
* Method used to add relavent information to user tooltips.
*
* @param event = event passed.
*/
// @SideOnly(Side.CLIENT)
@SubscribeEvent
public void onItemHover(ItemTooltipEvent event) {
ItemStack stack = event.getItemStack();
if (stack != null) {
insertTileEntityInfo(event, stack);
Block b = Block.getBlockFromItem(stack.getItem());
if (b instanceof BlockAtomicBomb) {
event.getToolTip().add(TextFormatting.GOLD + "WARNING: " + TextFormatting.WHITE + "Highly Destructive!");
event.getToolTip().add(TextFormatting.GREEN + "Unbreakable");
}
}
}
示例11: 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());
}
}
}
}
示例12: onLanolinTooltip
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onLanolinTooltip(ItemTooltipEvent event){
ItemStack stack = event.getItemStack();
if (!stack.isEmpty() && ItemLanolin.canCraftWith(stack) && stack.hasTagCompound()
&& stack.getTagCompound().hasKey("lanolin")) {
String levelKey = "tooltip.lanolin.level." + stack.getTagCompound().getByte("lanolin");
event.getToolTip().add(TextFormatting.DARK_AQUA + "" + TextFormatting.ITALIC +
I18n.format("tooltip.lanolin.lanolin") + " " +
I18n.format(levelKey));
}
}
示例13: showTooltip
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void showTooltip(ItemTooltipEvent event) {
if (event.getItemStack().getItem() != Item.getItemFromBlock(Blocks.MOB_SPAWNER)) return;
ItemStack tooltipper = event.getItemStack();
if (!tooltipper.hasTagCompound() || (tooltipper.hasTagCompound() && !tooltipper.getTagCompound().hasKey("Spawner"))) return;
NBTTagCompound tag = tooltipper.getTagCompound().getCompoundTag("Spawner");
event.getToolTip().add("Mob spawner data:");
event.getToolTip().add(TextFormatting.GOLD + tag.getCompoundTag("SpawnData").getString("id"));
}
示例14: 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(stack.getItem() == Items.ENCHANTED_BOOK && InteractionBWM.HIDDEN_ENCHANTS)
{
event.getToolTip().clear();
event.getToolTip().add(TextFormatting.WHITE+I18n.format("item.ancient_manuscript.name"));
}
}
示例15: onFoodHover
import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onFoodHover(ItemTooltipEvent e)
{
if (e.getItemStack() != null && e.getItemStack().getItem() instanceof ItemFood) {
ItemFood food = (ItemFood) e.getItemStack().getItem();
double healAmount = food.getHealAmount(e.getItemStack());
double saturationModifier = food.getSaturationModifier(e.getItemStack());
df.setRoundingMode(RoundingMode.FLOOR);
if (GuiScreen.isShiftKeyDown())
e.getToolTip().add("H: " + healAmount + " | S: " + df.format(saturationModifier));
else
e.getToolTip().add(I18n.translateToLocalFormatted("tooltip.littlethings.foodrating", String.valueOf(new Double(healAmount * saturationModifier).intValue())));
}
}