LootTweaker

LootTweaker

17M Downloads

[0.0.5] Dump command produces innaccurate loot_table files

thephoenixlodge opened this issue ยท 5 comments

commented

The dump command doesn't distinguish between item and loot_table type entries, incorrectly labelling them ALL as item. As a result, using these output files as a baseline for writing full overrides results in them not being valid, erroring on loading them.

An example:
{ "entryName": "minecraft:entities/sheep", "weight": 1, "quality": 0, "type": "item", "name": "minecraft:entities/sheep" }

should be:
{ "entryName": "minecraft:entities/sheep", "weight": 1, "quality": 0, "type": "loot_table", "name": "minecraft:entities/sheep" }
(this example comes from every sheep loot table dump produced by LT's dump command)

In the case of unedited vanilla tables this is a bit of a null issue as those files can probably be sourced elsewhere, but when it comes to any mod altered table, this is not an obvious issue, and as far as I'm aware there's no real way to get pack specific loot tables other than this command. Any table with botania or reliquary injecting into it will have this issue.

commented

This makes no sense. I just tell the loot tables to serialise and dump the JSON string I get back into the appropriate file.

commented

Hmm, looks like a Forge bug. I found this in the loot entry serialiser:

if (p_serialize_1_ instanceof LootEntryItem)
{
jsonobject.addProperty("type", "item");
}
else if (p_serialize_1_ instanceof LootEntryTable)
{
jsonobject.addProperty("type", "item");
}
else
{
if (!(p_serialize_1_ instanceof LootEntryEmpty))
{
throw new IllegalArgumentException("Don't know how to serialize " + p_serialize_1_);
}
jsonobject.addProperty("type", "empty");
}

The vanilla serialiser is serialising loot table entries as item entries. This probably went unnoticed because vanilla never serialises its loot tables.

EDIT: I've examined the Forge patches to LootEntry and it looks like this is actually a vanilla bug.

commented

I'm currently working on a patch for this. It'll go into the 1.10.2 and 1.11 branches, then I'll make a PR to Forge to fix it properly and remove the patch in the 1.11 branch when the PR is merged.

commented

The patch is done

commented

0.0.5.1 is now on CF with the patch