LootTweaker

LootTweaker

17M Downloads

[1.11.2] Adding the same item twice with different data

SeriousCreeper opened this issue ยท 4 comments

commented

Heya,

i'm trying to add two iron sword to my loot pool, one with a pre defined enchantment, the other with an enchantWithLevels function.

However if i add both and reload the script, i get the error:
ERROR: Error executing lootchests.zs: Attempted to add a duplicate entry to pool: minecraft:iron_sword_0

Is this a limitation of minecraft loot tables or an issue with LootTweaker?
Using the latest version of LootTweaker and co.

Thanks,
SC

commented

It's a current limitation of LootTweaker. Forge requires that loot table entries have unique names within their pool. LootTweaker names Item entries according to the format itemRegistryName_metadata. This works fine for item entries that are differentiated by metadata, but not by NBT. I've been considering sticking a hashcode on the end of the name, it should make names unique.

commented

@KIYAKU
I'm currently testing a fix for this with the below test script:
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 pig = LootTables.getTable("minecraft:entities/pig");
val dupeTest = pig.addPool("dupeTest", 1, 1, 1, 1);
dupeTest.addItemEntryHelper(\<minecraft:iron_sword\>, 20, 1, [], []); //Standard
dupeTest.addItemEntryHelper(\<minecraft:iron_sword\>, 15, 1, [], []); //Differentiated by weight
dupeTest.addItemEntryHelper(\<minecraft:iron_sword\>, 20, 5, [], []); //Differentiated by quality
dupeTest.addItemEntryHelper(\<minecraft:iron_sword\> * 3, 20, 1, [], []); //Differentiated by amount
dupeTest.addItemEntryHelper(\<minecraft:iron_sword:20\>, 20, 1, [], []); //Differentiated by damage
dupeTest.addItemEntryHelper(\<minecraft:iron_sword\>.withTag({display: {Name: "Legendary Sword of Doom, Destruction and Kittens"}}), 20, 1, [], []); //Differentiated by NBT
dupeTest.addItemEntryHelper(\<minecraft:iron_sword\>, 20, 1, [], [Conditions.killedByPlayer()]); //Differentiated by conditions
dupeTest.addItemEntryHelper(\<minecraft:iron_sword\>, 20, 1, [Functions.enchantWithLevels(5, 20, true)],[]); //Differentiated by functions

Can you think of anything I've missed in the test?

commented

The random enchantment one maybe (and one where you use both?)

dupeTest.addItemEntryHelper(minecraft:iron_sword, 20, 1, [Functions.enchantRandomly(["vanishing_curse"])], []);
dupeTest.addItemEntryHelper(minecraft:iron_sword, 20, 1, [Functions.enchantRandomly(["vanishing_curse"]), Functions.enchantWithLevels(0, 10, true)], []);

Glad to hear it's getting there :D

commented

@KIYAKU
The script is for testing that all the ways a stack can be different while having the same item are covered. The two test cases you have supplied are covered by dupeTest.addItemEntryHelper(<minecraft:iron_sword>, 20, 1, [Functions.enchantWithLevels(5, 20, true)],[]);