Skip to content

Conversation

@Wilyicaro
Copy link
Contributor

  • Reworked Inventory to use ItemInstance references instead of pointers.
  • Removed MCPE quickslot system
  • Added Container and implemented in Inventory, together with ContainerListener, ContainerMenu and Slot
  • InventoryMenu, Player::m_pInventoryMenu and Player::m_pContainerMenu still needs to be implemented
  • Unlimited resources system needs to be tweaked/rethough with the container logic

void Gui::handleScrollWheel(bool down)
{
int slot = m_pMinecraft->m_pLocalPlayer->m_pInventory->m_selectedHotbarSlot;
int slot = m_pMinecraft->m_pLocalPlayer->m_pInventory->m_selected;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name this m_selectedSlot

Inventory* pInv = getInventory();

pInv->selectItem(m_selectedSlot, m_pMinecraft->m_pGui->getNumUsableSlots());
std::swap(pInv->getItem(m_selectedSlot), pInv->getSelected());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks odd, though I think I know what it's doing. It should really be in its own function.


ItemInstance* pItem = pPlayer->getSelectedItem();
if (pItem)
ItemInstance& pItem = pPlayer->getSelectedItem();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this to item

ItemInstance* pItem = pPlayer->getSelectedItem();
if (pItem)
ItemInstance& pItem = pPlayer->getSelectedItem();
//why only if it's empty?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the question, this was a null check before you changed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same is valid for the null check, why only if it isn't nullptr? Why the client would know if it's a null selected item before the player joined?

PlayerEquipmentPacket()
{
m_playerID = 0;
m_itemID = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the meaning behind this will absolutely break compatibility with network protocol v2 and v3. b1.2_02 does not have a PlayerEquipmentPacket, but in its AddPlayerPacket, it still specifies an item ID rather than a slot ID. I understand that this makes more sense when being sent from client-to-server, but when sent server-to-client, this implies that the client is expected to know the entire hotbar contents (or more) of another player's inventory, which they shouldn't.
For compatibility sake, I would prefer that you not change this, however, if you're really committed to it, please put the changes behind a NETWORK_PROTOCOL_VERSION >= 4 preprocessor check, even though I'm not even sure if protocol v4 supports this.

int getSelectedSlotNo() const { return m_selectedHotbarSlot; }
bool contains(const ItemInstance&) const;

int getSelectedSlotNo() const { return m_selected; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be unsigned?

return "Inventory";
}

void setChanged() override
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this use one line.


}

bool stillValid(Player* player) override
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this use one line.


public:
int m_selectedHotbarSlot;
int m_selected;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsigned?


int m_hotbar[C_MAX_HOTBAR_ITEMS];
std::vector<ItemInstance*> m_items;
mutable std::vector<ItemInstance> m_items;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What on earth does mutable do here? I've never seen it used before.

Copy link
Contributor Author

@Wilyicaro Wilyicaro Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be able to access the vector in const methods, like Inventory::getItem

@BrentDaMage BrentDaMage linked an issue Jan 23, 2026 that may be closed by this pull request
@BrentDaMage BrentDaMage added the enhancement New feature or request label Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Container Logic

2 participants