getting the fish item caught

Discussion in 'Plugin Development' started by pkt, Jun 22, 2013.

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

    pkt

    Does anyone know how to get the itemstack of the fish the has been caught when fishing?
     
  2. Offline

    Shzylo

    I have no idea, but I'm pretty sure you will use a PlayerFishEvent.
     
  3. Perhaps have your plugin check for entities, and see if any are a fish.
     
  4. Offline

    pkt

    Yea, that's what I'm using, I just cant find a method that returns the itemstack :(
    right now I'm just poking pigs with my fishing rod....

    I'm trying to do Mineblemone 's idea, but the nearby entities are not returning as DROPPED_ITEMs
    Code:
        @EventHandler
        public void fishing(PlayerFishEvent event) {
            if (event.getState() == State.CAUGHT_FISH) {
                for (Entity entity : event.getHook().getNearbyEntities(5, 5, 5)) {
                    if (entity.getType() == EntityType.DROPPED_ITEM)
                        event.getPlayer().sendMessage(entity.getType().toString());
                }
            }
        }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  5. Offline

    ZeusAllMighty11

    Code:
    if(e.getCaught() != null({ // fish is caught }
     
    Entity e = e.getCaught();
     
    pkt likes this.
  6. Offline

    pkt

    And... I'm caught being stupid again, I tested that earlier, and it only worked for the State.CAUGHT_ENTITY Fishing State, but now it works.. thanks. :)

    Now my problem is that getCaught() is an entity, but I want to get it as an ItemStack...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  7. Use an on player pick up event?
     
Thread Status:
Not open for further replies.

Share This Page