jaquadro / StorageDrawers

A mod adding compartmental storage for Minecraft Forge
MIT License
203 stars 160 forks source link

[bug]Integer overflow in the drawer with creative storage upgrade #1183

Open Forever-178 opened 1 week ago

Forever-178 commented 1 week ago

Item count overflows in the drawer with creative storage upgrade when insert items which count closing to Integer maximum value in the drawer.

Environment: Minecraft version: 1.21 Mod loader: NeoForge 21.0.167 Mod List:

Step to reproduce:

  1. Use this command to generate a drawer that item count closes to integer maximum. /setblock ~ ~ ~ storagedrawers:oak_full_drawers_1[facing=north]{Drawers:[{Count:2147483646,Item:{Count:1b,id:"minecraft:grass_block"}}],Upgrades:[{Count:1b,Slot:0b,id:"storagedrawers:creative_storage_upgrade"}]}
  2. Use advance logistical transporter insert grass block to this drawer. (Do not use hopper to insert item. It only send 1 item at once.)
  3. Item count will overflow.
Forever-178 commented 1 week ago

I read the source code of 1.12. I think the problem may lie here. https://github.com/Forever-178/StorageDrawers/commit/2631e4c088167047a43d648eaeb35faf62dd7a40 I haven't conducted detailed tests for various edge cases, but it works fine in the tests mentioned above.