Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.14.4] Item#doesSneakBypassUse() and PlayerInteractEvent#RightClickBlock

Featured Replies

Posted

Now that Item#doesSneakBypassUse() is back in, I've been trying to get my item to work properly again when dual wielding. In 1.12.2 I used PlayerInteractEvent#RightClickBlock to get Block#onBlockActivated() to trigger even when sneaking and holding an item in both hands (by setting UseBlock to Allow and UseItem to Deny under the right circumstances). Without this, half the functionalty of my wrench doesn't work if the player is holding a shield for example and tries to use the wrench while sneaking.

This approach doesn't seem to work anymore, because it is now required for both items to return true in doesSneakBypassUse() when sneaking, which is never the case for vanilla items (because the default behavior of IForgeItem#doesSneakBypassUse() is to return false).

boolean flag = !p_219441_1_.getHeldItemMainhand().isEmpty() || !p_219441_1_.getHeldItemOffhand().isEmpty();
boolean flag1 = !(p_219441_1_.isSneaking() && flag) || (p_219441_1_.getHeldItemMainhand().doesSneakBypassUse(p_219441_2_,blockpos,p_219441_1_) && p_219441_1_.getHeldItemOffhand().doesSneakBypassUse(p_219441_2_,blockpos,p_219441_1_));
if (event.getUseBlock() != net.minecraftforge.eventbus.api.Event.Result.DENY && flag1 && blockstate.onBlockActivated(p_219441_2_, p_219441_1_, p_219441_4_, p_219441_5_)) {
	return ActionResultType.SUCCESS;
}

Is this broken or intended behavior ...  or am I missing something ? I mean, isn't the whole purpose of PlayerInteractEvent#RightClickBlock to override default behavior?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.