Fabric API

Fabric API

108M Downloads

Loot Table JSON Serializer not working

TrollTaylor opened this issue ยท 2 comments

commented

I'm trying to deserialize a loot table JSON with this code

reader = new FileReader("piglin_bartering.json");			
JsonParser parser = new JsonParser();
JsonElement jsonElement = parser.parse(reader);
GsonBuilder gsonB = new GsonBuilder().registerTypeAdapter(net.minecraft.loot.LootTable.class, new LootTable.Serializer());
Gson gSson = gsonB.create();
LootTable lt = gSson.fromJson(jsonElement, LootTable.class); 

It is throwing this error

java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unable to invoke no-args constructor for interface net.minecraft.loot.provider.number.LootNumberProvider. Register an InstanceCreator with Gson for this type may fix this problem.

commented

This area is for bug reports of the fabric api.
It is not a help forum.
Try the discord, or the discussions tab.

commented

You can use the LootGsons class from vanilla for this. And yeah, help requests are better in other places like the Fabric discord.