Skip to content

Commit 9a257d6

Browse files
committed
Fix crash when trying to play sounds for modded blocks with misconfigured sound events. Fixes #339
1 parent 42ac71a commit 9a257d6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/main/java/eu/ha3/presencefootsteps/world/AbstractSubstrateLookup.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ abstract class AbstractSubstrateLookup<T> implements Lookup<T> {
1414
protected abstract Identifier getId(T key);
1515

1616
@Override
17-
public SoundsKey getAssociation(T key, String substrate) {
17+
public SoundsKey getAssociation(@Nullable T key, String substrate) {
18+
if (key == null) {
19+
return SoundsKey.UNASSIGNED;
20+
}
1821
final Identifier id = getId(key);
1922
return getSubstrateMap(id, substrate).getOrDefault(id, SoundsKey.UNASSIGNED);
2023
}

src/main/java/eu/ha3/presencefootsteps/world/PrimitiveLookup.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected Identifier getId(SoundEvent key) {
1818
public void writeToReport(boolean full, JsonObjectWriter writer, Map<String, BlockSoundGroup> groups) throws IOException {
1919
writer.each(groups.values(), group -> {
2020
SoundEvent event = group.getStepSound();
21-
if (full || !contains(event)) {
21+
if (event != null && (full || !contains(event))) {
2222
writer.field(getKey(group), getAssociation(event, getSubstrate(group)).raw());
2323
}
2424
});

0 commit comments

Comments
 (0)