Solved UNSOLVED help with fishingrod entity spawn

Discussion in 'Plugin Development' started by ResultStatic, Dec 31, 2013.

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

    ResultStatic

    i am trying to make a grappler kit and i want a fishing hook to appear when you right click and to pull you to that location when left click. i tried with the fish event but it would unhook when you pulled to them because you are right clicking again. also making it as a leash was hard to understand after looking at another post. here is my code
    Code:
    import java.util.List;
     
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.util.Vector;
    import org.result.api.UserUtil;
     
    public class Kitevents3 implements Listener {
       
        @EventHandler
          public void onInteract(PlayerInteractEvent event)
          {
            Player player = event.getPlayer();
            if ((UserUtil.getInstance().getKit(player).equals("grappler"))) {
                Player p = event.getPlayer();
                Action a = event.getAction();
                Vector vector = p.getEyeLocation().getDirection().multiply(3);
                List<Entity> nearbyEntities = p.getNearbyEntities(8, 8, 8);
                for(Entity entity : nearbyEntities){
                    entity.setVelocity(vector);
                    Entity hook = p.getWorld().spawnEntity(p.getEyeLocation(), EntityType.FISHING_HOOK);
                    if(a == Action.RIGHT_CLICK_BLOCK || a == Action.RIGHT_CLICK_AIR && p.getItemInHand().getType() == Material.FISHING_ROD){
                        event.setCancelled(true);
                        hook.setVelocity(vector);
                    }
                      else if(a == Action.LEFT_CLICK_BLOCK || a == Action.LEFT_CLICK_AIR && p.getItemInHand().getType() == Material.FISHING_ROD){
                        if (hook.isOnGround()) {
                        Location lc = player.getLocation();
                        Location to = hook.getLocation();
                        lc.setY(lc.getY() + 0.5D);
                        player.teleport(lc);
     
                        double d = to.distance(lc);
                        double t = d;
                        double v_x = (1.0D + 0.07000000000000001D * t) * (to.getX() - lc.getX()) / t;
                        double v_z = (1.0D + 0.07000000000000001D * t) * (to.getZ() - lc.getZ()) / t;
     
                        Vector v = player.getVelocity();
                        v.setX(v_x);
                        v.setZ(v_z);
                        player.setVelocity(v);
                    }
                }
            }
        }
      }
    }
     
        
    here is the errors
    Code:
    [20:52:52 ERROR]: Could not pass event PlayerInteractEvent to Resultkits v1.1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:427) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callPlayerInte
    ractEvent(CraftEventFactory.java:191) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b29
    74jnks]
            at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callPlayerInte
    ractEvent(CraftEventFactory.java:161) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b29
    74jnks]
            at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
    :978) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInArmAnimation.a(SourceFile:43
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInArmAnimation.handle(SourceFi
    le:9) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    55) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    Caused by: java.lang.IllegalArgumentException: Cannot spawn an entity for org.bu
    kkit.entity.Fish
            at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawn(CraftWorld.java:1039)
    ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawn(CraftWorld.java:804)
    ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawnEntity(CraftWorld.java
    :338) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.result.listeners.Kitevents3.onInteract(Kitevents3.java:30) ~[?:?]
     
            at sun.reflect.GeneratedMethodAccessor229.invoke(Unknown Source) ~[?:?]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .7.0_25]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_25]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            ... 15 more
    [20:52:52 ERROR]: Could not pass event PlayerInteractEvent to Resultkits v1.1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:427) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callPlayerInte
    ractEvent(CraftEventFactory.java:191) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b29
    74jnks]
            at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callPlayerInte
    ractEvent(CraftEventFactory.java:161) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b29
    74jnks]
            at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
    :604) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInBlockPlace.a(SourceFile:60)
    [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInBlockPlace.handle(SourceFile
    :9) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    55) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    Caused by: java.lang.IllegalArgumentException: Cannot spawn an entity for org.bu
    kkit.entity.Fish
            at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawn(CraftWorld.java:1039)
    ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawn(CraftWorld.java:804)
    ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawnEntity(CraftWorld.java
    :338) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.result.listeners.Kitevents3.onInteract(Kitevents3.java:30) ~[?:?]
     
            at sun.reflect.GeneratedMethodAccessor229.invoke(Unknown Source) ~[?:?]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .7.0_25]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_25]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            ... 15 more
    [20:52:52 ERROR]: Could not pass event PlayerInteractEvent to Resultkits v1.1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:427) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callPlayerInte
    ractEvent(CraftEventFactory.java:191) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b29
    74jnks]
            at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callPlayerInte
    ractEvent(CraftEventFactory.java:161) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b29
    74jnks]
            at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
    :978) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInArmAnimation.a(SourceFile:43
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInArmAnimation.handle(SourceFi
    le:9) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    55) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    Caused by: java.lang.IllegalArgumentException: Cannot spawn an entity for org.bu
    kkit.entity.Fish
            at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawn(CraftWorld.java:1039)
    ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawn(CraftWorld.java:804)
    ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftWorld.spawnEntity(CraftWorld.java
    :338) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            at org.result.listeners.Kitevents3.onInteract(Kitevents3.java:30) ~[?:?]
     
            at sun.reflect.GeneratedMethodAccessor229.invoke(Unknown Source) ~[?:?]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .7.0_25]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_25]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:425) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            ... 15 more
    thanks to anyone who can help
     
  2. Offline

    RawCode

    use
    new EntityFishingHook(world);
    +
    world.addEntity(entity, reason);
     
  3. Offline

    ResultStatic

    RawCode i am confused where do i put new EntityFishingHook(world) and what about the reason

    RawCode yeah i cant get it to work

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  4. Offline

    ResultStatic

  5. Offline

    xTrollxDudex

    RawCode
    Realize that most people can't understand from a brief post such as yours that are ofted attributed eith "minimalist" and "texting-like" format.
    ResultStatic
    This post may help you
    Bukkit doesn't like it when you manually spawn a fishing hook.
     
  6. Offline

    RawCode

    xTrollxDudex
    I provide only information required for solving problem, thread you given have absolutely same solution as i posted.
     
  7. Offline

    xTrollxDudex

    RawCode
    That's not my point; my point is that you need to provide further elaboration on your reply, provide an overview of what should be done (missed completely), provide options or a direct and explained way of doing it such as pseudo code (getting close, minimalist though) and sum up with background to prove your post (Good, at least there's a semicolon at the end).

    Of course, not all posts need this exact format, but seriously, at least capitalize your letters and put a few commas in so it's readable. You are a person with a lot of knowledge, but if people could actually comprehend what you are trying to communicate, then you may be a litte more a help than now (No offense).
     
  8. Offline

    ResultStatic

    xTrollxDudex I did a google search on trying to find out how to do this and i found that post and tried it but i couldnt get it to work with the imports but i figured out why. the names of the classes had changed to 1.7 instead of 1.6, i feel stupid now... ok ill see if i can get it to work thanks though.

    @RawCode @xTrollxDudex So i have been working with the code in the post for grappler. i managed to get it to work on 1.6.2 but not on 1.7.2. i get no errors on it but i cant figure out how to get an item in 1.7.2. in 1.6.2 it was Item.Leash and now that doesnt work. here is the extends class, im pretty sure this class will work now.
    Code:
    package org.result.listeners;
     
    import org.bukkit.Location;
    import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
    import org.bukkit.entity.Player;
    import net.minecraft.server.v1_7_R1.EntityFishingHook;
    import net.minecraft.server.v1_7_R1.Item;
    import net.minecraft.server.v1_7_R1.ItemStack;
    import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
     
        public class FishingLine extends EntityFishingHook {
            private Item item;
       
            public FishingLine(Player player, Item item2){
                super(((CraftWorld) player.getWorld()).getHandle(), ((CraftPlayer) player).getHandle());
                item2 =
                this.item = item2;
            }
           
            public void l_(){
                if(item != null){
                    ItemStack hand = this.owner.bD();
                    boolean shouldRemove = false;
       
                    if(this.owner.dead || !(this.owner.isAlive())){
                        shouldRemove = true;
                    }
       
                    if(hand == null){
                        shouldRemove = true;
                    } else {
                        if(hand.getItem() != item){
                            shouldRemove = true;
                        }
                    }
       
                    if(this.e(this.owner) > 1024.0D){
                        shouldRemove = true;
                    }
       
                    if(shouldRemove){
                        super.die();
                        super.owner.hookedFish = null;
                    }
                }
            }
       
            public void spawn(Location loc){
                net.minecraft.server.v1_7_R1.World nmsWorld = ((CraftWorld) loc.getWorld()).getHandle();
       
                nmsWorld.addEntity(this);
                this.setPosition(loc.getX(), loc.getY(), loc.getZ());
            }
        }
    here is my other class where i use it, i dont understand it when you type Item it comes up with stuff like REGISTRY, a() etc. i looked at the code and it doesnt make any since.
    Code:
     @EventHandler
          public void onInteract(PlayerInteractEvent event)
          {
            Player player = event.getPlayer();
            Item item = (Item) net.minecraft.server.v1_7_R1.Item.REGISTRY.a("lead"); //help here
    if ((UserUtil.getInstance().getKit(player).equals("grappler")) && (
              ((event.getAction() == Action.RIGHT_CLICK_AIR) && (event.getMaterial() == Material.LEASH)) || ((event.getAction() == Action.RIGHT_CLICK_BLOCK) && (event.getMaterial() == Material.LEASH)))) {
              event.setCancelled(true);
              FishingLine fish = new FishingLine(player, item);
              Location location = player.getLocation();
              fish.spawn(location);
    }
    }
    }
    here is the diffrence in src code in 1.6.2 and 1.7.2
    Code:
    (1.6.2)  public static Item LEASH = new ItemLeash(164).b("leash").d("lead");
    Code:
    (1.7.2)    REGISTRY.a(420, "lead", new ItemLeash().c("leash").f("lead"));
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  9. Offline

    ResultStatic

    @chasechocolate im just gonna tahg you here because you are the one who wrote this code for 1.6.2

    OMG i did it i got it to work here is the code one of variables had changed
    Code:
    import org.bukkit.Location;
    import org.bukkit.craftbukkit.v1_7_R1.CraftWorld;
    import org.bukkit.entity.Player;
     
    import net.minecraft.server.v1_7_R1.EntityFishingHook;
    import net.minecraft.server.v1_7_R1.Item;
    import net.minecraft.server.v1_7_R1.ItemStack;
     
    import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
     
        public class FishingLine extends EntityFishingHook {
            private Item item;
       
            public FishingLine(Player player, Item item2){
                super(((CraftWorld) player.getWorld()).getHandle(), ((CraftPlayer) player).getHandle());
                item2 =
                this.item = item2;
            }
            @Override
            public void h(){
                if(item != null){
                    ItemStack hand = this.owner.bD();
                    boolean shouldRemove = false;
       
                    if(this.owner.dead || !(this.owner.isAlive())){
                        shouldRemove = true;
                    }
       
                    if(hand == null){
                        shouldRemove = true;
                    } else {
                        if(hand.getItem() != item){
                            shouldRemove = true;
                        }
                    }
       
                    if(this.e(this.owner) > 1024.0D){
                        shouldRemove = true;
                    }
       
                    if(shouldRemove){
                        super.die();
                        super.owner.hookedFish = null;
                    }
                }
            }
       
            public void spawn(Location loc){
                net.minecraft.server.v1_7_R1.World nmsWorld = ((CraftWorld) loc.getWorld()).getHandle();
       
                nmsWorld.addEntity(this);
                this.setPosition(loc.getX(), loc.getY(), loc.getZ());
            }
        }
    here is the class that shoots the hooks
    Code:
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.result.api.UserUtil;
    public class Kitevents3 implements Listener {
        @EventHandler
          public void onInteract(PlayerInteractEvent event)
          {
            Player player = event.getPlayer();
            Item item = (Item) net.minecraft.server.v1_7_R1.Item.REGISTRY.a("lead");
    if ((UserUtil.getInstance().getKit(player).equals("grappler")) && (
              ((event.getAction() == Action.RIGHT_CLICK_AIR) && (event.getMaterial() == Material.LEASH)) || ((event.getAction() == Action.RIGHT_CLICK_BLOCK) && (event.getMaterial() == Material.LEASH)))) {
              event.setCancelled(true);
              FishingLine fish = new FishingLine(player, item);
              Location location = player.getLocation();
              fish.spawn(location);
    }
    }
    }
    feel free to use this code, original credit goes to @chasechocolate i just updated it to 1.7.2.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  10. ResultStatic
    code isn't working for me.
     
  11. Offline

    ResultStatic

    TheAnswerIsMinecraft you are going to have to be more specific than "isnt working". also its better to look at the source code and take all of the code from that method that you override. thats what i did in the end
     
  12. Offline

    SneakyLegend

    it doesnt shoot it teleports back to its launching location
     
  13. Offline

    ResultStatic

    SneakyLegend well it works for me. something isnt working when you override if its cancelling it
     
  14. Offline

    SneakyLegend

    i tried everything but it just doesnt work can you send me you code or say whats wrong with mine
    Code:
    public class FishingLine extends EntityFishingHook {
        private Item item;
     
        public FishingLine(Player player, Item item2){
            super(((CraftWorld) player.getWorld()).getHandle(), ((CraftPlayer) player).getHandle());
            item2 =
            this.item = item2;
        }
       
        public void h(){
            if(item != null){
                ItemStack hand = this.owner.bD();
                boolean shouldRemove = false;
     
                if(this.owner.dead || !(this.owner.isAlive())){
                    shouldRemove = true;
                }
     
                if(hand == null){
                    shouldRemove = true;
                } else {
                    if(hand.getItem() != item){
                        shouldRemove = true;
                    }
                }
     
                if(this.e(this.owner) > 9999999.0D){
                    shouldRemove = true;
                }
     
                if(shouldRemove){
                    super.die();
                    super.owner.hookedFish = null;
                }
            }
        }
     
        public void spawn(Location loc){
            net.minecraft.server.v1_7_R1.World nmsWorld = ((CraftWorld) loc.getWorld()).getHandle();
           
            nmsWorld.addEntity(this);
        }
    }
     
  15. Offline

    ResultStatic

    SneakyLegend try this

    Item item = (Item) net.minecraft.server.v1_7_R1.Items.LEASH;

    when you override the method it takes away everything that a hook would normally do like hit players hook onto things and disapear. you need to add code from the original method or use packets like entitydestroy and entityattatch
     
  16. Offline

    SneakyLegend

    still glitches back :/
    plz help me
    i have been working on it for 6 hours
     
  17. Offline

    ResultStatic

  18. Offline

    SneakyLegend

    nvm i fixed it
     
  19. Offline

    vRiiP

    Can you send me the complete code please? :D
     
Thread Status:
Not open for further replies.

Share This Page