1
1
package me .ryleu .armornerf ;
2
2
3
- import me .ryleu .armornerf .formula .FlatToughnessFormula ;
4
- import me .ryleu .armornerf .formula .LargeToughnessFormula ;
5
- import me .ryleu .armornerf .formula .ToughnessDisabledFormula ;
6
- import me .ryleu .armornerf .formula .VanillaFormula ;
3
+ import me .ryleu .armornerf .formula .*;
7
4
import net .fabricmc .api .ModInitializer ;
8
5
import org .slf4j .Logger ;
9
6
import org .slf4j .LoggerFactory ;
12
9
13
10
public class ArmorNerf implements ModInitializer {
14
11
public static final String MOD_ID = "armor-nerf" ;
15
- public static final Logger LOGGER = LoggerFactory .getLogger (MOD_ID );
16
12
public static final me .ryleu .armornerf .ArmorNerfConfig CONFIG = me .ryleu .armornerf .ArmorNerfConfig .createAndLoad ();
17
13
18
- static ArmorFormula armorFormula = new VanillaFormula ();
19
- static HashMap <String , ArmorFormula > formulaRegistry = new HashMap <>();
14
+ private static final Logger LOGGER = LoggerFactory .getLogger (MOD_ID );
15
+
16
+ private static ArmorFormula armorFormula = new VanillaFormula ();
17
+ private static final HashMap <String , ArmorFormula > formulaRegistry = new HashMap <>();
20
18
21
19
public static ArmorFormula getToughnessFormula () {
22
20
return armorFormula ;
@@ -28,7 +26,7 @@ public static ArmorFormula getToughnessFormula() {
28
26
* @return Whether it is registered
29
27
*/
30
28
public static boolean isRegistered (String id ) {
31
- return formulaRegistry == null || formulaRegistry .containsKey (id );
29
+ return formulaRegistry .containsKey (id );
32
30
}
33
31
34
32
/**
@@ -46,15 +44,20 @@ public void onInitialize() {
46
44
registerFormula ("toughness_disabled" , new ToughnessDisabledFormula ());
47
45
registerFormula ("flat_toughness" , new FlatToughnessFormula ());
48
46
registerFormula ("large_toughness" , new LargeToughnessFormula ());
47
+ registerFormula ("debug" , new DebugFormula ());
48
+
49
+ setArmorFormula (CONFIG .armorFormula ());
50
+
51
+ CONFIG .subscribeToArmorFormula (this ::setArmorFormula );
52
+ }
49
53
50
- CONFIG .subscribeToArmorFormula ((String newFormulaId ) -> {
51
- ArmorFormula newFormula = formulaRegistry .get (newFormulaId );
52
- if (newFormula == null ) {
53
- CONFIG .armorFormula ("toughness_disabled" );
54
- } else {
55
- armorFormula = newFormula ;
56
- }
57
- });
58
- LOGGER .info ("Armor and protection nerfed." );
54
+ private void setArmorFormula (String newFormulaId ) {
55
+ ArmorFormula newFormula = formulaRegistry .get (newFormulaId );
56
+ if (newFormula == null ) {
57
+ CONFIG .armorFormula ("toughness_disabled" );
58
+ } else {
59
+ LOGGER .info ("Set formula to {}" , newFormulaId );
60
+ armorFormula = newFormula ;
61
+ }
59
62
}
60
63
}
0 commit comments