Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made container menu to be able to scale to any size #946

Merged
merged 2 commits into from
Feb 20, 2025

Conversation

Prunoideae
Copy link
Contributor

Description

Removed the restriction of must having 9 columns for the inventory GUI in ServerPlayer.openInventoryGUI and made it possible to specify the rows and columns to any size up to 9 (columns) * 6 (rows).

Example Script

ItemEvents.rightClicked('minecraft:diamond', event => {
    let { player } = event
    let container = new $SimpleContainer([Item.getEmpty(), Item.getEmpty(), Item.getEmpty(), Item.getEmpty(),])
    // Opens the inventory gui with the given container
    // Both width and height can be specified, first width*height in the container will be used
    // Error will be thrown if the container slots are less than width*height
    // It's also ok to use only width, or omit both width and height
    // Width and height will be automatically calculated considering the size
    player.openInventoryGUI(container, Component.translatable('item.minecraft.diamond'), 2, 2)
})

image

Other details

@ChiefArug
Copy link
Contributor

How does this work with vanilla/non KubeJS clients? or did the old system not work with those anyway?

@Prunoideae
Copy link
Contributor Author

The old system does not work, it has KubeJSScreen which is a client-side class to render the container screen. The PR did not create any new client-side classes but modify the old ones to make it functional.

@Prunoideae
Copy link
Contributor Author

And the one will work with non-KJS client is dev.latvian.mods.kubejs.gui.chest.CustomChestMenu which is in kjs$openChestGUI, the PR fixed the method kjs$openInventoryGUI that returns a different menu.

@LatvianModder LatvianModder merged commit c704911 into KubeJS-Mods:main Feb 20, 2025
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.

3 participants