[SPIGOT-2741] ITEM_BREAK particle type disconnects clients Created: 24/Oct/16 Updated: 25/Oct/16 Resolved: 25/Oct/16 |
|
| Status: | Resolved |
| Project: | Spigot |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Nathan Wolf | Assignee: | Unassigned |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | spigot | ||
| Environment: |
OSX Server git-Spigot-850da7e-b5fb9a1 (MC: 1.10.2) (Implementing API version 1.10.2-R0.1-SNAPSHOT) |
||
| Description |
|
Sending an item_crack particle will disconnect clients with a server-side IndexOutOfBounds exception. Debugging this a little, it appears that particle now takes a two-dimentional array of material id/durability, rather than a single combined integer. This is my suspicion, because if I send a raw packet formatted like that (2D data array) it does not cause an error and shows the correct particle, even for items like colored wool. I am confused by this, however, because looking at the mcserver code it doesn't seem like it actually does this internally (see: EntityLiving, the only use case I can see for this particle). I may be misreading something there. This bug is easy enough to reproduce, just put this in a PlayerInteractEvent handler: event.getPlayer().playEffect(event.getPlayer().getEyeLocation(), Effect.ITEM_BREAK, Material.DIAMOND_AXE); I checked for duplicate issues and found only |
| Comments |
| Comment by Nathan Wolf [ 25/Oct/16 ] |
|
Cool, thanks, that works for me! |
| Comment by md_5 [ 25/Oct/16 ] |
|
Right, you were attempting to use the legacy Spigot particle API from before Bukkit had one. I have pushed a commit to deprecate all aspects of this API. |
| Comment by pokechu22 [ 25/Oct/16 ] |
|
I agree - calling a valid method with a valid type shouldn't disconnect players. But the breaking item particle isn't a member of the Effect enum. Still, that should have created a compile error, not a runtime error (and I got compile errors when I tried to use your example)... For reference, the distinction between effects and particles is mostly just due to the fact that they're separated into several packets protocol-wise (and some have different spawn conditions). Unfortunately most of them aren't documented too deeply (the count and offset fields vary by packet). |
| Comment by Nathan Wolf [ 24/Oct/16 ] |
|
Thanks! I was under the impression that all particles were mirrored in Effect, but I could certainly be mistaken there. Your code works (it doesn't cause an error). The particles fly away at a crazy speed, but I'm guessing that's tweakable. If that's the right way to spawn particles, then that's fine by me. I was using a non-deprecated playEffect method, though, with the proper data type- it seems like that shouldn't cause client-disconnecting errors in any case, though, right? I'm fine with this being closed if it's considered a non-issue, I just wanted to bring up a problem I ran into. |
| Comment by pokechu22 [ 24/Oct/16 ] |
|
Per wiki.vg's info on the particle packet, iconcrack does take 2 parameters. (Note: you say "2-dimensional array", but I think you mean "array with a length of 2"). You're also mixing up particles and effects. There is no Effect named ITEM_BREAK (you can see effects here). You need to use the Particle enum for particles. The Particle named ITEM_CRACK does take a parameter: an itemstack, not a Material. It should correctly translate it into 2 ints. Does this code work correctly? event.getPlayer().spawnParticle(Particle.ITEM_CRACK, event.getPlayer().getEyeLocation(), 1, new ItemStack(Material.DIAMOND_AXE));
|