Jump to content

Recommended Posts

Posted

Hi everyone,

      I wondered why my mob doesn't drop anything, so I used the loot tables for the sheep and it works, I returned to the webpage where I learned to make loot tables it turns out it was posted 5 years ago, HAHA Idiot me, so I was looking for a tutorial on making custom loot tables thanks a bunch.

Posted
  1. Make sure that your loottable is a valid json and has proper syntax (name property defined)
  2. Place it somewhere within assets/modid/loot_tables/
  3. Get a ResourceLocation pointing to it in your core. It should point to your loottable file, but it should not include the path up to loot_tables folder and the extension. 
  4. Obtain a registry ResourceLocation using LootTableList::register
  5. Double check that your ResourceLocation is correct, your json is correct, etc.

That ResourceLocation you obtain in step 4 is what you need.

Refer to this topic for more details and examples:

It is a very recent one too, so all the information there is up to date.

 

Another related topic I've found:

loottable file, location and syntax example.

And registration example.

 

Posted
2 minutes ago, V0idWa1k3r said:

 

I've changed those files since posting in that other thread, you can see the latest versions (as of the writing of this post) here:

 

Loot table file

Loot table registration

 

For anyone reading this thread in the future, you can use the Tree/Branch/Tag dropdown on GitHub to see the latest versions of these files on each branch. The branches are currently named after the Minecraft version they're targeting.

  • Like 1

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
Just now, V0idWa1k3r said:
  1. Make sure that your loottable is a valid json and has proper syntax (name property defined)
  2. Place it somewhere within assets/modid/loot_tables/
  3. Get a ResourceLocation pointing to it in your core. It should point to your loottable file, but it should not include the path up to loot_tables folder and the extension. 
  4. Obtain a registry ResourceLocation using LootTableList::register
  5. Double check that your ResourceLocation is correct, your json is correct, etc.

That ResourceLocation you obtain in step 4 is what you need.

Refer to this topic for more details and examples:

It is a very recent one too, so all the information there is up to date.

 

Another related topic I've found:

loottable file, location and syntax example.

And registration example.

 

Do I have to extend my lootable list to minecraft's LootTableList?

Posted
3 hours ago, V0idWa1k3r said:

Make sure that your loottable is a valid json and has proper syntax (name property defined)

Your json has no name property defined for your pools. Forge requires that property to be defined for mod loottables.

Posted
Just now, V0idWa1k3r said:

Your json has no name property defined for your pools. Forge requires that property to be defined for mod loottables.

So you're telling me that minecraft van put anything without name property but modders need to?

Posted
Just now, V0idWa1k3r said:

Your json has no name property defined for your pools. Forge requires that property to be defined for mod loottables.

So you're telling me that minecraft van put anything without name property but modders need to?

 

Just now, V0idWa1k3r said:

Erm, yes

Am I forgetting something?

 

package com.TheRPGAdventurer;

import static com.TheRPGAdventurer.RealmOfTheDragonsLootTables.RegistrationHandler.create;
import com.TheRPGAdventurer.RealmOfTheDragons;
import java.util.HashSet;
import java.util.Set;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.LootTable;
import net.minecraft.world.storage.loot.LootTableList;

public class RealmOfTheDragonsLootTables {
    
    public static final ResourceLocation ENTITIES_DRAGON_AMETHYST = create("amethsyt");
    public static final ResourceLocation ENTITIES_DRAGON_GARNET = create("garnet");
    public static final ResourceLocation ENTITIES_DRAGON_JADE = create("jade");
    public static final ResourceLocation ENTITIES_DRAGON_RUBY = create("ruby");
    public static final ResourceLocation ENTITIES_DRAGON_SAPPHIRE = create("sapphire");

    /**
     * Register this mod's {@link LootTable}s.
     */
    public static void registerLootTables() {
        RegistrationHandler.LOOT_TABLES.forEach(LootTableList::register);
    }

    public static class RegistrationHandler {

