Draylar / inmis

I need more inventory space! A Fabric backpack mod.
https://www.curseforge.com/minecraft/mc-mods/inmis
MIT License
33 stars 30 forks source link

Support for Inventory Management #128

Open ModProg opened 2 years ago

ModProg commented 2 years ago

Its author claims it should be possible to do so from here (https://github.com/Roundaround/mc-fabric-inventory-management/issues/2).

If I find time, I'll maybe look into this myself.

Roundaround commented 2 years ago

Hi! It should be pretty easy to integrate (famous last words)!

Unfortunately I'm pretty busy today so I won't be able to come up with more details yet but I poked around the source code and saw it was extending ScreenHandler with a SimpleInventory backing it, which means you should be able to utilize the registration methods in InventoryButtonsManager to do it by registering BackpackScreenHandler.class:

https://github.com/Roundaround/mc-fabric-inventory-management/blob/1.18.2/src/main/java/me/roundaround/inventorymanagement/client/InventoryButtonsManager.java#L79 https://github.com/Roundaround/mc-fabric-inventory-management/blob/1.18.2/src/main/java/me/roundaround/inventorymanagement/client/InventoryButtonsManager.java#L83

Roundaround commented 2 years ago

Okay I found myself a bit more time to play around with it and I think it works!

You'll need to add my Maven repo:

maven {
  name = 'Roundaround Maven'
  url = "https://maven.rnda.dev/releases"
}

and then add Inventory Management as a compile only dependency:

modCompileOnly "me.roundaround:inventorymanagement:1.0.2+1.18.2"

From there, you can integrate similarly to how the Trinket integration is set up. Create a compat class to make sure none of the Inventory Management classes are loaded directly in the main Inmis loader class, and use Fabric loader's API to check if Inventory Management is loaded:

if (FabricLoader.getInstance().isModLoaded("inventorymanagement")) {
  InventoryManagementCompat.registerScreenHandler();
}

Then within your compat class, simply call the appropriate registration methods to setup the backpack screens for integration:

public static void registerScreenHandler() {
  InventoryButtonsManager.INSTANCE.registerSimpleInventorySortableHandler(BackpackScreenHandler.class);
  InventoryButtonsManager.INSTANCE.registerSimpleInventoryTransferableHandler(BackpackScreenHandler.class);
}
ModProg commented 2 years ago

Thanks a lot, I'll try to make a path with this :+1: