#Finding Namespacedkey of datapack loot-table

1 messages · Page 1 of 1 (latest)

cosmic jay
#

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.

inland fiber
#

Make sure the plugin isn't loading too early

cosmic jay
inland fiber
#

You're going to have to provide more information

#

What's the exact code you're running and when

cosmic jay
#

thanks for taking the time to test it. I'll provide my code shortly

cosmic jay
# inland fiber What's the exact code you're running and when

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"

inland fiber
#

What's the name of the plugin

cosmic jay
#

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

inland fiber
#

Yeah AdonisUHC != crateloot

cosmic jay
#

crateloot is the datapack name

inland fiber
#

Yeah

#

Put you passed your plugin instance in the namespace

#

so it takes the plugin name

cosmic jay
#

ohhh

#

so I need to pass the datapack then

inland fiber
#

Pass "crateloot"

#

as first param instead of this

cosmic jay
#

trying it now, I used the other one because using string said its deprecated

inland fiber
#

It's not though 🤔

#

oh nvm

#

it is

#

Rename datapack to match plugin or just use deprecated

cosmic jay
#

its working!!!

#

Ill just use it as deprecated

#

THANK YOU SO MUCH