theishiopian Posted December 28, 2018 Posted December 28, 2018 How do I detect (on the server) if a player is swinging a sword? I want to make an enchantment that lets you deflect arrows like ghast fireballs, but I can't find an event that fires when the player left clicks. I looked into sending a packet from the client to the server when there's a left click on the client side, but I couldn't figure out how to send the server an event object for the left click event. If theres an easier way to do this, I'd love to hear it. Quote
Cadiboo Posted December 28, 2018 Posted December 28, 2018 I think you want the PlayerInteractEvent.LeftClickEmpty and AttackEntityEvent events Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
theishiopian Posted December 28, 2018 Author Posted December 28, 2018 (edited) Will attackEntityEvents work with projectiles? Also, leftclickempty only works on the client. Edited December 28, 2018 by theishiopian events Quote
Cadiboo Posted December 28, 2018 Posted December 28, 2018 IIRC all projectiles are entities except for eggs Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
Cadiboo Posted December 28, 2018 Posted December 28, 2018 (edited) Thats the only reference to it I could find, I think its been changed in newer versions tho Edit: https://bugs.mojang.com/browse/MC-31338 yeah, it was changed ages ago Edited December 28, 2018 by Cadiboo Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
theishiopian Posted December 28, 2018 Author Posted December 28, 2018 Lol, this codebase scares me sometimes with how janky it is. I seem to recall arrows not responding to being hit with a sword, but I'll test again and report back. Quote
theishiopian Posted December 28, 2018 Author Posted December 28, 2018 (edited) @Cadiboo I just tested and AttackEntityEvent event by firing arrows at myself from a dispenser and swinging a sword at them. It appears that arrows dont fire the event. Code: @SubscribeEvent public static void event(AttackEntityEvent event) { if(event.getEntity() instanceof IProjectile) { System.out.println("x"); } } EDIT: Holy shit I'm dumb, I forgot to register the event. EDIT2: After registering the event, it still doesn't work. Edited December 28, 2018 by theishiopian im dumb Quote
Cadiboo Posted December 30, 2018 Posted December 30, 2018 Try the onProjectileImpact event maybe? You could also check the arrow code & possibly submit a PR to forge Quote About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
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.