OpenContainer
com.jsmacrosce.jsmacros.client.api.event.impl.inventory.EventOpenContainer
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
screen
The container screen that is opening, as an IScreen. Its class name is available from getScreenClassName().
Methods
toString
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