org.bukkit.inventory.ItemStack.setTypeId()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.bukkit.inventory.ItemStack.setTypeId()方法的一些代码示例,展示了ItemStack.setTypeId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ItemStack.setTypeId()方法的具体详情如下:
包路径:org.bukkit.inventory.ItemStack
类名称:ItemStack
方法名:setTypeId

ItemStack.setTypeId介绍

[英]Sets the type id of this item

Note that in doing so you will reset the MaterialData for this stack
[中]设置此项目的类型id
请注意,这样做会重置此堆栈的MaterialData

代码示例

代码示例来源:origin: Bukkit/Bukkit

/**
 * Sets the type of this item
 * <p>
 * Note that in doing so you will reset the MaterialData for this stack
 *
 * @param type New type to set the items in this stack to
 */
@Utility
public void setType(Material type) {
  Validate.notNull(type, "Material cannot be null");
  setTypeId(type.getId());
}

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * Sets the type of this item
 * <p>
 * Note that in doing so you will reset the MaterialData for this stack
 *
 * @param type New type to set the items in this stack to
 */
@Utility
public void setType(Material type) {
  Validate.notNull(type, "Material cannot be null");
  setTypeId(type.getId());
}

代码示例来源:origin: bergerkiller/BKCommonLib

/**
 * Transfers the item type, data and enchantments from one item stack to the other
 * 
 * @param from which Item Stack to read the info
 * @param to which Item Stack to transfer the info to
 */
@SuppressWarnings("deprecation")
public static void transferInfo(org.bukkit.inventory.ItemStack from, org.bukkit.inventory.ItemStack to) {
  // Transfer type, durability and any other remaining metadata information
  to.setTypeId(from.getTypeId());
  to.setDurability(from.getDurability());
  setMetaTag(to, LogicUtil.clone(getMetaTag(from)));
}

相关文章