move shouldParticlesSpawn to own class
This commit is contained in:
@@ -20,8 +20,6 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
import static net.minecraft.world.biome.BiomeKeys.LUSH_CAVES;
|
import static net.minecraft.world.biome.BiomeKeys.LUSH_CAVES;
|
||||||
|
|
||||||
public class MathHelper {
|
public class MathHelper {
|
||||||
private static float timer;
|
|
||||||
public static boolean shouldParticlesSpawn;
|
|
||||||
|
|
||||||
public static double normalize(double min, double max, double val) {
|
public static double normalize(double min, double max, double val) {
|
||||||
return 1 - ((val - min) / (max - min));
|
return 1 - ((val - min) / (max - min));
|
||||||
@@ -40,35 +38,4 @@ public class MathHelper {
|
|||||||
return ThreadLocalRandom.current().nextDouble(min, max);
|
return ThreadLocalRandom.current().nextDouble(min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean shouldParticlesSpawn(MinecraftClient client, CaveDustConfig config) {
|
|
||||||
|
|
||||||
//checks if the config is enabled, if the game isn't paused, if the world is valid, if the particle is valid and if the player isn't in a lush caves biome
|
|
||||||
if (!config.getCaveDustEnabled()
|
|
||||||
|| client.isPaused()
|
|
||||||
|| client.world == null
|
|
||||||
|| !client.world.getDimension().isBedWorking()
|
|
||||||
|| Objects.equals(client.world.getBiomeKey(Objects.requireNonNull(client.player).getBlockPos()), Optional.of(LUSH_CAVES))
|
|
||||||
|| Objects.requireNonNull(client.player).isSubmergedInWater())
|
|
||||||
{
|
|
||||||
timer = 0;
|
|
||||||
shouldParticlesSpawn = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
World world = client.world;
|
|
||||||
int seaLevel = world.getSeaLevel();
|
|
||||||
|
|
||||||
if (!client.player.clientWorld.isSkyVisible(client.player.getBlockPos())) {
|
|
||||||
if (client.player.getBlockPos().getY() < seaLevel){
|
|
||||||
timer = timer + 1;
|
|
||||||
if (timer > 10){
|
|
||||||
timer = 10;
|
|
||||||
shouldParticlesSpawn = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
shouldParticlesSpawn = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ public class ParticleSpawnUtil {
|
|||||||
|| client.isPaused()
|
|| client.isPaused()
|
||||||
|| client.world == null
|
|| client.world == null
|
||||||
|| !client.world.getDimension().isBedWorking()
|
|| !client.world.getDimension().isBedWorking()
|
||||||
|| Objects.equals(client.world.getBiomeKey(Objects.requireNonNull(client.player).getBlockPos()), Optional.of(LUSH_CAVES))
|
|
||||||
|| Objects.requireNonNull(client.player).isSubmergedInWater())
|
|| Objects.requireNonNull(client.player).isSubmergedInWater())
|
||||||
{
|
{
|
||||||
timer = 0;
|
timer = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user