Skip to content

Commit a0bba06

Browse files
committed
Added configs for the quantum computer
1 parent c80fd13 commit a0bba06

File tree

6 files changed

+150
-25
lines changed

6 files changed

+150
-25
lines changed

Diff for: gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ loader_version_range=[4,)
1414
mod_id=advanced_ae
1515
mod_name=Advanced AE
1616
mod_license=LGPL-3.0
17-
mod_version=0.4.1-1.21.1
17+
mod_version=0.4.2-1.21.1
1818
mod_group_id=net.pedroksl.advanced_ae
1919
mod_authors=Pedroksl
2020
mod_description=This mod aims to expand on the added capabilities of Extended AE.
+129-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,139 @@
11
package net.pedroksl.advanced_ae;
22

3-
import net.neoforged.bus.api.SubscribeEvent;
4-
import net.neoforged.fml.common.EventBusSubscriber;
5-
import net.neoforged.fml.event.config.ModConfigEvent;
3+
import net.neoforged.fml.ModContainer;
4+
import net.neoforged.fml.config.ModConfig;
65
import net.neoforged.neoforge.common.ModConfigSpec;
76

8-
@EventBusSubscriber(modid = AdvancedAE.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
97
public class AAEConfig {
108

11-
private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();
9+
private final AAEConfig.ClientConfig client = new AAEConfig.ClientConfig();
10+
private final AAEConfig.CommonConfig common = new AAEConfig.CommonConfig();
1211

13-
public static final ModConfigSpec SPEC = BUILDER.build();
12+
private static AAEConfig INSTANCE;
1413

15-
@SubscribeEvent
16-
static void onLoad(final ModConfigEvent event) {
17-
if (event.getConfig().getSpec() == SPEC) {}
14+
AAEConfig(ModContainer container) {
15+
container.registerConfig(ModConfig.Type.CLIENT, client.spec);
16+
container.registerConfig(ModConfig.Type.COMMON, common.spec);
17+
}
18+
19+
public int getQuantumComputerMaxSize() {
20+
return common.quantumComputerMaxSize.get();
21+
}
22+
23+
public int getQuantumComputerMaxMultiThreaders() {
24+
return common.quantumComputerMaxMultiThreaders.get();
25+
}
26+
27+
public int getQuantumComputermaxDataEntanglers() {
28+
return common.quantumComputermaxDataEntanglers.get();
29+
}
30+
31+
public int getQuantumComputerMultiThreaderMultiplication() {
32+
return common.quantumComputerMultiThreaderMultiplication.get();
33+
}
34+
35+
public int getQuantumComputerDataEntanglerMultiplication() {
36+
return common.quantumComputerDataEntanglerMultiplication.get();
37+
}
38+
39+
public void save() {
40+
common.spec.save();
41+
client.spec.save();
42+
}
43+
44+
public static void register(ModContainer container) {
45+
if (!container.getModId().equals(AdvancedAE.MOD_ID)) {
46+
throw new IllegalArgumentException();
47+
}
48+
INSTANCE = new AAEConfig(container);
49+
}
50+
51+
public static AAEConfig instance() {
52+
return INSTANCE;
53+
}
54+
55+
private static class ClientConfig {
56+
private final ModConfigSpec spec;
57+
58+
public ClientConfig() {
59+
var builder = new ModConfigSpec.Builder();
60+
61+
this.spec = builder.build();
62+
}
63+
}
64+
65+
private static class CommonConfig {
66+
private final ModConfigSpec spec;
67+
68+
public final ModConfigSpec.IntValue quantumComputerMaxSize;
69+
public final ModConfigSpec.IntValue quantumComputerMaxMultiThreaders;
70+
public final ModConfigSpec.IntValue quantumComputermaxDataEntanglers;
71+
public final ModConfigSpec.IntValue quantumComputerMultiThreaderMultiplication;
72+
public final ModConfigSpec.IntValue quantumComputerDataEntanglerMultiplication;
73+
74+
public CommonConfig() {
75+
var builder = new ModConfigSpec.Builder();
76+
77+
builder.push("quantum computer");
78+
quantumComputerMaxSize = define(
79+
builder,
80+
"quantumComputerMaxSize",
81+
5,
82+
5,
83+
16,
84+
"Define the maximum dimensions of the Quantum Computer Multiblock.");
85+
quantumComputerMaxMultiThreaders = define(
86+
builder,
87+
"quantumComputerMaxMultiThreaders",
88+
1,
89+
0,
90+
2,
91+
"Define the maximum amount of multi threaders per Quantum Computer Multiblock.");
92+
quantumComputermaxDataEntanglers = define(
93+
builder,
94+
"quantumComputermaxDataEntanglers",
95+
1,
96+
0,
97+
2,
98+
"Define the maximum amount of Data Entanglers per Quantum Computer Multiblock.");
99+
quantumComputerMultiThreaderMultiplication = define(
100+
builder,
101+
"quantumComputerMultiThreaderMultiplication",
102+
4,
103+
2,
104+
8,
105+
"Define the multiplication factor of the multi threaders.");
106+
quantumComputerDataEntanglerMultiplication = define(
107+
builder,
108+
"quantumComputerDataEntanglerMultiplication",
109+
4,
110+
2,
111+
8,
112+
"Define the multiplication factor of the data entanglers.");
113+
builder.pop();
114+
115+
this.spec = builder.build();
116+
}
117+
118+
private static ModConfigSpec.IntValue define(
119+
ModConfigSpec.Builder builder, String name, int defaultValue, String comment) {
120+
builder.comment(comment);
121+
return define(builder, name, defaultValue);
122+
}
123+
124+
private static ModConfigSpec.IntValue define(
125+
ModConfigSpec.Builder builder, String name, int defaultValue, int min, int max, String comment) {
126+
builder.comment(comment);
127+
return define(builder, name, defaultValue, min, max);
128+
}
129+
130+
private static ModConfigSpec.IntValue define(
131+
ModConfigSpec.Builder builder, String name, int defaultValue, int min, int max) {
132+
return builder.defineInRange(name, defaultValue, min, max);
133+
}
134+
135+
private static ModConfigSpec.IntValue define(ModConfigSpec.Builder builder, String name, int defaultValue) {
136+
return define(builder, name, defaultValue, Integer.MIN_VALUE, Integer.MAX_VALUE);
137+
}
18138
}
19139
}

Diff for: src/main/java/net/pedroksl/advanced_ae/AdvancedAE.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import net.neoforged.fml.ModList;
88
import net.neoforged.fml.ModLoader;
99
import net.neoforged.fml.common.Mod;
10-
import net.neoforged.fml.config.ModConfig;
1110
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
1211
import net.neoforged.neoforge.capabilities.Capabilities;
1312
import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent;
@@ -42,6 +41,8 @@ public AdvancedAE(IEventBus eventBus, ModContainer container) {
4241
}
4342
INSTANCE = this;
4443

44+
AAEConfig.register(container);
45+
4546
AAEBlocks.DR.register(eventBus);
4647
AAEItems.DR.register(eventBus);
4748
AAEBlockEntities.DR.register(eventBus);
@@ -52,8 +53,6 @@ public AdvancedAE(IEventBus eventBus, ModContainer container) {
5253
eventBus.addListener(AdvancedAE::initUpgrades);
5354
eventBus.addListener(AdvancedAE::initCapabilities);
5455

55-
container.registerConfig(ModConfig.Type.COMMON, AAEConfig.SPEC);
56-
5756
eventBus.addListener(AAENetworkHandler.INSTANCE::onRegister);
5857
eventBus.addListener((RegisterEvent event) -> {
5958
if (event.getRegistryKey() == Registries.RECIPE_TYPE) {

Diff for: src/main/java/net/pedroksl/advanced_ae/common/blocks/AAECraftingUnitType.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.pedroksl.advanced_ae.common.blocks;
22

33
import net.minecraft.world.item.Item;
4+
import net.pedroksl.advanced_ae.AAEConfig;
45
import net.pedroksl.advanced_ae.common.definitions.AAEBlocks;
56

67
import appeng.block.crafting.ICraftingUnitType;
@@ -30,7 +31,7 @@ public long getStorageBytes() {
3031
}
3132

3233
public int getStorageMultiplier() {
33-
return this == STORAGE_MULTIPLIER ? 4 : 0;
34+
return this == STORAGE_MULTIPLIER ? AAEConfig.instance().getQuantumComputerDataEntanglerMultiplication() : 0;
3435
}
3536

3637
@Override
@@ -42,7 +43,7 @@ public int getAcceleratorThreads() {
4243
}
4344

4445
public int getAccelerationMultiplier() {
45-
return this == MULTI_THREADER ? 4 : 0;
46+
return this == MULTI_THREADER ? AAEConfig.instance().getQuantumComputerMultiThreaderMultiplication() : 0;
4647
}
4748

4849
public String getAffix() {

Diff for: src/main/java/net/pedroksl/advanced_ae/common/cluster/AdvCraftingCPUCalculator.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.minecraft.core.BlockPos;
66
import net.minecraft.server.level.ServerLevel;
77
import net.minecraft.world.level.block.entity.BlockEntity;
8+
import net.pedroksl.advanced_ae.AAEConfig;
89
import net.pedroksl.advanced_ae.common.blocks.AAECraftingUnitType;
910
import net.pedroksl.advanced_ae.common.entities.AdvCraftingBlockEntity;
1011

@@ -21,15 +22,17 @@ public AdvCraftingCPUCalculator(AdvCraftingBlockEntity t) {
2122

2223
@Override
2324
public boolean checkMultiblockScale(BlockPos min, BlockPos max) {
24-
if (max.getX() - min.getX() > 4) {
25+
var maxSize = AAEConfig.instance().getQuantumComputerMaxSize() - 1;
26+
27+
if (max.getX() - min.getX() > maxSize) {
2528
return false;
2629
}
2730

28-
if (max.getY() - min.getY() > 4) {
31+
if (max.getY() - min.getY() > maxSize) {
2932
return false;
3033
}
3134

32-
return max.getZ() - min.getZ() <= 4;
35+
return max.getZ() - min.getZ() <= maxSize;
3336
}
3437

3538
@Override
@@ -41,8 +44,10 @@ public AdvCraftingCPUCluster createCluster(ServerLevel level, BlockPos min, Bloc
4144
public boolean verifyInternalStructure(ServerLevel level, BlockPos min, BlockPos max) {
4245
boolean core = false;
4346
boolean storage = false;
44-
boolean entangler = false;
45-
boolean multi = false;
47+
int entangler = 0;
48+
int entanglerLimit = AAEConfig.instance().getQuantumComputermaxDataEntanglers();
49+
int multi = 0;
50+
int multiLimit = AAEConfig.instance().getQuantumComputerMaxMultiThreaders();
4651

4752
for (BlockPos blockPos : BlockPos.betweenClosed(min, max)) {
4853
final IAEMultiBlock<?> te = (IAEMultiBlock<?>) level.getBlockEntity(blockPos);
@@ -80,16 +85,16 @@ public boolean verifyInternalStructure(ServerLevel level, BlockPos min, BlockPos
8085
break;
8186
}
8287
case STORAGE_MULTIPLIER: {
83-
if (!isBoundary && !entangler) {
84-
entangler = true;
88+
if (!isBoundary && entangler < entanglerLimit) {
89+
entangler++;
8590
} else {
8691
return false;
8792
}
8893
break;
8994
}
9095
case MULTI_THREADER: {
91-
if (!isBoundary && !multi) {
92-
multi = true;
96+
if (!isBoundary && multi < multiLimit) {
97+
multi++;
9398
} else {
9499
return false;
95100
}

Diff for: src/main/java/net/pedroksl/advanced_ae/xmod/emi/recipes/AAERecipeCategory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package net.pedroksl.advanced_ae.xmod.emi.recipes;
22

33
import net.minecraft.network.chat.Component;
4+
import net.pedroksl.advanced_ae.AdvancedAE;
45

56
import dev.emi.emi.api.recipe.EmiRecipeCategory;
67
import dev.emi.emi.api.render.EmiRenderable;
7-
import net.pedroksl.advanced_ae.AdvancedAE;
88

99
public class AAERecipeCategory extends EmiRecipeCategory {
1010
private final Component name;

0 commit comments

Comments
 (0)