Solved Item -> Cansee(Player) How?

Discussion in 'Plugin Development' started by iZanax, Oct 21, 2012.

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

    iZanax

    PHP:
    Item test player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.DIRT));
    test.canSee(player); 
    Is it possible to make a check, if the player canSee() the Item on the ground?
    Or is there any other function to accomplish it?
     
  2. you need to do advanced ray tracing ( i guess its called that, hard to remember word) to find out the blocks between the item and player, if there are no blocks, the player can see it, depending on his view distance, and the distance where items can disappear. don't forget to tract about other entities in the path, as they can block the sight too
     
  3. Offline

    iZanax

    If it is too advanced I will not attempt it for now.
    Btw: Other entities should not be block the sight, if that is possible.
    But is there any approach to do it? (spawn fake entity/player?)

    *BUMP*

    Any thought how this can be done?

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

    Ammar Askar

    I answered a similar question a while ago and here's the n.m.s method that came up to ray trace a player to a location. The usage is self explanatory.

    Code:java
    1.  
    2. public boolean canSee(Player player, Location loc2) {
    3. Location loc1 = player.getLocation();
    4. return ((CraftWorld)loc1.getWorld()).getHandle().a(Vec3D.a().create(loc1.getX(), loc1.getY() + player.getEyeHeight(), loc1.getZ()), Vec3D.a().create(loc2.getX(), loc2.getY(), loc2.getZ())) == null;
    5. }
    6.  


    Edit: by the way, the canSee method in the player class is for the visibility api i.e making a player disappear to another
     
  5. Offline

    iZanax

    Thanks, will test it tonight.

    Ammar Askar

    Thanks it worked, that will fix a really big glitch :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
Thread Status:
Not open for further replies.

Share This Page