One of the causes for items randomly dropping out of your inventory/teleporting to you when you’re mining happens because there’s too many items the player. My solution is stacking the dropped items like in minecraft where instead of one item being individual item is turned into a singular entity containing all of the items.
For terraria though, make the value of an item the same value as all the matching surrounding items near by
For example: There are 50 stone blocks and 20 cobalt ores nearby, All of the stone blocks stack into a singular stone block that gives 50 stone blocks when picked up and doesn’t have any cobalt in them. Cobalt also stacks into a singular cobalt entity and gives 20 cobalt ores when picked up.