How to spawn smoke?

Discussion in 'Plugin Development' started by Olof Larsson, Mar 7, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Olof Larsson

    How do I spawn smoke? With smoke I mean the smoke effect that appeads when you kill an animal or a tnt explodes.

    I found the word smoke in this file:
    and from looking at that code I guess I should do something like this:
    CraftWorld cw = (CraftWorld)player.getWorld();
    cw.getHandle().a("smoke", a, b, c, d, e, f);
    a, b, c, d, e, f
    are doubles... but what do they represent? XD
    --- merged: Mar 7, 2011 6:32 PM ---
    a = x
    b = y
    c = z
    So they represent the world position... Anyone knows what d, e, f is?
    For a tnt explosion about 700 smokes are generated...
  2. Interesting.. I wanna know more of this too.
  3. Offline


    Have you checked torches? d,e,f might be coords that the spawned smoke travels to before disappearing.
  4. Offline

    Olof Larsson

    this .a method is called 44 times in all of CraftBukkit source. The first parameter takes these different values:
    smoke, largesmoke, bubble, splash, snowballpoof, explode, flame :)

    So this method seems to be some kind of animation related.
    In many of the cases where the method is called d,e,f is set to 0. Take this for example:

    However I have still not managed to generate an animation I am able to see...
    --- merged: Mar 7, 2011 7:11 PM ---
    Yeah I think you are right. Passed values are usual close to zero and exists both possitive and negative like this:

    so they are probable some delta position for x, y and z.
    --- merged: Mar 7, 2011 7:20 PM ---
    I try this but see nothing:

    Location playerLocation = player.getLocation();
    double x = playerLocation.getX() + Math.random() * 2D - 1D;
    double y = playerLocation.getY() + Math.random() * 2D - 1D;
    double z = playerLocation.getZ() + Math.random() * 2D - 1D;
    double w = 0.0D;
    CraftWorld cw = (CraftWorld)player.getWorld();
    cw.getHandle().a("smoke", x+Math.random(), y+Math.random(), z+Math.random(), w, w, w);
    cw.getHandle().a("largesmoke", x+Math.random(), y+Math.random(), z+Math.random(), w, w, w);
    cw.getHandle().a("bubble", x+Math.random(), y+Math.random(), z+Math.random(), w, w, w);
    cw.getHandle().a("splash", x+Math.random(), y+Math.random(), z+Math.random(), w, w, w);
    cw.getHandle().a("snowballpoof", x+Math.random(), y+Math.random(), z+Math.random(), w, w, w);
    cw.getHandle().a("explode", x+Math.random(), y+Math.random(), z+Math.random(), w, w, w);
    cw.getHandle().a("flame", x+Math.random(), y+Math.random(), z+Math.random(), w, w, w);
    Anyone got any ideas?
  5. Offline


    I'm working on hack api so I will look into this.
  6. Offline

    Edward Hand

    That function doesn't result in any packet being sent to the client so it can't affect it. It seems to be a remnant of a copy+paste from client to server, or perhaps due to shared classes (there are a few examples of that).

    For an idea of what the server can make the client do, take a look at the names of all the classes starting with 'Packet'.
  7. Offline

    Olof Larsson

    Ok... that's most informative :) Where do I find the packettypes? Could you please give me a hint? And... Do you know if smoke / animation packets exist? Would smoke generation be possible?
  8. Offline

    Dinnerbone Bukkit Team Member

    You cannot do this. The animations are clientside purely, the server does not control them. Believe me, if it were possible I'd have made the API a long time ago :p
  9. Offline


  10. Offline

    Edward Hand

    The Packet class has a list of all the Packet types in a hash map defined at the bottom.
    And if you want to see how the server handles them, you want NetServerHandler not NetHandler. NetHandler is the interface shared by NetServerHandler on the server and NetClientHandler on the client (which of course you wont find in bukkit). It thus contains a number of functions that are used only by the client, not the server.
  11. Offline


    It would have been fun to create smoke at arenas or to make a chimney. :)
  12. Offline

    Olof Larsson

    Ok thank's a lot for the help :)
    I'll have give up on the animation effects then [​IMG]
    I was hoping I could use them for my vampire plugin but well well. It will work well without smoke effects anyhow :)

    Some things you should be able to add to bukkit though:

    And an interface to send packages to simulate a damage jerk... I used this in my vampire plugin:
    public void damageVisualize() {
        Player player = this.getPlayer();
        CraftPlayer cPlayer = (CraftPlayer)this.getPlayer();
        int currentHealth = player.getHealth();
        cPlayer.getHandle().a.b(new Packet8UpdateHealth(20));
        cPlayer.getHandle().a.b(new Packet8UpdateHealth(19));
        cPlayer.getHandle().a.b(new Packet8UpdateHealth(currentHealth));
  13. Offline


    Thanks, good to know. I linked the interface because it's easier to find the packets list there.
  14. Offline


    Ooooh... that's neat! Thanks for sharing :)
  15. You could better use the animation packet :) (1 = arm swing, 2 = damage)
  16. Offline


    The obvious guess would be rotation, but that doesn't seem to make sense here.
  17. Offline

    Olof Larsson

    You are welcome :) I think I found it in some forum thread by Edward Hand. So thanks Edward :)
  18. Offline


    Yah, Thanks Edward!

    I don't know what I want to use this for yet, but I'm thinking definitely a spell!

    Seems like, on its own, it wouldn't really do much but irritate a player- I could call it "poke" :)
  19. Offline


  20. Offline

    Dinnerbone Bukkit Team Member

    "poke" sounds like it should .setVelocity(.getVelocity().setY(2));
  21. Offline

    Olof Larsson

    Yeah lol :) ... those new velocity methods... Could they be used to make players jump higher or run faster? That might be a cool thing for my vampire mod. Is there a way to hook into keyboard movement right now? To know when the player pressed space?
  22. Offline

    Dinnerbone Bukkit Team Member

    Yes, they can. And no, there isn't and can't be other than PLAYER_MOVE.
Thread Status:
Not open for further replies.

Share This Page