Skip to content

Slot Element

Frinn38 edited this page Nov 11, 2021 · 8 revisions

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

Beside the 3 mandatory properties (type/x/y) and the 3 optional properties (width/height/priority) the Slot Element have 1 mandatory and 2 optional properties.

ID (Mandatory)

Description : A String value that will be used to find an Item Component with the same id in the machine.

Example : "id": "slot1" Will find the Item Component with id "slot1" and show it's item into the slot.

Texture (Optional)

Description : The slot texture file to be rendered in the Machine GUI.

Default : custommachinery:textures/gui/base_slot.png The default slot texture provided by Custom Machinery.

Example : "texture": "namespace:textures/my_slot_texture.png" The texture loader will use the file assets/namespace/textures/my_slot_texture.png as the slot texture.

Note : If a custom texture is provided the Slot Element width and height properties will be adjusted automatically but the size and the position of the item rendered inside the slot cannot be changed.

Item (Optional)

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 : "minecraft:air" (no item)

Example : "item": "minecraft:coal" A ghost coal item will be shown on the slot.

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 :

slot_element

(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 :

slot_element_item

Clone this wiki locally