mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-12-22 14:59:22 +01:00
add config
This commit is contained in:
parent
6f66c40036
commit
0b1036009e
3 changed files with 49 additions and 5 deletions
26
src/main/java/de/ellpeck/naturesaura/ModConfig.java
Normal file
26
src/main/java/de/ellpeck/naturesaura/ModConfig.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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> 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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue