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.

Featured Replies

Posted

I'm trying to manually set EntityPlayerSP.activeHand using EntityPlayerSP.setActiveHand(). Which would be the correct Forge event to do this through? I can't solve this via getItemUseAction() or something similar since I want to implement a new right click action for an existing vanilla item and not a new one from my mod.

I already tried LivingEvent.LivingUpdateEvent, but that one didn't seem to work for my purpose. So which event would be correct?

Edited by Fusseel

51 minutes ago, Fusseel said:

I'm trying to manually set EntityPlayerSP.activeHand using EntityPlayerSP.setActiveHand(). Which would be the correct Forge event to do this through? I can't solve this via getItemUseAction() or something similar since I want to implement a new right click action for an existing vanilla item and not a new one from my mod.

I already tried LivingEvent.LivingUpdateEvent, but that one didn't seem to work for my purpose. So which event would be correct?

Just use one of PlayerInteractEvent sub events to add a new rightClick for an item.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • Author

Thanks a lot guys for the very quick responses as usual!

Turns out I actually had it working before using LivingEvent.LivingUpdateEvent, but I just didn't notice since the effect I was looking for didn't occur. Isn't setActiveHand supposed to eventually slow down the player by a lot and disable sprinting? That's what I'm going for and what I thought would be happening, but it's not.

My current implementation looks this:

@SubscribeEvent
public void rightClickItem(PlayerInteractEvent.RightClickItem event) {
    if (event.getItemStack().getItem() instanceof ItemSword) {
        this.mc.player.setActiveHand(EnumHand.MAIN_HAND);
    }
}

From my understanding due to isHandActive being true now (and it really is, I checked) this code in EntityPlayerSP (line 992-) would be executed now:

if (this.isHandActive() && !this.isRiding())
{
    this.movementInput.moveStrafe *= 0.2F;
    this.movementInput.moveForward *= 0.2F;
    this.sprintToggleTimer = 0;
}

So either it isn't or it's not slowing the player down like I thought it would...

Any idea what's wrong?

Edited by Fusseel

  • Author

Thanks a lot for pointing that out! It's just a lot of new territory I'm trying to get at with this.

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.