Skip to content

Commit f72fd3b

Browse files
committed
Revert to single-input-color version
1 parent 4299dc8 commit f72fd3b

File tree

4 files changed

+29
-56
lines changed

4 files changed

+29
-56
lines changed

run/kubejs/server_scripts/PrismaC_test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
11
ServerEvents.recipes(event =>{
22
event.recipes.gtceu.prismatic_crucible("test2")
3-
.inputColor(PrismaticColor.RED)
3+
.inputStates(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-
.inputColor(PrismaticColor.GREEN)
11+
.inputStates(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-
.inputColor(PrismaticColor.GREEN)
19+
.inputStates(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-
.inputColor(PrismaticColor.BASIC)
27+
.inputStatesSpecial(SpecialCase.BASIC)
2828
.itemInputs("minecraft:white_dye")
2929
.itemOutputs("minecraft:black_dye")
3030
.EUt(128)
3131
.duration(100)
32-
.outputStates(PrismaticColor.MAGENTA)
3332

3433
event.recipes.gtceu.prismatic_crucible("test6")
35-
.inputColor(PrismaticColor.RED)
34+
.inputStates(PrismaticColor.RED)
3635
.itemInputs("minecraft:stone")
3736
.itemOutputs("minecraft:diamond", 4)
3837
.EUt(128)

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

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

33
import java.util.ArrayList;
44
import java.util.List;
5-
import java.util.stream.Stream;
65

76
import com.google.gson.JsonElement;
87
import com.google.gson.JsonPrimitive;
@@ -29,25 +28,9 @@ public boolean isRecipeSearchFilter() {
2928
public List<AbstractMapIngredient> convertToMapIngredient(Object ingredient) {
3029
if (ingredient instanceof Color ingredientColor) {
3130
//TODO add the generic/special case "colors" ie primary colors
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-
};
31+
List<AbstractMapIngredient> list = new ArrayList<>();
32+
list.add(new MapColorIngredient(ingredientColor));
33+
return list;
5134
} else {
5235
return super.convertToMapIngredient(ingredient);
5336
}

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

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,17 @@ 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),
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);
110+
PINK(11, "monilabs.prismatic.color_name.pink", 1.0f, 0f, 0.5f);
116111

117112
public static final Color[] COLORS = Color.values();
118113

119-
public static final Color[] ACTUAL_COLORS = new Color[]{RED, ORANGE, YELLOW, LIME, GREEN, TEAL, CYAN, AZURE, BLUE, INDIGO, MAGENTA, PINK};
120-
121114
public final String nameKey;
122115
public final int key;
123116
public final float r;
124117
public final float g;
125118
public final float b;
126119

127-
public static final int COLOR_COUNT = COLORS.length;
128-
129-
public static final int ACTUAL_COLOR_COUNT = ACTUAL_COLORS.length;
120+
public static final int COLOR_COUNT = Color.values().length;
130121

131122
Color(int key, String nameKey, float r, float g, float b) {
132123
this.key = key;
@@ -136,27 +127,11 @@ public enum Color {
136127
this.b = b;
137128
}
138129

139-
public boolean isPrimary() {
140-
return this == RED || this == GREEN || this == BLUE;
141-
}
142-
143-
public boolean isSecondary() {
144-
return this == YELLOW || this == CYAN || this == MAGENTA;
145-
}
146-
147-
public boolean isBasic() {
148-
return isPrimary() || isSecondary();
149-
}
150-
151-
public boolean isTertiary() {
152-
return !isBasic();
153-
}
154-
155130
public static Color getColorFromKey(int pKey) {
156131
return COLORS[pKey];
157132
}
158133
public static int getRandomColor() {
159-
return (int) Math.floor(Math.random() * Color.ACTUAL_COLOR_COUNT);
134+
return (int) Math.floor(Math.random() * Color.COLOR_COUNT);
160135
}
161136

162137
public static int getRandomColorFromKeys(int[] keys) {

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

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

3235
return this;
3336
}
3437

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+
3551

3652
public GTRecipeSchema.GTRecipeJS outputStates(boolean relative, Color... states) {
3753

0 commit comments

Comments
 (0)