Hi, I want to put a glowing effect on a PLAYER_HEAD ItemStack, but the method of put an enchant on it doesn't work (because a player head can't have an enchantment I think)... Does anyone here know a method to do this ? Or is this impossible to do ? Thank's !
yes: Code (Java): ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1, (short)3); SkullMeta headMeta = (SkullMeta) head.getItemMeta(); headMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); head.setItemMeta(headMeta); head.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 1);
if youre looking to make the only the item a player is wearing as a helmet glow, im 100 % that's not possible.
oh, well in that case... just for the sake of it: have you tried adding the enchantment to the ItemMeta (or skull meta in this case), rather than the ItemStack directly?
It's possible to register your own enchantment with no name and add that to an item. Here's how I did it. GlowEnchant class (extends Enchantment) And in my plugin's onEnable: Code (Java): try { Field f = Enchantment.class.getDeclaredField("acceptingNew"); f.setAccessible(true); f.set(null, true); Enchantment.registerEnchantment(glowEnchant); f.setAccessible(false); } catch (NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException ignore) {} Be warned: this may not be safe. I'm not sure as to how much this actually affects things, I just found it somewhere.