Creating a horizontal Vector instead of verticle.

Discussion in 'Plugin Development' started by OmgzMonkeeh, Mar 4, 2015.

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

    OmgzMonkeeh

    The end process is to have the ability to :
    • Check if the player has Redstone in one's hand.
    • If Redstone is there , fire a helix from the redstone.
    What I want to know how to create a spiral of "Firework stars" horizontally once you click a redstone block!
    Help anyone?

    Code:
    public class Main extends JavaPlugin implements Listener {
        public void onEnable() {
            PluginManager pm = Bukkit.getPluginManager();
            pm.registerEvents(this, this);
        }
    
    
        public void CreateHelix(Player player) {
            Location loc = player.getLocation();
            int radius = 2;
            for (double y = 0; y <= 50; y += 0.05) {
                double x = radius * Math.cos(y);
                double z = radius * Math.sin(y);
                PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles("slime",
                        (float) (loc.getX() + x),
                        (float) (loc.getY() + y),
                        (float) (loc.getZ() + z), 0, 0, 0, 0, 2);
                for (Player online : Bukkit.getOnlinePlayers()) {
                    ((CraftPlayer) online).getHandle().playerConnection.sendPacket(packet);
                }
            }
        }
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
        {
            if (cmd.getName().equalsIgnoreCase("Spiral")) {
                Player p = (Player)sender;
                CreateHelix(p);
            }
            return false;
    
        }
    }
    
     
    Last edited: Mar 4, 2015
  2. Offline

    mythbusterma

    @OmgzMonkeeh

    If you want a horizontal spiral, just swap the z and y or x and y axis. Then it will be horizontal.
     
  3. Offline

    OmgzMonkeeh

    Can you reply with the code highlighted or something so I can find out where you're on about lol. New to coding.
     
  4. Offline

    mythbusterma

    @OmgzMonkeeh

    ....pick x or z. I'll assume x. Any time you see y, replace it with x (except in the particle spawn), any time you see x, replace it with y (again, except for the spawn code).
     
Thread Status:
Not open for further replies.

Share This Page