Posted November 8, 20195 yr 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.