Skip to content

Commit 3539ba7

Browse files
committed
Re-enable configuring armor settins for main module
1 parent 8f603db commit 3539ba7

File tree

7 files changed

+150
-104
lines changed

7 files changed

+150
-104
lines changed

src/main/java/mekanism/common/config/GearConfig.java

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
import mekanism.common.config.value.CachedLongValue;
1010
import net.minecraft.SharedConstants;
1111
import net.minecraft.world.entity.ai.attributes.Attributes;
12-
import net.minecraft.world.item.ArmorItem;
13-
import net.minecraft.world.item.ArmorMaterials;
1412
import net.neoforged.fml.config.ModConfig.Type;
1513
import net.neoforged.neoforge.common.ModConfigSpec;
1614
import net.neoforged.neoforge.fluids.FluidType;
@@ -22,16 +20,15 @@ public class GearConfig extends BaseMekanismConfig {
2220
private static final String ENERGY_TABLET_CATEGORY = "energy_tablet";
2321
private static final String GAUGE_DROPPER_CATEGORY = "gauge_dropper";
2422
private static final String FLAMETHROWER_CATEGORY = "flamethrower";
25-
private static final String FREE_RUNNER_CATEGORY = "free_runner";
26-
private static final String ARMORED_SUBCATEGORY = "armored";
27-
private static final String JETPACK_CATEGORY = "jetpack";
23+
public static final String FREE_RUNNER_CATEGORY = "free_runner";
24+
public static final String JETPACK_CATEGORY = "jetpack";
2825
private static final String NETWORK_READER_CATEGORY = "network_reader";
2926
private static final String PORTABLE_TELEPORTER_CATEGORY = "portable_teleporter";
3027
private static final String SCUBA_TANK_CATEGORY = "scuba_tank";
3128
private static final String SEISMIC_READER_CATEGORY = "seismic_reader";
3229
private static final String CANTEEN_CATEGORY = "canteen";
3330
private static final String MEKATOOL_CATEGORY = "mekatool";
34-
private static final String MEKASUIT_CATEGORY = "mekasuit";
31+
public static final String MEKASUIT_CATEGORY = "mekasuit";
3532
private static final String MEKASUIT_DAMAGE_CATEGORY = "damage_absorption";
3633

3734
private final ModConfigSpec configSpec;
@@ -69,17 +66,9 @@ public class GearConfig extends BaseMekanismConfig {
6966
public final CachedFloatValue freeRunnerFallDamageRatio;
7067
public final CachedFloatingLongValue freeRunnerMaxEnergy;
7168
public final CachedFloatingLongValue freeRunnerChargeRate;
72-
//Armored Free Runner
73-
public final CachedIntValue armoredFreeRunnerArmor;
74-
public final CachedFloatValue armoredFreeRunnerToughness;
75-
public final CachedFloatValue armoredFreeRunnerKnockbackResistance;
7669
//Jetpack
7770
public final CachedLongValue jetpackMaxGas;
7871
public final CachedLongValue jetpackFillRate;
79-
//Armored Jetpack
80-
public final CachedIntValue armoredJetpackArmor;
81-
public final CachedFloatValue armoredJetpackToughness;
82-
public final CachedFloatValue armoredJetpackKnockbackResistance;
8372
//Portable Teleporter
8473
public final CachedFloatingLongValue portableTeleporterMaxEnergy;
8574
public final CachedFloatingLongValue portableTeleporterChargeRate;
@@ -136,12 +125,7 @@ public class GearConfig extends BaseMekanismConfig {
136125
public final CachedIntValue mekaSuitNutritionalTransferRate;
137126
public final CachedLongValue mekaSuitJetpackMaxStorage;
138127
public final CachedLongValue mekaSuitJetpackTransferRate;
139-
public final CachedIntValue mekaSuitHelmetArmor;
140-
public final CachedIntValue mekaSuitBodyArmorArmor;
141-
public final CachedIntValue mekaSuitPantsArmor;
142-
public final CachedIntValue mekaSuitBootsArmor;
143-
public final CachedFloatValue mekaSuitToughness;
144-
public final CachedFloatValue mekaSuitKnockbackResistance;
128+
145129
public final CachedFloatValue mekaSuitFallDamageRatio;
146130
public final CachedFloatValue mekaSuitMagicDamageRatio;
147131
public final CachedFloatValue mekaSuitUnspecifiedDamageRatio;
@@ -218,28 +202,14 @@ public class GearConfig extends BaseMekanismConfig {
218202
"maxEnergy", FloatingLong.createConst(64_000));
219203
freeRunnerChargeRate = CachedFloatingLongValue.define(this, builder, "Amount (joules) of energy the Free Runners can accept per tick.",
220204
"chargeRate", FloatingLong.createConst(320));
221-
builder.comment("Armored Free Runner Settings").push(ARMORED_SUBCATEGORY);
222-
armoredFreeRunnerArmor = CachedIntValue.wrap(this, builder.comment("Armor value of the Armored Free Runners")
223-
.defineInRange("armor", 3, 0, Integer.MAX_VALUE));
224-
armoredFreeRunnerToughness = CachedFloatValue.wrap(this, builder.comment("Toughness value of the Armored Free Runners.")
225-
.defineInRange("toughness", 2.0, 0, Float.MAX_VALUE));
226-
armoredFreeRunnerKnockbackResistance = CachedFloatValue.wrap(this, builder.comment("Knockback resistance value of the Armored Free Runners.")
227-
.defineInRange("knockbackResistance", 0.0, 0, Float.MAX_VALUE));
228-
builder.pop(2);
205+
builder.pop();
229206

230207
builder.comment("Jetpack Settings").push(JETPACK_CATEGORY);
231208
jetpackMaxGas = CachedLongValue.wrap(this, builder.comment("Jetpack Gas Tank capacity in mB.")
232209
.defineInRange("maxGas", 24_000, 1, Long.MAX_VALUE));
233210
jetpackFillRate = CachedLongValue.wrap(this, builder.comment("Amount of hydrogen the Jetpack can accept per tick.")
234211
.defineInRange("fillRate", 16, 1, Long.MAX_VALUE));
235-
builder.comment("Armored Jetpack Settings").push(ARMORED_SUBCATEGORY);
236-
armoredJetpackArmor = CachedIntValue.wrap(this, builder.comment("Armor value of the Armored Jetpack.")
237-
.defineInRange("armor", 8, 0, Integer.MAX_VALUE));
238-
armoredJetpackToughness = CachedFloatValue.wrap(this, builder.comment("Toughness value of the Armored Jetpack.")
239-
.defineInRange("toughness", 2.0, 0, Float.MAX_VALUE));
240-
armoredJetpackKnockbackResistance = CachedFloatValue.wrap(this, builder.comment("Knockback resistance value of the Armored Jetpack.")
241-
.defineInRange("knockbackResistance", 0.0, 0, Float.MAX_VALUE));
242-
builder.pop(2);
212+
builder.pop();
243213

244214
builder.comment("Network Reader Settings").push(NETWORK_READER_CATEGORY);
245215
networkReaderMaxEnergy = CachedFloatingLongValue.define(this, builder, "Maximum amount (joules) of energy the Network Reader can contain.",
@@ -358,18 +328,6 @@ public class GearConfig extends BaseMekanismConfig {
358328
.defineInRange("jetpackMaxStorage", 24_000, 1, Long.MAX_VALUE));
359329
mekaSuitJetpackTransferRate = CachedLongValue.wrap(this, builder.comment("Rate at which Hydrogen can be transferred into the jetpack unit.")
360330
.defineInRange("jetpackTransferRate", 256, 1, Long.MAX_VALUE));
361-
mekaSuitHelmetArmor = CachedIntValue.wrap(this, builder.comment("Armor value of MekaSuit Helmets.")
362-
.defineInRange("helmetArmor", ArmorMaterials.NETHERITE.value().defense().get(ArmorItem.Type.HELMET), 0, Integer.MAX_VALUE));
363-
mekaSuitBodyArmorArmor = CachedIntValue.wrap(this, builder.comment("Armor value of MekaSuit BodyArmor.")
364-
.defineInRange("bodyArmorArmor", ArmorMaterials.NETHERITE.value().defense().get(ArmorItem.Type.CHESTPLATE), 0, Integer.MAX_VALUE));
365-
mekaSuitPantsArmor = CachedIntValue.wrap(this, builder.comment("Armor value of MekaSuit Pants.")
366-
.defineInRange("pantsArmor", ArmorMaterials.NETHERITE.value().defense().get(ArmorItem.Type.LEGGINGS), 0, Integer.MAX_VALUE));
367-
mekaSuitBootsArmor = CachedIntValue.wrap(this, builder.comment("Armor value of MekaSuit Boots.")
368-
.defineInRange("bootsArmor", ArmorMaterials.NETHERITE.value().defense().get(ArmorItem.Type.BOOTS), 0, Integer.MAX_VALUE));
369-
mekaSuitToughness = CachedFloatValue.wrap(this, builder.comment("Toughness value of the MekaSuit.")
370-
.defineInRange("toughness", ArmorMaterials.NETHERITE.value().toughness(), 0, Float.MAX_VALUE));
371-
mekaSuitKnockbackResistance = CachedFloatValue.wrap(this, builder.comment("Knockback resistance value of the MekaSuit.")
372-
.defineInRange("knockbackResistance", ArmorMaterials.NETHERITE.value().knockbackResistance(), 0, Float.MAX_VALUE));
373331
builder.push(MEKASUIT_DAMAGE_CATEGORY);
374332
mekaSuitFallDamageRatio = CachedFloatValue.wrap(this, builder.comment("Percent of damage taken from falling that can be absorbed by MekaSuit Boots when they have enough power.")
375333
.defineInRange("fallDamageReductionRatio", 1D, 0, 1));

src/main/java/mekanism/common/config/MekanismConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ private MekanismConfig() {
1111
public static final CommonConfig common = new CommonConfig();
1212
public static final GeneralConfig general = new GeneralConfig();
1313
public static final GearConfig gear = new GearConfig();
14+
public static final MekanismStartupConfig startup = new MekanismStartupConfig();
1415
public static final StorageConfig storage = new StorageConfig();
1516
public static final TierConfig tiers = new TierConfig();
1617
public static final UsageConfig usage = new UsageConfig();
@@ -21,6 +22,7 @@ public static void registerConfigs(ModContainer modContainer) {
2122
MekanismConfigHelper.registerConfig(modContainer, common);
2223
MekanismConfigHelper.registerConfig(modContainer, general);
2324
MekanismConfigHelper.registerConfig(modContainer, gear);
25+
MekanismConfigHelper.registerConfig(modContainer, startup);
2426
MekanismConfigHelper.registerConfig(modContainer, storage);
2527
MekanismConfigHelper.registerConfig(modContainer, tiers);
2628
MekanismConfigHelper.registerConfig(modContainer, usage);
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package mekanism.common.config;
2+
3+
import mekanism.common.config.value.CachedFloatValue;
4+
import mekanism.common.config.value.CachedIntValue;
5+
import net.minecraft.world.item.ArmorItem;
6+
import net.minecraft.world.item.ArmorMaterials;
7+
import net.neoforged.fml.config.ModConfig.Type;
8+
import net.neoforged.neoforge.common.ModConfigSpec;
9+
10+
public class MekanismStartupConfig extends BaseMekanismConfig {
11+
12+
private static final String ARMORED_SUBCATEGORY = "armored";
13+
14+
private final ModConfigSpec configSpec;
15+
16+
//Armored Free Runner
17+
public final CachedIntValue armoredFreeRunnerArmor;
18+
public final CachedFloatValue armoredFreeRunnerToughness;
19+
public final CachedFloatValue armoredFreeRunnerKnockbackResistance;
20+
//Armored Jetpack
21+
public final CachedIntValue armoredJetpackArmor;
22+
public final CachedFloatValue armoredJetpackToughness;
23+
public final CachedFloatValue armoredJetpackKnockbackResistance;
24+
//MekaSuit
25+
public final CachedIntValue mekaSuitHelmetArmor;
26+
public final CachedIntValue mekaSuitBodyArmorArmor;
27+
public final CachedIntValue mekaSuitPantsArmor;
28+
public final CachedIntValue mekaSuitBootsArmor;
29+
public final CachedFloatValue mekaSuitToughness;
30+
public final CachedFloatValue mekaSuitKnockbackResistance;
31+
32+
MekanismStartupConfig() {
33+
ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
34+
builder.comment("Mekanism Startup Config. This config is loaded on early, and requires a game restart to take effect, and is not synced automatically between "
35+
+ "client and server. It is highly recommended to ensure you are using the same values for this config on the server and client.").push("startup");
36+
37+
builder.comment("Startup gear configs").push("gear");
38+
39+
builder.comment("Free Runner Settings").push(GearConfig.FREE_RUNNER_CATEGORY);
40+
builder.comment("Armored Free Runner Settings").push(ARMORED_SUBCATEGORY);
41+
armoredFreeRunnerArmor = CachedIntValue.wrap(this, builder.comment("Armor value of the Armored Free Runners")
42+
.defineInRange("armor", 3, 0, Integer.MAX_VALUE));
43+
armoredFreeRunnerToughness = CachedFloatValue.wrap(this, builder.comment("Toughness value of the Armored Free Runners.")
44+
.defineInRange("toughness", 2.0, 0, Float.MAX_VALUE));
45+
armoredFreeRunnerKnockbackResistance = CachedFloatValue.wrap(this, builder.comment("Knockback resistance value of the Armored Free Runners.")
46+
.defineInRange("knockbackResistance", 0.0, 0, Float.MAX_VALUE));
47+
builder.pop(2);//End free runner and armored
48+
49+
builder.comment("Jetpack Settings").push(GearConfig.JETPACK_CATEGORY);
50+
builder.comment("Armored Jetpack Settings").push(ARMORED_SUBCATEGORY);
51+
armoredJetpackArmor = CachedIntValue.wrap(this, builder.comment("Armor value of the Armored Jetpack.")
52+
.defineInRange("armor", 8, 0, Integer.MAX_VALUE));
53+
armoredJetpackToughness = CachedFloatValue.wrap(this, builder.comment("Toughness value of the Armored Jetpack.")
54+
.defineInRange("toughness", 2.0, 0, Float.MAX_VALUE));
55+
armoredJetpackKnockbackResistance = CachedFloatValue.wrap(this, builder.comment("Knockback resistance value of the Armored Jetpack.")
56+
.defineInRange("knockbackResistance", 0.0, 0, Float.MAX_VALUE));
57+
builder.pop(2);//End jetpack and armored
58+
59+
builder.comment("MekaSuit Settings").push(GearConfig.MEKASUIT_CATEGORY);
60+
mekaSuitHelmetArmor = CachedIntValue.wrap(this, builder.comment("Armor value of MekaSuit Helmets.")
61+
.defineInRange("helmetArmor", ArmorMaterials.NETHERITE.value().defense().get(ArmorItem.Type.HELMET), 0, Integer.MAX_VALUE));
62+
mekaSuitBodyArmorArmor = CachedIntValue.wrap(this, builder.comment("Armor value of MekaSuit BodyArmor.")
63+
.defineInRange("bodyArmorArmor", ArmorMaterials.NETHERITE.value().defense().get(ArmorItem.Type.CHESTPLATE), 0, Integer.MAX_VALUE));
64+
mekaSuitPantsArmor = CachedIntValue.wrap(this, builder.comment("Armor value of MekaSuit Pants.")
65+
.defineInRange("pantsArmor", ArmorMaterials.NETHERITE.value().defense().get(ArmorItem.Type.LEGGINGS), 0, Integer.MAX_VALUE));
66+
mekaSuitBootsArmor = CachedIntValue.wrap(this, builder.comment("Armor value of MekaSuit Boots.")
67+
.defineInRange("bootsArmor", ArmorMaterials.NETHERITE.value().defense().get(ArmorItem.Type.BOOTS), 0, Integer.MAX_VALUE));
68+
mekaSuitToughness = CachedFloatValue.wrap(this, builder.comment("Toughness value of the MekaSuit.")
69+
.defineInRange("toughness", ArmorMaterials.NETHERITE.value().toughness(), 0, Float.MAX_VALUE));
70+
mekaSuitKnockbackResistance = CachedFloatValue.wrap(this, builder.comment("Knockback resistance value of the MekaSuit.")
71+
.defineInRange("knockbackResistance", ArmorMaterials.NETHERITE.value().knockbackResistance(), 0, Float.MAX_VALUE));
72+
builder.pop();//End mekasuit
73+
74+
builder.pop();//End gear
75+
76+
builder.pop();
77+
configSpec = builder.build();
78+
}
79+
80+
@Override
81+
public String getFileName() {
82+
return "startup";
83+
}
84+
85+
@Override
86+
public ModConfigSpec getConfigSpec() {
87+
return configSpec;
88+
}
89+
90+
@Override
91+
public Type getConfigType() {
92+
return Type.STARTUP;
93+
}
94+
}

src/main/java/mekanism/common/item/gear/ItemMekaSuitArmor.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,13 @@
4040
import mekanism.common.capabilities.laser.item.LaserDissipationHandler;
4141
import mekanism.common.capabilities.radiation.item.RadiationShieldingHandler;
4242
import mekanism.common.config.MekanismConfig;
43-
import mekanism.common.config.value.CachedIntValue;
4443
import mekanism.common.content.gear.IModuleContainerItem;
4544
import mekanism.common.content.gear.Module;
4645
import mekanism.common.content.gear.ModuleContainer;
4746
import mekanism.common.content.gear.ModuleHelper;
4847
import mekanism.common.content.gear.mekasuit.ModuleElytraUnit;
4948
import mekanism.common.content.gear.mekasuit.ModuleJetpackUnit;
5049
import mekanism.common.item.interfaces.IJetpackItem;
51-
import mekanism.common.lib.attribute.AttributeCache;
5250
import mekanism.common.registration.impl.CreativeTabDeferredRegister.ICustomCreativeTabContents;
5351
import mekanism.common.registries.MekanismArmorMaterials;
5452
import mekanism.common.registries.MekanismDataMapTypes;
@@ -100,8 +98,8 @@
10098
public class ItemMekaSuitArmor extends ItemSpecialArmor implements IModuleContainerItem, IJetpackItem, ICustomCreativeTabContents, IAttachmentAware {
10199

102100
private static final AttributeModifier CREATIVE_FLIGHT_MODIFIER = new AttributeModifier(Mekanism.rl("mekasuit_gravitational_modulation"), 1D, Operation.ADD_VALUE);
101+
private static final ItemAttributeModifiers.Entry CREATIVE_FLIGHT = new ItemAttributeModifiers.Entry(NeoForgeMod.CREATIVE_FLIGHT, CREATIVE_FLIGHT_MODIFIER, EquipmentSlotGroup.CHEST);
103102

104-
private final AttributeCache attributeCacheWithFlight;
105103
//TODO: Expand this system so that modules can maybe define needed tanks?
106104
private final List<ChemicalTankSpec<Gas>> gasTankSpecs = new ArrayList<>();
107105
private final List<ChemicalTankSpec<Gas>> gasTankSpecsView = Collections.unmodifiableList(gasTankSpecs);
@@ -116,15 +114,13 @@ public ItemMekaSuitArmor(ArmorItem.Type armorType, Properties properties) {
116114
super(MekanismArmorMaterials.MEKASUIT, armorType, IModuleHelper.INSTANCE.applyModuleContainerProperties(
117115
properties.rarity(Rarity.EPIC).setNoRepair().stacksTo(1)
118116
));
119-
CachedIntValue armorConfig;
120117
switch (armorType) {
121118
case HELMET -> {
122119
fluidTankSpecs.add(FluidTankSpec.createFillOnly(MekanismConfig.gear.mekaSuitNutritionalTransferRate, MekanismConfig.gear.mekaSuitNutritionalMaxStorage,
123120
fluid -> fluid.is(MekanismFluids.NUTRITIONAL_PASTE.getFluid()), stack -> hasModule(stack, MekanismModules.NUTRITIONAL_INJECTION_UNIT)));
124121
absorption = 0.15F;
125122
laserDissipation = 0.15;
126123
laserRefraction = 0.2;
127-
armorConfig = MekanismConfig.gear.mekaSuitHelmetArmor;
128124
}
129125
case CHESTPLATE -> {
130126
gasTankSpecs.add(ChemicalTankSpec.createFillOnly(MekanismConfig.gear.mekaSuitJetpackTransferRate, stack -> {
@@ -135,25 +131,19 @@ public ItemMekaSuitArmor(ArmorItem.Type armorType, Properties properties) {
135131
absorption = 0.4F;
136132
laserDissipation = 0.3;
137133
laserRefraction = 0.4;
138-
armorConfig = MekanismConfig.gear.mekaSuitBodyArmorArmor;
139134
}
140135
case LEGGINGS -> {
141136
absorption = 0.3F;
142137
laserDissipation = 0.1875;
143138
laserRefraction = 0.25;
144-
armorConfig = MekanismConfig.gear.mekaSuitPantsArmor;
145139
}
146140
case BOOTS -> {
147141
absorption = 0.15F;
148142
laserDissipation = 0.1125;
149143
laserRefraction = 0.15;
150-
armorConfig = MekanismConfig.gear.mekaSuitBootsArmor;
151144
}
152145
default -> throw new IllegalArgumentException("Unknown Equipment Slot Type");
153146
}
154-
this.attributeCacheWithFlight = new AttributeCache(builder -> {
155-
builder.add(new ItemAttributeModifiers.Entry(NeoForgeMod.CREATIVE_FLIGHT, CREATIVE_FLIGHT_MODIFIER, EquipmentSlotGroup.CHEST));
156-
}, armorConfig, MekanismConfig.gear.mekaSuitToughness, MekanismConfig.gear.mekaSuitKnockbackResistance);
157147
}
158148

159149
@Override
@@ -416,7 +406,8 @@ public void useJetpackFuel(ItemStack stack) {
416406
@Override
417407
public ItemAttributeModifiers getAttributeModifiers(@NotNull ItemStack stack) {
418408
if (getEquipmentSlot() == EquipmentSlot.CHEST && CommonPlayerTickHandler.isGravitationalModulationReady(stack)) {
419-
return attributeCacheWithFlight.get();
409+
//TODO - 1.21: Figure out how to get flight working again:
410+
// CREATIVE_FLIGHT
420411
}
421412
return super.getAttributeModifiers(stack);
422413
}

0 commit comments

Comments
 (0)