ColossalChests icon indicating copy to clipboard operation
ColossalChests copied to clipboard

Inventory Tweaks sorting support

Open NovaViper opened this issue 8 years ago • 39 comments

Hey, could you possible make the chests be able to be sorted by the Crafting Tweaks/Inventory Tweaks mod?

NovaViper avatar Mar 01 '17 00:03 NovaViper

There already is Inventory Tweaks support: https://github.com/CyclopsMC/ColossalChests/blob/master-1.10/src/main/java/org/cyclops/colossalchests/inventory/container/ContainerColossalChest.java#L36

rubensworks avatar Mar 01 '17 06:03 rubensworks

Oh, I didn't realize that, but whenever I try to use the middle mouse button to sort, it just pulls the items to fill in empty spaces, not sort the actual items by the default settings.

NovaViper avatar Mar 01 '17 15:03 NovaViper

@NovaViper Do you see the invtweaks buttons in the gui? Do those work?

rubensworks avatar Mar 01 '17 15:03 rubensworks

I do and yeah, I've tried those as well. I can get it line up vertically and horizontally, but can't get the items to actual sort by their characteristics based in the default settings

NovaViper avatar Mar 01 '17 16:03 NovaViper

Try reporting to the Inv Tweaks issue tracker.

rubensworks avatar Mar 01 '17 16:03 rubensworks

Just sent the issue to them

NovaViper avatar Mar 01 '17 17:03 NovaViper

Hey I just got a response back

Kobata commented 2 hours ago. From a quick look at that mod, since I'm not very familiar with it, it doesn't appear to be very friendly to the way Inventory Tweaks does sorting -- with the scrollbars there's a big mismatch between what the mod probably knows about (all the items) and what it can actually interact with (what's currently visible). I don't expect sorting to work well with it at all.

So it seems to be something on this mod's side.

NovaViper avatar Mar 01 '17 23:03 NovaViper

I'll throw a more detailed thing here: Inventory Tweaks (for reasons including working on non-modded servers) works by sending click commands more or less as-if you physically clicked the mouse (just really fast), so it can only really work on items that are visible on screen, and as such doesn't work very well for things so large they have to resort to scrolling and only showing parts of the contents at a time.

Kobata avatar Mar 01 '17 23:03 Kobata

@Kobata Does your API provide a way to sort on a custom list of items? If so, I can probably hook that in.

rubensworks avatar Mar 02 '17 07:03 rubensworks

No, and it's not really about that -- it would know about all the items already if I understand it right (because there's slots) -- but it can't interact with them (because not all of them are visible at the same time)

Kobata avatar Mar 03 '17 00:03 Kobata

Hey, you might be able to add a sort of checking method that scans the number of visible slots on the screen and with each time you scroll, have the mod execute the checking method again and then send that data to Inventory Tweaks (In theory that is)

NovaViper avatar Mar 03 '17 00:03 NovaViper

Ok, in that case it's going to be a wontfix.

@Kobata If you ever would add a custom hook for sorting, let me know ;-)

rubensworks avatar Mar 03 '17 06:03 rubensworks

@rubensworks There kinda is? You can do what AE does and do your own sorting using the ordering in the API.

Note that like the rest of the API that's only available client-side, so if you want it to actually persist and not just be a local 'remapping' it's up to you to do the client-server communication.

Kobata avatar Mar 03 '17 07:03 Kobata

@Kobata Oh ok, in that case I misunderstood you. Could you point me to the location in the API for that?

rubensworks avatar Mar 03 '17 07:03 rubensworks

https://github.com/Inventory-Tweaks/inventory-tweaks/blob/develop/src/main/java/invtweaks/api/InvTweaksAPI.java#L70

The sort one below won't do what you want, that's just a way of programatically starting the normal Invtweaks sort.

I'll add an extra note that the comparison may not be suitable for use with Java's built-in sorts -- sometimes it seems to get slightly confused as to whether or not an item belongs before or after another item.

Kobata avatar Mar 03 '17 22:03 Kobata

See https://github.com/Inventory-Tweaks/inventory-tweaks/issues/397 about the possible comparison order thing -- I haven't managed to get into putting enough debug in to track it down.

Kobata avatar Mar 03 '17 22:03 Kobata

after getting some error while Kobata's Inventory Tweaks mod with your mod, I checked with Kobata and he found some codes that not working well; `at org.cyclops.colossalchests.inventory.container.ContainerColossalChest.getContainerSelection(ContainerColossalChest.java:306)

