No loot for vanilla chests and wither drops ("lootpool" is null)
Closed this issue ยท 5 comments
So, I have created a 1.21.1 NeoForge modpack for my small SMP server and after finishing the pack (fairly big, 230 mods) I noticed some of the vanilla chests, like buried treasures, illager outposts, were empty. More like they were not actually opening with Lootr mod and, after disabling it, they opened but were empty. Also, after ignoring it and playing more I also noticed the Wither had no drops.
First I took a look at the logs and noticed it didn't "blame" any mod. Because of that I took the time to do some binary search and it came down to this mod.
java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.storage.loot.LootPool.addRandomItems(java.util.function.Consumer, net.minecraft.world.level.storage.loot.LootContext)" because "lootpool" is null
[Server thread/ERROR] [net.minecraft.network.protocol.game.ServerPacketListener/]: Failed to handle packet net.minecraft.network.protocol.game.ServerboundUseItemOnPacket@300caf89, suppressing error
java.lang.NullPointerException: Cannot invoke "net.minecraft.world.level.storage.loot.LootPool.addRandomItems(java.util.function.Consumer, net.minecraft.world.level.storage.loot.LootContext)" because "lootpool" is null
These were the errors that appeared after killing the Wither and trying to open a chest, respectively (there's more after that, I can send the logs if needed).
I have no clue on why this is happening in my modpack or if there's another mod causing some compatibility issues together, just thought it would be good to let you know. If you need me to do anything to help just lmk.
Also my pack name is "ObsidianVale Season 4" on CurseForge if you want to take a look at the mods in there.
Hey @Leitoooor thank you for reporting! I tried to figured out what's mod causing this issue. I installed several mods that might modify loot system on my own testing mod pack but didn't find anything from it. Even with my modified FOT on my local test still can't find the root cause.
With my limited time I couldn't test every scenarios. Maybe could you try to test as much as possible, probably less mods.
I did more testing with the code, I had to disable this line of code https://github.com/SteveKunG/FishOfThieves/blob/1.21.1/neoforge/src/main/java/com/stevekung/fishofthieves/neoforge/proxy/CommonProxyNeoForge.java#L53 and it worked. I don't know why though.
I did more testing with the code, I had to disable this line of code https://github.com/SteveKunG/FishOfThieves/blob/1.21.1/neoforge/src/main/java/com/stevekung/fishofthieves/neoforge/proxy/CommonProxyNeoForge.java#L53 and it worked. I don't know why though.
maybe add a null check to avoid breaking loot generation as a temporary fix:
if (tableBuilder instanceof FabricLootTableBuilder fabricBuilder && !tableBuilder.pools.isEmpty()) {
fabricBuilder.modifyPools(builder -> {
FOTLootManager.getInjectedLootTableMap().forEach((resourceKey, function) -> {
if (id.equals(resourceKey)) {
function.apply(builder, provider);
}
});
});
}I did more testing with the code, I had to disable this line of code https://github.com/SteveKunG/FishOfThieves/blob/1.21.1/neoforge/src/main/java/com/stevekung/fishofthieves/neoforge/proxy/CommonProxyNeoForge.java#L53 and it worked. I don't know why though.
maybe add a null check to avoid breaking loot generation as a temporary fix:
if (tableBuilder instanceof FabricLootTableBuilder fabricBuilder && !tableBuilder.pools.isEmpty()) {
fabricBuilder.modifyPools(builder -> {
FOTLootManager.getInjectedLootTableMap().forEach((resourceKey, function) -> {
if (id.equals(resourceKey)) {
function.apply(builder, provider);
}
});
});
}
Nope, I'm trying your solution still doesn't work. Hopefully this neoforged/NeoForge#2334 get merged. I will recommended to use latest 1.21.1 NeoForge.