Skip to content

Commit 412601b

Browse files
authored
Fix #1093: Rethink creative menu order a bit (#1095)
1 parent 3e503d3 commit 412601b

File tree

10 files changed

+183
-97
lines changed

10 files changed

+183
-97
lines changed

src/main/java/aztech/modern_industrialization/MIItem.java

Lines changed: 72 additions & 80 deletions
Large diffs are not rendered by default.

src/main/java/aztech/modern_industrialization/items/SortOrder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
*/
2424
package aztech.modern_industrialization.items;
2525

26+
import aztech.modern_industrialization.nuclear.NuclearOrder;
2627
import org.jetbrains.annotations.NotNull;
2728

2829
public final class SortOrder implements Comparable<SortOrder> {
2930
public static final SortOrder GUIDE_BOOK = new SortOrder();
3031
public static final SortOrder FORGE_HAMMER = new SortOrder();
31-
public static final SortOrder HAMMER = new SortOrder();
32-
public static final SortOrder STEAM_TIER = new SortOrder();
33-
public static final SortOrder ITEMS_OTHER = new SortOrder();
32+
public static final SortOrderGroup.Counted ITEMS_ORDERED = new SortOrderGroup.Counted(new SortOrder());
33+
public static final SortOrderGroup.Parametrized<NuclearOrder> NUCLEAR = new SortOrderGroup.Parametrized<>(new SortOrder());
3434
public static final SortOrder CABLES = new SortOrder();
3535
public static final SortOrder PIPES = new SortOrder();
3636
public static final SortOrder TANKS = new SortOrder();
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2020 Azercoco & Technici4n
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package aztech.modern_industrialization.items;
25+
26+
public final class SortOrderGroup {
27+
public static final class Counted {
28+
private final SortOrder sortOrder;
29+
private int localOrder = 0;
30+
31+
public Counted(SortOrder sortOrder) {
32+
this.sortOrder = sortOrder;
33+
}
34+
35+
public SortOrder next() {
36+
return sortOrder.and(localOrder++);
37+
}
38+
}
39+
40+
public static final class Parametrized<T extends Comparable<T>> {
41+
private final SortOrder sortOrder;
42+
43+
public Parametrized(SortOrder sortOrder) {
44+
this.sortOrder = sortOrder;
45+
}
46+
47+
public SortOrder create(T parameter) {
48+
return sortOrder.and(parameter);
49+
}
50+
}
51+
}

src/main/java/aztech/modern_industrialization/materials/MIMaterials.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import aztech.modern_industrialization.MIItem;
3131
import aztech.modern_industrialization.api.energy.CableTier;
3232
import aztech.modern_industrialization.compat.kubejs.KubeJSProxy;
33+
import aztech.modern_industrialization.items.SortOrder;
3334
import aztech.modern_industrialization.machines.init.MIMachineRecipeTypes;
3435
import aztech.modern_industrialization.materials.part.*;
3536
import aztech.modern_industrialization.materials.property.MaterialProperty;
@@ -44,6 +45,7 @@
4445
import aztech.modern_industrialization.nuclear.IsotopeFuelParams;
4546
import aztech.modern_industrialization.nuclear.NuclearAbsorbable;
4647
import aztech.modern_industrialization.nuclear.NuclearConstant;
48+
import aztech.modern_industrialization.nuclear.NuclearOrder;
4749
import net.minecraft.util.valueproviders.UniformInt;
4850

4951
// @formatter:off
@@ -392,7 +394,7 @@ public static MaterialBuilder addVanillaGem(boolean compressor, String gemPath,
392394
.of(englishName, itemPath, 3200, -0.9 * NuclearConstant.BASE_HEAT_CONDUCTION,
393395
INeutronBehaviour.of(NuclearConstant.ScatteringType.MEDIUM, NuclearConstant.INVAR,
394396
2),
395-
NuclearConstant.DESINTEGRATION_BY_ROD * 2)))
397+
NuclearConstant.DESINTEGRATION_BY_ROD * 2, SortOrder.NUCLEAR.create(NuclearOrder.LARGE_PLATE))))
396398
.addParts(BLOCK.of(MaterialBlockSet.IRON)).addRecipes(StandardRecipes::apply, SmeltingRecipes::apply));
397399

