jrbudda / minecrift

VR mod for Minecraft. For Minecraft version 1.7.10
http://www.vivecraft.org
Other
322 stars 32 forks source link

Add quick hotbar switching "backpack" #280

Closed cincodenada closed 7 years ago

cincodenada commented 7 years ago

Playing Vivecraft is a blast, but sometimes a little too literally - I've found while playing that it's too hard quickly switch item slots precisely, meaning I can't quickly pull out my sword or bow when a creeper sneaks up on me.

Inspired by Space Pirate Trainer's gun/shield switching mechanic, I decided to try hacking in some functionality to allow (virtually) pinning a couple of items to your back, always ready for quick-access.

I'm a software dev by trade but I haven't done any modding before, so I'm poking around in the dark a bit here, but what I've got so far is pretty functional, I think, and worth a WIP pull request, I think.

I based it heavily off EatingTracker - the functionality is that if you put either controller behind your head and press the action key, the currently-held item (say, a sword) will be "pinned" to your back in a slot tied to that controller. Then you can switch back to whatever you want to work with and go on your merry way. If you need to pull out your sword quickly, you can just throw the same controller you pinned it with behind your back, and when you pull it out (without pressing action), you'll have the sword in hand.

I'm not super convinced that the action key is the best trigger, so I'm quite open to suggestions there, and on anything, really - like I said, I'm super new to fiddling with Minecraft mods. There's definitely some tidying (parameterization, etc) to do, but I wanted to get some early feedback with a proof-of-concept, so let me know what you think.

Also I'd love to have this in 1.11.2 as well. I haven't tried poking around, but the README said to poke you if I wanted help there.

jrbudda commented 7 years ago

Thanks this was something on the 'to-do-sometime' list. I may tweak it to not require the button press and maybe some other adjustments. I should get to it this week and will incorporate it into all 3 versions.

cincodenada commented 7 years ago

Cool, thanks! I'll let you know if I come up with any improvements or bugs as I toy with it this week as well.

jrbudda commented 7 years ago

Alright I pulled this, and pretty much had to re-write it. The way you had it it would only work if the player was facing a specific direction, the 'z' direction is not 'forward' so you have to do a bit more math. I like the mechanic in general of pinning a specific item, but without a GUI for the player to remember what they pinned I feel it's not the best way. We could create a GUI indicator but then you get into issues with Forge and mod compatibility and yadda yadda.

I think what I'd like to do to start is just have the backpack action, with no buttons at all, just switch between the first hotbar slot, and whichever one you used last. This way you can put your sword, or whatever, in that slot and quickly switch between that and another item. For 1.10+ the mechanic would be a little different for the offhand as it would switch hotbar slot 2 with the offhand slot.

cincodenada commented 7 years ago

Ah! Yes, of course, I didn't think the "hot zone" boxing through, of course the coordinate system isn't relevant to the player. In retrospect, that explains why I got weird behavior when not facing forward.

I was thinking along similar lines about the pinning, actually. I was pondering how to indicate on the hotbar, how to pin without the awkward button-pushing, etc...and had been arriving at similar places: probably best to just have the primary hand swap between slot 0/previous hotbar slot, and offhand swap between slot 1/previous, since that's where most people keep their important stuff anyway - it ties in nicely with what most people already do.

So I think that's a great place to start - perhaps if people want it, allow choosing which slots are "special" (maybe some people keep their fancy stuff in slots 0 and 9)? I also wasn't sure what to do with 1.10+, personally even if it makes more sense storywise for the offhand to switch the offhand slot, I think I'd prefer to be able to have two options for my on-hand (say, sword and bow/arrow).

But I guess one might want to be able to, say, be mining and have hand(offhand) be pick(torch), and then swap to sword(shield) by quick-swapping both hands. Hmm. This is not a well-thought-out idea, but what about being able to "throw" an item from the main hand to an offhand, perhaps by touching the main controller to the offhand controller? That way I'd have two slots, but if shield/sword was more important, I could load shield into my right, toss it to left, then load sword into right and go.

But I think either way is certainly an improvement, thanks for taking this up! I'm happy to play with more improvements as well.