LootTweaker

LootTweaker

17M Downloads

Spawn bonus chest resets to default

Ashur420 opened this issue ยท 10 comments

commented

The first generation of a world runs correctly. Deleting the world and making another world resets the spawn bonus chest's loot table to default. Closing minecraft, reopening it and generating a new world runs correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Run minecraft
  2. Create new world - bonus spawn chest option turned on (will run successfully)
  3. Log out and create a new world - bonus spawn chest option turned on (will reset to default tables)
  4. Shut down minecraft/server
  5. Run minecraft
  6. Create new world - bonus spawn chest option turned on (will run successfully)

Expected behavior
Possibly my script is causing the issue as I am a novice, but I am trying to delete all tables from the bonus spawn chest and then populate it with my own lists.

Logs & scripts
If a script is required to reproduce the problem, link or paste it here. Also provide crafttweaker.log, which is found in the minecraft instance folder (the folder the scripts folder is in).
Scripts that replicate the issue while referring to a minimal number of mods or only vanilla are preferred. They make debugging issues much simpler as I don't have to install large quantities of mods into my development workspace. Thank you for your cooperation.

-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;
import crafttweaker.item.IItemStack;

val bchest = LootTables.getTable("minecraft:chests/spawn_bonus_chest");
bchest.clear();

val pool1 = bchest.addPool("pool1", 1, 1, 1, 1);
pool1.setRolls(1, 1);
pool1.setBonusRolls(1, 1);
pool1.addItemEntry(<pyrotech:crude_axe>, 50);
pool1.addItemEntry(<pyrotech:crude_hammer>, 50);

val pool2 = bchest.addPool("pool2", 1, 1, 1, 1);
pool2.setRolls(1, 1);
pool2.setBonusRolls(0, 0);
pool2.addItemEntry(<pyrotech:crude_pickaxe>, 100);

val pool3 = bchest.addPool("pool3", 1, 1, 1, 1);
pool3.setRolls(1, 1);
pool3.setBonusRolls(0, 0);
pool3.addItemEntry(<akashictome:tome>, 100);

val pool4 = bchest.addPool("pool4", 1, 1, 1, 1);
pool4.setRolls(1, 1);
pool4.setBonusRolls(0, 0);
pool4.addItemEntry(<evilcraft:origins_of_darkness>, 100);

val pool5 = bchest.addPool("pool5", 1, 1, 1, 1);
pool5.setRolls(1, 3);
pool5.setBonusRolls(0, 2);
pool5.addItemEntry(<evilcraft:condensed_blood> * 4, 60);
pool5.addItemEntry(<evilcraft:condensed_blood> * 8, 40);
pool5.addItemEntry(<evilcraft:condensed_blood> * 12, 20);
pool5.addItemEntry(<evilcraft:condensed_blood> * 16, 10);

-crafttweaker-

