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
top2001 I believe ProtocolLib has a very simple way for you to play out a particle effect. Look it up.
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.
top2001 Get the x, y, z of the block and fill your new PacketPlayOutWorldParticles object's parameters with them.
How would I put that into this code? Code:java package me.top2001.OreCloudJumpPads; import java.util.ArrayList; import org.bukkit.Bukkit;import org.bukkit.Material;import org.bukkit.Sound;import org.bukkit.block.BlockFace;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.entity.EntityDamageEvent;import org.bukkit.event.entity.EntityDamageEvent.DamageCause;import org.bukkit.event.player.PlayerMoveEvent;import org.bukkit.plugin.java.JavaPlugin;import org.bukkit.util.Vector; public class Main extends JavaPlugin implements Listener{ private ArrayList<Player> jumpers = new ArrayList<Player>(); public void onEnable() { getLogger().info("Plugin Enabled!"); Bukkit.getServer().getPluginManager().registerEvents(this, this); } public void onDisable() { getLogger().info("Plugin Disabled!"); } @EventHandler public void onPlayerMove(PlayerMoveEvent e) { if (e.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.SPONGE) { e.getPlayer().setVelocity(e.getPlayer().getLocation().getDirection().multiply(3)); e.getPlayer().setVelocity(new Vector(e.getPlayer().getVelocity().getX(), 1.00, e.getPlayer().getVelocity().getZ())); e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.ORB_PICKUP, 200, 3); e.getPlayer(). jumpers.add(e.getPlayer()); } } @EventHandler public void onPlayerDamage(EntityDamageEvent e) { if (e.getEntity() instanceof Player) { Player player = (Player) e.getEntity(); if (e.getCause() == DamageCause.FALL && jumpers.contains(player)) { e.setDamage(0.0); jumpers.remove(player); } } }}
top2001 in your PlayerMoveEvent add this line of code: Code:java Location block = e.getTo().getBlock().getLocation();World w = e.getPlayer().getWorld();w.playEffect(block, Effect.EXPLOSION_HUGE, 10); You can change the effect to whatever you want. So like this: Code:java @EventHandler public void onPlayerMove(PlayerMoveEvent e) { if (e.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.SPONGE) { e.getPlayer().setVelocity(e.getPlayer().getLocation().getDirection().multiply(3)); e.getPlayer().setVelocity(new Vector(e.getPlayer().getVelocity().getX(), 1.00, e.getPlayer().getVelocity().getZ())); e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.ORB_PICKUP, 200, 3); e.getPlayer(). jumpers.add(e.getPlayer()); Location block = e.getTo().getBlock().getLocation(); World w = e.getPlayer().getWorld(); w.playEffect(block, Effect.EXPLOSION_HUGE, 10); } }