CC: Tweaked

CC: Tweaked

59M Downloads

Inventory update event

umnikos opened this issue ยท 2 comments

commented

Turtles already have the turtle_inventory event that occurs when the inventory of the turtle changes in any way. I propose an inventory event that occurs when an inventory connected to a wired network has its inventory change. This will eliminate the need to constantly poll inventories with .list(), and instead they can be polled once at the start and then kept up-to-date internally with the events. Pretty much every application which uses a large amount of chests will benefit from this

commented

Some motivating examples:

  • Storage systems already internally keep track of the items in storage, but this cache easily becomes invalid if the chests are accessed manually for any reason
  • Shops have attached storage that does get accessed manually and thus have to poll the storage every minute or so
  • I am writing a program for generic inventory transfer jobs and constantly having to scan inventories due to any of them being able to change puts an upper limit on the amount of chests that can be connected, even if most of those chests remain idle 99% of the time
commented

Thank you for the feature request! While I definitely understand the motivation for this, unfortunately there's no efficient way to implement this. Minecraft doesn't expose a generic way to observe inventory changes, so we'd just have to poll the inventory on the Java side, which is no better than doing it in Lua!