Diamond Chest Shops

Diamond Chest Shops

132k Downloads

Sign Shops with a lot of NBT Data Cause can Chunk Corruption/Block Chunk Saving

OblivionCreator opened this issue · 6 comments

commented

ISSUE:

Using Chest Shops for blocks that contain a lot of NBT Data will result in the chunk not saving due to excessive size.

Console Output:
[18:12:00] [IO-Worker-31/ERROR]: Failed to store chunk [-2, 1]
java.io.UTFDataFormatException: encoded string ({BlockEn...BT)"']}}) too long: 99612 bytes
at java.io.DataOutputStream.writeUTF(DataOutputStream.java:369) ~[?:?]
at java.io.DataOutputStream.writeUTF(DataOutputStream.java:333) ~[?:?]
at net.minecraft.class_2519.method_10713(class_2519.java:79) ~[server-intermediary.jar:?]
at net.minecraft.class_2487.method_10555(class_2487.java:476) ~[server-intermediary.jar:?]
at net.minecraft.class_2487.method_10713(class_2487.java:165) ~[server-intermediary.jar:?]
at net.minecraft.class_2499.method_10713(class_2499.java:128) ~[server-intermediary.jar:?]
at net.minecraft.class_2487.method_10555(class_2487.java:476) ~[server-intermediary.jar:?]
at net.minecraft.class_2487.method_10713(class_2487.java:165) ~[server-intermediary.jar:?]
at net.minecraft.class_2507.method_10631(class_2507.java:134) ~[server-intermediary.jar:?]
at net.minecraft.class_2507.method_10628(class_2507.java:99) ~[server-intermediary.jar:?]
at net.minecraft.class_2867.method_23726(class_2867.java:79) ~[server-intermediary.jar:?]
at net.minecraft.class_4698.method_23701(class_4698.java:174) ~[server-intermediary.jar:?]
at net.minecraft.class_4698.method_23719(class_4698.java:164) ~[server-intermediary.jar:?]
at net.minecraft.class_3847$class_3907.run(class_3847.java:59) [server-intermediary.jar:?]
at net.minecraft.class_3846.method_16907(class_3846.java:91) [server-intermediary.jar:?]
at net.minecraft.class_3846.method_16900(class_3846.java:146) [server-intermediary.jar:?]
at net.minecraft.class_3846.run(class_3846.java:102) [server-intermediary.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]
at java.lang.Thread.run(Thread.java:831) [?:?]

We discovered this bug when using Bits & Chisels and selling Bits and Chisels blocks using the chestshop. After restarting the server it reset the chunk the chest shops were in.

The same issue does not occur in other chunks using more bits & chisels blocks, and in chunks with bits&chisels blocks inside a chest that has not been made into a shop, leading me to believe the issue lies in how the Sign is storing too much NBT data.

STEPS TO REPRODUCE:

  • Build a bits & chisels block (Or get another block/item with a lot of NBT data)
  • Set up multiple shops selling this item inside a chunk
  • Restart Server/unload chunk

The chunk does not save and instead seems to reset. This could be used for duping naturally spawning materials (i.e infinitely refilling a dungeon chest that contains valuable loot)

I can't say exactly how you would fix this - Possibly by limiting the amount of NBT data that can be stored in the sign (either per-sign or per-chunk?) or by moving the shop data outside of the chunk file?

commented

I'll take a look now and let you know

commented

Does this release work?

Make sure you backup your world first

After doing some testing, it appears that the first few shops work however after I did about 10 or so, the plugin seemed to break completely - It stopped allowing you to buy/sell any items from chest shops within that chunk. Additionally, it seemed to break any new chestshops containing blocks with NBT Data elsewhere.

(Notably, this seemed to happen immediately after I tried selling a chest that that had bits 'n chisels items inside)

After restarting the server, I noticed the chunk has not been deleted, but now the console seems to be full of SQL errors that seem to point back to DiamondChestShop.

[23:35:57 INFO]: [STDERR]: org.sqlite.SQLiteException: [SQLITE_CONSTRAINT_NOTNULL] A NOT NULL constraint failed (NOT NULL constraint failed: chestshop.item) [23:35:57 INFO]: [STDERR]: at org.sqlite.core.DB.newSQLException(DB.java:1030) [23:35:57 INFO]: [STDERR]: at org.sqlite.core.DB.newSQLException(DB.java:1042) [23:35:57 INFO]: [STDERR]: at org.sqlite.core.DB.execute(DB.java:881) [23:35:57 INFO]: [STDERR]: at org.sqlite.core.DB.executeUpdate(DB.java:922) [23:35:57 INFO]: [STDERR]: at org.sqlite.jdbc3.JDBC3PreparedStatement.executeUpdate(JDBC3PreparedStatement.java:98) [23:35:57 INFO]: [STDERR]: at com.gmail.sneakdevs.diamondchestshop.sql.ChestshopSQLiteDatabaseManager.addShop(ChestshopSQLiteDatabaseManager.java:23) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_2624.handler$cic000$diamondchestshop_loadMixin(class_2624.java:578) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_2624.method_11014(class_2624.java:38) [23:35:57 INFO]: [STDERR]: at com.finallion.graveyard.blockentities.SarcophagusBlockEntity.method_11014(SarcophagusBlockEntity.java:71) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_2586.method_17897(class_2586.java:132) [23:35:57 INFO]: [STDERR]: at java.base/java.util.Optional.map(Unknown Source) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_2586.method_11005(class_2586.java:130) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_2852.method_39797(class_2852.java:416) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_2818.method_12206(class_2818.java:431) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_3898.method_17227(class_3898.java:715) [23:35:57 INFO]: [STDERR]: at com.mojang.datafixers.util.Either.lambda$mapLeft$0(Either.java:162) [23:35:57 INFO]: [STDERR]: at com.mojang.datafixers.util.Either$Left.map(Either.java:38) [23:35:57 INFO]: [STDERR]: at com.mojang.datafixers.util.Either.mapLeft(Either.java:162) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_3898.method_20460(class_3898.java:703) [23:35:57 INFO]: [STDERR]: at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source) [23:35:57 INFO]: [STDERR]: at java.base/java.util.concurrent.CompletableFuture$Completion.run(Unknown Source) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_3900.method_17634(class_3900.java:62) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_1255.method_18859(class_1255.java:157) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_3215$class_4212.method_18859(class_3215.java:552) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_1255.method_16075(class_1255.java:131) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_3215$class_4212.method_16075(class_3215.java:561) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_3215.method_19492(class_3215.java:278) [23:35:57 INFO]: [STDERR]: at net.minecraft.server.MinecraftServer.method_20415(MinecraftServer.java:796) [23:35:57 INFO]: [STDERR]: at net.minecraft.server.MinecraftServer.method_16075(MinecraftServer.java:784) [23:35:57 INFO]: [STDERR]: at net.minecraft.class_1255.method_18857(class_1255.java:140) [23:35:57 INFO]: [STDERR]: at net.minecraft.server.MinecraftServer.method_16208(MinecraftServer.java:769) [23:35:57 INFO]: [STDERR]: at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:701) [23:35:57 INFO]: [STDERR]: at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:273) [23:35:57 INFO]: [STDERR]: at java.base/java.lang.Thread.run(Unknown Source)

(Possibly it's the nested NBT data causing it? We didn't notice this at first but that seems just as likely as too-much NBT data)

Attached is a screenshot of the shops, as well as a log file.

image
Uploading latest.log…

commented

you should go back to the backup, I know what I messed up

commented

it looks like the issue you were having was fixed in that release but there was another one with updating chestshops from old data. The curseforge and modrinth release fixed it.

commented

I cant seem to reproduce this. How many shops do you have in a chunk? I've got 15 of them with high nbt bits and chisel blocks and it isn't breaking.

commented

Does this release work?

Make sure you backup your world first