So I’m working on inventory logging and for that purpose I need the location of the inventory involved in the event.
This is what I currently have and it works fine for vanilla Inventories, but now I want to add modded inventories and I have a hard time getting the inventory location or even figuring out if the slottransaction involves a modded inventory.
This works okayish, but for most inventories there seems to be no method to get the parent tileentity or location !(slot.parent() instanceof PlayerInventory)`
If the object you’re getting the inventory from is a tile entity, it should be an instance of TileEntityInventory provided it has an inventory.
Given a slot in this inventory, it should be the case that a TileEntityInventory is present somewhere in the inventory hierarchy. If it is, then you can call getTileEntity() on the inventory and obtain the location from the TileEntity.