[PREINITIALIZATION][CLIENT][INFO] Current loaders after merging: [[preinit]]
[PREINITIALIZATION][CLIENT][INFO] Loading scripts for loader with names [preinit]
[PREINITIALIZATION][CLIENT][INFO] [preinit | SIDE_CLIENT]: Skipping file {[0:crafttweaker]: modtweaks\loottweaker.zs} as we are currently loading with a different loader
[PREINITIALIZATION][CLIENT][INFO] Completed script loading in: 3ms
[INITIALIZATION][CLIENT][INFO] CraftTweaker: Building registry
[INITIALIZATION][CLIENT][INFO] CraftTweaker: Successfully built item registry
[INITIALIZATION][CLIENT][INFO] Current loaders after merging: [[preinit], [recipeevent | crafttweaker]]
[INITIALIZATION][CLIENT][INFO] Loading scripts for loader with names [crafttweaker | recipeevent]
[INITIALIZATION][CLIENT][INFO] [crafttweaker | SIDE_CLIENT]: Loading Script: {[0:crafttweaker]: modtweaks\loottweaker.zs}
[INITIALIZATION][CLIENT][INFO] Queued all pools of table minecraft:chests/spawn_bonus_chest for removal
[INITIALIZATION][CLIENT][INFO] Queued pool pool1 for addition to table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Rolls of pool pool1 in table minecraft:chests/spawn_bonus_chest will be set to (1.000000, 1.000000)
[INITIALIZATION][CLIENT][INFO] Bonus rolls of pool pool1 in table minecraft:chests/spawn_bonus_chest will be set to (1.000000, 1.000000)
[INITIALIZATION][CLIENT][INFO] Queued item entry 'pyrotech:crude_axe' for addition to pool pool1 of table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Queued item entry 'pyrotech:crude_hammer' for addition to pool pool1 of table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Queued pool pool2 for addition to table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Rolls of pool pool2 in table minecraft:chests/spawn_bonus_chest will be set to (1.000000, 1.000000)
[INITIALIZATION][CLIENT][INFO] Bonus rolls of pool pool2 in table minecraft:chests/spawn_bonus_chest will be set to (0.000000, 0.000000)
[INITIALIZATION][CLIENT][INFO] Queued item entry 'pyrotech:crude_pickaxe' for addition to pool pool2 of table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Queued pool pool3 for addition to table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Rolls of pool pool3 in table minecraft:chests/spawn_bonus_chest will be set to (1.000000, 1.000000)
[INITIALIZATION][CLIENT][INFO] Bonus rolls of pool pool3 in table minecraft:chests/spawn_bonus_chest will be set to (0.000000, 0.000000)
[INITIALIZATION][CLIENT][INFO] Queued item entry 'akashictome:tome' for addition to pool pool3 of table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Queued pool pool4 for addition to table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Rolls of pool pool4 in table minecraft:chests/spawn_bonus_chest will be set to (1.000000, 1.000000)
[INITIALIZATION][CLIENT][INFO] Bonus rolls of pool pool4 in table minecraft:chests/spawn_bonus_chest will be set to (0.000000, 0.000000)
[INITIALIZATION][CLIENT][INFO] Queued item entry 'evilcraft:origins_of_darkness' for addition to pool pool4 of table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Queued pool pool5 for addition to table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Rolls of pool pool5 in table minecraft:chests/spawn_bonus_chest will be set to (1.000000, 3.000000)
[INITIALIZATION][CLIENT][INFO] Bonus rolls of pool pool5 in table minecraft:chests/spawn_bonus_chest will be set to (0.000000, 2.000000)
[INITIALIZATION][CLIENT][INFO] Queued item entry 'evilcraft:condensed_blood' for addition to pool pool5 of table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Queued item entry 'evilcraft:condensed_blood' for addition to pool pool5 of table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Queued item entry 'evilcraft:condensed_blood' for addition to pool pool5 of table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Queued item entry 'evilcraft:condensed_blood' for addition to pool pool5 of table minecraft:chests/spawn_bonus_chest
[INITIALIZATION][CLIENT][INFO] Completed script loading in: 313ms
[POSTINITIALIZATION][CLIENT][INFO] Removing recipes for various outputs
[AVAILABLE][CLIENT][INFO] Fixed the RecipeBook
[SERVER_ABOUT_TO_START][SERVER][INFO] Added new pool pool1 to table minecraft:chests/spawn_bonus_chest
[SERVER_ABOUT_TO_START][SERVER][INFO] Added new pool pool2 to table minecraft:chests/spawn_bonus_chest
[SERVER_ABOUT_TO_START][SERVER][INFO] Added new pool pool3 to table minecraft:chests/spawn_bonus_chest
[SERVER_ABOUT_TO_START][SERVER][INFO] Added new pool pool4 to table minecraft:chests/spawn_bonus_chest
[SERVER_ABOUT_TO_START][SERVER][INFO] Added new pool pool5 to table minecraft:chests/spawn_bonus_chest

Version Info (Exact versions only):
LootTweaker: 0.1.1
CraftTweaker/Minetweaker: 1.12-4.1.19
Forge: 14.23.5.2847
Minecraft: 1.12.2

Additional context
Thank you for your time

commented

@Ashur420 Why did you close this?

commented

I was unable to repeat the bug after I posted this. It started defaulting all the time no matter what I ran. Even just a bchest.clear(); would result in a default loot table. I figured the issue was with the mods I was using so I intended on creating another barebones world, but it got late and I haven't to it. I closed it because I couldn't sustain two of your questions on the template. Repeatable. And as few mods as possible. My apologies for the confusion.

