Botcraft 1.21.4
Loading...
Searching...
No Matches
Botcraft::Window Class Reference

#include <Window.hpp>

Public Member Functions

 Window (const InventoryType type_=InventoryType::Default)
 
void Init ()
 
ProtocolCraft::Slot GetSlot (const short index) const
 
std::map< short, ProtocolCraft::SlotGetSlots () const
 
Utilities::ScopeLockedWrapper< const std::map< short, ProtocolCraft::Slot >, std::shared_mutex, std::shared_lock > GetLockedSlots () const
 Get a read-only locked version of all the slots.
 
InventoryType GetType () const
 
void SetSlot (const short index, const ProtocolCraft::Slot &slot)
 
void SetContent (const std::vector< ProtocolCraft::Slot > &slots_)
 
int GetStateId () const
 
void SetStateId (const int state_id_)
 
short GetFirstPlayerInventorySlot () const
 

Static Public Attributes

static constexpr short PLAYER_INVENTORY_INDEX = 0
 
static constexpr short INVENTORY_CRAFTING_OUTPUT_INDEX = 0
 
static constexpr short INVENTORY_CRAFTING_INPUT_START = 1
 
static constexpr short INVENTORY_ARMOR_START = 5
 
static constexpr short INVENTORY_HEAD_ARMOR = INVENTORY_ARMOR_START + 0
 
static constexpr short INVENTORY_CHEST_ARMOR = INVENTORY_ARMOR_START + 1
 
static constexpr short INVENTORY_LEGS_ARMOR = INVENTORY_ARMOR_START + 2
 
static constexpr short INVENTORY_FEET_ARMOR = INVENTORY_ARMOR_START + 3
 
static constexpr short INVENTORY_STORAGE_START = 9
 
static constexpr short INVENTORY_HOTBAR_START = 36
 
static constexpr short INVENTORY_OFFHAND_INDEX = 45
 

Private Attributes

std::shared_mutex window_mutex
 
std::map< short, ProtocolCraft::Slotslots
 
const InventoryType type
 
int state_id
 

Detailed Description

Definition at line 13 of file Window.hpp.

Constructor & Destructor Documentation

◆ Window()

Botcraft::Window::Window ( const InventoryType  type_ = InventoryType::Default)

Definition at line 8 of file Window.cpp.

References Init().

Member Function Documentation

◆ GetFirstPlayerInventorySlot()

◆ GetLockedSlots()

Utilities::ScopeLockedWrapper< const std::map< short, ProtocolCraft::Slot >, std::shared_mutex, std::shared_lock > Botcraft::Window::GetLockedSlots ( ) const

Get a read-only locked version of all the slots.

Returns
Basically an object you can use as a std::map<short, ProtocolCraft::Slot>*. ALL UPDATE OF THIS INVENTORY WILL BE BLOCKED WHILE THIS OBJECT IS ALIVE, make sure it goes out of scope as soon as you don't need it. You can use GetSlots instead to get a copy without blocking future updates

Definition at line 41 of file Window.cpp.

References slots, and window_mutex.

◆ GetSlot()

Slot Botcraft::Window::GetSlot ( const short  index) const

Definition at line 24 of file Window.cpp.

References slots, and window_mutex.

◆ GetSlots()

std::map< short, Slot > Botcraft::Window::GetSlots ( ) const

Definition at line 35 of file Window.cpp.

References slots, and window_mutex.

◆ GetStateId()

int Botcraft::Window::GetStateId ( ) const

Definition at line 74 of file Window.cpp.

References state_id, and window_mutex.

◆ GetType()

InventoryType Botcraft::Window::GetType ( ) const

Definition at line 46 of file Window.cpp.

References type, and window_mutex.

◆ Init()

void Botcraft::Window::Init ( )

Definition at line 13 of file Window.cpp.

References slots, state_id, and window_mutex.

Referenced by Window().

◆ SetContent()

void Botcraft::Window::SetContent ( const std::vector< ProtocolCraft::Slot > &  slots_)

Definition at line 58 of file Window.cpp.

References slots, and window_mutex.

◆ SetSlot()

void Botcraft::Window::SetSlot ( const short  index,
const ProtocolCraft::Slot slot 
)

Definition at line 52 of file Window.cpp.

References slots, and window_mutex.

◆ SetStateId()

void Botcraft::Window::SetStateId ( const int  state_id_)

Definition at line 80 of file Window.cpp.

References state_id, and window_mutex.

Member Data Documentation

◆ INVENTORY_ARMOR_START

constexpr short Botcraft::Window::INVENTORY_ARMOR_START = 5
staticconstexpr

Definition at line 20 of file Window.hpp.

Referenced by Botcraft::Renderer::RenderingManager::Run().

◆ INVENTORY_CHEST_ARMOR

constexpr short Botcraft::Window::INVENTORY_CHEST_ARMOR = INVENTORY_ARMOR_START + 1
staticconstexpr

Definition at line 22 of file Window.hpp.

Referenced by Botcraft::PhysicsManager::InputsToFly().

◆ INVENTORY_CRAFTING_INPUT_START

constexpr short Botcraft::Window::INVENTORY_CRAFTING_INPUT_START = 1
staticconstexpr

Definition at line 19 of file Window.hpp.

Referenced by Botcraft::Renderer::RenderingManager::Run().

◆ INVENTORY_CRAFTING_OUTPUT_INDEX

constexpr short Botcraft::Window::INVENTORY_CRAFTING_OUTPUT_INDEX = 0
staticconstexpr

Definition at line 18 of file Window.hpp.

Referenced by Botcraft::Renderer::RenderingManager::Run().

◆ INVENTORY_FEET_ARMOR

constexpr short Botcraft::Window::INVENTORY_FEET_ARMOR = INVENTORY_ARMOR_START + 3
staticconstexpr

◆ INVENTORY_HEAD_ARMOR

constexpr short Botcraft::Window::INVENTORY_HEAD_ARMOR = INVENTORY_ARMOR_START + 0
staticconstexpr

Definition at line 21 of file Window.hpp.

Referenced by Botcraft::DigImpl().

◆ INVENTORY_HOTBAR_START

◆ INVENTORY_LEGS_ARMOR

constexpr short Botcraft::Window::INVENTORY_LEGS_ARMOR = INVENTORY_ARMOR_START + 2
staticconstexpr

Definition at line 23 of file Window.hpp.

Referenced by Botcraft::PhysicsManager::InputsToCrouch().

◆ INVENTORY_OFFHAND_INDEX

constexpr short Botcraft::Window::INVENTORY_OFFHAND_INDEX = 45
staticconstexpr

◆ INVENTORY_STORAGE_START

◆ PLAYER_INVENTORY_INDEX

◆ slots

std::map<short, ProtocolCraft::Slot> Botcraft::Window::slots
private

Definition at line 56 of file Window.hpp.

Referenced by GetLockedSlots(), GetSlot(), GetSlots(), Init(), SetContent(), and SetSlot().

◆ state_id

int Botcraft::Window::state_id
private

Definition at line 63 of file Window.hpp.

Referenced by GetStateId(), Init(), and SetStateId().

◆ type

const InventoryType Botcraft::Window::type
private

Definition at line 57 of file Window.hpp.

Referenced by GetFirstPlayerInventorySlot(), and GetType().

◆ window_mutex

std::shared_mutex Botcraft::Window::window_mutex
mutableprivate

The documentation for this class was generated from the following files: