Slot element

Add an item slot in the machine gui.

The slot elements is used to render an item slot into the Machine GUI.

Slot elements are defined in json with : "type": "custommachinery:slot".

A slot must be associated with an Item Component using the id property. It will display the item stored in the Item Component and allow you to put or remove the item trough the Machine GUI.

If the slot element cannot find the item component (usually because of an error in the id) the slot will still be rendered but it will be empty and you will not be able to put or remove items.

Properties

The slot element has 4 mandatory properties and 5 optional properties :

Mandatory properties

"type": "custommachinery:slot" //Mandatory to define a slot element.
X

Name : x

Description :

A positive integer value that define the x axis position of the element to be displayed on the Machine GUI.

Example :

The element will be rendered 100px to the right from the top-left corner of the gui.

"x": 100
Y

Name : y

Description :

A positive integer value that define the y axis position of the element to be displayed on the Machine GUI.

Example :

The element will be rendered 100px to the bottom from the top-left corner of the gui.

"y": 100
Id

Name : id

Description :

The id of the Item Component you want to link to this element. It must be the exact same id specified in the item component json id property.

Example :

The element will void the item component with id slot1, if no item component has this id it will do nothing.

"id": "slot1"

Optional properties

Width

Name : width

Description :

A positive integer value that define the width of the element on the Machine GUI.

Default :

The same width as the texture specified in the texture property.

Example :

The width of the element will be 100px.

"width": 100
Height

Name : height

Description :

A positive integer value that define the height of the element on the Machine GUI.

Default :

The same height as the texture specified in the texture property.

Example :

The height of the element will be 100px.

"height": 100
Priority

Name : priority

Description :

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.

"priority": 1000
Texture

Name : texture

Description :

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 :

The default slot element texture :

custommachinery:textures/gui/base_slot.png

Example :

The file assets/textures/my_slot_texture.png will be used for the slot element.

"texture": "namespace:textures/my_slot_texture.png"
Item

Name : item

Description :

If specified the slot will render a "ghost item" (slightly transparent item). The item will not be physically present on the slot (aka the player can't take it out). This can be used, for example, to show a filter.

The item must be referenced by it's registry name like "minecraft:stone" or modid:item_name in general.

This can be a single item, a tag (using "#namespace:id", for example "#forge:stone") or a list of both combined : ["minecraft:diamond", "#forge:stone"].

All possible items will be cycled in the slot as ghost items, the time between each items can be changed in the config file (default : 1 second).

Default : no item

Example :

"item": "minecraft:coal" //A ghost coal item will be shown on the slot.
Always render

Name : always_render

Description :

A boolean that define if the ghost item (set in the "item" property above) will render or not if there is a real item placed in the slot.

If true the ghost item will always render, otherwise it won't render if an item is placed in the slot.

Default : false

Example :

The ghost item will always render.

"always_render": true

Example :

A basic slot element linked to an item component using the id "slot1" and using the default texture :

{
    "type": "custommachinery:slot",
    "x": 20,
    "y": 20,
    "id": "slot1"
}

Result :

(Here the item component contains 32 diamonds, you can add and remove them through the Slot Element like in any other GUI)

If you add "item": "minecraft:coal" to the slot element json the slot will be rendered like this

Last updated