commented

I did receive this error in the log when attempting /ct loottables target

[21:52:08] [Server thread/WARN] [leviathan143.loottweaker.common.lib.LootTableDumper]: Failed to dump loot table minecraft:chests/spawn_bonus_chest
java.lang.IllegalArgumentException: Can't serialize unknown item null
	at net.minecraft.world.storage.loot.LootEntryItem.serialize(LootEntryItem.java:72) ~[bfp.class:?]
	at net.minecraft.world.storage.loot.LootEntry$Serializer.serialize(LootEntry.java:119) ~[bfr$a.class:?]
	at net.minecraft.world.storage.loot.LootEntry$Serializer.serialize(LootEntry.java:45) ~[bfr$a.class:?]
	at com.google.gson.internal.bind.TreeTypeAdapter.write(TreeTypeAdapter.java:81) ~[TreeTypeAdapter.class:?]
	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) ~[TypeAdapterRuntimeTypeWrapper.class:?]
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:97) ~[CollectionTypeAdapterFactory$Adapter.class:?]
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61) ~[CollectionTypeAdapterFactory$Adapter.class:?]
	at com.google.gson.Gson.toJson(Gson.java:669) ~[Gson.class:?]
	at com.google.gson.Gson.toJsonTree(Gson.java:562) ~[Gson.class:?]
	at com.google.gson.Gson.toJsonTree(Gson.java:541) ~[Gson.class:?]
	at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.serialize(TreeTypeAdapter.java:155) ~[TreeTypeAdapter$GsonContextImpl.class:?]
	at net.minecraft.world.storage.loot.LootPool$Serializer.serialize(LootPool.java:156) ~[bfq$a.class:?]
	at net.minecraft.world.storage.loot.LootPool$Serializer.serialize(LootPool.java:138) ~[bfq$a.class:?]
	at com.google.gson.internal.bind.TreeTypeAdapter.write(TreeTypeAdapter.java:81) ~[TreeTypeAdapter.class:?]
	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:69) ~[TypeAdapterRuntimeTypeWrapper.class:?]
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:97) ~[CollectionTypeAdapterFactory$Adapter.class:?]
	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.write(CollectionTypeAdapterFactory.java:61) ~[CollectionTypeAdapterFactory$Adapter.class:?]
	at com.google.gson.Gson.toJson(Gson.java:669) ~[Gson.class:?]
	at com.google.gson.Gson.toJsonTree(Gson.java:562) ~[Gson.class:?]
	at com.google.gson.Gson.toJsonTree(Gson.java:541) ~[Gson.class:?]
	at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.serialize(TreeTypeAdapter.java:155) ~[TreeTypeAdapter$GsonContextImpl.class:?]
	at net.minecraft.world.storage.loot.LootTable$Serializer.serialize(LootTable.java:211) ~[bfs$a.class:?]
	at net.minecraft.world.storage.loot.LootTable$Serializer.serialize(LootTable.java:199) ~[bfs$a.class:?]
	at com.google.gson.internal.bind.TreeTypeAdapter.write(TreeTypeAdapter.java:81) ~[TreeTypeAdapter.class:?]
	at com.google.gson.Gson.toJson(Gson.java:669) ~[Gson.class:?]
	at leviathan143.loottweaker.common.lib.LootTableDumper.dump(LootTableDumper.java:50) [LootTableDumper.class:?]
	at leviathan143.loottweaker.common.lib.LootTableDumper.dump(LootTableDumper.java:34) [LootTableDumper.class:?]
	at leviathan143.loottweaker.common.command.SubcommandDumpTargetsLootTable.execute(SubcommandDumpTargetsLootTable.java:58) [SubcommandDumpTargetsLootTable.class:?]
	at leviathan143.loottweaker.common.command.CommandLootTables.executeCommand(CommandLootTables.java:42) [CommandLootTables.class:?]
	at crafttweaker.mc1120.commands.CTChatCommand.execute(CTChatCommand.java:73) [CTChatCommand.class:?]
	at net.minecraft.command.CommandHandler.tryExecute(CommandHandler.java:119) [bj.class:?]
	at net.minecraft.command.CommandHandler.executeCommand(CommandHandler.java:91) [bj.class:?]
	at net.minecraft.network.NetHandlerPlayServer.handleSlashCommand(NetHandlerPlayServer.java:962) [pa.class:?]
	at net.minecraft.network.NetHandlerPlayServer.processChatMessage(NetHandlerPlayServer.java:941) [pa.class:?]
	at net.minecraft.network.play.client.CPacketChatMessage.processPacket(SourceFile:37) [la.class:?]
	at net.minecraft.network.play.client.CPacketChatMessage.processPacket(SourceFile:9) [la.class:?]
	at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:20) [hv$1.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_231]
	at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_231]
	at net.minecraft.util.Util.runTask(Util.java:529) [h.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:723) [MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668) [MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:252) [chd.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_231]
