Mod specific conditions?
SeriousCreeper opened this issue ยท 3 comments
Heya,
was wondering if LootTweaker can handle other mods own conditions or if that's something that needs to be implemented first.
Trying to add a fishing condition from harvest festival that looks like this:
"conditions": [ { "condition": "harvestfestival:tier", "level": 5 } ]
if i try to do the full "condition: harvestfestival:tier", it can't seem to parse it properly. If i remove the harvestfestival before tier, it says that it can't find condition "minecraft:tier".
Is this currently possible, am i just missing something maybe?
Thanks,
SC
Hey,
good to know it can use conditions from other mods as well, i'm guessing i just need to figure out the proper format still.
I think what i posted above was a bit confusing. The conditions part i posted is from the original loot_table file, not from my crafttweaker script. You can see it here: https://github.com/PenguinSquad/Harvest-Festival/blob/1.10.2-0.6.X/src/main/resources/assets/harvestfestival/loot_tables/gameplay/fishing/ocean_summer.json#L210
But i tried your solution in any case, which should result in this if i'm not mistaken:
main.addItemEntry(<minecraft:nether_star> * 1, 10000, 1, [], [ { "condition": "harvestfestival:tier", "level": 5 } ]);
Which gives this error:
ERROR: gameplay.zs:11 > cannot cast any[any] to string
ERROR: Error executing gameplay.zs: com.google.gson.stream.MalformedJsonException: Expected ':' at line 1 column 7
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected ':' at line 1 column 7
The only time i got it not to error out but tell me that "minecraft:tier" is not a condition, is if i do it like this:
main.addItemEntry(<minecraft:nether_star> * 1, 10000, 1, [], ["condition: tier, level: 5"]);
If i had the "harvestfestival:tier" there, it would give me a syntax error.
But that just gave me an idea....
...okay yeah this worked now:
main.addItemEntry(<minecraft:nether_star> * 1, 10000, 1, [], ["condition: 'harvestfestival:tier', level: 5"]);
Had to wrap the harvestfestival:tier in another set of apostrophes, derp!
Thanks a lot, i figured i was using the wrong format haha.
-SC
Yes, the format is rather complex, I forget it myself sometimes . I plan to add a helper class that allows you to construct functions and conditions by calling them. If you want to use the full capabilities of functions or conditions, you will always have to write them in json, but the helper class will help with the less complex usages.
LootTweaker should be fully capable of using other mods LootFunctions and LootConditions. That is why the CraftTweaker methods take JSON strings instead of an Enum or something similar.
The problem here is that your syntax is wrong. LootTweaker expects an array of "condition" elements, not a single "conditions" element which contains an array of "condition" elements.
This condition string should work:
[ { "condition": "harvestfestival:tier", "level": 5 } ]