diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 5359e64..dfa5d4a 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -52,7 +52,7 @@ jobs: java: 17 dependencies: | - fabric-api | depends | 0.46.0 + fabric | depends | 0.46.0 kirin | includes | 1.10.0-beta.2 modmenu | recommends | * diff --git a/src/main/java/net/lizistired/cavedust/utils/ParticleSpawnUtil.java b/src/main/java/net/lizistired/cavedust/utils/ParticleSpawnUtil.java new file mode 100644 index 0000000..25403eb --- /dev/null +++ b/src/main/java/net/lizistired/cavedust/utils/ParticleSpawnUtil.java @@ -0,0 +1,46 @@ +package net.lizistired.cavedust.utils; + +import net.lizistired.cavedust.CaveDustConfig; +import net.minecraft.client.MinecraftClient; +import net.minecraft.world.World; + +import java.util.Objects; +import java.util.Optional; + +import static net.minecraft.world.biome.BiomeKeys.LUSH_CAVES; + +public class ParticleSpawnUtil { + private static float timer; + public static boolean shouldParticlesSpawn; + 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; + } +}