1.15.2 Glowing effect on Player Head

Discussion in 'Spigot Plugin Development' started by AzodFR, Jan 24, 2020.

  1. 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 !
     
  2. drives_a_ford

    Moderator

  3. 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);
     
  4. if youre looking to make the only the item a player is wearing as a helmet glow, im 100 % that's not possible.
     
  5. No it's not for that, It's for a GUI, to tell the player that the reward is claimable
     
  6. im sorry but thats not possible either. the glowing effect can only apply to entities
     
  7. I believe they mean the enchantment glow of items that have enchantments on them.
     
    • Funny Funny x 1
  8. 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?
     
  9. 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.