Shoot carrots that damage

Discussion in 'Plugin Development' started by CraterHater, Aug 6, 2015.

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

    CraterHater

    How can I shoot carrots upon right clicking with an item in hand, those carrots should be the dropped entity and they should shoot forward and upon hitting deal damage how do I do that?
     
  2. Offline

    AcePilot10

    Listen for when the player right clicks, drop the item at the players location, set the velocity of the item, then run a runnable that every tick check if its the same location as a player.
     
  3. Offline

    xXCapzXx

    Awesome thinking man!
    I like this.
     
  4. Offline

    CraterHater

    @AcePilot10 What Velocity should I add if I want it to shoot like 20 blocks ahead?
     
  5. Offline

    AcePilot10

    Just off the tip of my head I think somewhere around the velocity multiplied by 3 should be good.
     
  6. Offline

    CraterHater

  7. Or you could spawn a snowball and let the carrot item ride the snowball and send a PacketPlayOutEntityDestroy to make the snowball invisible :p
     
  8. Offline

    CraterHater

    @FisheyLP I now did this using an arrow, a carrot is riding it but I want the arrow to be invisible, how to do that?
    Code:
    Arrow A = p.getPlayer().launchProjectile(Arrow.class);
                                        ItemStack item = new ItemStack(Material.CARROT_ITEM);
                                         Location x = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY()+15, p.getLocation().getZ());
                                         Entity e = p.getWorld().dropItemNaturally(x,(item));
                                         A.setPassenger(e);
                                         A.setKnockbackStrength(1);  
     
  9. I think it was:
    Code:
    PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(arrow.getEntityId());
    ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
     
  10. Offline

    CraterHater

    @FisheyLP that doesn't work, it does make the arrow invisible but an entity cannot ride it anymore. Any ideas?
     
  11. Offline

    Cycryl

    Just do it like this:
    make an arrayList of items (or uuids if you wanna be super efficient)
    every tick (0 tick scheduler) for all items in the list you do item.getNearbyEntities(x,y,z); (xyz being the size of the hitbox). That returns a list of entities. for all those entities you damage them and delete the carrrot.
    remember to also delete it from the array
    if there are no nearby entities the carrot wont be destroyed.
    Thank me later
     
Thread Status:
Not open for further replies.

Share This Page