jhuckaby / magic-sorting-system

A data pack for Minecraft 1.13, 1.14 and 1.15 (Java) for automatically sorting every item in the game.
39 stars 15 forks source link

Chest deleted when bare controller is activated #5

Closed jhuckaby closed 4 years ago

jhuckaby commented 5 years ago

From @k4ps: When you forget to destroy the chest and something gets sorted by a bare controller, the content of the chest is deleted.

groovy-d commented 5 years ago

I noticed when I pop a chest on the bare floor, whats inside gets sorted - if theres a ready chest, but if there is not then maybe those items go to the misc chests I set up, maybe not. the chest I broke in anycase is gone.

groovy-d commented 5 years ago

Addendum. The first 2 items of whatever is sorted sometimes dissapear. Especially chests. If I simply toss down 64 chests onto the pickup, then open the chests container, I see them filter in, but only get 62. Pretty much everytime.

jhuckaby commented 5 years ago

Yeah, there's a timing issue that I have been unable to fix in all cases, especially on multiplayer servers or in situations when other game tick lag is present. The problem is the chest is destroyed and becomes an item entity along with everything else you are sorting, so I need to "delete" exactly one chest so you don't gain a chest each time it is recreated. But if you are actually sorting chests into the chest this becomes a very tricky problem indeed.

execute at @s unless score #mss_cooldown mss_cooldown matches 1 run kill @e[limit=1,sort=nearest,type=item,nbt={Item:{id:"minecraft:chest",Count:1b}}]

Basically the system uses a cooldown variable that it decrements, and the chest item delete only tries to run once, and limits the kill (delete) to one item, but in practice this is error prone, and it often deletes more than it is supposed to. I think this is the source of your missing chests. The only other option is removing this delete, but that means each time you sort you gain a chest, which doesn't feel right to me either.

I will try to find a better way to do this in v2.0 that doesn't involve destroying a chest.

groovy-d commented 5 years ago

Thanks for the answer, Good to know how it works :)

jhuckaby commented 4 years ago

This should be fixed in v2.0.0 now.

Note that 2.0.0 is a major release, and much has changed. Specifically, there is no longer a chest that replaces itself. See the Upgrading from v1.0 section for details.