Jump Pads

Discussion in 'Plugin Development' started by top2001, Dec 3, 2014.

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

    top2001

    Hello, I was wondering how I would get particles to play on the block the player has jumped off with a jump pad plugin I am making. I've currently made the jump pad plugin but what I want to do is player an effect from where the player has jumped off the block. Basically getting the blocks location and playing an effect really. If anyone could help me with this, I would be really happy :)
     
  2. Offline

    mythbusterma

    top2001

    I believe ProtocolLib has a very simple way for you to play out a particle effect. Look it up.
     
  3. Offline

    Skionz

  4. Offline

    top2001


    I know how to send particle packets but I want to know how to make the particles appear on top of the block of where they jumped from.
     
  5. Offline

    Skionz

    top2001 Get the x, y, z of the block and fill your new PacketPlayOutWorldParticles object's parameters with them.
     
  6. Offline

    top2001


    How would I put that into this code?
    Code:java
    1. package me.top2001.OreCloudJumpPads;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.Material;
    7. import org.bukkit.Sound;
    8. import org.bukkit.block.BlockFace;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.event.EventHandler;
    11. import org.bukkit.event.Listener;
    12. import org.bukkit.event.entity.EntityDamageEvent;
    13. import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
    14. import org.bukkit.event.player.PlayerMoveEvent;
    15. import org.bukkit.plugin.java.JavaPlugin;
    16. import org.bukkit.util.Vector;
    17.  
    18. public class Main extends JavaPlugin implements Listener{
    19.  
    20. private ArrayList<Player> jumpers = new ArrayList<Player>();
    21.  
    22. public void onEnable() {
    23. getLogger().info("Plugin Enabled!");
    24. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    25. }
    26.  
    27. public void onDisable() {
    28. getLogger().info("Plugin Disabled!");
    29. }
    30.  
    31. @EventHandler
    32. public void onPlayerMove(PlayerMoveEvent e) {
    33. if (e.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.SPONGE) {
    34. e.getPlayer().setVelocity(e.getPlayer().getLocation().getDirection().multiply(3));
    35. e.getPlayer().setVelocity(new Vector(e.getPlayer().getVelocity().getX(), 1.00, e.getPlayer().getVelocity().getZ()));
    36. e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.ORB_PICKUP, 200, 3);
    37. e.getPlayer().
    38. jumpers.add(e.getPlayer());
    39. }
    40. }
    41.  
    42. @EventHandler
    43. public void onPlayerDamage(EntityDamageEvent e) {
    44. if (e.getEntity() instanceof Player) {
    45. Player player = (Player) e.getEntity();
    46. if (e.getCause() == DamageCause.FALL && jumpers.contains(player)) {
    47. e.setDamage(0.0);
    48. jumpers.remove(player);
    49. }
    50. }
    51. }
    52. }
    53.  
     
  7. Offline

    Skionz

    top2001 Look at the wiki for all of the parameters and do what I said above.
     
  8. Offline

    DeamonZ

    top2001 in your PlayerMoveEvent add this line of code:
    Code:java
    1. Location block = e.getTo().getBlock().getLocation();
    2. World w = e.getPlayer().getWorld();
    3. w.playEffect(block, Effect.EXPLOSION_HUGE, 10);


    You can change the effect to whatever you want.
    So like this:
    Code:java
    1. @EventHandler
    2. public void onPlayerMove(PlayerMoveEvent e) {
    3. if (e.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.SPONGE) {
    4. e.getPlayer().setVelocity(e.getPlayer().getLocation().getDirection().multiply(3));
    5. e.getPlayer().setVelocity(new Vector(e.getPlayer().getVelocity().getX(), 1.00, e.getPlayer().getVelocity().getZ()));
    6. e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.ORB_PICKUP, 200, 3);
    7. e.getPlayer().
    8. jumpers.add(e.getPlayer());
    9.  
    10. Location block = e.getTo().getBlock().getLocation();
    11. World w = e.getPlayer().getWorld();
    12. w.playEffect(block, Effect.EXPLOSION_HUGE, 10);
    13. }
    14. }
     
    top2001 likes this.
  9. Offline

    top2001


    Nice. Thanks for your excellent help :)
     
Thread Status:
Not open for further replies.

Share This Page