Skip to content

Expose the selected hotbar slot in inventory manager peripheral#823

Closed
CrazyDev05 wants to merge 1 commit into
IntelligenceModding:dev/1.21.1from
CrazyDev05:dev/1.21.1
Closed

Expose the selected hotbar slot in inventory manager peripheral#823
CrazyDev05 wants to merge 1 commit into
IntelligenceModding:dev/1.21.1from
CrazyDev05:dev/1.21.1

Conversation

@CrazyDev05

Copy link
Copy Markdown
Contributor

PLEASE READ THE GUIDELINES BEFORE MAKING A CONTRIBUTION

  • Please check if the PR fulfills these requirements
  • The commit message are well described
  • Docs have been added / updated (for features or maybe bugs which were noted). If not, please update the needed documentation here. Feel free to remove this check if you don't need it
  • All changes have fully been tested
  • What kind of change does this PR introduce? (Bug fix, feature, ...)
    This PR adds two api changes to get the selected hotbar slot from the inventory manager

  • What is the current behavior? (You can also link to an open issue here)
    Not possible to retrive the real selected slot, you can only iterate over all 9 slots and find a matching item to the one returned by getItemInHand which will break when one has two matching stacks in the hotbar

  • What is the new behavior (if this is a feature change)?

  • add slot to the getItemInHand method
  • add getSelectedSlot method
  • Does this PR introduce a breaking change? (What changes might users need to make in their scripts due to this PR?)
    No

@zyxkad

zyxkad commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR.
We already provided the selected slot along with the holding item in the 0.8 branch.

@LuaFunction(mainThread = true)
public final int getHandSlot() throws LuaException {
return this.getOwnerPlayerOrError().getInventory().selected + 1;
}
@LuaFunction(mainThread = true)
public final Map<String, Object> getItemInHand() throws LuaException {
Player player = this.getOwnerPlayerOrError();
return LuaConverter.itemStackToLuaWithSlot(player.getMainHandItem(), player.getInventory().selected);
}

We won't adding any new features to 0.7, so please wait till the 0.8 branch to release (won't be far I believe).

@zyxkad zyxkad closed this Jun 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Build Preview

badge

You can find files attached to the below linked Workflow Run URL (Logs).

Name Link
Commit bfbda12
Logs https://github.com/IntelligenceModding/AdvancedPeripherals/actions/runs/27476816785
Jar Files AdvancedPeripherals PR 823
Expires At 2026-09-11T19:30:57Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants