11package com .adccadc .rust ;
22
33import java .io .*;
4+ import java .lang .ref .WeakReference ;
5+ import java .util .ArrayList ;
6+ import java .util .Arrays ;
7+ import java .util .List ;
48import java .util .Properties ;
9+ import java .util .regex .Matcher ;
10+ import java .util .regex .Pattern ;
511
612public class RustConfig {
713 private static final String CONFIG_FILE_PATH = "./config/rust.properties" ;
814
915 private static final String USE_LEGACY_KEY = "use_legacy_oxidize_logic" ;
1016 private static final String AFFECT_REDSTONE = "affect_redstone" ;
17+ private static final String AFFECT_ENTITY = "effect_entity" ;
1118
1219 private static final String EXPOSED_WPPB = "exposed_weighted_pressure_plate" ;
1320 private static final String WEATHERED_WPPB = "weathered_weighted_pressure_plate" ;
@@ -17,18 +24,56 @@ public class RustConfig {
1724 private static final String WAXED_WEATHERED_WPPB = "waxed_weathered_weighted_pressure_plate" ;
1825 private static final String WAXED_OXIDIZED_WPPB = "waxed_oxidized_weighted_pressure_plate" ;
1926
27+ private static final String EXPOSED_IG = "exposed_iron_golem" ;
28+ private static final String WEATHERED_IG = "weathered_iron_golem" ;
29+ private static final String OXIDIZED_IG = "oxidized_iron_golem" ;
30+ private static final String WAXED_IG = "waxed_iron_golem" ;
31+ private static final String WAXED_EXPOSED_IG = "waxed_exposed_iron_golem" ;
32+ private static final String WAXED_WEATHERED_IG = "waxed_weathered_iron_golem" ;
33+ private static final String WAXED_OXIDIZED_IG = "waxed_oxidized_iron_golem" ;
34+
2035 private static boolean useLegacyLogic = false ; // 是否采用旧版氧化逻辑
36+
2137 private static boolean affectRedstone = true ; // 是否影响红石
22- private static Integer exposed_WPPB = 170 ; // 斑驳的测重压力板每增加一格信号所需实体量
23- private static Integer weathered_WPPB = 190 ; // 锈蚀的测重压力板每增加一格信号所需实体量
24- private static Integer oxidized_WPPB = 210 ; // 氧化的测重压力板每增加一格信号所需实体量
25- private static Integer waxed_WPPB = 160 ; // 涂蜡的测重压力板每增加一格信号所需实体量
26- private static Integer waxed_exposed_WPPB = 180 ; // 涂蜡的斑驳测重压力板每增加一格信号所需实体量
27- private static Integer waxed_weathered_WPPB = 200 ; // 涂蜡的锈蚀测重压力板每增加一格信号所需实体量
28- private static Integer waxed_oxidized_WPPB = 220 ; // 涂蜡的氧化测重压力板每增加一格信号所需实体量
38+ // 各种测重压力板每一级信号所需实体重量
39+ private static Integer exposed_WPPB = 170 ;
40+ private static Integer weathered_WPPB = 190 ;
41+ private static Integer oxidized_WPPB = 210 ;
42+ private static Integer waxed_WPPB = 160 ;
43+ private static Integer waxed_exposed_WPPB = 180 ;
44+ private static Integer waxed_weathered_WPPB = 200 ;
45+ private static Integer waxed_oxidized_WPPB = 220 ;
46+
47+ private static boolean affectEntity = true ; // 是否影响实体
48+ // 各种铁傀儡的生物属性
49+ private static List <?> default_IG = new ArrayList <>(Arrays .asList ((double ) 100.0F , (double ) 0.25F , (double ) 1.0F , (double ) 15.0F , (double ) 1.0F , (double ) 16.0F )); //原版铁傀儡属性
50+ private static List <?> exposed_IG = new ArrayList <>(Arrays .asList ((double ) 90.0F , (double ) 0.22F , (double ) 0.95F , (double ) 14.0F , (double ) 1.0F , (double ) 15.0F ));
51+ private static List <?> weathered_IG = new ArrayList <>(Arrays .asList ((double ) 80.0F , (double ) 0.19F , (double ) 0.90F , (double ) 13.0F , (double ) 1.0F , (double ) 14.0F ));
52+ private static List <?> oxidized_IG = new ArrayList <>(Arrays .asList ((double ) 70.0F , (double ) 0.16F , (double ) 0.85F , (double ) 12.0F , (double ) 1.0F , (double ) 13.0F ));
53+ private static List <?> waxed_IG = new ArrayList <>(Arrays .asList ((double ) 110.0F , (double ) 0.23F , (double ) 1.0F , (double ) 14.5F , (double ) 0.9F , (double ) 16.0F ));
54+ private static List <?> waxed_exposed_IG = new ArrayList <>(Arrays .asList ((double ) 100.0F , (double ) 0.20F , (double ) 0.98F , (double ) 13.5F , (double ) 0.9F , (double ) 15.0F ));
55+ private static List <?> waxed_weathered_IG = new ArrayList <>(Arrays .asList ((double ) 90.0F , (double ) 0.17F , (double ) 0.93F , (double ) 12.5F , (double ) 0.9F , (double ) 14.0F ));
56+ private static List <?> waxed_oxidized_IG = new ArrayList <>(Arrays .asList ((double ) 80.0F , (double ) 0.14F , (double ) 0.88F , (double ) 11.5F , (double ) 0.9F , (double ) 13.0F ));
2957
3058 private RustConfig () {}
3159
60+ protected static List <Double > convertWithRegex (String input ) {
61+ List <Double > result = new ArrayList <>();
62+
63+ Pattern pattern = Pattern .compile ("\\ d+(?:\\ .\\ d+)?(?:F|f)?" );
64+ Matcher matcher = pattern .matcher (input );
65+
66+ while (matcher .find ()) {
67+ String match = matcher .group ();
68+
69+ if (match .toUpperCase ().endsWith ("F" )) {
70+ match = match .substring (0 , match .length () - 1 );
71+ }
72+ result .add (Double .parseDouble (match ));
73+ }
74+ return result ;
75+ }
76+
3277 public static void loadConfig () {
3378 File configFile = new File (CONFIG_FILE_PATH );
3479
@@ -41,15 +86,25 @@ public static void loadConfig() {
4186 try (InputStream input = new FileInputStream (configFile )) {
4287 props .load (input );
4388 useLegacyLogic = Boolean .parseBoolean (props .getProperty (USE_LEGACY_KEY , "false" ).trim ());
44- affectRedstone = Boolean .parseBoolean (props .getProperty (AFFECT_REDSTONE , "false" ).trim ());
89+ affectRedstone = Boolean .parseBoolean (props .getProperty (AFFECT_REDSTONE , "true" ).trim ());
90+ affectEntity = Boolean .parseBoolean (props .getProperty (AFFECT_ENTITY , "true" ));
4591 exposed_WPPB = Integer .parseUnsignedInt (props .getProperty (EXPOSED_WPPB , "150" ).trim ());
4692 weathered_WPPB = Integer .parseUnsignedInt (props .getProperty (WEATHERED_WPPB , "150" ).trim ());
4793 oxidized_WPPB = Integer .parseUnsignedInt (props .getProperty (OXIDIZED_WPPB , "150" ).trim ());
4894 waxed_WPPB = Integer .parseUnsignedInt (props .getProperty (WAXED_WPPB , "150" ).trim ());
4995 waxed_exposed_WPPB = Integer .parseUnsignedInt (props .getProperty (WAXED_EXPOSED_WPPB , "150" ).trim ());
5096 waxed_weathered_WPPB = Integer .parseUnsignedInt (props .getProperty (WAXED_WEATHERED_WPPB , "150" ).trim ());
5197 waxed_oxidized_WPPB = Integer .parseUnsignedInt (props .getProperty (WAXED_OXIDIZED_WPPB , "150" ).trim ());
52- System .out .println ("Loaded oxidize config: use_legacy_logic = " + useLegacyLogic );
98+ exposed_IG = convertWithRegex (props .getProperty (EXPOSED_IG , "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]" ).trim ());
99+ weathered_IG = convertWithRegex (props .getProperty (WEATHERED_IG , "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]" ).trim ());
100+ oxidized_IG = convertWithRegex (props .getProperty (OXIDIZED_IG , "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]" ).trim ());
101+ waxed_IG = convertWithRegex (props .getProperty (WAXED_IG , "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]" ));
102+ waxed_exposed_IG = convertWithRegex (props .getProperty (WAXED_EXPOSED_IG , "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]" ).trim ());
103+ waxed_weathered_IG = convertWithRegex (props .getProperty (WAXED_WEATHERED_IG , "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]" ).trim ());
104+ waxed_oxidized_IG = convertWithRegex (props .getProperty (WAXED_OXIDIZED_IG , "[100.0F,0.25F,1.0F,15.0F,1.0F,16.0F]" ).trim ());
105+ System .out .println ("Loaded rust config: use_legacy_logic = " + useLegacyLogic );
106+ System .out .println ("Loaded rust config: affect_redstone = " + affectRedstone );
107+ System .out .println ("Loaded rust config: affect_entity = " + affectEntity );
53108 } catch (IOException e ) {
54109 System .err .println ("Failed to load config file, using default settings: " + e .getMessage ());
55110 createDefaultConfig (configFile );
@@ -77,7 +132,7 @@ private static void createDefaultConfig(File configFile) {
77132 writer .println ("# if the value is false, rust will not use subsequent config, use original block state and logic" );
78133 writer .println (AFFECT_REDSTONE + "= true" );
79134 writer .println ();
80- writer .println ("# - number" );
135+ writer .println ("# - number(int) " );
81136 writer .println ("# How much weight is required for each level of signal (original version is 150)" );
82137 writer .println (EXPOSED_WPPB + "= 170" );
83138 writer .println (WEATHERED_WPPB + "= 190" );
@@ -86,6 +141,22 @@ private static void createDefaultConfig(File configFile) {
86141 writer .println (WAXED_EXPOSED_WPPB + "= 180" );
87142 writer .println (WAXED_WEATHERED_WPPB + "= 200" );
88143 writer .println (WAXED_OXIDIZED_WPPB + "= 220" );
144+ writer .println ();
145+ writer .println ("# - true: Rust can affect entity" );
146+ writer .println ("# - false: Rust can't affect entity" );
147+ writer .println ("# if the value is false, rust will not use subsequent config, use original entity attributes" );
148+ writer .println (AFFECT_ENTITY + "= true" );
149+ writer .println ();
150+ writer .println ("# - [decimal(float),decimal(float),decimal(float),decimal(float),decimal(float),decimal(float)]" );
151+ writer .println ("# - [max health,movement speed,knockback resistance,attack damage,step height,follow range] *Please add F at the end of each float value" );
152+ writer .println ("# This will change the attributes of the golem, some of which may not be effective for existing golem" );
153+ writer .println (EXPOSED_IG + "= [90.0F,0.22F,0.95F,14.0F,1.0F,15.0F]" );
154+ writer .println (WEATHERED_IG + "= [80.0F,0.19F,0.90F,13.0F,1.0F,14.0F]" );
155+ writer .println (OXIDIZED_IG + "= [70.0F,0.16F,0.85F,12.0F,1.0F,13.0F]" );
156+ writer .println (WAXED_IG + "= [110.0F,0.23F,1.0F,14.5F,0.9F,16.0F]" );
157+ writer .println (WAXED_EXPOSED_IG + "= [100.0F,0.20F,0.98F,13.5F,0.9F,15.0F]" );
158+ writer .println (WAXED_WEATHERED_IG + "= [90.0F,0.17F,0.93F,12.5F,0.9F,14.0F]" );
159+ writer .println (WAXED_OXIDIZED_IG + "= [80.0F,0.16F,0.88F,11.5F,0.9F,13.0F]" );
89160
90161 System .out .println ("Created default config file: " + configFile .getAbsolutePath ());
91162 System .out .println ("Please edit the file and restart Minecraft to apply changes." );
@@ -104,4 +175,12 @@ private static void createDefaultConfig(File configFile) {
104175 public static Integer getWaxed_exposed_WPPB () {return affectRedstone ? waxed_exposed_WPPB : 150 ;}
105176 public static Integer getWaxed_weathered_WPPB () {return affectRedstone ? waxed_weathered_WPPB : 150 ;}
106177 public static Integer getWaxed_oxidized_WPPB () {return affectRedstone ? waxed_oxidized_WPPB : 150 ;}
178+
179+ public static List <?> getExposed_IG () {return affectEntity ? exposed_IG : default_IG ;}
180+ public static List <?> getWeathered_IG () {return affectEntity ? weathered_IG : default_IG ;}
181+ public static List <?> getOxidized_IG () {return affectEntity ? oxidized_IG : default_IG ;}
182+ public static List <?> getWaxed_IG () {return affectEntity ? waxed_IG : default_IG ;}
183+ public static List <?> getWaxed_exposed_IG () {return affectEntity ? waxed_exposed_IG : default_IG ;}
184+ public static List <?> getWaxed_weathered_IG () {return affectEntity ? waxed_weathered_IG : default_IG ;}
185+ public static List <?> getWaxed_oxidized_IG () {return affectEntity ? waxed_oxidized_IG : default_IG ;}
107186}
0 commit comments