11package eu .ha3 .presencefootsteps ;
22
33import java .nio .file .Path ;
4+ import java .util .HashSet ;
5+ import java .util .Set ;
6+
7+ import com .minelittlepony .common .util .settings .Config ;
8+ import com .minelittlepony .common .util .settings .Setting ;
49
510import eu .ha3 .presencefootsteps .config .EntitySelector ;
6- import eu .ha3 .presencefootsteps .config .JsonFile ;
711import eu .ha3 .presencefootsteps .config .VolumeOption ;
812import eu .ha3 .presencefootsteps .sound .generator .Locomotion ;
13+ import net .minecraft .entity .EntityType ;
14+ import net .minecraft .registry .Registries ;
15+ import net .minecraft .util .Identifier ;
916import net .minecraft .util .crash .CrashReportSection ;
1017import net .minecraft .util .math .MathHelper ;
1118
12- public class PFConfig extends JsonFile {
13-
14- private int volume = 70 ;
15-
16- public VolumeOption clientPlayerVolume = new VolumeOption (this , 100 );
17- public VolumeOption otherPlayerVolume = new VolumeOption (this , 100 );
18- public VolumeOption hostileEntitiesVolume = new VolumeOption (this , 100 );
19- public VolumeOption passiveEntitiesVolume = new VolumeOption (this , 100 );
20- public int runningVolumeIncrease = 0 ;
21- public VolumeOption wetSoundsVolume = new VolumeOption (this , 50 );
22- public VolumeOption foliageSoundsVolume = new VolumeOption (this , 100 );
23-
24- private int maxSteppingEntities = 50 ;
25-
26- private boolean disabled = false ;
27- private boolean multiplayer = true ;
28- private boolean global = true ;
29- private boolean footwear = true ;
30- private boolean visualiser = false ;
31- private boolean exclusive = false ;
19+ public class PFConfig extends Config {
20+
21+ private final Setting <Boolean > disabled = value ("client" , "disabled" , false )
22+ .addComment ("Disables all functionality of the mod" );
23+
24+ private final Setting <Integer > volume = value ("volume" , "volume" , 70 )
25+ .addComment ("Sets the global footsteps volume on a value between 0% and 100%" )
26+ .addComment ("Default: 70" );
27+ public final Setting <Integer > runningVolumeIncrease = value ("volume" , "runningVolumeIncrease" , 0 )
28+ .addComment ("Controls how much the footsteps sound changes when running on a percentage range between -100% to +100%" )
29+ .addComment ("Default: 0" );
30+
31+ public VolumeOption clientPlayerVolume = new VolumeOption (this , value ("volume" , "clientPlayerVolume" , 100 )
32+ .addComment ("Sets the volume of your own footsteps on a value between 0% and 100%" )
33+ .addComment ("Default: 100" ));
34+ public VolumeOption otherPlayerVolume = new VolumeOption (this , value ("volume" , "otherPlayerVolume" , 100 )
35+ .addComment ("Sets the volume of other players' footsteps on a value between 0% and 100%" )
36+ .addComment ("Default: 100" ));
37+ public VolumeOption hostileEntitiesVolume = new VolumeOption (this , value ("volume" , "hostileEntitiesVolume" , 100 )
38+ .addComment ("Sets the volume of hostile mob's footsteps on a value between 0% and 100%" )
39+ .addComment ("Default: 100" ));
40+ public VolumeOption passiveEntitiesVolume = new VolumeOption (this , value ("volume" , "passiveEntitiesVolume" , 100 )
41+ .addComment ("Sets the volume of passive and friendly mob's footsteps on a value between 0% and 100%" )
42+ .addComment ("Default: 100" ));
43+
44+ public VolumeOption wetSoundsVolume = new VolumeOption (this , value ("volume" , "wetSoundsVolume" , 50 )
45+ .addComment ("Sets the volume of sounds generated by walking on wet surfaces during rain or thunderstorms" )
46+ .addComment ("Default: 50" ));
47+ public VolumeOption foliageSoundsVolume = new VolumeOption (this , value ("volume" , "foliageSoundsVolume" , 100 )
48+ .addComment ("Sets the volume of sounds generated due to walking through foliage and brush" )
49+ .addComment ("Default: 50" ));
50+
51+
52+ private final Setting <Integer > maxSteppingEntities = value ("performance" , "maxSteppingEntities" , 50 )
53+ .addComment ("Controls the maximum number of entities the mod can generate footsteps for in a single frame" )
54+ .addComment ("Default: 50" );
55+
56+ private final Setting <Boolean > multiplayer = value ("sound" , "multiplayer" , true )
57+ .addComment ("Sets whether footsteps should be generated for other players when in multiplayer" );
58+ private final Setting <Boolean > global = value ("sound" , "global" , true )
59+ .addComment ("Sets whether footsteps should be generated for other (non-player) mobs" );
60+ private final Setting <Boolean > footwear = value ("sound" , "footwear" , true )
61+ .addComment ("When enabled, special footstep sounds will be generated matching the boots you are wearing." )
62+ .addComment ("Note not all types of boots are supported. Modded boots may sound strange or not work." );
63+ private final Setting <Boolean > visualiser = value ("debug" , "visualiser" , false )
64+ .addComment ("Enables a visualiser to show where sound/material checks are occuring" );
65+ private final Setting <Boolean > exclusive = value ("sound" , "exclusive" , false )
66+ .addComment ("Sets whether to block vanilla footstep sounds when generating sounds for other entities or players" );
67+
68+ private final Setting <Locomotion > stance = value ("client" , "stance" , Locomotion .NONE );
69+ private final Setting <EntitySelector > targetEntities = value ("client" , "targetEntities" , EntitySelector .ALL );
70+
71+ public final Setting <Set <Identifier >> ignoredEntityTypes = this .<Identifier , Set <Identifier >>value ("compatibility" , "ignoredEntityTypes" , () -> new HashSet <Identifier >(Set .of (
72+ Identifier .ofVanilla ("ghast" ),
73+ Identifier .ofVanilla ("happy_ghast" ),
74+ Identifier .ofVanilla ("phantom" )
75+ )), Identifier .class )
76+ .addComment ("A list of dimensions ids that do not have an atmosphere, and thus shouldn't allow pegasi to fly." );
3277
33- private Locomotion stance = Locomotion .NONE ;
34- private EntitySelector targetEntities = EntitySelector .ALL ;
3578
3679 private transient final PresenceFootsteps pf ;
3780
3881 public PFConfig (Path file , PresenceFootsteps pf ) {
39- super (file );
82+ super (HEIRARCHICAL_JSON_ADAPTER , file );
4083 this .pf = pf ;
4184 }
4285
4386 public boolean toggleMultiplayer () {
44- multiplayer = !multiplayer ;
87+ multiplayer . set ( !multiplayer . get ()) ;
4588 save ();
4689
47- return multiplayer ;
90+ return multiplayer .get ();
91+ }
92+
93+ public boolean isIgnoredForFootsteps (EntityType <?> type ) {
94+ return this .ignoredEntityTypes .get ().contains (Registries .ENTITY_TYPE .getId (type ));
4895 }
4996
5097 public EntitySelector cycleTargetSelector () {
51- targetEntities = EntitySelector .VALUES [(getEntitySelector ().ordinal () + 1 ) % EntitySelector .VALUES .length ];
98+ targetEntities . set ( EntitySelector .VALUES [(getEntitySelector ().ordinal () + 1 ) % EntitySelector .VALUES .length ]) ;
5299
53100 save ();
54101
55- return targetEntities ;
102+ return targetEntities . get () ;
56103 }
57104
58105 public Locomotion setLocomotion (Locomotion loco ) {
59106 if (loco != getLocomotion ()) {
60- stance = loco ;
107+ stance . set ( loco ) ;
61108 save ();
62109
63110 pf .getEngine ().reload ();
@@ -67,82 +114,82 @@ public Locomotion setLocomotion(Locomotion loco) {
67114 }
68115
69116 public boolean isVisualiserRunning () {
70- return visualiser ;
117+ return visualiser . get () ;
71118 }
72119
73120 public Locomotion getLocomotion () {
74- return stance == null ? Locomotion .NONE : stance ;
121+ return stance . get () == null ? Locomotion .NONE : stance . get () ;
75122 }
76123
77124 public EntitySelector getEntitySelector () {
78- return targetEntities == null ? EntitySelector .ALL : targetEntities ;
125+ return targetEntities . get () == null ? EntitySelector .ALL : targetEntities . get () ;
79126 }
80127
81128 public boolean getEnabledFootwear () {
82- return footwear ;
129+ return footwear . get () ;
83130 }
84131
85132 public boolean toggleFootwear () {
86- footwear = !footwear ;
133+ footwear . set ( !footwear . get ()) ;
87134 save ();
88- return footwear ;
135+ return footwear . get () ;
89136 }
90137
91138 public boolean isExclusiveMode () {
92- return exclusive ;
139+ return exclusive . get () ;
93140 }
94141
95142 public boolean toggleExclusiveMode () {
96- exclusive = !exclusive ;
143+ exclusive . set ( !exclusive . get ()) ;
97144 save ();
98- return exclusive ;
145+ return exclusive . get () ;
99146 }
100147
101148 public boolean getEnabledMP () {
102- return multiplayer ;
149+ return multiplayer . get () ;
103150 }
104151
105152 public int getMaxSteppingEntities () {
106- return Math .max (1 , maxSteppingEntities );
153+ return Math .max (1 , maxSteppingEntities . get () );
107154 }
108155
109156 public boolean toggleDisabled () {
110- disabled = !disabled ;
157+ disabled . set ( !disabled . get ()) ;
111158 save ();
112- pf .onEnabledStateChange (!disabled );
113- return disabled ;
159+ pf .onEnabledStateChange (!disabled . get () );
160+ return disabled . get () ;
114161 }
115162
116163 public boolean setDisabled (boolean disabled ) {
117- if (disabled != this .disabled ) {
164+ if (disabled != this .disabled . get () ) {
118165 toggleDisabled ();
119166 }
120167 return disabled ;
121168 }
122169
123170 public boolean getDisabled () {
124- return disabled ;
171+ return disabled . get () ;
125172 }
126173
127174 public boolean getEnabled () {
128- return !disabled && getGlobalVolume () > 0 ;
175+ return !disabled . get () && getGlobalVolume () > 0 ;
129176 }
130177
131178 public int getGlobalVolume () {
132- return MathHelper .clamp (volume , 0 , 100 );
179+ return MathHelper .clamp (volume . get () , 0 , 100 );
133180 }
134181
135182 public int getRunningVolumeIncrease () {
136- return MathHelper .clamp (runningVolumeIncrease , -100 , 100 );
183+ return MathHelper .clamp (runningVolumeIncrease . get () , -100 , 100 );
137184 }
138185
139186 public float setGlobalVolume (float volume ) {
140- volume = volumeScaleToInt (volume );
187+ int vvolume = volumeScaleToInt (volume );
141188
142- if (this .volume != volume ) {
189+ if (this .volume . get () != vvolume ) {
143190 boolean wasEnabled = getEnabled ();
144191
145- this .volume = ( int ) volume ;
192+ this .volume . set ( vvolume ) ;
146193 save ();
147194
148195 if (getEnabled () != wasEnabled ) {
@@ -154,18 +201,18 @@ public float setGlobalVolume(float volume) {
154201 }
155202
156203 public float setRunningVolumeIncrease (float volume ) {
157- runningVolumeIncrease = volume > 97 ? 100 : volume < -97 ? -100 : (int )volume ;
204+ runningVolumeIncrease . set ( volume > 97 ? 100 : volume < -97 ? -100 : (int )volume ) ;
158205 save ();
159206 return getRunningVolumeIncrease ();
160207 }
161208
162209 public void populateCrashReport (CrashReportSection section ) {
163210 section .add ("Disabled" , getDisabled ());
164- section .add ("Global Volume" , volume );
211+ section .add ("Global Volume" , volume . get () );
165212 section .add ("User's Selected Stance" , getLocomotion ());
166213 section .add ("Target Selector" , getEntitySelector ());
167- section .add ("Enabled Global" , global );
168- section .add ("Enabled Multiplayer" , multiplayer );
214+ section .add ("Enabled Global" , global . get () );
215+ section .add ("Enabled Multiplayer" , multiplayer . get () );
169216 }
170217
171218 private static int volumeScaleToInt (float volume ) {
0 commit comments