[21:52:08] [Server thread/WARN] [net.minecraft.command.CommandHandler]: Couldn't process command: ct loottables target
java.lang.NullPointerException: null
	at leviathan143.loottweaker.common.command.SubcommandDumpTargetsLootTable.linkDumpFileInChat(SubcommandDumpTargetsLootTable.java:111) ~[SubcommandDumpTargetsLootTable.class:?]
	at leviathan143.loottweaker.common.command.SubcommandDumpTargetsLootTable.execute(SubcommandDumpTargetsLootTable.java:60) ~[SubcommandDumpTargetsLootTable.class:?]
	at leviathan143.loottweaker.common.command.CommandLootTables.executeCommand(CommandLootTables.java:42) ~[CommandLootTables.class:?]
	at crafttweaker.mc1120.commands.CTChatCommand.execute(CTChatCommand.java:73) ~[CTChatCommand.class:?]
	at net.minecraft.command.CommandHandler.tryExecute(CommandHandler.java:119) [bj.class:?]
	at net.minecraft.command.CommandHandler.executeCommand(CommandHandler.java:91) [bj.class:?]
	at net.minecraft.network.NetHandlerPlayServer.handleSlashCommand(NetHandlerPlayServer.java:962) [pa.class:?]
	at net.minecraft.network.NetHandlerPlayServer.processChatMessage(NetHandlerPlayServer.java:941) [pa.class:?]
	at net.minecraft.network.play.client.CPacketChatMessage.processPacket(SourceFile:37) [la.class:?]
	at net.minecraft.network.play.client.CPacketChatMessage.processPacket(SourceFile:9) [la.class:?]
	at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:20) [hv$1.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_231]
	at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_231]
	at net.minecraft.util.Util.runTask(Util.java:529) [h.class:?]
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:723) [MinecraftServer.class:?]
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:668) [MinecraftServer.class:?]
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:252) [chd.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
	at java.lang.Thread.run(Unknown Source) [?:1.8.0_231]
[21:52:08] [Client thread/INFO] [net.minecraft.client.gui.GuiNewChat]: [CHAT] An unknown error occurred while attempting to perform this command
[21:52:18] [Client thread/INFO] [net.minecraft.client.Minecraft]: Stopping!
commented

Okay I just got done testing this bug and it is present with just LootTweaker and CraftTweaker installed and running just the 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;
import crafttweaker.item.IItemStack;

val bchest = LootTables.getTable("minecraft:chests/spawn_bonus_chest");
bchest.clear();

It will correctly clear the chest on run but deleting the world and recreating it without closing minecraft causes the bonus spawn chest loot table to reset to default.

commented

Related to this, I saw a case recently where creating a new world (that hadn't been created before) used items that I'd removed in scripting; I'm inclined to think that the "recreating the world" part of this bug may be a red herring. I might add details or track down the bug more consistently later, but there's something buggy happening here.

commented

@Ashur420
Thanks for minimising the reproduction case, as the template says, it's not required but it is appreciated.

commented

@Ashur420
Just noticed your script is slightly inefficient.
You add all pools with rolls and bonus rolls of 1, then set different values immediately after.

commented

After testing, this occurs for all loot tables if any save is reloaded, or saves are switched.

commented

Fix released in 0.1.3

commented

@Daomephsta haha thanks for the tip, but I did realize it. I've learned quite a bit looking at how other modpacks did their scripts, lol. It's super confusing just starting out. Thanks for the quick fix!