MCPVP GRAPPLER QUESTIONS

Discussion in 'Plugin Development' started by saxocellphone, Feb 9, 2014.

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

    saxocellphone

    Code:
    @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
        public void onPlayerFish(PlayerFishEvent event) {
            final Player player = event.getPlayer();
            if (player.getItemInHand().getItemMeta().getDisplayName()
                    .equals("Grapple Rod")) {
                event.getHook().setBounce(false);
                if (event.getState().equals(PlayerFishEvent.State.IN_GROUND)) {
                    Location lc = player.getLocation();
                    Location to = event.getHook().getLocation();
                    lc.setY(lc.getY() + 0.5D);
                    player.teleport(lc);
                    double g = -0.08D;
                    double d = to.distance(lc);
                    double t = d;
                    double v_x = (1.0D + 0.07000000000000001D * t)
                            * (to.getX() - lc.getX()) / t;
                    double v_y = (1.0D + 0.03D * t) * (to.getY() - lc.getY()) / t
                            - 0.5D * g * t;
                    double v_z = (1.0D + 0.007000000000000001D * t)
                            * (to.getZ() - lc.getZ()) / t;
                    Vector v = player.getVelocity();
                    v.setX(v_x);
                    v.setY(v_y);
                    v.setZ(v_z);
                    player.setVelocity(v);
                   
                } else if (event.getState().equals(
                        PlayerFishEvent.State.CAUGHT_ENTITY)) {
                    Location lc = player.getLocation();
                    Location to = event.getHook().getLocation();
                    lc.setY(lc.getY() + 0.5D);
                    player.teleport(lc);
                    double g = -0.08D;
                    double d = to.distance(lc);
                    double t = d;
                    double v_x = (1.0D + 0.07000000000000001D * t)
                            * (to.getX() - lc.getX()) / t;
                    double v_y = (1.0D + 0.03D * t) * (to.getY() - lc.getY()) / t
                            - 0.5D * g * t;
                    double v_z = (1.0D + 0.07000000000000001D * t)
                            * (to.getZ() - lc.getZ()) / t;
                    Vector v = player.getVelocity();
                    v.setX(v_x);
                    v.setY(v_y);
                    v.setZ(v_z);
                    player.setVelocity(v);
                }
            }
        }
    Hi, I'm having trouble with mcpvp's grappler. If you don't know what I'm talking about watch this video .

    My first question is how do I make the bobber to hook on walls? Normal fishing rod can't hook on the walls, I wonder if there is a way to do that.

    My second question is there a way to make the line go longer and faster?

    My final question is how can I make the throwing tool leash/lead instead of the fishing rod? Thank you.
     
  2. saxocellphone
    For your questions:
    1. Extend EntityFishingHook (not sure about this one)
    2. ent.setVelocity(ent.getVelocity().multiply(speed));
    3. You cant launch fishing hook entity with bukkit... youll have to create your own one, and launch it when you need it. Theres a theard in the forums that ChaseChocolate replied in with a code for extended entity fishing hook that you can just launch...
     
    saxocellphone likes this.
Thread Status:
Not open for further replies.

Share This Page