Skip to content

Commit

Permalink
Improve error handling for incompatible particles
Browse files Browse the repository at this point in the history
  • Loading branch information
LizIsTired committed May 22, 2023
1 parent 5f48fec commit f453148
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/net/lizistired/cavedust/CaveDustConfig.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package net.lizistired.cavedust;

import net.lizistired.cavedust.utils.JsonFile;
import net.minecraft.client.MinecraftClient;
import net.minecraft.particle.ParticleEffect;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.registry.Registries;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import static net.lizistired.cavedust.CaveDust.*;
import static net.lizistired.cavedust.utils.MathHelper.*;
Expand Down Expand Up @@ -140,7 +142,14 @@ public ParticleEffect setParticle(String particleType){
}

public ParticleEffect getParticle(){
return (ParticleEffect) Registries.PARTICLE_TYPE.get(new Identifier(Registries.PARTICLE_TYPE.getEntry(getParticleID()).get().getKey().get().getValue().toString().toLowerCase()));
try {
return (ParticleEffect) Registries.PARTICLE_TYPE.get(new Identifier(Registries.PARTICLE_TYPE.getEntry(getParticleID()).get().getKey().get().getValue().toString().toLowerCase()));
} catch (ClassCastException e) {
MinecraftClient.getInstance().player.sendMessage(Text.literal("Issue loading particle, defaulting to white ash particle!"), false);
setParticleID(WHITE_ASH_ID);
save();
return ParticleTypes.WHITE_ASH;
}
}

public boolean getSeaLevelCheck() {
Expand Down

0 comments on commit f453148

Please sign in to comment.