PackMenu Button Schema [1.20 and prior] - Shadows-of-Fire/PackMenu GitHub Wiki
here.
Note: This wiki is only for Minecraft 1.20 and earlier! Users of PackMenu for Minecraft 1.21 and higher should seePackMenu lets users define additional menu buttons using a JSON format.
Buttons are loaded as objects from a resource pack.
Each button must be defined in it's own file.
Format Specification
Each button may have the following keys. Some keys are optional, but some are required. In the section below, every possible key will be defined, as well as what type that key represents, and if that key is required or not.
The format of this specification is "key name": [Required / Optional] (Data Type) Description
"x": [Required] (Integer) X offset from the center of the screen.
"y": [Required] (Integer) Y offset from the center of the screen.
"width": [Required] (Integer) Width of this button.
"height": [Required] (Integer) Height of this button.
"texture": [Semi-Optional] (String) The texture that this button will draw from. Defaults to vanilla's widgets.png
"u": [Optional] (Integer) The texture X coordinate of where the button will begin drawing from.
"v": [Optional] (Integer) The texture Y coordinate of where the button will begin drawing from.
"hoverU": [Semi-Optional] (Integer) The texture X coordinate of where the button will draw from when hovered.
"hoverV": [Semi-Optional] (Integer) The texture Y coordinate of where the button will draw from when hovered.
"texWidth": [Semi-Optional] (Integer) The width of the texture file that this button is sourced to.
"texHeight": [Semi-Optional] (Integer) The height of the texture file that this button is sourced to.
"widgets": [Optional] (Boolean) If you are using a widgets.png texture file or not. Defaults to true if "texture" contains the word widgets.
"langKey": [Optional] (String) Language key of the text to draw on this button.
"hoverLangKey": [Optional] (String) Language key of the text to draw on this button when hovered.
"action": [Required] (String) What happens when this button is clicked. See "Button Actions" below.
"data": [Optional] (Variable Type) Additional data depending on the value of "action". See "Button Actions" below.
"fontColor": [Optional] (Integer) The color of the text on this button. See notes on colors.
"hoverFontColor": [Optional] (Integer) The color of the text when hovered. See notes on colors.
"anchor": [Semi-Optional] (String) The anchor point of this button. See "Anchor Points" below.
"textXOffset": [Optional] (Integer) X Offset for text drawn on this button. Defaults to 0.
"textYOffset": [Optional] (Integer) Y Offset for text drawn on this button. Defaults to -4.
"dropShadow": [Optional] (Boolean) If the text on the button will be drawn with a drop shadow or not.
"active": [Optional] (Boolean) Determines if this button is clickable. If disabled, the button cannot be interacted with.
Additional Notes
Certain values are marked as "Semi-Optional", which means that they are not necessarily required, but will generally be included.
The hoverU
and hoverV
values are required if you want the button to change texture when hovered.
The texture
, texWidth
, and texHeight
all default to values for vanilla's widgets.png file, but if you use any other texture, you should change these.
The langKey
value will be translated, so using this will require a translation to be provided in an en_us.json
file.
Any colors required by PackMenu must be provided as an integer. This integer is obtained by converting a hexidecimal color to decimal. This means that for example, the color white (0xFFFFFF) is represented as 16777215. The color black (0x000000) is represented as 0.
Anchor Points
PackMenu elements can be anchored at different points on the screen, indicating where their coordinates will be before offsets. Currently, the following anchor points exists:
TOP_LEFT
TOP_CENTER
TOP_RIGHT
MIDDLE_LEFT
MIDDLE_CENTER
MIDDLE_RIGHT
BOTTOM_LEFT
BOTTOM_CENTER
BOTTOM_RIGHT
DEFAULT
DEFAULT_LOGO
The DEFAULT
and DEFAULT_LOGO
values correspond to magic numbers that dictate where the anchor points were before the definition of this system. They remain the default locations as to not break existing setups.
Button Actions
Button Actions are a predefined set of things that PackMenu buttons can do.
Each Action may have an additional value for the "data"
key associated with it.
The types of actions are as follows:
CONNECT_TO_SERVER
-
- Data: Server IP Address as a String.
LOAD_WORLD
(Not Implemented)REALMS
RELOAD
OPEN_GUI
-
- Data: GUI Type as a String. GUI Types are defined below.
OPEN_URL
-
- Data: URL to open as a String.
QUIT
NONE
GUI Types
Used for the OPEN_GUI
Button Action, these are identifiers for the various types of menus that PackMenu can open.
The GUI Types are as follows:
SINGLEPLAYER
MULTIPLAYER
MODS
LANGUAGE
OPTIONS
ACCESSIBILITY
RESOURCE_PACKS
SUPPORTERS
Examples
Examples are provided in the generated resource pack for all vanilla buttons. The following example is the Akliz Hosting button from the ATM 5 Menu.
{
"x": 75,
"y": -40,
"width": 120,
"height": 30,
"langKey": "packmenu.atm.akliz",
"action": "OPEN_URL",
"data": "https://akliz.net/allthemods",
"u": 0,
"v": 0,
"hoverU": 0,
"hoverV": 30,
"texWidth": 120,
"texHeight": 60,
"texture": "atm:textures/akliz.png",
"fontColor": 0,
"hoverFontColor": 1140326,
"dropShadow": false,
"textXOffset": 5,
"textYOffset": -6
}