Fusseel Posted July 23, 2018 Share Posted July 23, 2018 (edited) 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 July 23, 2018 by Fusseel Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted July 23, 2018 Share Posted July 23, 2018 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. Quote 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. Link to comment Share on other sites More sharing options...
Fusseel Posted July 23, 2018 Author Share Posted July 23, 2018 (edited) 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 July 23, 2018 by Fusseel Quote Link to comment Share on other sites More sharing options...
Fusseel Posted July 24, 2018 Author Share Posted July 24, 2018 Thanks a lot for pointing that out! It's just a lot of new territory I'm trying to get at with this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.