Shift Clicking does not work properly
haveric opened this issue ยท 13 comments
Shift clicking needs to be overwritten to allow items to stack properly.
Implemented in 0.8.3. Needs testing to find what else should work or what doesn't work. Please let me know if there is anything that is broken or could be improved.
Version 0.8.3 now has shift clicking! There will still be some issues with it and some containers may not work ideally. If there is anything that seems broken, please let me know.
Figured I'd update anyone who is interested. I've got shift clicking about half done. It appears to be working from containers to your inventory for all containers this time around.
Next is to handle player inventory to containers, which I should have most of the functionality already built for. After that should be back and forth between inventory and hotbar when in the crafting view (or normal inventory view).
Again, I should have most of the functionality already built, I just need to put it all together and hopefully it will all work and I can get it released soon.
Finally, after the initial release of shift clicking, I'll go back over it and try to clean it up a bit. By that I mean make normal items still use the built in stacking instead of overriding everything with my own stacking.
Funny enough, it's a simple issue. I didn't implement any furnace shift clicking functionality so it is still using vanilla. The reason for this was that I wasn't sure how to handle where to move items to so I skipped it.
It really comes down to which items get moved to the fuel slot and which get moved to the cooking spot and then handle the rest by moving them to/from the hotbar. Or maybe none go to the fuel/cooking spot and they should always go between the hotbar and main inventory? I'll take a look at vanilla and see how it handles it.
Edit: I haven't looked at the crafting yet, but that could be much worse of a problem.
Sexy, I will give it a whirl on my dev server and roll out :) I appreciate you checking this out so quickly! Now we wait for 1.3 so we can have parties -_-
Just a quick update to the furnace issue. I have it working properly now, but it currently obeys max stack amounts in the furnace, which may be seen as good to some, but annoying to others, so I'll be adding a config option along the lines of:
useStackAmountsInFurnace:
- true: Player is limited to burn the stack amounts that they have (say 1 at a time)
- false: Furnaces still work like normal and can have up to 64 items (Users would still be limited when grabbing items by their stack amounts)
Another thing to note is that there is no way (that I know of) to get a list of the fuel sources for a furnace, so I had to create a list of them, which will be setup like this:
/lists/defaultFuels.txt - This is a default fuel list that I provide and can update between versions (there is also a version # to this file which is listed at the top). This file will be used if customFuels.txt is empty
/lists/customFuels.txt - If an update comes out that adds more fuels and I disappear off the face of the planet or you have another plugin that uses something else as a fuel, this can be used to keep updated or add custom fuels. If there is anything in this file, it will override anything in defaultFuels.
What does this fuel list do you might ask? Well, for shift clicking in a furnace, I made it function this way:
- Is the item a fuel? If so, check the fuel slot and move it there if you can. If not a fuel or fuel slot is full->
- Is the item used in any furnace recipe? If so, add it to the ingredient slot if possible. If not used in any recipes->
- Move the item between hotbar and main inventory.
If using any custom recipes, an /si reload may be necessary to get the new recipes (depends on the load order of plugins)
I still have a bit to finish up with it, but I'll put up a test version tonight once that part is finished.
@eatmybiglazer Test version with furnace functionality here: https://github.com/haveric/StackableItems/tree/master/versions/test
Let me know how that works and if anything is broken.
I am so far unable to reproduce your crafting bug so I'm not sure what is going on. Is there anything else you can give me to help debug that?
Shift clicking has been working properly for a while. Only thing left are improvements and tweaks which I'll create a new issue for.
I've noticed that when shift-clicking an item with a crafting, container, or furnace menu open, the shift-clicked item flickers back and forth between what would happen if the plugin was not installed, but still ultimately results in the correct result expected from the plugin. It's a bit of a gripe, since it's functional, but it would be nice if the flicker went away. I took a look at the code for this and it looks like the way you override the game's shift-clicking system is by setting the event triggered through Bukkit to null and then proceeding to write your own code for the shift-click event, which works, but for some reason it doesn't seem to act fast enough for the initial event to not take effect. It's odd, because it flickers to the Bukkit-coded result of what should happen, and then the event is cancelled, so it reverses itself and follows through with your code afterwards. Perhaps it's possible to intercept the event earlier on before Bukkit gets word of it?
As far as I know, this is a result of bukkit not having enough control (ie. mostly a client side issue) and is an unfortunate side effect of overriding the functionality. There are ways to improve it though, such as checking to see if custom stacking is required before using it so that it doesn't occur as often. I do plan on implementing that soon, but will keep a look out for other ways to improve upon it or maybe even fix it.
Ok, I was experimenting and I got it to work where it wouldn't use the custom shift-clicking if a block didn't have a custom stack limit. It could have something to do with the method I used, but an unhappy side-effect of this is that you can't shift-click items into furnaces or crafting tables. I didn't even realize this wasn't a stock feature until I found out it was working through your plugin. It's an awesome feature, so I wish there was some way you could work around the stuttering without having to sacrifice it.
Also worth mentioning is an issue with 8.0.3 where if you shift click a stack of items that have a custom stack limit higher than their default from the result box of the crafting table, it gives you the items in their default stack count instead of the custom one. This happens with at least mushroom stew, doors, and signs (i.e. the crafting table says 3 signs can be crafted, I shift click them, and they appear in my inventory in 3 separate slots instead of 1 stack). This gets maddening when you have enough materials to craft 32 doors or 64 mushroom stews.
Some of these issues will be fixed with the next version. I just need to test it and finish up a couple things I had started. I've been busier than usual with work lately and the Steam summer sale hasn't helped at all either so I haven't had much time to work on this. The major one that you are probably running into is that my custom adding of items to the inventory was slightly flawed.
Please try the test version here and let me know if these issues are still happening: https://github.com/haveric/StackableItems/tree/master/versions/test
Hello there haveric!
lazertester here, I am the lead developer of MineZ. We are using your plugin to limit players to one item per slot, and many of our users have discovered an issue with shift clickingt hat works out in their favor. Our config is set to limit everything but bread(4) and cookies(8) to 1 item per slot. Here is a message I received from a user:
Hello, I have noticed that when you are using a furnace, and you have exactly one slot open in your hotbar, you can shiftclick 2 separate stacks of items and they will combine in your hotbar. This makes anything stackable in vanilla, stackable in MineZ as long as you have a furnace nearby. Of course, clicking on the stack to pick it up unstacks one and gives you that one. The only way I know of to move these stacked items in your inventory is shiftclicking in a furnace or by replacing the stacked item's slot with another item.
Now, onto the duplication bug (possibly). When you put a stack of 2 wheat, 2 cocoa, then 2 wheat in a crafting table and shiftclick, it will give you the normal 2 stacks of cookies but sometimes it will only consume the 2 wheat on the side and 1 cocoa. I have noticed that the items leftover are 'ghosts' and the moment you pick them up they disappear, but if you shiftclick on the cookies to craft them with the ghost items, then all three stacks of cookies will appear to be non-ghostly and edible.
In short: Shiftclicking in a furnace with one slot in your hotbar allows for stacking like vanilla,
and trying to craft 2 at a time using shiftclicking may sometimes duplicate the crafted material.
I might poke around the code and see if I can find the cause/a fix, but I'm not sure when I will be able. Also if you feel like hopping over and playing on MineZ let me know, your plugin is so central to our servers we'd be happy to grant you unlimited access to our private servers. Thank you for your work!