Check an items coords (On land, not on throw)

Discussion in 'Plugin Development' started by -_Husky_-, Jun 23, 2012.

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

    -_Husky_-

    can someone help with this please? i can't seem to get this, i tried using ItemSpawnEvent
    but, that's not having a 'cause' for example 'Player_Drop'
     
  2. Offline

    Firefly

    -_Husky_- likes this.
  3. Offline

    -_Husky_-

  4. Offline

    Firefly

    Np :)
     
  5. Offline

    -_Husky_-

    You wouldnt happen to know how to spawn a item (entity form dropped) at coords would you?
     
  6. Offline

    Firefly

    Lemme see if I can find that out..

    [EDIT] Any item? (like a sword) or just a dropped block item?

    Here's a method for a World object...
    [EDIT][EDIT] world.dropItemNaturally(Location location, ItemStack item)
     
    -_Husky_- likes this.
  7. Offline

    -_Husky_-

    Sword please, (diamond)
     
  8. Offline

    Gravity Retired Staff

    player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.DIRT, 1));
     
    -_Husky_- likes this.
  9. Offline

    Firefly

    See my second edit above :p
     
  10. Offline

    Gravity Retired Staff

    Ninja
     
  11. Offline

    Firefly

    Haha. :)
     
  12. Offline

    -_Husky_-

    Thanks for the help

    h31ix

    Code:java
    1. Item i = e.getItemDrop();
    2. Location l = i.getLocation();
    3. double x = l.getBlockX();
    4. double y = l.getBlockY() + 1;
    5. double z = l.getBlockZ();
    6. ItemStack stick = new ItemStack(Material.STICK, 1);
    7. ItemStack diamond = new ItemStack(Material.DIAMOND, 2);
    8. ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
    9. Location loc = new Location(p.getWorld(), x,y,z);
    10. System.out.println("drop");
    11. if(i == diamond) {
    12. System.out.println("264");
    13. if(i.getNearbyEntities(x,y,z).contains(stick)) {
    14. System.out.println("nearby");
    15. i.getNearbyEntities(x, y, z).remove(diamond);
    16. i.getNearbyEntities(x, y, z).remove(stick);
    17. p.getWorld().dropItem(loc, sword);
    18. }
    19. } else if (i == stick) {
    20. System.out.println("280");
    21. if(i.getNearbyEntities(x,y,z).contains(diamond)) {
    22. System.out.println("nearby");
    23. i.getNearbyEntities(x, y, z).remove(diamond);
    24. i.getNearbyEntities(x, y, z).remove(stick);
    25. p.getWorld().dropItem(loc, sword);
    26. }
    27. } else if (i.equals(stick)) {
    28. System.out.println("280");
    29. if(i.getNearbyEntities(x,y,z).contains(diamond)) {
    30. System.out.println("nearby");
    31. i.getNearbyEntities(x, y, z).remove(diamond);
    32. i.getNearbyEntities(x, y, z).remove(stick);
    33. p.getWorld().dropItem(loc, sword);
    34. }
    35. } else if(i.equals(diamond)) {
    36. System.out.println("264");
    37. if(i.getNearbyEntities(x,y,z).contains(stick)) {
    38. System.out.println("nearby");
    39. i.getNearbyEntities(x, y, z).remove(diamond);
    40. i.getNearbyEntities(x, y, z).remove(stick);
    41. p.getWorld().dropItem(loc, sword);
    42. }
    43. } else {
    44. System.out.println("NONE");
    45. }

    Why isn't this working ?

    Is there a way i can the coords WHEN the item lands, not when it was thrown

    Help please :p

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  13. Offline

    r0306

    -_Husky_-
    Rather than getting the item, I believe it is this:
    Code:
    ItemStack i = e.getItemDrop().getItemStack();
    Then use:
    Code:
    i.getTypeId() == 278;
    to compare items.
     
  14. Offline

    -_Husky_-

    Will try, thanks!

    Ok so that worked r0306 . thankyou :D

    Now is there a way to get the location of the Dropped entity when it Lands?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  15. Offline

    ferrybig

    check the location every tick (may to fast) and if it stops chancing, then its landed (may not work whit water)
     
Thread Status:
Not open for further replies.

Share This Page