Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Getting location data from inventory object

Comments in 'Plugin Development' started by Nightt_Fury, Jul 12, 2016.

  1. Nightt_Fury
    Offline

    Nightt_Fury New Member

    Joined:
    Jul 12, 2016
    Posts:
    4
    I have a plugin where I am creating a custom chest so that it will craft special items. When ever the player closes the chest it will check the location of the chest within an array and if it is there it will create the new item. Is there any way to get the coordinate data for an inventory on the InventoryCloseEvent? Or do any of you recommend using a different event.
  2. Nightt_Fury
    Offline

    Nightt_Fury New Member

    Joined:
    Jul 12, 2016
    Posts:
    4
    I have figured it out. If anyone is wondering the getHolder() function in the inventory object will return the position. So the code will look something like this $event->getInventory()->getHolder()->x
  3. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    getHolder() does not return a position it does return a player wich extends position
  4. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    getHolder() can be myriad instances of InventoryHolder that may or may not be a player. You need to check.
    a player is a position.
  5. Nightt_Fury
    Offline

    Nightt_Fury New Member

    Joined:
    Jul 12, 2016
    Posts:
    4
    Ok, so my execution was correct but my understanding was wrong. Thanks for the help guys.
  6. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Didn't I already say that a player EXTENDS position. He 'is' a position therefore, but i don't like to express it in that way
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    You said 'getHolder() does not return a position' but it does return InventoryHolder instance which in this case is player and player is also position so things you said are pretty confusing.
    SOFe likes this.

Share This Page

Advertisement