Player Particle Effects

Discussion in 'Plugin Development' started by Jombi, Dec 15, 2012.

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

    Jombi

    I've looked around a bit and found a few other threads about particle effects and such, but none are helping me solve this issue. I want to place a particle effect above a player while he has a specific item in his inventory. I want the particle to be the item.

    I can easily create the particle effects, but getting it above the player, and showing the actual item he's carrying.... that's where I'm stumped. Any help?
     
  2. Offline

    fireblast709

    what kind of particle are you spawning?
     
  3. Offline

    alexmack929

    What do you mean by 'showing' the item?
     
  4. Offline

    Jombi

    Instead of showing smoke for the smoke effect, I want to show the item in their hand.
     
  5. Offline

    fireblast709

    that is not directly possible. You would have to have an Item (the entity) floating over the player
     
  6. Offline

    chasechocolate

    You could spawn the player's item in hand, set it's velocity so it shoots up about 3 blocks, and then de-spawn it (this will happen multiple times per second). If you want to see what I am talking about, join the McCTF Minecraft servers (mcctf.com) and find someone with the flag.
     
  7. Offline

    Jombi

    Yeah, that's what I'm talking about. After going back and looking at what they had again, I realized I had remember the effects wrong.

    Do you how to do it? I just need a nudge in the right direction.
     
  8. Offline

    chasechocolate

  9. Offline

    heisan213

    I suggest you set the item as the player's passenger. (The same as the player is the minecarts passenger when he sits in it.) Make sure to prevent players from picking up the item!
     
  10. Offline

    fireblast709

    (stealing my idea?)
     
  11. Offline

    Jombi

    Thanks for the link. I'm having some issues with casting and timing the tasks. If you can help, I'll post some of what I have and see what I'm doing wrong.
     
  12. Offline

    fireblast709

    Code:java
    1. /*
    2. * The ID
    3. **/
    4. private UUID id;
    5.  
    6. /*
    7. * The command
    8. **/
    9. if(label.equals("flag"))
    10. {
    11. if(id == null)
    12. {
    13. Item i = p.getWorld().dropItem(p.getLocation(), new ItemStack(Material.DIAMOND_SWORD, 1));
    14. id = i.getUniqueId();
    15. p.setPassenger(i);
    16. }
    17. else
    18. {
    19. p.getPassenger().remove();
    20. id = null;
    21. }
    22. }
    23.  
    24. /*
    25. * The events
    26. **/
    27.  
    28. @EventHandler
    29. public void onPickup(PlayerPickupItemEvent event)
    30. {
    31. UUID tid = event.getItem().getUniqueId();
    32. if(tid.equals(id))
    33. {
    34. event.setCancelled(true);
    35. }
    36. }
    37.  
    38. @EventHandler
    39. public void onItemDespawn(ItemDespawnEvent event)
    40. {
    41. UUID tid = event.getEntity().getUniqueId();
    42. if(tid.equals(id))
    43. {
    44. event.setCancelled(true);
    45. }
    46. }

    Problem solved ;D. The effect:
    Show Spoiler
    flag_hovering.png
     
    Regagames, chasechocolate and Jombi like this.
  13. Offline

    Jombi

    +rep to you!

    Do you have a recommendation on how to test when the player scores, and when to make the item despawn?
     
  14. Offline

    fireblast709

    depends on your code I guess
     
  15. Offline

    Jombi

    Well, I want the players to break the wool block (flag) in order to take it. Then they get the flag over their head when they make their way back to their base.
     
  16. Offline

    fireblast709

    on the BlockBreakEvent you set the Item as hovering like I did. You cancel the event, set the block to air, and then use:
    Code:java
    1. Item i = p.getWorld().dropItem(p.getLocation(), new ItemStack(Material.DIAMOND_SWORD, 1));
    2. id = i.getUniqueId();
    3. p.setPassenger(i);
     
  17. Offline

    Live2Pwn

    fireblast709
    Sorry to open up an old thread, but would it be possible to make it so the item hovers at a different height?
     
  18. Offline

    fireblast709

    Live2Pwn if you either override EntityItem from net.minecraft.server or manage everything with a scheduler and events
     
Thread Status:
Not open for further replies.

Share This Page