Skip to content

Conversation

@ButterSus
Copy link

@ButterSus ButterSus commented Jun 29, 2024

Overview

This PR adds a new keybind for quick item switching: [Standing] Insulated Wire, [Standing] Bundled Cable. By default, it is set to the R key, but it can be reassigned in the settings:

image

Interactivity

When this keybind is held, a HUD overlay is added with a selection of several options of the same color. Scroll with mouse in order to switch. This solves the issue of excessive variations of essentially the same functional block, which previously occupied more than 50 slots, now reduced to 17.

image

This feature only works in creative mode, and the switching is cyclic.

Technical Changes

image

  • The implementation of the HUD overlay itself should ideally be reworked (in my opinion). Link to implementation.
  • Added names for two keybindings.

Request

  • Please review the sections where I have left comments, as I am not sure they align with the structure of your project.
  • It's not hard to add color switching in the same way, I just haven't figured out how to make a grid in Layout yet.

val menuIndex = wiresAndCables.indexOf(activeItem)

val hotbarX = guiGraphics.scaledWindowWidth / 2 - 91
val hotbarY = guiGraphics.scaledWindowHeight - 22
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic code, don't touch if works

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code looks fine. I can tell generally what it's doing and how to tweak it if necessary.

ci.cancel();
@ModifyArg(method = "renderHeldItemTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;drawShadowedText(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)I"), index = 3)
private int modifyHeldItemTooltipOffset(int offset) {
return offset - WRKeyBindings.getHeldItemTooltipOffset();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found out that I can greatly simplify the mixin responsible for HUD offset

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine and makes sense.

@ButterSus
Copy link
Author

Maybe I should improve the UI when selecting a state. I will probably use the following source as a basis: https://github.com/AntiCope/radialhud

@Kneelawk
Copy link
Owner

Kneelawk commented Jul 1, 2024

Wow! This looks really good! I'll checkout this branch when I get the chance to get a closer look at how everything works but I like what I've seen so far. Good work! Thanks for working on this!

@Kneelawk
Copy link
Owner

Kneelawk commented Jul 1, 2024

I'm probably going to tweak a couple things, like switching the networking over to LNS, and changing the keybinding key to ALT, but in general, this looks really solid.

@Kneelawk
Copy link
Owner

Kneelawk commented Jul 1, 2024

I might also want to add some stuff to make this work in survival.

@Kneelawk
Copy link
Owner

Kneelawk commented Jul 1, 2024

The radial menu would work great here, allowing wr show multiple colors from a single item. It would also work with survival too, allowing wr to ex-out items the player doesn't have in their inventory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants