I've been trying to load a custom loot-table for my plugin. I have created a datapack called "crateloot" with a namespace "crateloot" and a json file loot-table "levelcrate". when I use the command /give @p minecraft:chest{BlockEntityTag:{LootTable:"crateloot:levelcrate"}} I get a chest and when placed it has my custom loot-table. However, no matter what I try, doing Bukkit.getServer().getLootTable(new NamespacedKey(this, "levelcrate")) does not work (it will be null). I tried it with "crateloot/levelcrate" and "crateloot:levelcrate" also but none work. I've been at this for so long now dont know what to do anymore. I would really appreciate the help even if its just a link to some resource about loading loot-table some other way because all the possibilities I found just would not work.
#Finding Namespacedkey of datapack loot-table
1 messages · Page 1 of 1 (latest)
Make sure the plugin isn't loading too early
Its loading at the very end when the world and everything else is already initialized. Would you say what I'm doing seems correct at first glance then? Or am I on the completely wrong path?
Just tested it myself seems to work just fine
You're going to have to provide more information
What's the exact code you're running and when
thanks for taking the time to test it. I'll provide my code shortly
It seems I cant share my exact datapack file on here but that probably doesnt matter. I have the datapack installed in the main world which is loaded much earlier before this plugin according to the logs.
This is the code in my plugin which runs at onEnable()
LootTable levelcrate = Bukkit.getServer().getLootTable(new NamespacedKey(this, "levelcrate"));
getLogger().info("levelcrate initialized: " + (levelcrate != null));```
the output of the log is always "levelcrate initialized: false"
What's the name of the plugin
AdonisUHC, just a uhc plugin im trying to create and Im currently working on the chests its supposed to fill before the game starts
everything works when I use one of the preset chest tables like ancient city
Yeah AdonisUHC != crateloot
crateloot is the datapack name
Yeah
Put you passed your plugin instance in the namespace
so it takes the plugin name
trying it now, I used the other one because using string said its deprecated