Skip to content

Commit 73dbdf1

Browse files
authored
check group exists before setting sound or variations (#237)
1 parent 807f9ee commit 73dbdf1

File tree

1 file changed

+10
-4
lines changed
  • src/main/java/com/cleanroommc/groovyscript/compat/mods/chisel

1 file changed

+10
-4
lines changed

src/main/java/com/cleanroommc/groovyscript/compat/mods/chisel/Carving.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,19 @@ public static CarvingGroup carvingGroup(String group) {
4141

4242
@Override
4343
public void onReload() {
44-
removeScripted().forEach(pair -> getRegistry().removeVariation(pair.getValue(), pair.getKey()));
45-
restoreFromBackup().forEach(pair -> getRegistry().addVariation(pair.getKey(), CarvingUtils.variationFor(pair.getValue(), 0)));
46-
4744
groupStorage.restoreFromBackup().forEach(group -> getRegistry().addGroup(CarvingUtils.getDefaultGroupFor(group)));
4845
groupStorage.removeScripted().forEach(getRegistry()::removeGroup);
4946

50-
soundStorage.restoreFromBackup().forEach(pair -> getRegistry().setVariationSound(pair.getKey(), pair.getValue()));
47+
removeScripted().forEach(pair -> {
48+
if (getRegistry().getGroup(pair.getKey()) != null) getRegistry().removeVariation(pair.getValue(), pair.getKey());
49+
});
50+
restoreFromBackup().forEach(pair -> {
51+
if (getRegistry().getGroup(pair.getKey()) != null) getRegistry().addVariation(pair.getKey(), CarvingUtils.variationFor(pair.getValue(), 0));
52+
});
53+
54+
soundStorage.restoreFromBackup().forEach(pair -> {
55+
if (getRegistry().getGroup(pair.getKey()) != null) getRegistry().setVariationSound(pair.getKey(), pair.getValue());
56+
});
5157
}
5258

5359
@MethodDescription(example = {@Example("'demo', item('minecraft:diamond_block')"),

0 commit comments

Comments
 (0)