Skip to content

Commit c496421

Browse files
authored
Porting more KJS Multi examples to Java (#3852)
1 parent 9a4c1f8 commit c496421

File tree

5 files changed

+575
-279
lines changed

5 files changed

+575
-279
lines changed

docs/content/Modpacks/Examples/Example_Steam_Multiblock.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Steam multiblocks such as the Steam Grinder and Steam Oven use this class.
1111

1212
=== "JavaScript"
1313
```js title="example_steam_multiblock_multiblock.js"
14+
1415
// In order to use multiblock logic extending beyond the default multiblock type for KJS (WorkableElectricMultiblockMachine), you need to load a class.
1516
const $SteamMulti = Java.loadClass('com.gregtechceu.gtceu.common.machine.multiblock.steam.SteamParallelMultiblockMachine');
1617

@@ -44,7 +45,7 @@ Steam multiblocks such as the Steam Grinder and Steam Oven use this class.
4445
```
4546

4647
=== "Java"
47-
```java
48+
```java title="MultiMachines.java"
4849
public static final MultiblockMachineDefinition LARGE_STEAM_COMPRESSOR = REGISTRATE
4950
.multiblock("large_steam_compressor", (holder) -> new SteamParallelMultiblockMachine(holder, 4))
5051
.rotationState(RotationState.NON_Y_AXIS)

docs/content/Modpacks/Examples/Example_Turbine.md

Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,74 @@ title: "Example Turbine"
44

55
### Example Turbine
66

7-
In order to use multiblock logic extending beyond the normal WorkableElectricMultiblockMachine, (This is the multiblock type used by default for kubejs) you need to load a class. LargeTurbineMachines such as the gas, steam, and plasma turbines use this class.
7+
Below is an example of a multiblock using the LargeTurbineMachine class for making custom large turbines.
88

9-
```const $LargeTurbineMachine = Java.loadClass("com.gregtechceu.gtceu.common.machine.multiblock.generator.LargeTurbineMachine")```
9+
### Multiblock
1010

11-
Below is an example of a multiblock using the CoilWorkableElectricMultiblockMachine class and the pyrolyseOvenOverclock machine logic.
11+
=== "JavaScript"
12+
```js title="hyper_gas_turbine.js"
13+
// In order to use multiblock logic extending beyond the normal WorkableElectricMultiblockMachine, (This is the multiblock type used by default for kubejs) you need to load a class. LargeTurbineMachines such as the gas, steam, and plasma turbines use this class.
14+
const $LargeTurbineMachine = Java.loadClass("com.gregtechceu.gtceu.common.machine.multiblock.generator.LargeTurbineMachine")
15+
16+
GTCEuStartupEvents.registry('gtceu:machine', event => {
17+
event.create('hyper_gas_turbine', 'multiblock')
18+
.machine((holder) => new $LargeTurbineMachine(holder, GTValues.LuV))
19+
.rotationState(RotationState.NON_Y_AXIS)
20+
.recipeTypes("gas_turbine")
21+
.recipeModifiers([GTRecipeModifiers.OC_NON_PERFECT_SUBTICK, GTRecipeModifiers.BATCH_MODE])
22+
.appearanceBlock(GTBlocks.CASING_TITANIUM_STABLE)
23+
.pattern(definition => FactoryBlockPattern.start()
24+
.aisle("BBBBBBB", "BBBCBBB", "BBBDBBB", "BBBCBBB", "BBBBBBB")
25+
.aisle("BBBCBBB", "BBCACBB", "BBCECBB", "BBCACBB", "BBBCBBB")
26+
.aisle("BBCCCBB", "BCAAACB", "BCAEACB", "BCAEACB", "BBCCCBB")
27+
.aisle("BCCCCCB", "CAAEAAC", "CEEEEEC", "CAEEEAC", "BCCFCCB")
28+
.aisle("BBCCCBB", "BCAAACB", "BCAEACB", "BCAEACB", "BBCCCBB")
29+
.aisle("BBBCBBB", "BBCACBB", "BBCECBB", "BBCACBB", "BBBCBBB")
30+
.aisle("BBBBBBB", "BBBCBBB", "BBBGBBB", "BBBCBBB", "BBBBBBB")
31+
.where("A", Predicates.blocks("minecraft:air"))
32+
.where("B", Predicates.any())
33+
.where("C", Predicates.blocks("gtceu:stainless_steel_turbine_casing")
34+
.or(Predicates.autoAbilities(definition.getRecipeTypes()))
35+
.or(Predicates.abilities(PartAbility.MAINTENANCE).setExactLimit(1)))
36+
.where("D", Predicates.ability(PartAbility.MUFFLER).setExactLimit(1))
37+
.where("F", Predicates.ability(PartAbility.ROTOR_HOLDER).setExactLimit(1))
38+
.where("E", Predicates.blocks("gtceu:stainless_steel_frame"))
39+
.where("G", Predicates.controller(Predicates.blocks(definition.get())))
40+
.build())
41+
.workableCasingModel("gtceu:block/casings/mechanic/machine_casing_turbine_stainless_steel",
42+
"gtceu:block/multiblock/generator/large_gas_turbine")
43+
});
44+
```
1245

13-
### Multiblock
46+
=== "Java"
47+
```java title="MultiMachines.java"
48+
public static final MultiblockMachineDefinition HYPER_GAS_TURBINE = REGISTRATE
49+
.multiblock("hyper_gas_turbine", (holder) -> new LargeTurbineMachine(holder, 4))
50+
.rotationState(RotationState.NON_Y_AXIS)
51+
.recipeType(GTRecipeTypes.GAS_TURBINE_FUELS)
52+
.recipeModifiers(GTRecipeModifiers.OC_NON_PERFECT_SUBTICK, GTRecipeModifiers.BATCH_MODE)
53+
.pattern(definition -> FactoryBlockPattern.start()
54+
.aisle("BCCCB", "BBCBB", "BBCBB", "BBBBB", "BBBBB")
55+
.aisle("CDDDC", "BDBDB", "BDEDB", "BBDBB", "BBBBB")
56+
.aisle("CDDDC", "CBBBC", "CEFEC", "BDDDB", "BBGBB")
57+
.aisle("CDDDC", "BDBDB", "BDEDB", "BBDBB", "BBBBB")
58+
.aisle("BCCCB", "BBHBB", "BBCBB", "BBBBB", "BBBBB")
59+
.where('B', Predicates.any())
60+
.where('C', Predicates.blocks(GTBlocks.CASING_BRONZE_BRICKS.get()).setMinGlobalLimited(10)
61+
.or(Predicates.abilities(PartAbility.STEAM_IMPORT_ITEMS).setMaxGlobalLimited(1))
62+
.or(Predicates.abilities(PartAbility.STEAM).setMaxGlobalLimited(1))
63+
.or(Predicates.abilities(PartAbility.STEAM_EXPORT_ITEMS).setMaxGlobalLimited(1)))
64+
.where('D', Predicates.blocks(GCYMBlocks.CASING_INDUSTRIAL_STEAM.get()))
65+
.where('E', Predicates.blocks(GTBlocks.BRONZE_BRICKS_HULL.get()))
66+
.where('F', Predicates.blocks(GTBlocks.FIREBOX_BRONZE.get()))
67+
.where('G', Predicates.blocks(GTBlocks.BRONZE_HULL.get()))
68+
.where('H', Predicates.controller(Predicates.blocks(definition.get())))
69+
.build())
70+
.workableCasingModel(GTCEu.id("block/casings/steam/bronze/bottom"),
71+
GTCEu.id("block/machines/compressor"))
72+
.register();
73+
```
1474

15-
```js title="hyper_gas_turbine_multiblock.js"
16-
GTCEuStartupEvents.registry('gtceu:machine', event => {
17-
event.create('hyper_gas_turbine', 'multiblock')
18-
.machine((holder) => new $LargeTurbineMachine(holder, GTValues.LuV))
19-
.rotationState(RotationState.NON_Y_AXIS)
20-
.recipeTypes("gas_turbine")
21-
.recipeModifiers([GTRecipeModifiers.OC_NON_PERFECT_SUBTICK, GTRecipeModifiers.BATCH_MODE])
22-
.appearanceBlock(GTBlocks.CASING_TITANIUM_STABLE)
23-
.pattern(definition => FactoryBlockPattern.start()
24-
.aisle("BBBBBBB", "BBBCBBB", "BBBDBBB", "BBBCBBB", "BBBBBBB")
25-
.aisle("BBBCBBB", "BBCACBB", "BBCECBB", "BBCACBB", "BBBCBBB")
26-
.aisle("BBCCCBB", "BCAAACB", "BCAEACB", "BCAEACB", "BBCCCBB")
27-
.aisle("BCCCCCB", "CAAEAAC", "CEEEEEC", "CAEEEAC", "BCCFCCB")
28-
.aisle("BBCCCBB", "BCAAACB", "BCAEACB", "BCAEACB", "BBCCCBB")
29-
.aisle("BBBCBBB", "BBCACBB", "BBCECBB", "BBCACBB", "BBBCBBB")
30-
.aisle("BBBBBBB", "BBBCBBB", "BBBGBBB", "BBBCBBB", "BBBBBBB")
31-
.where("A", Predicates.blocks("minecraft:air"))
32-
.where("B", Predicates.any())
33-
.where("C", Predicates.blocks("gtceu:stainless_steel_turbine_casing")
34-
.or(Predicates.autoAbilities(definition.getRecipeTypes()))
35-
.or(Predicates.abilities(PartAbility.MAINTENANCE).setExactLimit(1)))
36-
.where("D", Predicates.ability(PartAbility.MUFFLER).setExactLimit(1))
37-
.where("F", Predicates.ability(PartAbility.ROTOR_HOLDER).setExactLimit(1))
38-
.where("E", Predicates.blocks("gtceu:stainless_steel_frame"))
39-
.where("G", Predicates.controller(Predicates.blocks(definition.get())))
40-
.build())
41-
.workableCasingModel("gtceu:block/casings/mechanic/machine_casing_turbine_stainless_steel",
42-
"gtceu:block/multiblock/generator/large_gas_turbine")
43-
});
44-
```
4575

4676
### Lang
4777

0 commit comments

Comments
 (0)