Button element
Add a clickable button to the machine gui
The button gui element is used to add a clickable button to the machine gui.
All button elements have a unique string id (that you must specify in the elements properties), when the button is pressed a boolean flag will be written in the machine data. This data can be accessed using Crafttweaker or KubeJS Function requirement.
Simply using data.buttonID will give you a boolean that represent the current state of the button (true for pressed, false for released).
A Button requirement can also be used to make the recipe start only if the button is pressed.
Button elements are defined in json with : "type": "custommachinery:button".
Properties
The button gui element has 4 mandatory properties and 8 optional properties.
Mandatory properties
"type": "custommachinery:button" //Mandatory to define a button element.Id
Name : id
idDescription :
A string representing the id of the button, can be used in a Function requirement to check the state of the button, or in a Button requirement to make the recipe start only when the button is pressed.
Example :
The id of the button will be button1 :
"id": "button1"Optional properties
Texture
Name : texture
textureDescription :
The location of the texture that will be rendered into the GUI.
The location must be referenced by : namespace:path/file.png The texture loader will search for textures in the assets/namespace folder, the .png extension is required or the file will not be found.
The texture can be any size, if the texture size is different from the default size the width and height properties of the element will be automatically changed to fit the texture size if not provided.
If the width and/or height properties of the element are provided, the texture will be stretched to fit the dimensions of the element (it can render weirdly in that case).
Default :
Example :
The file assets/textures/my_texture.png will be used.
Texture toogle
Name : texture_toogle
texture_toogleDescription :
The location of the texture that will be rendered into the GUI when the button is toogled and pressed.
The location must be referenced by : namespace:path/file.png The texture loader will search for textures in the assets/namespace folder, the .png extension is required or the file will not be found.
The texture can be any size, if the texture size is different from the default size the width and height properties of the element will be automatically changed to fit the texture size if not provided.
If the width and/or height properties of the element are provided, the texture will be stretched to fit the dimensions of the element (it can render weirdly in that case).
Default :
Example :
The file assets/textures/my_texture.png will be used.
Priority
Name : priority
priorityDescription :
An integer property that define the priority of the Element to be rendered.
Elements with higher priority will be rendered first. If 2 elements are at the same position the first to be rendered will be under and the last will be above.
Default : 0
Example :
The element will be rendered under each element that have a priority lower than 1000.
Text
Name : text
textDescription :
A text component that will be rendered on top of the button texture.
Note that by default the button texture is 20x20px square so a text too big will overflow from the button texture.
Default : empty
emptyExample :
The following will add "Click Me !" text on the button :
The same in red :
Example
A basic button element using the base texture provided by Custom Machinery with a diamond :

Last updated