diff --git a/src/main/java/de/ellpeck/naturesaura/ModConfig.java b/src/main/java/de/ellpeck/naturesaura/ModConfig.java new file mode 100644 index 00000000..fa9f1234 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/ModConfig.java @@ -0,0 +1,26 @@ +package de.ellpeck.naturesaura; + +import net.minecraftforge.common.config.Config; +import net.minecraftforge.common.config.Config.Comment; +import net.minecraftforge.common.config.Config.RangeDouble; + +@Config(modid = NaturesAura.MOD_ID, category = "") +public final class ModConfig { + + public static General general = new General(); + public static Client client = new Client(); + + public static class General { + + } + + public static class Client { + + @Comment("The percentage of particles that should be displayed, where 1 is 100% and 0 is 0%.") + @RangeDouble(min = 0, max = 1) + public double particleAmount = 1; + + @Comment("If particle spawning should respect the particle setting in Minecraft's video settings screen") + public boolean respectVanillaParticleSettings = true; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java index 33923afc..5fca1565 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java @@ -7,8 +7,11 @@ import de.ellpeck.naturesaura.packet.PacketHandler; import net.minecraft.util.ResourceLocation; import net.minecraft.world.WorldServer; import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.config.Config; +import net.minecraftforge.common.config.ConfigManager; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.world.ChunkWatchEvent; +import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -45,4 +48,11 @@ public class CommonEvents { PacketHandler.sendTo(event.getPlayer(), auraChunk.makePacket()); } } + + @SubscribeEvent + public void onConfigChanged(OnConfigChangedEvent event) { + if (NaturesAura.MOD_ID.equals(event.getModID())) { + ConfigManager.sync(NaturesAura.MOD_ID, Config.Type.INSTANCE); + } + } } diff --git a/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java b/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java index 61ff9a8b..af420ad5 100644 --- a/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java +++ b/src/main/java/de/ellpeck/naturesaura/particles/ParticleHandler.java @@ -1,5 +1,6 @@ package de.ellpeck.naturesaura.particles; +import de.ellpeck.naturesaura.ModConfig; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.Particle; import net.minecraft.client.renderer.ActiveRenderInfo; @@ -25,12 +26,19 @@ public final class ParticleHandler { public static void spawnParticle(Supplier particle, double x, double y, double z, int range) { if (Minecraft.getMinecraft().player.getDistanceSq(x, y, z) <= range * range) { Minecraft mc = Minecraft.getMinecraft(); - int setting = mc.gameSettings.particleSetting; - if (setting == 0 || - setting == 1 && mc.world.rand.nextInt(3) == 0 || - setting == 2 && mc.world.rand.nextInt(10) == 0) { - PARTICLES.add(particle.get()); + if (ModConfig.client.respectVanillaParticleSettings) { + int setting = mc.gameSettings.particleSetting; + if (setting != 0 && + (setting != 1 || mc.world.rand.nextInt(3) != 0) && + (setting != 2 || mc.world.rand.nextInt(10) != 0)) { + return; + } } + double setting = ModConfig.client.particleAmount; + if (setting < 1 && mc.world.rand.nextDouble() > setting) { + return; + } + PARTICLES.add(particle.get()); } }