Skip to content

Commit 66e0efc

Browse files
committed
1.21.5 -> 1.21.7
1 parent d2b9ef4 commit 66e0efc

10 files changed

Lines changed: 125 additions & 101 deletions

File tree

gradle.properties

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ org.gradle.daemon=false
33

44
# Fabric Properties
55
# check these on https://fabricmc.net/develop
6-
minecraft_version=1.21.5-rc1
7-
yarn_mappings=1.21.5-rc1+build.2
8-
loader_version=0.16.10
9-
fabric_version=0.119.2+1.21.5
6+
minecraft_version=1.21.7
7+
yarn_mappings=1.21.7+build.8
8+
loader_version=0.16.14
9+
fabric_version=0.128.2+1.21.7
1010

1111
# Mod Properties
1212
group=com.presencefootsteps
@@ -16,15 +16,15 @@ org.gradle.daemon=false
1616
url=http://presencefootsteps.ha3.eu
1717

1818
# Publishing
19-
minecraft_version_range=>=1.21.5
19+
minecraft_version_range=>=1.21.6
2020
modrinth_loader_type=fabric
2121
modrinth_project_id=rcTfTZr3
2222

2323
# Testing
2424
use_minelp=1
2525

2626
# Dependencies
27-
modmenu_version=14.0.0-beta.1
28-
minelp_version=4.13.3+1.21.5
29-
kirin_version=1.20.5+1.21.5
27+
modmenu_version=15.0.0-beta.3
28+
minelp_version=4.14.0-beta.2+1.21.7
29+
kirin_version=1.21.0+1.21.7
3030
pehkui_version=3.7.2

src/main/java/eu/ha3/presencefootsteps/PFConfig.java

Lines changed: 102 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,110 @@
11
package eu.ha3.presencefootsteps;
22

33
import 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

510
import eu.ha3.presencefootsteps.config.EntitySelector;
6-
import eu.ha3.presencefootsteps.config.JsonFile;
711
import eu.ha3.presencefootsteps.config.VolumeOption;
812
import eu.ha3.presencefootsteps.sound.generator.Locomotion;
13+
import net.minecraft.entity.EntityType;
14+
import net.minecraft.registry.Registries;
15+
import net.minecraft.util.Identifier;
916
import net.minecraft.util.crash.CrashReportSection;
1017
import 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) {

src/main/java/eu/ha3/presencefootsteps/config/JsonFile.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
public abstract class JsonFile {
2121
private transient final Gson gson = new GsonBuilder()
2222
.registerTypeAdapter(getClass(), (InstanceCreator<JsonFile>)t -> this)
23-
.registerTypeAdapter(VolumeOption.class, new VolumeOption.Adapter(this))
2423
.setPrettyPrinting()
2524
.create();
2625

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,31 @@
11
package eu.ha3.presencefootsteps.config;
22

3-
import java.lang.reflect.Type;
4-
5-
import com.google.gson.JsonDeserializationContext;
6-
import com.google.gson.JsonDeserializer;
7-
import com.google.gson.JsonElement;
8-
import com.google.gson.JsonParseException;
9-
import com.google.gson.JsonSerializationContext;
10-
import com.google.gson.JsonSerializer;
113
import com.minelittlepony.common.client.gui.IField.IChangeCallback;
4+
import com.minelittlepony.common.util.settings.Config;
5+
import com.minelittlepony.common.util.settings.Setting;
126

137
import net.minecraft.util.math.MathHelper;
148

159
public class VolumeOption implements IChangeCallback<Float> {
1610

17-
private transient final JsonFile config;
18-
19-
private int value;
11+
private final Config config;
12+
private final Setting<Integer> value;
2013

21-
public VolumeOption(JsonFile config, int value) {
14+
public VolumeOption(Config config, Setting<Integer> value) {
2215
this.config = config;
2316
this.value = value;
2417
}
2518

2619
public int get() {
27-
return MathHelper.clamp(value, 0, 100);
20+
return MathHelper.clamp(value.get(), 0, 100);
2821
}
2922

3023
public float getPercentage() {
3124
return get() / 100F;
3225
}
3326

3427
public float set(float volume) {
35-
value = volumeScaleToInt(volume);
28+
value.set(volumeScaleToInt(volume));
3629
config.save();
3730
return get();
3831
}
@@ -50,21 +43,4 @@ public String toString() {
5043
private static int volumeScaleToInt(float volume) {
5144
return volume > 97 ? 100 : volume < 3 ? 0 : (int)volume;
5245
}
53-
54-
static class Adapter implements JsonSerializer<VolumeOption>, JsonDeserializer<VolumeOption> {
55-
private final JsonFile file;
56-
Adapter(JsonFile file) {
57-
this.file = file;
58-
}
59-
@Override
60-
public JsonElement serialize(VolumeOption src, Type typeOfSrc, JsonSerializationContext context) {
61-
return context.serialize(src.get());
62-
}
63-
64-
@Override
65-
public VolumeOption deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException {
66-
return new VolumeOption(file, context.deserialize(json, int.class));
67-
}
68-
}
69-
7046
}

src/main/java/eu/ha3/presencefootsteps/mixins/MSoundSystem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414

1515
@Mixin(SoundSystem.class)
1616
abstract class MSoundSystem {
17-
@Shadow
18-
abstract float getSoundVolume(@Nullable SoundCategory category);
17+
@Shadow(aliases = {"getSoundVolume", "method_72233"})
18+
abstract float method_72233(@Nullable SoundCategory category);
1919

2020
@Inject(method = "getAdjustedVolume(Lnet/minecraft/client/sound/SoundInstance;)F", at = @At("HEAD"), cancellable = true)
2121
private void onGetAdjustedVolume(SoundInstance sound, CallbackInfoReturnable<Float> info) {
2222
if (sound instanceof ImmediateSoundPlayer.UncappedSoundInstance t) {
23-
info.setReturnValue(MathHelper.clamp(t.getVolume() * getSoundVolume(t.getCategory()), 0, t.getMaxVolume()));
23+
info.setReturnValue(MathHelper.clamp(t.getVolume() * method_72233(t.getCategory()), 0, t.getMaxVolume()));
2424
}
2525
}
2626
}

0 commit comments

Comments
 (0)