at org.cyclops.colossalchests.inventory.container.ContainerColossalChest.invtweaks$slotMap(ContainerColossalChest.java)`

And he found an error (maybe unrelated); "error in the code to delay messages until a world's loaded, that's making the messages keep appearing more than they should?"

Please advice.

KusanagiRyu avatar Apr 26 '17 12:04 KusanagiRyu

@KusanagiRyu If it's a crash, I'll need the full log. And if so, please create a separate issue for that.

I don't think I understand your latest sentence. This mod is not doing anything related to delaying messages.

rubensworks avatar Apr 26 '17 12:04 rubensworks

That second comment was about my error outputs, the log he posted to me had a whole bunch of them without any obvious related exception.

Kobata avatar Apr 26 '17 12:04 Kobata

And I'll throw you the link he gave me too: https://drive.google.com/file/d/0BxtS3Obx6GxjMmpadkFReUNYSWc/view?usp=sharing

java.lang.IndexOutOfBoundsException: Index: 9027, Size: 9027
	at java.util.ArrayList.rangeCheck(ArrayList.java:653)
	at java.util.ArrayList.get(ArrayList.java:429)
	at net.minecraft.inventory.Container.func_75139_a(Container.java:113)
	at org.cyclops.colossalchests.inventory.container.ContainerColossalChest.getContainerSelection(ContainerColossalChest.java:306)
	at org.cyclops.colossalchests.inventory.container.ContainerColossalChest.invtweaks$slotMap(ContainerColossalChest.java)
	at invtweaks.InvTweaksObfuscation.getContainerSlotMap(InvTweaksObfuscation.java)
	at invtweaks.container.DirectContainerManager.initSlots(DirectContainerManager.java:37)
	at invtweaks.container.DirectContainerManager.<init>(DirectContainerManager.java:33)
	at invtweaks.InvTweaks.getContainerManager(InvTweaks.java:143)
	at invtweaks.InvTweaks.getCurrentContainerManager(InvTweaks.java:148)
	at invtweaks.container.ContainerSectionManager.<init>(ContainerSectionManager.java:23)
	at invtweaks.InvTweaksGuiSettingsButton.func_146116_c(InvTweaksGuiSettingsButton.java:48)
	at net.minecraft.client.gui.GuiScreen.func_73864_a(GuiScreen.java:452)
	at net.minecraft.client.gui.inventory.GuiContainer.func_73864_a(GuiContainer.java:320)
	at org.cyclops.cyclopscore.client.gui.container.ScrollingGuiContainer.func_73864_a(ScrollingGuiContainer.java:127)
	at net.minecraft.client.gui.GuiScreen.func_146274_d(GuiScreen.java:548)
	at org.cyclops.cyclopscore.client.gui.container.ScrollingGuiContainer.func_146274_d(ScrollingGuiContainer.java:111)
	at net.minecraft.client.gui.GuiScreen.func_146269_k(GuiScreen.java:517)
	at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1700)
	at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1055)
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:371)
	at net.minecraft.client.main.Main.main(SourceFile:124)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

Kobata avatar Apr 26 '17 12:04 Kobata

Seems to be #77. Could you provide more details there if the latest release (0.5.1) is still causing that crash?

rubensworks avatar Apr 26 '17 12:04 rubensworks

there's no CTD at all... it just give me error message whenever i sort with and of the colossal chests and sorting doesn't work.

Edit: Sorry, that error was for 1.5.0, before you released the latest one. now it CTD whenever i press the sort button. I have created another "Issue" thread, Issue #80 .

KusanagiRyu avatar Apr 26 '17 13:04 KusanagiRyu

i honestly think all of this could be easly solved by creating a custom sorting button inside the chest, trying to make something that is not supposed to work on scrollable inventories isn't really gonna work (sorry @Kobata ) the only things is to make sure that this algorithm doesn't make items disappear at random, maybe comparing the raw number of items from before and after and if it isn't equal it cancels? (not the slots number because that can change)

npgx avatar Dec 27 '17 21:12 npgx

So is there going to be some sort of support between these mods (1.10.2)? At the moment when I try to sort things by rows or columns, the chat gets an error message saying "InvTweaks [ERROR] [3] Failed to sort container: null (l101 in HandlerSorting.java)" and as previously said nothing seems to actually "sort", empty slots just get filled when using the default sort. I'd love to see these mods work together even if it would work only when the server also has both of the mods. I'll honestly program the feature myself if you just tell me how exactly it should be done. So my question is, is this going anywhere?

SanteriLoitomaa avatar Mar 31 '18 15:03 SanteriLoitomaa

@Santtinen This is not on my roadmap at the moment, so this is not coming any time soon. (Definitely not for 1.10, as 1.12 is the main target now)

But I'm open to PRs.

rubensworks avatar Mar 31 '18 22:03 rubensworks

@rubensworks I understand. How about making your own sorting method for the newer versions then since the way InvTweaks is programmed doesn't really work with scrollable containers? I'll be changing versions anyway once the mods I use get updated. I just feel like being able to sort the colossal chests would improve the mod immensely. I think it could be done with @Kobata 's sorting list as a base but then just modify it to change the container's slots directly so it would be like an inbuilt InvTweaks. If you're both up for this collab of a sort I think it would work out pretty well in the end. If you lack manpower I have experience in Java and have always wanted to try out making a mod for Minecraft.

SanteriLoitomaa avatar Apr 01 '18 10:04 SanteriLoitomaa

If you lack manpower

That's the problem indeed. I am maintaining quite a few mods at the moment, for which bugfixes have a priority. I don't have a lot of time left for new features and enhancements unfortunately. But if you're up for it, a PR for this would be more than welcome.

rubensworks avatar Apr 01 '18 10:04 rubensworks

@rubensworks Great, I'd love to try it out. I just want @Kobata 's blessing for this as well since what I'm planning is basically a port.

SanteriLoitomaa avatar Apr 01 '18 10:04 SanteriLoitomaa

If you read my comments above, you don't really need to do a 'port' (the full sorting code is massively overkill anyway, a lot of what it does is for handling features that only work on the player inventory) -- just hook the comparison to a fairly standard sort, albeit be careful of the potential bug listed above.

If you do hit that bug information on the specific pair of items would be nice so see why it breaks, though.

Kobata avatar Apr 02 '18 10:04 Kobata

@Kobata Well, I didn't mean like a full port. Just the default sort button for the chest since that is the one I believe people use the most. And instead of using the cursor for the sorting, the chest would just get sorted directly (since the server needs to have the mod anyway). That's basically what I'd like to do but since I basically have no idea what I'm doing if you have a better idea, do tell.

SanteriLoitomaa avatar Apr 03 '18 08:04 SanteriLoitomaa