GuiBorder
Description & Properties
The GuiBorder
class is used to create a border around a GUI. It has the following properties:
leftOffset
: The number of empty slots on the left side of the GUI.rightOffset
: The number of empty slots on the right side of the GUI.topOffset
: The number of empty slots on the top side of the GUI.bottomOffset
: The number of empty slots on the bottom side of the GUI.leftItemStack
: The item stack to use for the left border.rightItemStack
: The item stack to use for the right border.topItemStack
: The item stack to use for the top border.bottomItemStack
: The item stack to use for the bottom border.defaultItemStack
: The default item stack to use for the border if no specific item stack is provided.
Example
You can create a GuiBorder
object and customize its appearance by setting the offsets and item stacks for each side of the GUI. The defaultItemStack
property is used as a fallback if no specific item stack is provided for a side.
Here is an example of how to create a GuiBorder
object in Kotlin:
kotlin
In this example, we create a GuiBorder
object with custom offsets and item stacks for each side of the GUI. The defaultItemStack
property is set to a gray stained-glass pane, which will be used as the default item stack for the border.
You can then use this GuiBorder
object when building a GUI to add a border around it. The border will be displayed using the specified item stacks and offsets, enhancing the visual appearance of the GUI.
In this code snippet, we create a KGui
object and use its builder
method to create a new inventory GUI. We set the title, number of rows, and border of the GUI using the setTitle
, setRows
, and setBorder
methods, respectively. The build
method is then called to create the inventory GUI with the specified properties, including the custom border.
Summary
The GuiBorder
class provides a convenient way to add a border around a GUI in Minecraft. By customizing the offsets and item stacks for each side of the border, you can create visually appealing and interactive GUIs that enhance the gameplay experience for players.