Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shulker Boxes do not immediately open when placing and holding right-click #28

Closed
VL4DST3R opened this issue Jan 17, 2025 · 8 comments
Closed
Assignees
Labels
bug Something isn't working fixed This issue is fixed in an upcoming update

Comments

@VL4DST3R
Copy link

I noticed that when you place shulker boxes in multiplayer, if you palce it and then keep holding right-click it does not automatically open the box the next tick after it gets placed, instead it does nothing and you have to release and press again to open it. In single player this works as intended (I can place and keep holding right-click to immediately open it)

This is a small nitpick but when you develop muscle memory for something you notice very fast when it changes XD.

@KadTheHunter KadTheHunter changed the title Inconsistency between singleplayer and multipllayer when placing and interacting w/ shulker boxes? Shulker Boxes do not immediately open when placing and holding right-click Jan 17, 2025
@KadTheHunter
Copy link
Collaborator

A quick test confirms this is an issue on singleplayer as well, unsure how it works for you in singleplayer. Will look into it alongside #19 as the behavior is similar.

@KadTheHunter KadTheHunter self-assigned this Jan 17, 2025
@KadTheHunter KadTheHunter added the bug Something isn't working label Jan 17, 2025
@KadTheHunter
Copy link
Collaborator

KadTheHunter commented Jan 17, 2025

Reference for myself:
GameRendererMixin
L229 prevents activate-able items from being overridden (i.e. food, like sweet berries)
L251 prevents activate-able blocks from being overridden (i.e. crafting tables, shulkers) unless the player is sneaking

The issue with L251 is that it doesn't take into account behavior where vanilla interaction is cancelled while sneaking, thus resulting in utterly inaccessible behavior, i.e. ABP active shulker boxes wont open when right click is held, sneaking to revert to vanilla behavior wont open them because vanilla behavior is to not open inventories/menus when sneaking.

The relation to #19 is that scaffolding has the interesting property of being activate-able, but not having a menu, and only when the hand item is also scaffolding.

The potential solution for #19 is to add a check if hand item and target block are both scaffolding and current and lastplaced are the same, then revert to vanilla behavior

The potential solution for this issue (#28) is more complicated. Sneaking to revert to vanilla behavior is obviously a dumb idea because of how sneaking affects vanilla behavior, but there's also not a very good way to have an in-game modifier similar to sneaking, other than some sort of additional key or toggle that sets whether the mod should override vanilla behaviors for activate-able blocks. I suppose I could make the #19 check universal by checking if hand/target are the same and current/lastplaced are the same, reverting to vanilla behavior if all true, though I'm unsure how well that would work, and how many edge cases that would cover or introduce.

Decisions, decisions...

Edit 1: Using my above plan does work, however there are some side-effects:

  1. If camera is moved quickly enough, blocks will be placed while the menu is opening. This isn't that bad, and honestly isn't worth trying to fix.
  2. If movement is stopped sharply or the crosshair is panned back across placed blocks (within the criteria), the menu will open. This is logical, but unwanted, and is just a new form of the original problem.
  3. Scaffolding will not stack up infinitely in true vanilla behavior, unless you continue to aim at the originally placed scaffolding. Vanilla scaffolding behavior allows looking up/down, whereas this change only allows looking at the original.

Edit 2:
Issue 1 can be solved by fixing Issue 2
Issue 2 I have no idea how to gracefully solve
Issue 3 can be solved by a hyperspecific patch similar to the new L257 that checks current - item vs target block, but not pos
Have to go to work now, will fix tonight.

@VL4DST3R
Copy link
Author

Have you considered adding a keybind as a somewhat of a workaround to this? So you can disable the "accurate block placing" feature when you're not building and want the classic "held" behavior, as realistically you don't always need it. This is not really a fix but it may alleviate things until a proper fix can be found

@KadTheHunter
Copy link
Collaborator

KadTheHunter commented Jan 17, 2025

@VL4DST3R That feature exists, there's a section in Minecrafts controls for ABP where you can bind keys for toggling ABP and FBB.

While that is technically a solution, I'd still prefer to fix this properly over relying on the toggle.

I have a few ideas how to handle it, it's just a matter of testing them tonight.

@KadTheHunter
Copy link
Collaborator

Ok, after more than 5 hours of trying to fix this, I think I've done it.

Most of that time was spent trying every solution under the sun, and determining that the weird edge case where placing shulkers while moving and turning diagonally often opens them instead of placing more is actually just ABPs behavior regardless of whether of what solution I use.

The solution that will be released soon is to check if the target block is a BlockWithEntity, and if the players position from the last known placement is within 0.6 blocks of the players current position, and if both are true, passing it back to Vanilla so that you can open it.

// if the target block is a BlockWithEntity (i.e. storage container) and the player has moved less than 0.6 blocks, let vanilla take over
if((targetBlock instanceof BlockWithEntity) && (lastPlayerPlacedBlockPos != null && lastPlayerPlacedBlockPos.distanceTo(client.player.getPos()) <= 0.6)) {
	return;
}

Will close this issue when the commit is pushed.

@KadTheHunter KadTheHunter added the fixed This issue is fixed in an upcoming update label Jan 18, 2025
@VL4DST3R
Copy link
Author

weird edge case where placing shulkers while moving and turning diagonally often opens them instead

So could this be why I thought there was a difference between sp and mp? I just got lucky with my angle? Regardless, thank you for this, this kind of quality of life stuff makes using your mod a joy!

@KadTheHunter
Copy link
Collaborator

@VL4DST3R Probably not, that's just something I discovered during testing, and initially believed to be related to the issue. It's quite hard to even intentionally reproduce, and I couldn't even give more precise instructions beyond "place shulkers while moving body and camera diagonally". It also only typically occurs when placing multiple shulkers (i.e. in creative mode), not placing one shulker and opening it in the same click.

Not sure what specific differences you noticed in single vs multiplayer, but I reproduced the original issue here in singleplayer, and all my testing was done in singleplayer. I (possibly incorrectly) believe that any discrepancies in multiplayer are the result of some sort of serverside interference or modification

@KadTheHunter
Copy link
Collaborator

@VL4DST3R This is now released in v1.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed This issue is fixed in an upcoming update
Projects
None yet
Development

No branches or pull requests

2 participants