398400
CUPRONICKEL = MaterialRegistry.addMaterial(new MaterialBuilder("Cupronickel", "cupronickel")
@@ -507,7 +509,7 @@ public static MaterialBuilder addVanillaGem(boolean compressor, String gemPath,
507509
.of(englishName, itemPath, 2500, 2 * NuclearConstant.BASE_HEAT_CONDUCTION,
508510
INeutronBehaviour.of(NuclearConstant.ScatteringType.MEDIUM, NuclearConstant.CARBON,
509511
2),
510-
NuclearConstant.DESINTEGRATION_BY_ROD * 2)))
512+
NuclearConstant.DESINTEGRATION_BY_ROD * 2, SortOrder.NUCLEAR.create(NuclearOrder.LARGE_PLATE))))
511513
.addRecipes(context -> new MIRecipeBuilder(context, MIMachineRecipeTypes.COMPRESSOR, "dust").addTaggedPartInput(DUST, 1)
512514
.addPartOutput(PLATE, 1))
513515
.addRecipes(StandardRecipes::apply));

src/main/java/aztech/modern_industrialization/materials/part/ControlRodPart.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525

2626
import static aztech.modern_industrialization.materials.part.MIParts.FUEL_ROD;
2727

28+
import aztech.modern_industrialization.items.SortOrder;
2829
import aztech.modern_industrialization.nuclear.INeutronBehaviour;
2930
import aztech.modern_industrialization.nuclear.IsotopeParams;
3031
import aztech.modern_industrialization.nuclear.NuclearAbsorbable;
3132
import aztech.modern_industrialization.nuclear.NuclearConstant;
33+
import aztech.modern_industrialization.nuclear.NuclearOrder;
3234

3335
public class ControlRodPart implements PartKeyProvider {
3436

@@ -47,7 +49,8 @@ public PartTemplate of(int maxTemperature, double heatConduction, double thermal
4749
new IsotopeParams(thermalAbsorbProba, fastAbsorbProba, thermalScatteringProba,
4850
fastScatteringProba),
4951
size),
50-
NuclearConstant.DESINTEGRATION_BY_ROD))
52+
NuclearConstant.DESINTEGRATION_BY_ROD,
53+
SortOrder.NUCLEAR.create(NuclearOrder.CONTROL_ROD)))
5154
.withCustomPath("%s_control_rod");
5255
}
5356

@@ -58,7 +61,8 @@ public PartTemplate of(int maxTemperature, double heatConduction, NuclearConstan
5861
.of(partContext.getMaterialEnglishName() + " Control Rod", itemPath1, maxTemperature,
5962
heatConduction * NuclearConstant.BASE_HEAT_CONDUCTION,
6063
INeutronBehaviour.of(scatteringType, params, size),
61-
NuclearConstant.DESINTEGRATION_BY_ROD))
64+
NuclearConstant.DESINTEGRATION_BY_ROD,
65+
SortOrder.NUCLEAR.create(NuclearOrder.CONTROL_ROD)))
6266
.withCustomPath("%s_control_rod");
6367
}
6468

src/main/java/aztech/modern_industrialization/materials/part/NuclearFuelPart.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@
3131
import aztech.modern_industrialization.nuclear.NuclearConstant;
3232
import aztech.modern_industrialization.nuclear.NuclearFuel;
3333
import aztech.modern_industrialization.nuclear.NuclearFuel.NuclearFuelParams;
34+
import aztech.modern_industrialization.nuclear.NuclearOrder;
3435
import java.util.List;
3536

