LootTweaker scripts unable to load
Stormister opened this issue ยท 10 comments
Describe the bug
The script I have written using LootTweaker does nothing, and provides an error upon world join. This happens with all mods that I attempt to add/remove loot to. I use Bewitchment here as an example.
To Reproduce
Steps to reproduce the behavior:
- Create script using the LootTweaker imports
- Start game
- Enter a world
- If trying to edit tables for a mod, see error "No Getter Found"
- Use /ct lottables all to dump tables and see that nothing has been changed
Expected behavior
Upon using /ct loottables all, the provided dump should represent the changes made in the script
Logs & scripts
crafttweaker.log
addedLoot.zs
import loottweaker.vanilla.loot.LootTables;
import loottweaker.vanilla.loot.LootTable;
import loottweaker.vanilla.loot.LootPool;
import loottweaker.vanilla.loot.Conditions;
import loottweaker.vanilla.loot.Functions;
val cow = LootTables.getTable("minecraft:entities/cow");
val steve = cow.getPool("main");
steve.addItemEntry(<minecraft:apple>, 5);
//Bewitchment
val bewitchChestMaterials = LootTables.getTable("bewitchment:chests/materials");
val materials = bewitchChestMaterials.getPool("materials");
materials.addItemEntryHelper(<thermalfoundation:material:130>, 1, 0, [
Functions.setCount(1, 2)
], []);
Version Info (Exact versions only):
LootTweaker: 0.1.2+
CraftTweaker: 4.1.19
Forge: 14.23.5.2838
Minecraft: 1.12.2
Additional Notes
When I attempt to add loot to a mods loot pool, I received the error in the log. However, when I JUST try to use the documented script to add apples to the default Minecraft loot table for cows, I do NOT get the error, but still nothing is added.
Do you have JER installed? If so, this is possibly related to #60
I can't reproduce this at all with Bewitchment & Thermal Foundation, using the exact script you gave, there is no error, and all loot is added as expected.
Installing JER causes the loot tables not to be added to, but does not reproduce the exception.
Said exception seems to be related to ZenGetters. LootTweaker doesn't have any at all, so I think it's unrelated.
I do have JER installed, as a matter of fact. Removing it helped with adding the apple to the cow loot table, but not with the error. I changed addItemEntryHelper to just addItemEntry while changing the parameters accordingly and that got rid of the error, but now it's crashing the game on world load with a totally DIFFERENT error
crash-2019-11-25_17.46.24-server.txt
I do have JER installed, as a matter of fact. Removing it helped with adding the apple to the cow loot table, but not with the error. I changed addItemEntryHelper to just addItemEntry while changing the parameters accordingly and that got rid of the error.
Another mod, or perhaps another of your scripts, is causing that. I used the exact script you gave, and there was no such error.
but now it's crashing the game on world load with a totally DIFFERENT error
I rewrote large parts of LootTweaker in 0.1.0. I thought the large suite of unit tests I wrote caught all my mistakes, but I seem to have forgotten to re-implement the part of the automatic entry naming algorithm that prevents it generating duplicate names, and to write a unit test for that feature. Fortunately LootTweaker supports manual naming, so you can work around that for now. Just add a string argument to the end of the call's arguments.
somePool.addItemEntry(<minecraft:dye:14>, 5)
-> somePool.addItemEntry(<minecraft:dye:14>, 5, "OrangeDye")
All loot adding methods support this.
Note that you will need to make sure the given name does not conflict with the name of any other entry in the same pool.
Commit 76cde38 should fix the duplicate entry error.
No release for now.
@Stormister
Please test again with this test JAR. I have tested this JAR myself, but you are experiencing an issue I cannot reproduce, and several other issues which may be interacting.
You will need to test without JER, as I have not yet debugged that issue.
The JAR is provided solely for testing.
That jar did fix the issue. All of my loot is being added properly without any crashes. I have to do some more testing with the addItemEntryHelper method to see what is causing that to not work. I am developing a modpack so it's probably something interfering with it.
I'm looking forward to a fix with JER.
@Stormister Check #60 for an update on the JER situation. It's fixed now.