Java Code Examples for net.minecraft.enchantment.Enchantment#getEnchantmentID()

The following examples show how to use net.minecraft.enchantment.Enchantment#getEnchantmentID() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemAirUtils.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
public boolean isStackValidAirContainer(ItemStack stack) {
	if(stack == null)
		return false;

	//Check for enchantment
	boolean isEnchanted = false;
	NBTTagList enchList = stack.getEnchantmentTagList();
	if(enchList != null) {
		for(int i = 0 ; i < enchList.tagCount(); i++) {
			NBTTagCompound compound = enchList.getCompoundTagAt(i);
			isEnchanted = compound.getShort("id") == Enchantment.getEnchantmentID(AdvancedRocketryAPI.enchantmentSpaceProtection);
			if(isEnchanted)
				break;
		}
	}
	return isEnchanted;
}
 
Example 2
Source File: EnchantmentUtils.java    From ForgeHax with MIT License 5 votes vote down vote up
public String getShortName() {
  int id = Enchantment.getEnchantmentID(enchantment);
  if (SHORT_ENCHANT_NAMES.containsKey(id)) {
    if (enchantment.getMaxLevel() <= 1) {
      return SHORT_ENCHANT_NAMES.get(id);
    } else {
      return SHORT_ENCHANT_NAMES.get(id) + this.level;
    }
  } else {
    return toString();
  }
}