How to make custom loot tables and mob drops

Discussion in 'Spigot Plugin Help' started by AppleSauceTea, Jul 5, 2021.

  1. I am currently working on a plugin and I would like to make a custom loot table for some mobs. I did not find anything online on how to do this in spigot so I am asking here. How could I go about doing this?
  2. First e.getDrops().clear();
  3. what event should i use for this
  4. use EntityDeathEvent
  5. I am pretty sure what you are proposing makes it so the custom drop is obtained every single time the entity is killed. I want to make a custom loot table, which would allow me to give each drop of a mob a different chance of dropping. Do you know how to do this?
  6. Code (Text):
    event.getDrops().add(new ItemStack(Material.DIAMOND, 1));
  7. This is great, but it makes the item drop every time the mob is killed. What I want to do is give an item a 10% chance of dropping upon killing a specific mob. Is there any way to do that?
  8. Please properly explain what custom items are.
  9. Items that I have created in my plugin, such as this for example:
    Code (Java):
    private static void createBasicAlloy() {
            ItemStack item = new ItemStack(Material.IRON_NUGGET, 1);
            ItemMeta meta = item.getItemMeta();
            meta.setDisplayName("§fBasic Alloy");
            List<String> lore = new ArrayList<>();
            lore.add("§7An unrefined alloy which can");
            lore.add("§7be refined through smelting");
            lore.add("§f§lCOMMON ITEM");
            meta.addEnchant(Enchantment.LUCK, 1, true);
            basicAlloy = item;

            //Shapeless Recipe
            ShapelessRecipe ba = new ShapelessRecipe(NamespacedKey.minecraft("basicalloy"), item);
            ba.addIngredient(4, Material.IRON_INGOT);
            ba.addIngredient(4, Material.DIAMOND);
    I also edited my previous post to ask a different question.
  10. Why use static method to add recipe to onEnable code? It's a really useless way to use it.