Crock Pot

Crock Pot

328k Downloads

[bug]Cannot save crockpot data after reload

khjxiaogu opened this issue ยท 2 comments

commented

After using /reload command, crockpot creates great lagging and cannot save its data
stack trace:
trace

[12:47:31] [Server thread/ERROR] [minecraft/Chunk]: A TileEntity type com.sihenzhang.crockpot.tile.CrockPotTileEntity has thrown an exception trying to write state. It will not persist, Report this to the mod author
java.lang.IllegalStateException: Unrecognized tag
	at net.minecraft.tags.ITagCollection.getIdOrThrow(ITagCollection.java:35) ~[forge:?] {re:classloading}
	at net.minecraft.item.crafting.Ingredient$TagList.serialize(Ingredient.java:284) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.item.crafting.Ingredient.toJson(Ingredient.java:117) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at com.sihenzhang.crockpot.util.NbtUtils.writeIngredient(NbtUtils.java:17) ~[?:?] {re:classloading}
	at com.sihenzhang.crockpot.recipe.pot.requirement.RequirementMustContainIngredient.serializeNBT(RequirementMustContainIngredient.java:33) ~[?:?] {re:classloading}
	at com.sihenzhang.crockpot.recipe.pot.requirement.RequirementMustContainIngredient.serializeNBT(RequirementMustContainIngredient.java:10) ~[?:?] {re:classloading}
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[?:?] {}
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) ~[?:?] {}
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?] {}
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?] {}
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?] {}
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?] {}
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?] {}
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) ~[?:?] {}
	at com.sihenzhang.crockpot.recipe.pot.CrockPotRecipe.serializeNBT(CrockPotRecipe.java:78) ~[?:?] {re:classloading}
	at com.sihenzhang.crockpot.tile.CrockPotTileEntity.save(CrockPotTileEntity.java:234) ~[?:?] {re:classloading}
	at net.minecraft.world.chunk.Chunk.getBlockEntityNbtForSaving(Chunk.java:427) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.world.chunk.storage.ChunkSerializer.write(ChunkSerializer.java:287) ~[forge:?] {re:classloading}
	at net.minecraft.world.server.ChunkManager.save(ChunkManager.java:682) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176) ~[?:?] {}
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) ~[?:?] {}
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[?:?] {}
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) ~[?:?] {}
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[?:?] {}
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?] {}
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?] {}
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?] {}
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?] {}
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) ~[?:?] {}
	at net.minecraft.world.server.ChunkManager.saveAllChunks(ChunkManager.java:337) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.world.server.ServerChunkProvider.save(ServerChunkProvider.java:307) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.world.server.ServerWorld.save(ServerWorld.java:698) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.saveAllChunks(MinecraftServer.java:532) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:568) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.server.dedicated.DedicatedServer.stopServer(DedicatedServer.java:514) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:679) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:232) ~[forge:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at java.lang.Thread.run(Thread.java:834) [?:?] {}
commented

Seems it is caused by the same reason as #33 and I need to debug it further.

commented

Using /reload command will refresh the Tag cache maintained by Minecraft, so when serializing, the tag in the Ingredient stored in TileEntity does not match the tag in the cache, so an exception is thrown with "Unrecognized tag". By using Supplier, the Ingredient is retrieved each time, so that the tag in the Ingredient will be consistent with the cached tag.