3637
public class NuclearFuelPart implements PartKeyProvider {
3738

3839
public enum Type {
39-
DEPLETED(0, "fuel_rod_depleted"),
4040
SIMPLE(1, "fuel_rod"),
4141
DOUBLE(2, "fuel_rod_double"),
42-
QUAD(4, "fuel_rod_quad");
42+
QUAD(4, "fuel_rod_quad"),
43+
DEPLETED(0, "fuel_rod_depleted");
4344

4445
public final int size;
4546
public final String key;
@@ -73,8 +74,9 @@ private PartTemplate of() {
7374

7475
var out = new PartTemplate(englishNameFormatter, key)
7576
.withRegister((partContext, part, itemPath, itemId, itemTag, englishName) -> {
77+
var sortOrder = SortOrder.NUCLEAR.create(NuclearOrder.FUEL_ROD).and(partContext.getMaterialName()).and(type);
7678
if (Type.DEPLETED == type) {
77-
MIItem.item(englishName, itemPath, SortOrder.ITEMS_OTHER);
79+
MIItem.item(englishName, itemPath, sortOrder);
7880
} else {
7981
IsotopeFuelParams params = partContext.get(MaterialProperty.ISOTOPE);
8082
if (params == null) {
@@ -88,7 +90,7 @@ private PartTemplate of() {
8890
INeutronBehaviour neutronBehaviour = INeutronBehaviour.of(NuclearConstant.ScatteringType.HEAVY, params, type.size);
8991

9092
NuclearFuel.of(englishName, itemPath, fuelParams,
91-
neutronBehaviour, partContext.getMaterialName() + "_fuel_rod_depleted");
93+
neutronBehaviour, partContext.getMaterialName() + "_fuel_rod_depleted", sortOrder);
9294
}
9395
});
9496
if (type == Type.DEPLETED) {

src/main/java/aztech/modern_industrialization/nuclear/NuclearAbsorbable.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ public void setRemainingDesintegrations(ItemStack stack, int value) {
5151
}
5252

5353
public static ItemDefinition<NuclearComponentItem> of(String englishName, String id, int maxTemperature, double heatConduction,
54-
INeutronBehaviour neutronBehaviour,
55-
int desintegrationMax) {
54+
INeutronBehaviour neutronBehaviour, int desintegrationMax, SortOrder sortOrder) {
5655
return MIItem.item(englishName, id,
5756
(settings) -> new NuclearAbsorbable(settings.stacksTo(1), maxTemperature, heatConduction, neutronBehaviour, desintegrationMax),
58-
SortOrder.ITEMS_OTHER);
57+
sortOrder);
5958
}
6059

6160
public double getDurabilityBarProgress(ItemStack stack) {

src/main/java/aztech/modern_industrialization/nuclear/NuclearComponentItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static ItemDefinition<NuclearComponentItem> of(String englishName, String
4646
INeutronBehaviour neutronBehaviour) {
4747
return MIItem
4848
.item(englishName, id, (settings) -> new NuclearComponentItem(settings.stacksTo(1), maxTemperature, heatConduction, neutronBehaviour),
49-
SortOrder.ITEMS_OTHER);
49+
SortOrder.NUCLEAR.create(NuclearOrder.HEAT_EXCHANGER).and(heatConduction));
5050
}
5151

5252
public int getMaxTemperature() {

src/main/java/aztech/modern_industrialization/nuclear/NuclearFuel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ private NuclearFuel(Properties settings, int desintegrationMax, int maxTemperatu
8484
}
8585

8686
public static ItemDefinition<NuclearFuel> of(String englishName, String id, NuclearFuelParams params, INeutronBehaviour neutronBehaviour,
87-
String depletedVersionId) {
87+
String depletedVersionId, SortOrder sortOrder) {
8888
return MIItem
8989
.item(englishName, id, (settings) -> new NuclearFuel(settings.stacksTo(1), params, neutronBehaviour, MI.id(depletedVersionId)),
90-
SortOrder.ITEMS_OTHER);
90+
sortOrder);
9191
}
9292

9393
@Override
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* MIT License
3+
*
4+
* Copyright (c) 2020 Azercoco & Technici4n
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package aztech.modern_industrialization.nuclear;
25+
26+
import aztech.modern_industrialization.items.SortOrder;
27+
28+
/**
29+
* {@link SortOrder} component for nuclear items.
30+
*/
31+
public enum NuclearOrder {
32+
FUEL_ROD,
33+
HEAT_EXCHANGER,
34+
LARGE_PLATE,
35+
CONTROL_ROD,
36+
}

0 commit comments

Comments
 (0)