Topic category: Advanced modding
Im making a rather game changing rpg-esque mod and one of the features i wanted to replace was the vanilla inventory system with something akin to Diablo or Dark and Darker, where a block in the inventory could take up 2x2 slots and torches 1x2, pickaxes 2x3, potions 1x1, etc.
is there a decent way for me to do this?
the current ideas i have come with a few hiccups
#1: Render pictures over the item slots; the problem with this being i would need to have an image placed under every slot for every item. and have an inventory sprite made for every game item though i suppose thats doable. though a solution would be if someone could point out setting the image location with a returned value so it can change dynamically
#2: Render a custom entity that looks like the item; the issue here being unlike #1 the displayed entity can be set with a procedure though i would still need to set the entity under every slot in every inventory, and i dont want to destroy performance and load times with hundreds of entity models
#3: Another issue is getting the location of the mouse cursor on screen and the item in its hand if applicable, and also need to change the size of the item slots and/or the items that render in them; this would be the easiest to make compatible with other mods though im not certain its possible in mcreator
I'm really not sure where you'd start with this. It's a cool idea, don't get me wrong! But you're right, MCreator really doesn't have the tools for something that changes a built-in system this fundamentally. You would definitely need a fair bit of java experience, and possibly some external tools. It could be pretty cool though!
i was thinking of getting a normal gui with slots, getting the item in the players cursor and locking/unlocking slots based on the size of that item. issue is I don't know how to find the item that a player holds in their cursor
the only roundabout solution i can think of for this is have an event that logs the item a player last picked up from an inventory which may work fine if i end up changing every inventory in the game
and i would like to properly display the vanilla items, with my modded items i can just change the display settings to fit the box
The tricky part is the 'changing every inventory in the game.' There's just so much code built around the existing inventory system that would make this very difficult to accomplish, especially since there aren't good ways to lock slots in vanilla inventories. You'll still be running into in-hand rendering issues if you try to just change the texture size.
You could possibly try using non stackable items for each 'piece' of the multi-slot item, and setting the original itemstack in the player's hand if they interact with any of the others, or as you suggested, using a variable system to keep track of things... but I'm still struggling to think of a good way to do this that won't be an absolute pain to manage. Usually I've got at least some idea of where to start, but I'm afraid I really can't come up with a decent method. (Sorry this isn't all that helpful...)
actually by "changing" the inventory i more meant replacing it entirely. but i have come up with the idea of overwriting the vanilla item display settings so they can appear larger in the gui, but the textures and item itself will remain the same, then i can set the extra slots it takes up as a "token" item that will copy the name, nbt, and tooltip of the original item and when said item is picked up it simply does a switch with the real item and the tokens vanish
as for locking slots. im not aware of any way to do this with vanilla gui but mcreator gui slots definitely allow it. so when a player takes an item out of a slot a player variable will be set to the size of the item picked up and the item stack itself; then the new inventory gui will lock any slots that would cause overlap with the items/border in the inventory which can be done just by reading the slots that are filled and the size of the cursor item
this will allow the inventory to work with any item set that either has an item tag added by the mod ex: "tetrisinv:1x2" or uses a forge tag like forge:block (2x2), forge:pickaxe (2x3), minecraft:potion (1x1), etc.
of course item display settings will still need to be added by tetrisinv, unless theres some way to import different item display settings based on what mods are loaded into the game,
as for armor/hotbar slots; the ones added in vanilla can just mimic a decoy slot located in the tetris inv, though any vanilla inventory slots added by mods will need to be added manually via either of the mods
Yeah, it's worth giving it a try! Just be forewarned it will likely be pretty difficult to get working consistently, and will probably have a lot of conflicts with other mods.