[Solved] IndexOutOfBoundsException when sending particles :/

Discussion in 'Spigot Plugin Development' started by xkev320x, May 17, 2015.

  1. Hey guys, I've been working on a specific plugin with some certain items, they have unique skills (like shooting blocks, etc..), so I remove them from the inventory when their certain durability is zero, because otherwise the durability would go negative :D To make it more realistic, I want to send the break particles, if that happens.
    So I checked the methods therefore and tried.. 3 different ways and the same error: java.lang.ArrayIndexOutOfBoundsException: 1 That's all :/
    Then you get kicked from the server with this message: http://puu.sh/hQXUW/673da749c6.png
    I don't know exactly what it means, but sometimes it's not 39 but 40..
    My Code:

    First ->
    Code (Java):

    ((CraftWorld)p.getWorld()).getHandle().sendParticles(((CraftPlayer)p).getHandle(), EnumParticle.ITEM_CRACK, true, p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), 359, 0D, 0D, 0D, 0.5D, 3);
     
    Which basically sends the packet 'PacketPlayOutWorldParticles' with given parameters, 359 = id of shears, i want that certain break particle;

    Second ->
    Code (Java):

    p.getWorld().spigot().playEffect(p.getLocation().add(0, 1, 0), Effect.ITEM_BREAK, 359, 0, 0, 0, 0, 0.5F, 3, 1);
     
    (Look at the APIdocs to see the parameters :D)
    Third ->
    Code (Java):

    p.getWorld().playEffect(p.getLocation(), Effect.ITEM_BREAK, 359, 1);
     
    They're all not working, I don't understand. Of course, one value must be too high, 'cause of the exception but I don't know why nor which :/ I can't believe that it's the id, 'cause this must be given somewhere and I'm pretty sure I put the id in the right parameter..

    Thankful for any help :)
     
    #1 xkev320x, May 17, 2015
    Last edited: May 18, 2015
  2. Those are shouldnt be the problem it has to be something about an arraylist. Also is that gives error on your console? If that so can you send that too please.
     
  3. But the problem must come with the effects, because without them, there aren't any errors...
    And the only thing in the console is(as I said): java.lang.ArrayIndexOutOfBoundsException: 1
    No other errors, no lines of code, which can make the error, only that..
     
  4. Can you add your latest log please or no body cant help you
     
  5. I don't know what you want with that, but anyway:
    (tried to destroy the item, so the particles can show up, then:)
    Code (Text):

    [20:51:52] [Server thread/INFO]: Done (8,708s)! For help, type "help" or "?"
    [20:51:53] [User Authenticator #1/INFO]: UUID of player xkev320x is 9a86a32a-ee2a-4fdc-ac9f-05b750231ca8
    [20:51:53] [Server thread/INFO]: xkev320x[/86.56.0.66:55198] logged in with entity id 186 at ([pvpu]-154.548380021157, 68.0, 449.8780080158165)
    [20:53:01] [Netty Server IO #2/ERROR]: java.lang.ArrayIndexOutOfBoundsException: 1
    [20:53:01] [Server thread/INFO]: xkev320x lost connection: Disconnected
    [20:53:01] [Server thread/INFO]: Ā«PvP-UnlimitedĀ» xkev320x hat das Spiel verlassen
     
     
  6. I am not sure but i think its client side error.
     
  7. But my friend had that problem too and the exception can't come from nowhere...
    Maybe some other users know, what's going on.. @DarkSeraphim ? :D
     
  8. No server cause the error but not on server side.
     
  9. But then, something with the particles must be wrong, so the client can't display them and gets kicked, from server side.
    That's what I asked for: If something with the particles is wrong..
     
  10. Really? Why? I know what causes the error.. the particles heyyy! So I don't know how that'll help me..
     
  11. I mean as to why the index isn't what you expected it to be.
     
  12. The problem is, I don't know which index is too high, maybe the data but it's required to make the particle more specific and 359 is for shears..
    So I also don't know how I should debug without knowing which index, hope you understand :p
     
  13. @xkev320x it appears to be Spigot's fault. ITEM_CRACK requires a 1D int array with two ints, but Spigot only gives it a 1D int array with one int (so one int too little). It's quite likely that this is from old/other code, as it certainly used to be that for falling blocks in 1.7.

    The only fix I can come up with right now is sending the packet manually (which means you have to depend on Spigot rather than the Spigot-API) and give it a 1D array of two ints, the ID and datavalue.
     
    • Creative Creative x 1
  14. ok, I will try this, hopefully it works then :D we'll see later.
    EDIT: Ok I'm sending the packet manually now with an array, and it works thx :D @DarkSeraphim
     
    #15 xkev320x, May 18, 2015
    Last edited: May 18, 2015