-
Notifications
You must be signed in to change notification settings - Fork 8
Gui Modifiers
Gui Modifiers allow you to tweak many aspects of a GUI.
These include:
- Moving slots
- Adding images
- Changing slots highlight color
- Move some specific GUI elements
Modifiers were a feature from Slotify, mod which has been merged into Polytone. You can also refer to its old wiki page here
|GUI Name|Target Type|Target| |---|---|----|---| |Survival Inventory|menu_class|net.minecraft.class_1723| |Creative Inventory|menu_class|net.minecraft.class_481| |Chest|menu_id|generic_9x3| |Double Chest|menu_id|generic_9x6| |Ender Chest (uses slot modifiers from generic_9x3)|screen_title|container.enderchest|
You can start by adding a simple .json
files in your resource pack in the path assets/[your pack namespace]/polytone/gui_modifiers/[modifier name].json
You can name them whatever you want but you'll need to create ONE PER GUI you want to target.
Here is an example of a simple gui modifier. Following will be a more in depth explanation
{
"target_type": "menu_id",
"target": "generic_9x3",
"slot_modifiers": [
{
"slots": "27->62",
"x_offset": 0,
"y_offset": 7
}
],
"sprites": [
{
"x": -8,
"y": -8,
"z": -500,
"width": 16,
"height": 16,
"texture": "textures/block/stone.png"
}
]
}
This is a simple gui modifier for the normal chest. It places a 16x16 sprite of the minecraft stone texture in the middle of the screen, as well as offsetting the entire player inventory by 7 pixels to the bottom.
Each modifier can contain these fields:
Field | Function |
---|---|
target_type |
GUI targeting strategy |
target |
Information on GUI to target |
slots_modifiers |
Slot modification logic |
widgets_modifiers |
Button modification logic |
special_offsets |
Some special offset parameters for some specific GUI |
title_x_offset |
Screen title x offset |
title_y_offset |
Screen title y offset |
label_x_offset |
Screen label x offset |
label_y_offset |
Screen label y offset |
sprites |
Extra images to render on the Screen |
The target_type
is used to determine which GUI to target.
When it comes to GUI, game uses two types of concepts:
- Screens: represent what a player actually sees.
- Menu: a server side abstraction that handles Slots and communicates them to its own Screen.
Different targeting strategies are thus requires as not all Screens have a Menu and only Menu have a unique Registry ID associated with them. Both of them can have unique classes.
Here is what each of the target types are:
target_type value |
Required target Content |
Can modify slots? |
---|---|---|
menu_class |
Obfuscated full class path of target Menu class | yes |
menu_id |
Registry name of the Menu you are targeting | yes |
screen_title |
Sceen title's translation key | no |
screen_class |
Obfuscated full class path of target Screen class | no |
Note that all the _class
types can also work with non obfuscated / non fully qualified class paths in some circumstances.
Here below is an example for each:
The target
field defines which GUI is being targeted, when menu_class
is the target type, you will need the class obfuscated class path like shown below.
"target_type": "menu_class",
"target": "net.minecraft.class_1723"
If the target_type
is set to menu_id
, you will need to use one of the predefined GUI names as the target
, the full list can be found further down.
"target_type": "menu_id",
"target": "generic_9x6"
When using "screen_title" as your "target_type" you can either use translation strings or the screen name shown ingame as the "target".
"target_type": "screen_title",
"target": "container.enderchest"
The "target_type" "screen_class" refers to specific screen classes and needs the screen class name as the "target".
"target_type": "screen_class",
"target": "net.minecraft.client.gui.screen.inventory.SignEditScreen"
Do note that "screen_title" takes priority when layered with "menu_id"
Slot modifiers can be used to tweak the position of the specified GUI's slots on screen.
Note the square brackets denote a list meaning you can define multiple modifiers in the same slots_modifier
field.
Here is a list of all the parameters and their use
Parameter | Content |
---|---|
slots |
Slots to target |
x_offset |
Screen X pixel offset |
y_offset |
Screen Y pixel offset |
color |
Slot Highlight primary color |
color2 |
Slot Highlight secondary color |
The slot numbers are the ones are assigned to each slot, for figuring out which slot has which number, you can use this website
They can be defined either as an integer,
"slot_modifiers": [
{
"slots": 0,
"x_offset": -20,
"y_offset": 22
}
]
as an array of integers
"slot_modifiers": [
{
"slots": [1,2,3,4],
"x_offset": 27,
"y_offset": -11
}
]
or as a string formatted as "[from slot]->[to slot]".
"slot_modifiers": [
{
"slots": "5->8",
"x_offset": 36,
"y_offset": -1,
"color": "#696969",
"color2": "#tf67hj"
}
]
The specified slots' locations on the screen can be modified using x_offset
and y_offset
with an integer representing the offset in screen pixels.
Their hover color can be changed using color
, color2
and the #hexcode as a string.
The "special_offsets" currently only includes "player" (the survival inventory player model), which can be modified in the same way as slots (excluding color).
"special_offsets": {
"player": {
"x_offset": 35,
"y_offset": 0
}
}
Sprites are useful for appending further textures in inventories, they use "x", "y" and "z" to determine the position on screen.
"sprites": [
{
"x": -102,
"y": -95,
"z": -200,
"width": 204,
"height": 190,
"texture": "assets/modid/textures/gui/container/inventory_frame.png"
}
]
"z" determines the layer on which the texture is placed, ranging from -200 to 200. use -200 if items should appear on top of the custom sprite.
"width" and "height" determine the size of your sprite, it is recommended to use the actual size of your texture to get accurate pixel sizes.
The texture path is the same as in vanilla, pointing to a .png in your assets/textures folder.
Widget modifiers let you customize buttons such as the 'sign' button in the book and quill screen, they are split into target parameters and modifiers, the former being used to find the button that you want to modify and the latter to modify the button.
These are used to target the buttons upper left corner, the coordinates are measured in pixels, originating from the center of the screen.
"widget_modifiers": [
{
"target_x": 2,
"target_y": 2,
"target_message": "done",
"target_width": 4,
"target_class_name": "Button",
}
]
"target_message" is used to select the specific Button with this label.
"target_width" is used to specify the size of the targeted button.
"target_class_name" specifies the targeted button via class names.
"x_offset" and "y_offset" are used to offset the targeted button like slots.
"width_increment" modifies the width of the targeted button.
[
{
"x_offset": 5,
"y_offset": 4
"width_increment": 4
}
]
"title_x_offset" and "title_y_offset" move the title text of the GUI/screen.
"title_x_offset": -14,
"title_y_offset": 20
"label_x_offset" and "label_y_offset" move the label text of the GUI/screen.
"label_x_offset": -14,
"label_y_offset": 20
- generic_9x1
- generic_9x2
- generic_9x3
- generic_9x4
- generic_9x5
- generic_9x6
- generic_3x3
- anvil
- beacon
- blast_furnace
- brewing_stand
- crafting
- enchantment
- furnace
- grindstone
- hopper
- lectern
- loom
- merchant
- shulker_box
- smithing
- smoker
- cartography_table
- stonecutter
Sometimes a special class is required to modify the survival inventory without messing up the creative one. In this case, please use this as the target and target_type:
{
"target_type": "menu_class",
"target": "net.minecraft.class_1723"
}
When modifying the creative inventory without it affecting the survival one you will need another menu_class:
{
"target_type": "menu_class",
"target": "net.minecraft.class_481"
}