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

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

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

ItemStack.getType0介绍

暂无

代码示例

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

private Material getType0() {
  return getType0(this.type);
}

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

/**
 * Set the ItemMeta of this ItemStack.
 *
 * @param itemMeta new ItemMeta, or null to indicate meta data be cleared.
 * @return True if successfully applied ItemMeta, see {@link
 *     ItemFactory#isApplicable(ItemMeta, ItemStack)}
 * @throws IllegalArgumentException if the item meta was not created by
 *     the {@link ItemFactory}
 */
public boolean setItemMeta(ItemMeta itemMeta) {
  return setItemMeta0(itemMeta, getType0());
}

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

/**
 * Gets the type of this item
 *
 * @return Type of the items in this stack
 */
@Utility
public Material getType() {
  return getType0(getTypeId());
}

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

/**
 * Sets the type id of this item
 * <p>
 * Note that in doing so you will reset the MaterialData for this stack
 *
 * @param type New type id to set the items in this stack to
 * @deprecated Magic value
 */
@Deprecated
public void setTypeId(int type) {
  this.type = type;
  if (this.meta != null) {
    this.meta = Bukkit.getItemFactory().asMetaFor(meta, getType0());
  }
  createData((byte) 0);
}

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

/**
 * Get a copy of this ItemStack's {@link ItemMeta}.
 *
 * @return a copy of the current ItemStack's ItemData
 */
public ItemMeta getItemMeta() {
  return this.meta == null ? Bukkit.getItemFactory().getItemMeta(getType0()) : this.meta.clone();
}

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

/**
 * Adds the specified {@link Enchantment} to this item stack.
 * <p>
 * If this item stack already contained the given enchantment (at any
 * level), it will be replaced.
 * <p>
 * This method is unsafe and will ignore level restrictions or item type.
 * Use at your own discretion.
 *
 * @param ench Enchantment to add
 * @param level Level of the enchantment
 */
public void addUnsafeEnchantment(Enchantment ench, int level) {
  (meta == null ? meta = Bukkit.getItemFactory().getItemMeta(getType0()) : meta).addEnchant(ench, level, true);
}

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

/**
 * Creates a new item stack derived from the specified stack
 *
 * @param stack the stack to copy
 * @throws IllegalArgumentException if the specified stack is null or
 *     returns an item meta not created by the item factory
 */
public ItemStack(final ItemStack stack) throws IllegalArgumentException {
  Validate.notNull(stack, "Cannot copy null stack");
  this.type = stack.getTypeId();
  this.amount = stack.getAmount();
  this.durability = stack.getDurability();
  this.data = stack.getData();
  if (stack.hasItemMeta()) {
    setItemMeta0(stack.getItemMeta(), getType0());
  }
}

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

private Material getType0() {
  return getType0(this.type);
}

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

/**
 * Set the ItemMeta of this ItemStack.
 *
 * @param itemMeta new ItemMeta, or null to indicate meta data be cleared.
 * @return True if successfully applied ItemMeta, see {@link
 *     ItemFactory#isApplicable(ItemMeta, ItemStack)}
 * @throws IllegalArgumentException if the item meta was not created by
 *     the {@link ItemFactory}
 */
public boolean setItemMeta(ItemMeta itemMeta) {
  return setItemMeta0(itemMeta, getType0());
}

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

/**
 * Gets the type of this item
 *
 * @return Type of the items in this stack
 */
@Utility
public Material getType() {
  return getType0(getTypeId());
}

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

/**
 * Get a copy of this ItemStack's {@link ItemMeta}.
 *
 * @return a copy of the current ItemStack's ItemData
 */
public ItemMeta getItemMeta() {
  return this.meta == null ? Bukkit.getItemFactory().getItemMeta(getType0()) : this.meta.clone();
}

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

/**
 * Sets the type id of this item
 * <p>
 * Note that in doing so you will reset the MaterialData for this stack
 *
 * @param type New type id to set the items in this stack to
 * @deprecated Magic value
 */
@Deprecated
public void setTypeId(int type) {
  this.type = type;
  if (this.meta != null) {
    this.meta = Bukkit.getItemFactory().asMetaFor(meta, getType0());
  }
  createData((byte) 0);
}

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

/**
 * Adds the specified {@link Enchantment} to this item stack.
 * <p>
 * If this item stack already contained the given enchantment (at any
 * level), it will be replaced.
 * <p>
 * This method is unsafe and will ignore level restrictions or item type.
 * Use at your own discretion.
 *
 * @param ench Enchantment to add
 * @param level Level of the enchantment
 */
public void addUnsafeEnchantment(Enchantment ench, int level) {
  (meta == null ? meta = Bukkit.getItemFactory().getItemMeta(getType0()) : meta).addEnchant(ench, level, true);
}

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

/**
 * Creates a new item stack derived from the specified stack
 *
 * @param stack the stack to copy
 * @throws IllegalArgumentException if the specified stack is null or
 *     returns an item meta not created by the item factory
 */
public ItemStack(final ItemStack stack) throws IllegalArgumentException {
  Validate.notNull(stack, "Cannot copy null stack");
  this.type = stack.getTypeId();
  this.amount = stack.getAmount();
  this.durability = stack.getDurability();
  this.data = stack.getData();
  if (stack.hasItemMeta()) {
    setItemMeta0(stack.getItemMeta(), getType0());
  }
}

相关文章