Skip to content

Commit ed59ca0

Browse files
Modifying Multiblock Controller UI (#3942)
Co-authored-by: Jurre Groenendijk <jurre@jilles.com>
1 parent 792b76a commit ed59ca0

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: Modifying Multiblock Controller UI
3+
---
4+
# Modifying Multiblock Controller UI
5+
6+
## Adding text component
7+
To add text component to the UI, you need to use `.additionalDisplay` in the multiblock registration builder.
8+
`.additionalDisplay` takes a lambda that takes 2 arguments: the `IMultiController` machine that the components are being added to, and the `List<Component>` of existing components.
9+
An example of using it would be:
10+
11+
```js title="ui_modified_multiblock.js"
12+
GTCEuStartupEvents.registry('gtceu:machine', event => {
13+
event.create('ui_modified_multiblock', 'multiblock')
14+
.rotationState(RotationState.NON_Y_AXIS)
15+
.recipeType('electrolyzer')
16+
.recipeModifiers([GTRecipeModifiers.OC_NON_PERFECT_SUBTICK])
17+
.appearanceBlock(() => Block.getBlock("gtceu:solid_machine_casing"))
18+
.pattern(definition => FactoryBlockPattern.start()
19+
.aisle('###',' ','###')
20+
.aisle('###',' S ','###')
21+
.aisle('#C#',' ','###')
22+
.where('C', Predicates.controller(Predicates.blocks(definition.get())))
23+
.where('#', Predicates.blocks("gtceu:solid_machine_casing")
24+
.or(Predicates.abilities(PartAbility.IMPORT_ITEMS).setPreviewCount(1))
25+
.or(Predicates.abilities(PartAbility.EXPORT_ITEMS).setPreviewCount(1))
26+
.or(Predicates.abilities(PartAbility.INPUT_ENERGY).setMaxGlobalLimited(1).setPreviewCount(1)))
27+
.where('S', Predicates.blocks("gtceu:steel_machine_casing"))
28+
.where(' ', Predicates.any())
29+
.build())
30+
.workableCasingModel("gtceu:block/casings/solid/machine_casing_solid_steel", "gtceu:block/multiblock/blast_furnace")
31+
.additionalDisplay((machine, components) => { // (3)
32+
if (machine.isFormed()) { // (1)
33+
components.add(Component.literal("I am text component #1")) // (2)
34+
components.add(Component.literal("I am text component #2"))
35+
}
36+
})
37+
});
38+
```
39+
40+
1. Check if multiblock is formed
41+
2. To add new line - Use `components.add(Component)`.
42+
3. Using `.additionalDisplay()` to add text component.

0 commit comments

Comments
 (0)