Skip to content

OpenContainer ​

com.jsmacrosce.jsmacros.client.api.event.impl.inventory.EventOpenContainer

Since1.6.5Cancellable

Fires after a container screen is set. Cancelling restores the previously displayed screen, or a KeyMacrosScreen(null) fallback if there was none. In creative mode it is skipped for container screens other than the creative inventory. Unlike EventOpenScreen, it only fires for container screens and fires after that event.

js
JsMacros.on("OpenContainer", JavaWrapper.methodToJava(function (event) {
 if (event.screen.getScreenClassName() === "ShulkerBoxScreen") {
   Chat.log("no shulker boxes today");  
   event.cancel();  
 }
}))

Constructors ​

new EventOpenContainer ​

new EventOpenContainer(AbstractContainerScreen<?> screen)#
Wraps the supplied container screen and retains it as the event screen. This does not open or display a screen; a non-null screen must implement IScreen. A failed cast occurs after the inventory wrapper is created. A null input leaves both screen and inventory null.

Parameters:

  • screen: the container screen to wrap and retain; may be null

Fields ​

inventory ​

inventory: Inventory<?>read-only#
The opening container, wrapped in a fresh Inventory for the screen's menu.

screen ​

screen: IScreenread-only#
The container screen that is opening, as an IScreen. Its class name is available from getScreenClassName().

Methods ​

toString ​

toString(): String#
Returns a diagnostic string containing the event name, screen name, and inventory. The format is %s:{"screenName": "%s", "inventory": %s}; values are inserted with String.format(String, Object...) formatting, not JSON serialization. The computed screen name from the stored screen is rendered as "null" when null; a null inventory is rendered as unquoted null.
Returns: the formatted event and payload summary