Geyser
Geyser copied to clipboard
Shooting Projectiles via Plugin is Glitchy
Describe the bug
I'm working on a plugin for a minigame that shoots "bullets" that are projectiles (egg or snowball in this case). When I right click with an item (clay ball) it shoots snowballs at 4x velocity and as often as normal ones do. It kills mobs right away and players after a few hits. When I join with a Bedrock account though, the snowballs are only visible when they hit and only kill mobs when I right click on blocks.
To Reproduce
- Run a server with the plugin in this zip file: GunPlugin.zip (Here's the class with the problematic code from my source code. GunListener.java Pay special attention to right click.)
- Join with a Bedrock account.
- Right click with a clay ball.
- Again it doesn't hit any mobs or blocks on right clicking the air and only see it hit, but it does kill when right clicking blocks.
Expected behaviour
The snowballs should be completely visible and should shoot and kill mobs no matter if you right clicked in the air or on a block.
Screenshots / Videos
Java (works like normal): https://www.youtube.com/watch?v=S2kvUWMxcAE
Bedrock (problematic): https://www.youtube.com/watch?v=4z9v1kJxusg
Server Version and Plugins
Server version: This server is running Paper version git-Paper-274 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT) (Git: 04c7b16)
Server plugins: Floodgate, GunPlugin (the problematic one), Scoreboard (one of my custom plugins), ViaBackwards, ViaRewind, ViaVersion, WorldEdit
Geyser Dump
https://dump.geysermc.org/2pT5o8hGjItXjlPAgl640TS07gGgvbjv
Geyser Version
2.0.2-SNAPSHOT (git-master-fb26e26)
Minecraft: Bedrock Edition Version
1.18.12
Additional Context
No response
I'm having a similar problem, so I'll add to this issue.
It's not necessary just this plugin. Any player interaction that shoots a projectile when clicking has this problem. For the projectile to shoot, you need to be looking at a block, as shown in the video.
This is something I mocked up to show the method used:
@EventHandler
public void onInteraction(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
ItemStack mainItem = p.getInventory().getItemInMainHand();
if (mainItem.getType() == Material.IRON_HOE) {
p.launchProjectile(Snowball.class);
}
}
}
Confirming this issue, is likely related to the long-standing issue with registering click events targetting air. #2346 #2113
All my test cases that target a block work as expected. There is a discussion on this in #2113 with a potential solution, but was marked too low priority to do. I would love to see this brought back up, as I still think it is a more common usecase than it was marked as.
Just tested the provided plugin - It seems like this is working fine in the latest version of Geyser - ill therefore close this issue. If this still occurs, please open a new issue. Thanks!