Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
quat :verified_dragon: :ms_pup_flag:
@quat@types.pl  ·  activity timestamp last month

found a #cool item-deletion bug with the Packages inventory-interaction stuff because i checked slot.getMaxStackSize() instead of the max stack size of the item itself.

not much of a problem in 1.20 because most containers return 64 from this function. but because of the ✨ data driven ✨ stack sizes mojang added, slot.getMaxStackSize now usually returns 99 ! and that exposed the bug better

  • Copy link
  • Flag this post
  • Block
quat :verified_dragon: :ms_pup_flag:
@quat@types.pl replied  ·  activity timestamp last month

like to determine how many more items fit in a slot, it does slot.getMaxStackSize() - stack.getCount(), then it removes that many items from the package, and tries to add them into the corresponding slot. if there are any left over after the addition, it logs an "oops didn't think this was possible please report this!" message and deletes the leftovers

in 1.20 slot.getMaxStackSize returns 64 so it thinks there is room for 48 more stacks-to-16 than there really is.

in 1.21 it returns 99, so it was thinking there is room for 35 more of any item

however !

the "extract items from a package into a slot" code is triggered in only two ways

  • right clicking a package onto an empty slot
  • right clicking a completely full package onto a partially-filled slot containing the same item

but it will not remove more than one stack of items at a time from the package (computed via the correct getMaxStackSize function). so if you click items into an empty slot it will always function correctly.

and that is the vast-majority of package right clicks. if you right click a package which is not literally 100% full onto an item, it will instead take items from the slot and add them to the package, which is a different function that's not buggy

  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.2.21 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login