Skip to content

Commit a81c669

Browse files
committed
IndexOutOfBoundsException? Not sure why
1 parent 52902bb commit a81c669

File tree

4 files changed

+51
-29
lines changed

4 files changed

+51
-29
lines changed

run/kubejs/server_scripts/PrismaC_test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
ServerEvents.recipes(event =>{
22
event.recipes.gtceu.prismatic_crucible("test2")
3-
.inputStates(PrismaticColor.RED)
3+
.inputColor(PrismaticColor.RED)
44
.itemInputs("minecraft:red_dye")
55
.itemOutputs("minecraft:green_dye")
66
.EUt(128)
77
.duration(100)
88
.outputStates(PrismaticColor.GREEN)
99

1010
event.recipes.gtceu.prismatic_crucible("test3")
11-
.inputStates(PrismaticColor.GREEN)
11+
.inputColor(PrismaticColor.GREEN)
1212
.itemInputs("minecraft:green_dye")
1313
.itemOutputs("minecraft:red_dye")
1414
.EUt(128)
1515
.duration(100)
1616
.outputStates(PrismaticColor.RED)
1717

1818
event.recipes.gtceu.prismatic_crucible("test4")
19-
.inputStates(PrismaticColor.GREEN)
19+
.inputColor(PrismaticColor.GREEN)
2020
.itemInputs("minecraft:stone")
2121
.itemOutputs("minecraft:cobblestone")
2222
.EUt(128)
2323
.duration(100)
2424
.outputStates(PrismaticColor.RED)
2525

2626
event.recipes.gtceu.prismatic_crucible("test5")
27-
.inputStatesSpecial(SpecialCase.BASIC)
27+
.inputColor(PrismaticColor.BASIC)
2828
.itemInputs("minecraft:white_dye")
2929
.itemOutputs("minecraft:black_dye")
3030
.EUt(128)
3131
.duration(100)
3232

3333
event.recipes.gtceu.prismatic_crucible("test6")
34-
.inputStates(PrismaticColor.RED)
34+
.inputColor(PrismaticColor.RED)
3535
.itemInputs("minecraft:stone")
3636
.itemOutputs("minecraft:diamond", 4)
3737
.EUt(128)

src/main/java/net/neganote/monilabs/capability/recipe/ChromaRecipeCapability.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5+
import java.util.stream.Stream;
56

67
import com.google.gson.JsonElement;
78
import com.google.gson.JsonPrimitive;
@@ -28,9 +29,25 @@ public boolean isRecipeSearchFilter() {
2829
public List<AbstractMapIngredient> convertToMapIngredient(Object ingredient) {
2930
if (ingredient instanceof Color ingredientColor) {
3031
//TODO add the generic/special case "colors" ie primary colors
31-
List<AbstractMapIngredient> list = new ArrayList<>();
32-
list.add(new MapColorIngredient(ingredientColor));
33-
return list;
32+
return switch (ingredientColor) {
33+
case RED -> List.of(new MapColorIngredient(Color.RED));
34+
case ORANGE -> List.of(new MapColorIngredient(Color.ORANGE));
35+
case YELLOW -> List.of(new MapColorIngredient(Color.YELLOW));
36+
case LIME -> List.of(new MapColorIngredient(Color.LIME));
37+
case GREEN -> List.of(new MapColorIngredient(Color.GREEN));
38+
case TEAL -> List.of(new MapColorIngredient(Color.TEAL));
39+
case CYAN -> List.of(new MapColorIngredient(Color.CYAN));
40+
case AZURE -> List.of(new MapColorIngredient(Color.AZURE));
41+
case BLUE -> List.of(new MapColorIngredient(Color.BLUE));
42+
case INDIGO -> List.of(new MapColorIngredient(Color.INDIGO));
43+
case MAGENTA -> List.of(new MapColorIngredient(Color.MAGENTA));
44+
case PINK -> List.of(new MapColorIngredient(Color.PINK));
45+
case PRIMARY -> new ArrayList<>(Stream.of(Color.RED, Color.GREEN, Color.BLUE).map(MapColorIngredient::new).toList());
46+
case SECONDARY -> new ArrayList<>(Stream.of(Color.YELLOW, Color.CYAN, Color.MAGENTA).map(MapColorIngredient::new).toList());
47+
case BASIC -> new ArrayList<>(Stream.of(Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA).map(MapColorIngredient::new).toList());
48+
case TERTIARY -> new ArrayList<>(Stream.of(Color.ORANGE, Color.LIME, Color.TEAL, Color.AZURE, Color.INDIGO, Color.PINK).map(MapColorIngredient::new).toList());
49+
case ANY -> new ArrayList<>(Stream.of(Color.COLORS).map(MapColorIngredient::new).toList());
50+
};
3451
} else {
3552
return super.convertToMapIngredient(ingredient);
3653
}

src/main/java/net/neganote/monilabs/common/machine/multiblock/PrismaticCrucibleMachine.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,22 @@ public enum Color {
107107
BLUE(8, "monilabs.prismatic.color_name.blue", 0f, 0f, 1.0f),
108108
INDIGO(9, "monilabs.prismatic.color_name.indigo", 0.5f, 0f, 1.0f),
109109
MAGENTA(10, "monilabs.prismatic.color_name.magenta", 1.0f, 0f, 1.0f),
110-
PINK(11, "monilabs.prismatic.color_name.pink", 1.0f, 0f, 0.5f);
110+
PINK(11, "monilabs.prismatic.color_name.pink", 1.0f, 0f, 0.5f),
111+
PRIMARY(12, "", 0f, 0f, 0f),
112+
SECONDARY(13, "", 0f, 0f, 0f),
113+
BASIC(14, "", 0f, 0f, 0f),
114+
TERTIARY(15, "", 0f, 0f, 0f),
115+
ANY(16, "", 0f, 0f, 0f);
111116

112-
public static final Color[] COLORS = Color.values();
117+
public static final Color[] COLORS = new Color[]{RED, ORANGE, YELLOW, LIME, GREEN, TEAL, CYAN, AZURE, BLUE, INDIGO, MAGENTA, PINK};
113118

114119
public final String nameKey;
115120
public final int key;
116121
public final float r;
117122
public final float g;
118123
public final float b;
119124

120-
public static final int COLOR_COUNT = Color.values().length;
125+
public static final int COLOR_COUNT = COLORS.length;
121126

122127
Color(int key, String nameKey, float r, float g, float b) {
123128
this.key = key;
@@ -127,6 +132,22 @@ public enum Color {
127132
this.b = b;
128133
}
129134

135+
public boolean isPrimary() {
136+
return this == RED || this == GREEN || this == BLUE;
137+
}
138+
139+
public boolean isSecondary() {
140+
return this == YELLOW || this == CYAN || this == MAGENTA;
141+
}
142+
143+
public boolean isBasic() {
144+
return isPrimary() || isSecondary();
145+
}
146+
147+
public boolean isTertiary() {
148+
return !isBasic();
149+
}
150+
130151
public static Color getColorFromKey(int pKey) {
131152
return COLORS[pKey];
132153
}

src/main/java/net/neganote/monilabs/integration/kjs/recipe/MoniRecipeSchema.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,12 @@ enum SpecialCase {
2626
@SuppressWarnings({ "unused", "UnusedReturnValue" })
2727
@Accessors(chain = true, fluent = true)
2828
class MoniRecipeJS extends GTRecipeSchema.GTRecipeJS {
29-
30-
public GTRecipeSchema.GTRecipeJS inputStates(Color... states) {
31-
for (Color color : states) {
32-
this.input(MoniRecipeCapabilities.CHROMA, color);
33-
}
29+
public GTRecipeSchema.GTRecipeJS inputColor(Color color) {
30+
this.input(MoniRecipeCapabilities.CHROMA, color);
3431

3532
return this;
3633
}
3734

38-
// Used to have a shorthand for special cases in recipe definitions
39-
public GTRecipeSchema.GTRecipeJS inputStatesSpecial(SpecialCase specialCase) {
40-
return switch (specialCase) {
41-
case PRIMARY -> this.inputStates(Color.RED, Color.GREEN, Color.BLUE); // Red, Green, Blue
42-
case SECONDARY -> this.inputStates(Color.YELLOW, Color.CYAN, Color.MAGENTA); // Yellow, Cyan, Magenta
43-
case BASIC -> this.inputStates(Color.RED, Color.YELLOW, Color.GREEN, Color.CYAN, Color.BLUE, Color.MAGENTA); // Primary + Secondary Colors
44-
case TERTIARY -> this.inputStates(Color.ORANGE, Color.LIME, Color.TEAL, Color.AZURE, Color.INDIGO, Color.PINK); // Non-Basic Colors
45-
46-
// Saving computation by skipping unnecessary steps
47-
case ANY -> this.addData("input_states", Color.COLOR_COUNT);
48-
};
49-
}
50-
5135

5236
public GTRecipeSchema.GTRecipeJS outputStates(boolean relative, Color... states) {
5337

0 commit comments

Comments
 (0)