        /**
         * Stores the IDs of this mod's {@link LootTable}s.
         */
        private static final Set<ResourceLocation> LOOT_TABLES = new HashSet<>();

        /**
         * Create a {@link LootTable} ID.
         *
         * @param id The ID of the LootTable without the testmod3: prefix
         * @return The ID of the LootTable
         */
        protected static ResourceLocation create(String id) {
            final ResourceLocation lootTable = new ResourceLocation(RealmOfTheDragons.MODID, id);
            RegistrationHandler.LOOT_TABLES.add(lootTable);
            return lootTable;
        }
    }
}    

Posted
7 minutes ago, TheRPGAdventurer said:

So you're telling me that minecraft van put anything without name property but modders need to?

Yes. Forge adds the naming requirement for mod loot tables and auto-generates names for vanilla loot tables.

 

7 minutes ago, TheRPGAdventurer said:

Am I forgetting something?

You need to specify a name for each pool in the loot table file. I explained the naming requirements here (in the thread that @V0idWa1k3r linked).

 

Please use code blocks (the <> icon in the editor) when posting code. Alternatively, use Gist/Pastebin.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
Just now, Choonster said:

Yes. Forge adds the naming requirement for mod loot tables and auto-generates names for vanilla loot tables.

 

You need to specify a name for each pool in the loot table file. I explained the naming requirements here (in the thread that @V0idWa1k3r linked).

 

Please use code blocks (the <> icon in the editor) when posting code. Alternatively, use Gist/Pastebin.

I did, I mean in the loot table class.

Posted
2 minutes ago, TheRPGAdventurer said:

I did, I mean in the loot table class.

 

I'm talking about the loot table JSON file, not the class that registers the loot tables.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
5 minutes ago, TheRPGAdventurer said:

So there's nothing wrong in the class I made?

 

The class looks correct, but make sure you call RealmOfTheDragonsLootTables.registerLootTables in preInit.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
4 minutes ago, TheRPGAdventurer said:

what second pool?

 

There are two loot pools in that file, one that includes an entry for the rotd:amethsyt_dragon_scales item and one that includes an entry for the rotd:entities loot table. Only the first has a name.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
Just now, Choonster said:

 

There are two loot pools in that file, one that includes an entry for the rotd:amethsyt_dragon_scales item and one that includes an entry for the rotd:entities loot table. Only the first has a name.

Wait, you don't need to register it just like minecraft's loottablelist and the location is in the JSON itself?

Posted
36 minutes ago, TheRPGAdventurer said:

Wait, you don't need to register it just like minecraft's loottablelist and the location is in the JSON itself?

 

You're registering the loot table correctly, but it's the contents of the JSON file that need to fixed.

 

Each loot pool in the loot table JSON file needs to have a "name" property with a unique value. Currently only the first of the two loot pools has a "name" property.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
Just now, Choonster said:

 

You're registering the loot table correctly, but it's the contents of the JSON file that need to fixed.

 

Each loot pool in the loot table JSON file needs to have a "name" property with a unique value. Currently only the first of the two loot pools has a "name" property.

 

Just now, Choonster said:

 

You're registering the loot table correctly, but it's the contents of the JSON file that need to fixed.

 

Each loot pool in the loot table JSON file needs to have a "name" property with a unique value. Currently only the first of the two loot pools has a "name" property.

I actually based on the sheep's the second pool never existed and what probably causing the bug.

Posted
Just now, Choonster said:

 

You're registering the loot table correctly, but it's the contents of the JSON file that need to fixed.

 

Each loot pool in the loot table JSON file needs to have a "name" property with a unique value. Currently only the first of the two loot pools has a "name" property.

I updated it but it still doesn't drop anything can you see what's wrong with it?https://pastebin.com/HAKGmKp3

Posted
8 minutes ago, TheRPGAdventurer said:

I updated it but it still doesn't drop anything can you see what's wrong with it?https://pastebin.com/HAKGmKp3

 

That looks correct. Are there any errors in the log?

 

Post your loot table registration class and your entity class.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.