Skip to main content

ScreenJS

Download: CurseForge

The custom ContainerMenu event is a startup event.

Custom Container menus are created in a startup script. They cannot be reloaded without restarting the game. The event is not cancellable.

for block entities made with beJS:

StartupEvents.registry('menu', event => {
    event.create('example_block' /*name has tocan be same as BlockEntity's id*anything*/, 'block_entity')
        .addSlot(-10, -10) // adds a slot into this x,y position on the texture
        .addSlot(10, 200)
        .loop(builder /*this builder*/=> {
            for(let x = 0; x < 9; x++) {
                for (let y = 0; y < 4; y++) {
                    builder.addSlot(x * 18 /*<- the width of a slot, remember to add this*/, y * 18)
                }
            }
        })
        .addOutputSlot(118, 118) // adds a slot you can't put an item into, but can pull an item from
        .playerInventoryY(100) // marks the start of the player's inventory on the texture
        .tintColor(0x00FF00FF) // a color to tint the whole inventory texture, in hexadecimal [r, g, b, a]
  
        .setBlockEntity('kubejs:example_block') // the block entity that should open this GUI on right-click
})

for any block: 

StartupEvents.registry('menu', event => {
    event.create('grass_block' /*name can be anything*/, 'block')
        /*default parameter set*/
        .setBlock('minecraft:grass_block') // the block that should open this GUI on right-click
})

for entities: 

StartupEvents.registry('menu', event => {
    event.create('snow_golem' /*name can be anything*/, 'entity')
        /*default parameter set*/
        .setEntity('minecraft:snow_golem') // the enity type that should open this GUI on right-click
})

and lastly, for completely separate 'basic' GUIs:

currently nothing can access these!

StartupEvents.registry('menu', event => {
    event.create('snow_golem'name_here' /*name can be anything*/)
        /*default parameter set*/
})


valid menu types:

  • basic (this is the default)
  • block_entity
  • block
  • entity

methods the menu builder supports:

  • addSlot(x, y)
  • addOutputSlot(x, y)
  • loop()
  • tintColor(color)
  • drawable(screenX, screenY, textureX, textureY, u, v, textureLocation)
  • progressDrawable(x, y, textureX, textureY, textureWidth,rect2i, textureHeight, textureLocation, direction, type)
  • fluidDrawable(x, y, textureX, textureY, textureWidth, textureHeight,rect2i, textureLocation, direction, tankIndex)
  • backroundTexture(texture, x, y, u ,v)
  • quickMoveFunc((player, slotIndex, menu) => ... return item)
  • validityFunc((player, pos) => ... return boolean)
  • disablePlayerInventory()
  • playerInventoryY(yPos)
  • button(rect2i, textComponent, button => ...)