How to "Right Click" Dropped Item

Discussion in 'Plugin Development' started by 3ptO, Oct 16, 2013.

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

    3ptO

    Hello all,

    I'm in need of some help with theoretically right clicking a dropped item. Consider the following, the dropped item is a bomb and I must right click the bomb with shears in order to defuse the bomb.
    Now while I know you can not physically right click a dropped item, what are some alternatives?

    Thanks
     
  2. Offline

    drtshock

    Have you tried anything yet?

    Take a look at the PlayerInteractEvent and checking if the action is a right click.
     
  3. Offline

    JPG2000

    drtshock He means clicking an entity that is dropped.

    I've been messaging him on Skype, and we found a 'half solution".

    Baicly, we get the blocks in his line of site, and get the nearest entites (In interact event). Im not sure if its working, but maby we could find a better way...
     
  4. Offline

    3ptO

    Potentially use vectors to get the targeted entity, however, I'm not so good with vectors.
     
  5. Offline

    MrSnare

    on right click, scan for entities around you. if they are a bomb, do stuff
     
  6. Offline

    3ptO

    MrSnare What if there happens to be more than one bomb around you? Need to target a bomb...
     
  7. Offline

    MrSnare

    get the block you are looking at, scan the air above it to see if there is any entities there. I don't think you can get any more accurate than 1 block in this case
     
  8. Offline

    Garris0n

    Not without math.

    Your signature is amusing...but the for loop wouldn't work. Either while loop through the iterator or iterate through a list, but make up your mind :p
     
  9. Offline

    JPG2000

    Garris0n I know. If I tried to make it accurate it would be long. Ive keept it short and simple so peopl3 can see what im trying to illustrate.
     
  10. In short:
    1. Get nearby entities
    2. Filter all non ItemStacks
    3. Calculate vector between Player and each ItemStack
    4. Calculate the yaw and pitch of that Vector
    5. Compare yaw and pitch with the ones from Player.getLocation
    6. Take the ItemStack where pitch and yaw fits best, perhaps applying a threshold
    7. Check if ItemStakc is a bomb
    8. Do what you want with it
     
    MrSnare likes this.
  11. Offline

    Garris0n


    Code:java
    1. for(Thread t: BukkitFourms.getThreads(Section.PLUGIN_DEVELOPMENT))
    2. if(t.getAuthor().thinksTheyCanCode() && !t.getAuthor().canCode())
    3. t.getAuthor().murderInSleep();
     
  12. Offline

    JPG2000

Thread Status:
Not open for further replies.

Share This Page