Skip to content

Commit efd2988

Browse files
authored
Add to 7.0.0 rtui patch notes, and add Ambiguous Methods docs page (#3903)
1 parent 75daa31 commit efd2988

File tree

3 files changed

+75
-2
lines changed

3 files changed

+75
-2
lines changed

docs/content/Modpacks/Changes/v7.0.0.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ title: "Version 7.0.0"
55

66
# Updating from `1.6.4` to `7.0.0`
77

8+
## Custom UIs
9+
10+
In your custom `.rtui` files, you need to rename the following references:
11+
12+
- `phantom_fluid_slot` -> `gtm_phantom_fluid_slot`
13+
- `phantom_item_slot` -> `gtm_phantom_item_slot`
14+
- `item_slot` -> `gtm_item_slot`
15+
- `fluid_slot` -> `gtm_fluid_slot`
16+
- `container` -> `gtm_container`
17+
18+
This can be done in any NBT editor of choice, e.g. [webNBT](https://irath96.github.io/webNBT/).
819

920
## Models
1021

docs/content/Modpacks/Examples/Superheated_Pyrolyzing_Oven.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ Below is an example of a multiblock using the CoilWorkableElectricMultiblockMach
1818
.machine((holder) => new CoilWorkableElectricMultiblockMachine(holder))
1919
.rotationState(RotationState.NON_Y_AXIS)
2020
.recipeTypes('pyrolyse_oven')
21-
.recipeModifiers([GTRecipeModifiers.PARALLEL_HATCH, GTRecipeModifiers.OC_PERFECT,GTRecipeModifiers.BATCH_MODE, (machine, recipe) =>
22-
GTRecipeModifiers.pyrolyseOvenOverclock(machine, recipe)])
21+
.recipeModifiers(
22+
[
23+
GTRecipeModifiers.PARALLEL_HATCH,
24+
GTRecipeModifiers.OC_PERFECT,
25+
GTRecipeModifiers.BATCH_MODE,
26+
(machine, recipe) => GTRecipeModifiers.pyrolyseOvenOverclock(machine, recipe)
27+
]
28+
)
2329
.appearanceBlock(GTBlocks.CASING_STEEL_SOLID)
2430
.pattern(definition => FactoryBlockPattern.start()
2531
.aisle("BBCCCBB", "BBCDCBB", "BBCCCBB", "BBCCCBB", "BBEEEBB", "BBEEEBB")
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Ambiguous Methods
3+
---
4+
5+
Sometimes in KJS, you run into ambiguous methods when calling functions.
6+
This happens when there's multiple overloads (e.g. methods with the same name but different types) and KubeJS isn't sure which function to call with your arguments.
7+
8+
For example, when you do:
9+
```js
10+
11+
GTCEuStartupEvents.registry('gtceu:machine', event => {
12+
event.create('unboxinator', 'multiblock')
13+
.tooltips(Component.literal("I am a multiblock"))
14+
// Rest of the multiblock
15+
})
16+
```
17+
18+
you'd get the error:
19+
```
20+
Error in 'GTCEuStartupEvents.registry': The choice of Java method com.gregtechceu.gtceu.api.registry.registrate.MultiblockMachineBuilder.tooltips matching JavaScript argument types (net.minecraft.network.chat.MutableComponent) is ambiguous; candidate methods are:
21+
class com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder tooltips(java.util.List)
22+
class com.gregtechceu.gtceu.api.registry.registrate.MachineBuilder tooltips(net.minecraft.network.chat.Component[])
23+
```
24+
25+
In this case, there's ambiguity between the following 2 java functions:
26+
```java
27+
public MachineBuilder<DEFINITION> tooltips(@Nullable Component... components) {
28+
return tooltips(Arrays.asList(components));
29+
}
30+
31+
public MachineBuilder<DEFINITION> tooltips(List<? extends @Nullable Component> components) {
32+
tooltips.addAll(components.stream().filter(Objects::nonNull).toList());
33+
return this;
34+
}
35+
```
36+
37+
You would want to select one of the two, and this can be done in the following way:
38+
```js
39+
GTCEuStartupEvents.registry('gtceu:machine', event => {
40+
event.create('unboxinator', 'multiblock')
41+
["tooltips(java.util.List)"]([Component.literal("I am a multiblock")])
42+
// Rest of the multiblock
43+
})
44+
```
45+
or
46+
```js
47+
GTCEuStartupEvents.registry('gtceu:machine', event => {
48+
event.create('unboxinator', 'multiblock')
49+
["tooltips(net.minecraft.network.chat.Component[])"]([Component.literal("I am a multiblock")])
50+
// Rest of the multiblock
51+
})
52+
```
53+
54+
Because of the way javascript indexing works, `.foo` and `["foo"]` are the same thing, so you can just keep chaning your functions afterward, since it's just a "normal" builder method, just called in a more specific way.
55+
!!! Note
56+
Generics don't exist in compiled code, so e.g. a call to `memoize(Supplier<T> delegate)` would turn into `["memoize(Supplier)"](...)`

0 commit comments

Comments
 (0)