I’m in the process of switching over to Sponge development from a long time on Spigot/Bukkit. I’m trying to figure out how to create a custom inventory with Sponge (to use as a menu), but all the threads I’m seeing are from over a year ago and show something like “CustomInventory” which, I think, doesn’t exist anymore. I’ve gone through the javadocs but wasn’t able to piece together what to do.
Oh really? Dang. Yeah, I was going through the Sponge Docs and that seemed to be the only “main” thing missing. Well I guess I’ll have to wait on that or get really creative and find a work-around
Did they? I’m not too versed with GitHub, but CustomInventory has a red dash next to it, which I’d assume means removed. haha. Maybe I’m just meant to implement Inventory and then pass my new class to players to open…?
It was implemented for API 5.0.0; Inventory.builder().property("title", new InventoryTitle(Text.of("Custom inventory"))).property("inventorydimension", new InventoryDimension(9, 6)).build(TestPlugin.getPlugin());
Will create double chest, I don’t really like the way how you need to use properties to set the title & size but oh well thats how it works, but the properties are really useful if you need something extra for your plugin to know afterwards
I meant that you can add different (custom) properties to the custom inventorys to help out making stuff, example you could add property “Identifiable” and figure out if player is in that inventory
Here’s the code I’m using to create a custom inventory. There’s two problems that happen. The first is that it’s opening the inventory that looks like a chest inventory on top of a player’s, rather than a double chest inventory. The second is that the inventory name isn’t what I set here. Any ideas? Thanks!
Okay, so I just tried that, and although the dimensions are correct, it still shows it as a “connected” inventory. So it shows the chest inventory on top and the player’s on bottom. Would you happen to know how to “separate” those?
Lol. Alright, I appreciate it. Last thing, do you know how to get the slot number from a clicked inventory? I see that I can get the Slot through SlotTransactions, however, I can’t seem to find out how to see what slot number that is in the inventory without getting an iterable of the Slots, then just slotNumber++ in a loop until I find it. Surely there’s a more ‘clean’ way than that
Events extend other events, such as DestructEntityEvent.Death extending TargetEntityEvent. However, for specific variations of an event, such as ClickInventoryEvent which has many variations, the sub-event is a static interface inside the original event. Have a read of the javadocs for more information.
So, for instance, ClickInventoryEvent.Primary represents the primary click (left-click by default). Extending that is ClickInventoryEvent.Double which refers to a double-click. ClickInventoryEvent.NumberPress happens when, rather than an actual click, a number is pressed while hovering over a slot, which swaps it with that hotbar slot. All of these are different types of ClickInventoryEvents, so they are static inner interfaces of ClickInventoryEvent.