Solved Allow Enchanted Items to be enchanted in a Enchantment Table

Discussion in 'Spigot Plugin Development' started by jet315, Oct 13, 2018.

  1. Hey,

    All I am really looking for is a way to bring up these little windows:
    when an enchanted item is put into the enchantment table.

    Iv'e tried a few things like trying to spoof the item involved in the PrepareItemEnchantEvent event, but no luck.

    I don't mind what levels/enchants are shown in the windows, as other code is performed when the window is clicked, but I just need a way to make them appear.

  2. Spoof it as having no enchants at all?
  3. Yeah tried just a diamond_axe, although I did it by calling the event (PrepareItemEnchantEvent) myself, not sure if this is a good way?

    Iv'e tried by setting the views e.getView().setProperty(Property.ENCHANT_BUTTON1, 1) although this does nothing too when an enchanted item is in the table.
    Iv'e even tried creating a custom Enchantment Table inventory, and setting the property, but this wont work if an enchanted item is in the table (works fine if the item is not enchanted, but the property wont appear if it is enchanted).
  4. Try looking at Minecraft src code or use packets?
  5. Will look into packets ty
  6. Code (Java):
    public void onPrepareItemEnchant(PrepareItemEnchantEvent e) {
        Map<Enchantment, Integer> enchantments = e.getItem().getEnchantments();
        enchantments.keySet().forEach(enchantment -> e.getItem().removeEnchantment(enchantment));
        new BukkitRunnable() {
            public void run() {
        }.runTaskLater(this, 1L);
    Try to remove the enchantments when the item is put in the enchant table and directly re add them to the item i don't know if it work but i think yes
    • Like Like x 1
  7. Tysm, managed to do it with this and also setting the EXP for the levels.

Share This Page