Implemented SlotAction.isAvailable()

Discussion in 'Client & Site Suggestions' started by Aidden, Sep 6, 2014.

  1. Aidden

    Aidden The better executive ;)

    Joined:
    Dec 3, 2013
    Messages:
    3,211
    Likes Received:
    647
    We need a method to return whether the slot item is available. For example if we don't have any logs in the inventory and the slot contains logs it'll return false.

    Here's a use case: In my woodcutter i'm using the action bar to drop logs. I'm not storing the name of the type of logs i've cut so i'm searching for a SlotAction who's name in lowercase contains 'logs'. All is well and good up to that point, but then if you have logs in the actionbar slot and you've been cutting oak logs it'll try and use the logs slot button which obviously isn't going to work.

    This can be achieved by checking the color of the text. If it's 255,255,255 the item is available.
    I tried implementing this myself by using SlotAction.getSlot().getComponent().getTextColor().equals(new Color(255,255,255))
    But in doing so i found that you're using the component that doesn't contain the actions, so it doesn't work.

    @Cloud @Arbiter
     
  2. Cloud

    Cloud The Developer

    Joined:
    Jul 28, 2013
    Messages:
    2,323
    Likes Received:
    754
    Okay so I'm planning on adjusting SlotAction#isReady to account for this too, but should there be a seperate method for it? Something such as SlotAction#isActivatable? Or maybe rename isReady to isActivatable and make it handle all of that?
     
  3. Aidden

    Aidden The better executive ;)

    Joined:
    Dec 3, 2013
    Messages:
    3,211
    Likes Received:
    647
    I like isReady(), it's shorter :)
     
  4. Cloud

    Cloud The Developer

    Joined:
    Jul 28, 2013
    Messages:
    2,323
    Likes Received:
    754
    But is it the most appropriate?
     
  5. Aidden

    Aidden The better executive ;)

    Joined:
    Dec 3, 2013
    Messages:
    3,211
    Likes Received:
    647
    isAvailable would work too and sounds right in my head
     
    #5 Aidden, Sep 7, 2014
    Last edited: Sep 7, 2014
  6. Cloud

    Cloud The Developer

    Joined:
    Jul 28, 2013
    Messages:
    2,323
    Likes Received:
    754
    Can someone please verify that the current ActionSlot#isReady works for this situation?
     

Share This Page

Loading...