Getting hook location

Discussion in 'Plugin Development' started by Miniwarbos, Apr 17, 2014.

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

    Miniwarbos

    hello. I want to make a 'hookshot' plugin, and I was wondering what you guys think is the best way to track the location of the fishing hook, and check what player it's linked to. As far as I know there isn't an easy way to do this, and people are suggesting that it's best to get the closest entity's and check if it's a fishing hook, but if there was another players fishing hook near by it would track that instead. Thanks

    P. S. Also, what do you think would be the best way to multiply the velocity the player is thrown towards the hook at depending on the direction. I want to make it very much like the grappling hook they have on the show bow network. Thanks.
     
  2. Offline

    2MBKindiegames

  3. Offline

    thisguy128512

    If I am not mistaken, getDamager() would return the bobber. The fishing event would probably tell you what the bobber is, and you could get that bobber's ID and associate it with a player in an array, track of which is kept by the plugin. I did something similar with arrows to steal the Crusader's Crossbow from Team Fortress 2... let me see if I can help you here.

    Code:java
    1. @EventHandler
    2. onFish(FishingEvent event) {//Obviously I have no idea what this event is called.
    3. insert(hookBobbers, event.getBobber().getEntityId()); //Wherein hookBobbers is an int[] of the IDs of all hookshot bobbers.
    4. insert(hookPlayers, event.getPlayer().getEntityId());
    5. /* You'll have to keep track of which bobber goes to which player,
    6.   * and I hope you do this by keeping their indeces the same.
    7.   */
    8. /* Other fun stuff goes here.
    9.   * It's safe to remove the bobber from the list
    10.   * after a few seconds, since it's not going to hit
    11.   * an entity in any meaningful way after it lands
    12.   * on a block.
    13.   */
    14. }
    15.  
    16. //Blast Foghat and write code here
    17.  
    18. @EventHandler
    19. onDamage(EntityDamageByEntityEvent event) {
    20. //If event.getDamager().getEntityId() is in hookBobbers...
    21. /* Create a vector from the damagee
    22.   * to the player with the same index as
    23.   * the bobber and set the damagee's
    24.   * velocity to it.
    25.   */
    26. }
     
  4. Offline

    itzrobotix

    Try the ProjectileHitEvent and check to see if the entity is a FISHING_HOOK then schedule a repeating task that gets its location?
     
Thread Status:
Not open for further replies.

Share This Page