Figure out code

Discussion in 'Plugin Development' started by retsrif, Mar 2, 2011.

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

    retsrif

  2. Offline

    Edward Hand

    What exactly is it you want to know?
     
  3. Offline

    retsrif

    Though it doesn't seem like I can access it, I want to get whoever is in a bed. Also, whatever event or method is called when a player leaves a bed.
     
  4. Offline

    Edward Hand

    EntityHuman.E() is a function that returns whether a player is sleeping.

    Whether a bed is being slept in is stored in the data property for the block. The bit corresponding to 4 is set to 1 when the bed is occupied (from what I can tell).

    EntityHumans have a property for storing the coordinates of the bed they're sleeping in but its a private property and there seems to be no way to retrieve it. (EntityHuman.b)

    The method called when a player gets out of a bed is not within the bed class. Its within the EntityHuman class.
    its: public void a(boolean flag, boolean flag1) {
    and is called from half a dozen different places

    a BlockRightClick event is triggered when getting into a bed but I cant see one being triggered when they leave.

    Hopefully that helps
     
  5. Offline

    retsrif

    THANK YOU :D !!! just one question... Where did you get all this? I've been searching for a long time but no dice! Is it all from the docs? How do you understand! :eek:
    EDIT: Seems I didn't go deep enough... Anyway, all I need to use is if the player is sleeping! Thanks!
     
  6. Offline

    Edward Hand

    Elementary my dear Retsrif. Elementary.
     
  7. Offline

    retsrif

    Well, you seem to know a lot so I have another question: Where should I use the E method? In what listener or event?
     
  8. Offline

    Edward Hand

    Imagine you have a player event:
    Code:
    CraftPlayer cPlayer = (CraftPlayer)event.getPlayer();
    EntityHuman entityHuman = (EntityHuman)cPlayer.getHandle();
    if(entityHuman.E())
    {
        //etc etc
    (and no doubt you can work out how to adapt that for other circumstances)
     
  9. Offline

    retsrif

    Yes though that wouldn't be constant updating? Should I use onBlockInteract and check the block type, then check if the player is sleeping, and finally call the thread that should be performed for a specific time using scheduler?
     
  10. Offline

    Edward Hand

    For seeing when they go to sleep use onBlockRightClick.
    When they're sleeping they're probably not going to be moving, so you could trigger on playerMove events to see when they've woken up again.
     
  11. Offline

    retsrif

    So any change in location is a PlayerMove event? Is moving the cursor on the screen a PlayerMove event (most likely not)?
     
  12. Offline

    Edward Hand

    No. It only triggers when their coordinates change
     
  13. Offline

    retsrif

    So it doesn't happen ONLY when a player actually moves, it happens every time his location changes? Like would teleporting call that event too?
     
  14. Offline

    Edward Hand

    I'm not sure. Try it and see!
     
  15. Offline

    retsrif

    Um, how can I stop an inline thread? :s
     
Thread Status:
Not open for further replies.

Share This Page