Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 6e54812

Browse files
committed
Merge branch 'machine-flag-refactor' into dev-1.18
2 parents 3b82ec0 + d1ce1d0 commit 6e54812

File tree

4 files changed

+23
-57
lines changed

4 files changed

+23
-57
lines changed

common/src/main/java/muramasa/antimatter/blockentity/BlockEntityMachine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public Tier getPowerLevel() {
376376
return getMachineTier();
377377
}
378378

379-
public boolean has(MachineFlag flag) {
379+
public boolean has(String flag) {
380380
return getMachineType().has(flag);
381381
}
382382

common/src/main/java/muramasa/antimatter/integration/kubejs/AMCreationEvent.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ public void addFlagsToMaterial(String materialId, String... flags) {
7575
}
7676
}
7777

78-
public MachineFlag machineFlag(String id){
79-
return MachineFlag.valueOf(id);
80-
}
81-
8278
public MaterialType type(String type) {
8379
return AntimatterAPI.get(MaterialType.class, type);
8480
}

common/src/main/java/muramasa/antimatter/machine/MachineFlag.java

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,21 @@
1111
import java.util.Set;
1212
import java.util.stream.Collectors;
1313

14-
public enum MachineFlag {
15-
16-
BASIC, //
17-
STEAM,
18-
MULTI, //Has structure
19-
HATCH,
20-
ITEM, //Can store items
21-
CELL,
22-
FLUID,
23-
EU, //Needs power
24-
RF, //Uses RF instead of EU
25-
HEAT,
26-
RECIPE, //Has a recipe map
27-
GUI,
28-
GENERATOR, //Has a recipe map and converts applicable recipes to power.
29-
COVERABLE,
30-
PARTIAL_AMPS,
31-
UNCULLED;
32-
33-
@Override
34-
public String toString() {
35-
return super.toString().toLowerCase();
36-
}
14+
public final class MachineFlag {
15+
public static final String BASIC = "basic"; //
16+
public static final String STEAM = "steam";
17+
public static final String MULTI = "multi"; //Has structure
18+
public static final String HATCH = "hatch";
19+
public static final String ITEM = "item"; //Can store items
20+
public static final String CELL = "cell";
21+
public static final String FLUID = "fluid";
22+
public static final String EU = "eu"; //Needs power
23+
public static final String RF = "rf"; //Uses RF instead of EU
24+
public static final String HEAT = "heat";
25+
public static final String RECIPE = "recipe"; //Has a recipe map
26+
public static final String GUI = "gui";
27+
public static final String GENERATOR = "generator"; //Has a recipe map and converts applicable recipes to power.
28+
public static final String COVERABLE = "coverable";
29+
public static final String PARTIAL_AMPS = "partial_amps";
30+
public static final String UNCULLED = "unculled";
3731
}

common/src/main/java/muramasa/antimatter/machine/types/Machine.java

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -612,35 +612,21 @@ public IRecipeMap getRecipeMap(Tier tier) {
612612
return tierRecipeMaps.get("");
613613
}
614614

615-
public T addFlags(MachineFlag... flags) {
616-
for (MachineFlag flag : flags) {
617-
FLAG_MAP.computeIfAbsent(flag.toString(), s -> new ObjectOpenHashSet<>()).add(this);
618-
}
619-
return (T) this;
620-
}
621-
622615
public T addFlags(String... flags) {
623616
for (String flag : flags) {
624617
FLAG_MAP.computeIfAbsent(flag, s -> new ObjectOpenHashSet<>()).add(this);
625618
}
626619
return (T) this;
627620
}
628621

629-
public T removeFlags(MachineFlag... flags) {
630-
for (MachineFlag flag : flags) {
631-
FLAG_MAP.computeIfAbsent(flag.toString(), s -> new ObjectOpenHashSet<>()).remove(this);
632-
}
633-
return (T) this;
634-
}
635-
636622
public T removeFlags(String... flags) {
637623
for (String flag : flags) {
638624
FLAG_MAP.computeIfAbsent(flag, s -> new ObjectOpenHashSet<>()).remove(this);
639625
}
640626
return (T) this;
641627
}
642628

643-
public void setFlags(MachineFlag... flags) {
629+
public void setFlags(String... flags) {
644630
FLAG_MAP.forEach((s, m) -> m.remove(this));
645631
addFlags(flags);
646632
}
@@ -725,16 +711,6 @@ public boolean hasTierSpecificLang(){
725711
return tierSpecificLang;
726712
}
727713

728-
/**
729-
* Whether or not this machine has the given machine flag.
730-
*
731-
* @param flag the flag.
732-
* @return if it has it;.
733-
*/
734-
public boolean has(MachineFlag flag) {
735-
return has(flag.toString());
736-
}
737-
738714
/**
739715
* Whether or not this machine has the given machine flag.
740716
*
@@ -772,11 +748,11 @@ public static Optional<Machine<?>> get(String name, String domain) {
772748
return Optional.ofNullable(machine);
773749
}
774750

775-
public static Collection<Machine<?>> getTypes(MachineFlag... flags) {
751+
public static Collection<Machine<?>> getTypes(String... flags) {
776752
List<Machine<?>> types = new ObjectArrayList<>();
777-
for (MachineFlag flag : flags) {
778-
if (FLAG_MAP.containsKey(flag.toString())){
779-
types.addAll(FLAG_MAP.get(flag.toString()));
753+
for (var flag : flags) {
754+
if (FLAG_MAP.containsKey(flag)){
755+
types.addAll(FLAG_MAP.get(flag));
780756
}
781757

782758
}

0 commit comments

Comments
 (0)