spockbot.plugins.helpers.inventory module¶
The Inventory plugin keeps track of the inventory and provides simple inventory analysis and manipulation.
-
class
spockbot.plugins.helpers.inventory.
InventoryCore
(net_plugin, send_click)¶ Bases:
object
Handles operations with the player inventory.
-
active_slot
¶
-
click_slot
(slot, right=False)¶ Left-click or right-click the slot.
Parameters: slot (Slot) – The clicked slot. Can be Slot
instance or integer. Set toinventory.cursor_slot
for clicking outside the window.
-
close_window
()¶
-
creative_set_slot
(slot_nr=None, slot_dict=None, slot=None)¶
-
drop_slot
(slot=None, drop_stack=False)¶ Drop one or all items of the slot.
Does not wait for confirmation from the server. If you want that, use a
Task
andyield inventory.async.drop_slot()
instead.If
slot
is None, drops thecursor_slot
or, if that’s empty, the currently held item (active_slot
).Parameters: slot (Optional[Slot]) – The dropped slot. Can be None, integer, or Slot
instance.Returns: The action ID of the click Return type: int
-
find_slot
(wanted, slots=None)¶ Searches the given slots or, if not given, active hotbar slot, hotbar, inventory, open window in this order.
Parameters: wanted – function(Slot) or Slot or itemID or (itemID, metadata) Returns: The first slot containing the item or None if not found. Return type: Optional[Slot]
-
find_slots
(wanted, slots=None)¶ Yields all slots containing the item. Searches the given slots or, if not given, active hotbar slot, hotbar, inventory, open window in this order.
Parameters: wanted – function(Slot) or Slot or itemID or (itemID, metadata)
-
inv_slots_preferred
¶ List of all available inventory slots in the preferred search order. Does not include the additional slots from the open window.
- active slot
- remainder of the hotbar
- remainder of the persistent inventory
-
select_active_slot
(slot_or_hotbar_index)¶
-
total_stored
(wanted, slots=None)¶ Calculates the total number of items of that type in the current window or given slot range.
Parameters: wanted – function(Slot) or Slot or itemID or (itemID, metadata)
-
-
class
spockbot.plugins.helpers.inventory.
InventoryPlugin
(ploader, settings)¶ Bases:
spockbot.plugins.base.PluginBase
-
emit_open_window
(*_)¶
-
emit_set_slot
(slot)¶
-
events
= {'PLAY<Close Window': 'handle_close_window', 'PLAY<Window Property': 'handle_window_prop', 'PLAY<Set Slot': 'handle_set_slot', 'PLAY<Confirm Transaction': 'handle_confirm_transaction', 'PLAY<Open Window': 'handle_open_window', 'PLAY<Window Items': 'handle_window_items', 'PLAY>Close Window': 'handle_close_window', 'PLAY<Held Item Change': 'handle_held_item_change'}¶
-
handle_close_window
(event, packet)¶
-
handle_confirm_transaction
(event, packet)¶
-
handle_held_item_change
(event, packet)¶
-
handle_open_window
(event, packet)¶
-
handle_set_slot
(event, packet)¶
-
handle_window_items
(event, packet)¶
-
handle_window_prop
(event, packet)¶
-
pl_announce
= ('Inventory',)¶
-
requires
= ('Event', 'Net', 'Timers')¶
-
send_click
(click)¶ Sends a click to the server if the previous click has been confirmed.
Parameters: click (BaseClick) – The click to send. Returns: the click’s action ID if the click could be sent, None if the previous click has not been received and confirmed yet.
-
set_slot
(window_id, slot_nr, slot_data)¶
-