Solved Spawning item crack particles help.

Discussion in 'Spigot Plugin Development' started by KohakuSaintCrown, May 30, 2017.

  1. I want spawn item particles but how... this is my code but only spawn no texture particles :(

    Code (Text):
    public static void CreeperCookie(Location loc) {
            loc.getWorld().spawnParticle(Particle.ITEM_CRACK, loc.add(0, 1, 0), 10, 0.3, 0.5, 0.3, 0);
  2. Your using 1.11.2 right?
    Its missing the id at the end
  3. is still getting error
    loc.getWorld().spawnParticle(Particle.ITEM_CRACK, loc, 10, 0.3, 0.5, 0.3, 0, 357);
  4. MiniDigger


    what error do you get?
  5. Code (Text):

    Caused by: java.lang.IllegalArgumentException: data should be class org.bukkit.material.MaterialData got class java.lang.Float
        at org.bukkit.craftbukkit.v1_11_R1.CraftWorld.spawnParticle( ~[spigot-1.11.2.jar:git-Spigot-3fb9445-6e3cec8]
        at org.bukkit.craftbukkit.v1_11_R1.CraftWorld.spawnParticle( ~[spigot-1.11.2.jar:git-Spigot-3fb9445-6e3cec8]
        at me.KohakuSaintCrown.ElementalCreepers.Core.EffectsPresets.CreeperCookie( ~[?:?]
        at me.KohakuSaintCrown.ElementalCreepers.ElementalCreepers.onCommand( ~[?:?]
        at org.bukkit.command.PluginCommand.execute( ~[spigot-1.11.2.jar:git-Spigot-3fb9445-6e3cec8]
        ... 15 more
  6. I think it has to be an ItemStack instead of an int
  7. Choco


    >.< It's literally right in the stacktrace, how do you miss that?
    @OP you should be passing in a MaterialData parameter rather than a float. I would keep a constant MaterialData field because there's no need to create a new object every time that method is invoked.
  8. Didn't see that one... I had the same Error when I tested it and it asked for an ItemStack :confused:
  9. Choco


    Well, this may have changed in later versions of 1.11 or in 1.12 because at the moment, it does accept ItemStack. See the following lines of Bukkit's Particle enum. Not sure why it's asking for MaterialData when it clearly states ItemStack.
  10. Solved !!!

    Thank you guys

    Code (Text):
    public static void CreeperCookie(Location loc) {
            ItemStack itemData = new ItemStack(Material.COOKIE);
            loc.getWorld().spawnParticle(Particle.ITEM_CRACK, loc, 10, 0.3, 0.5, 0.3, 0, itemData);