Skip to content

Commit

Permalink
Redo all ambience to be more dynamic, split ambience config into mult…
Browse files Browse the repository at this point in the history
…iple sliders
  • Loading branch information
doctor4t committed Sep 22, 2024
1 parent 7b03745 commit e8979b5
Show file tree
Hide file tree
Showing 31 changed files with 244 additions and 62 deletions.
50 changes: 29 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,43 @@ plugins {
id("io.github.ladysnake.chenille") version "0.13.1"
}

version = project.mod_version;
group = project.maven_group;

base {
archivesName = project.archives_base_name
}

chenille {
configurePublishing {
withGithubRelease()
withModrinthRelease()
}
}

version = project.mod_version
group = project.maven_group
modrinth {
dependencies {
required.project "fabric-api"
embedded.project "cardinal-components-api"
embedded.project "midnightlib"
embedded.project "lodestonelib"
embedded.project "satin-api"
}
syncBodyFrom = rootProject.file("README.md").text
}

loom {
accessWidenerPath = file("src/client/resources/effective.accesswidener")

splitEnvironmentSourceSets()

mods {
"effective" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}

base {
archivesName = project.archives_base_name
}

repositories {
Expand Down Expand Up @@ -47,20 +72,6 @@ repositories {
}
}

loom {
accessWidenerPath = file("src/client/resources/effective.accesswidener")

splitEnvironmentSourceSets()

mods {
"effective" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}

}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
Expand Down Expand Up @@ -123,9 +134,6 @@ tasks.withType(JavaCompile).configureEach {
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_21
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ org.gradle.parallel=true
owners = Ladysnake
display_name = Effective
license_header = ARR
modrinth_id = effective
modrinth_id = pcPXJeZi
curseforge_versions = 1.20.1
release_type = release

# Fabric Properties
# check these on https://fabricmc.net/develop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,92 @@ public class EffectiveAmbience implements ClientModInitializer {

@Override
public void onInitializeClient() {
/* SURFACE */
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.AMBIENT_PLAINS_DAY, (world, pos, player) -> !isInCave(world, pos) && world.getBiome(pos).isIn(ConventionalBiomeTags.CLIMATE_TEMPERATE) && !Effective.isNightTime(world))); // plains day
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.AMBIENT_BEACH, (world, pos, player) -> !isInCave(world, pos) && world.getBiome(pos).isIn(ConventionalBiomeTags.BEACH))); // beach
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.CRICKETS, (world, pos, player) -> !isInCave(world, pos) && world.getBiome(pos).isIn(ConventionalBiomeTags.CLIMATE_TEMPERATE) && Effective.isNightTime(world))); // crickets for night time in temperate biomes

/* CAVES */
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.AMBIENT_CAVE, (world, pos, player) -> isInCave(world, pos) && !world.isSkyVisible(pos))); // cave
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.AMBIENT_DEEP_DARK, (world, pos, player) -> world.getBiome(pos).matchesKey(BiomeKeys.DEEP_DARK))); // deep dark
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.AMBIENT_LUSH_CAVE, (world, pos, player) -> world.getBiome(pos).matchesKey(BiomeKeys.LUSH_CAVES))); // lush caves
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.AMBIENT_DRIPSTONE_CAVE, (world, pos, player) -> world.getBiome(pos).matchesKey(BiomeKeys.DRIPSTONE_CAVES))); // dripstone caves
// bees in floral biomes during the day
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.ANIMAL_BEES, AmbientCondition.Type.ANIMAL,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && world.getBiome(pos).isIn(ConventionalBiomeTags.FLORAL) && !Effective.isNightTime(world)));

// birds in forests during the day
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.ANIMAL_BIRDS, AmbientCondition.Type.ANIMAL,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && world.getBiome(pos).isIn(ConventionalBiomeTags.FOREST) && !Effective.isNightTime(world)));

// cicadas in savannas during day
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.ANIMAL_CICADAS, AmbientCondition.Type.ANIMAL,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && world.getBiome(pos).isIn(ConventionalBiomeTags.SAVANNA) && !Effective.isNightTime(world)));

// crickets in temperate (excluding swamps to use their dedicated cricket and frog ambience instead) and floral biomes at night
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.ANIMAL_CRICKETS, AmbientCondition.Type.ANIMAL,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && ((world.getBiome(pos).isIn(ConventionalBiomeTags.CLIMATE_TEMPERATE) && !world.getBiome(pos).isIn(ConventionalBiomeTags.SWAMP)) || world.getBiome(pos).isIn(ConventionalBiomeTags.FLORAL)) && Effective.isNightTime(world)));

// frogs and crickets in swamps at night
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.ANIMAL_FROGS_AND_CRICKETS, AmbientCondition.Type.ANIMAL,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && (world.getBiome(pos).isIn(ConventionalBiomeTags.SWAMP)) && Effective.isNightTime(world)));

// day jungle animals in jungles during the day
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.ANIMAL_JUNGLE_DAY, AmbientCondition.Type.ANIMAL,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && (world.getBiome(pos).isIn(ConventionalBiomeTags.JUNGLE)) && !Effective.isNightTime(world)));

// night jungle animals in jungles at night
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.ANIMAL_JUNGLE_NIGHT, AmbientCondition.Type.ANIMAL,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && (world.getBiome(pos).isIn(ConventionalBiomeTags.JUNGLE)) && Effective.isNightTime(world)));

// owls in forests at
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.ANIMAL_OWLS, AmbientCondition.Type.ANIMAL,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && (world.getBiome(pos).isIn(ConventionalBiomeTags.FOREST)) && Effective.isNightTime(world)));

// rustling foliage in forests, floral biomes, swamps, jungles, wooded badlands and lush caves
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.FOLIAGE_LEAVES, AmbientCondition.Type.FOLIAGE,
(world, pos, player) -> isInOverworld(world, pos) && (!isInCave(world, pos) || world.getBiome(pos).matchesKey(BiomeKeys.LUSH_CAVES)) && (world.getBiome(pos).isIn(ConventionalBiomeTags.FOREST) || world.getBiome(pos).isIn(ConventionalBiomeTags.FLORAL) || world.getBiome(pos).isIn(ConventionalBiomeTags.SWAMP) || world.getBiome(pos).isIn(ConventionalBiomeTags.JUNGLE) || world.getBiome(pos).matchesKey(BiomeKeys.WOODED_BADLANDS) || world.getBiome(pos).matchesKey(BiomeKeys.LUSH_CAVES))));

// water dripping in dripstone caves
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.WATER_DRIPSTONE_CAVES, AmbientCondition.Type.WATER,
(world, pos, player) -> isInOverworld(world, pos) && world.getBiome(pos).matchesKey(BiomeKeys.DRIPSTONE_CAVES)));

// water streams in lush caves
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.WATER_LUSH_CAVES, AmbientCondition.Type.WATER,
(world, pos, player) -> isInOverworld(world, pos) && world.getBiome(pos).matchesKey(BiomeKeys.LUSH_CAVES)));

// water flowing in rivers
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.WATER_RIVER, AmbientCondition.Type.WATER,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && world.getBiome(pos).isIn(ConventionalBiomeTags.RIVER)));

// water waves in beaches and oceans
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.WATER_WAVES, AmbientCondition.Type.WATER,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && world.getBiome(pos).isIn(ConventionalBiomeTags.BEACH) || world.getBiome(pos).isIn(ConventionalBiomeTags.OCEAN)));

// arid wind in deserts and mesas
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.WIND_ARID, AmbientCondition.Type.WIND,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && (world.getBiome(pos).isIn(ConventionalBiomeTags.DESERT) || world.getBiome(pos).isIn(ConventionalBiomeTags.MESA))));

// cave wind in caves (excluding the deep dark to use its dedicated ambience instead)
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.WIND_CAVE, AmbientCondition.Type.WIND,
(world, pos, player) -> isInOverworld(world, pos) && isInCave(world, pos) && !world.getBiome(pos).matchesKey(BiomeKeys.DEEP_DARK)));

// cold wind in cold biomes (excluding peaks to use their dedicated wind instead) and mountain slopes
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.WIND_COLD, AmbientCondition.Type.WIND,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && (world.getBiome(pos).isIn(ConventionalBiomeTags.CLIMATE_COLD) || world.getBiome(pos).isIn(ConventionalBiomeTags.MOUNTAIN_SLOPE)) && !world.getBiome(pos).isIn(ConventionalBiomeTags.MOUNTAIN_PEAK)));

// deep dark ambience (classified as wind)
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.WIND_DEEP_DARK, AmbientCondition.Type.WIND,
(world, pos, player) -> isInOverworld(world, pos) && world.getBiome(pos).matchesKey(BiomeKeys.DEEP_DARK)));

// end ambience (classified as wind)
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.WIND_END, AmbientCondition.Type.WIND,
(world, pos, player) -> world.getBiome(pos).isIn(ConventionalBiomeTags.IN_THE_END)));

// mountain wind in peaks
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.WIND_MOUNTAINS, AmbientCondition.Type.WIND,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && world.getBiome(pos).isIn(ConventionalBiomeTags.MOUNTAIN_PEAK)));

// soft wind in temperate, floral, savanna, jungle and mushroom field biomes
AMBIENT_CONDITIONS.add(new AmbientCondition(EffectiveAmbienceSounds.WIND_TEMPERATE, AmbientCondition.Type.WIND,
(world, pos, player) -> isInOverworld(world, pos) && !isInCave(world, pos) && (world.getBiome(pos).isIn(ConventionalBiomeTags.CLIMATE_TEMPERATE) || world.getBiome(pos).isIn(ConventionalBiomeTags.FLORAL) || world.getBiome(pos).isIn(ConventionalBiomeTags.SAVANNA)|| world.getBiome(pos).isIn(ConventionalBiomeTags.JUNGLE) || world.getBiome(pos).isIn(ConventionalBiomeTags.MUSHROOM))));
}

public static final boolean isInCave(World world, BlockPos pos) {
return pos.getY() <= world.getSeaLevel();
return pos.getY() < world.getSeaLevel() && !world.isSkyVisibleAllowingSea(pos);
}

public static final boolean isInOverworld(World world, BlockPos pos) {
return world.getBiome(pos).isIn(ConventionalBiomeTags.IN_OVERWORLD);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,26 @@ public class EffectiveAmbienceSounds {
protected static final List<SoundEvent> SOUND_EVENTS = new LinkedList<>();

/* SURFACE */
public static final SoundEvent AMBIENT_PLAINS_DAY = create("ambient.plains.day");
public static final SoundEvent AMBIENT_BEACH = create("ambient.beach");
public static final SoundEvent CRICKETS = create("ambient.crickets");

/* CAVES */
public static final SoundEvent AMBIENT_CAVE = create("ambient.cave");
public static final SoundEvent AMBIENT_DEEP_DARK = create("ambient.deep_dark");
public static final SoundEvent AMBIENT_LUSH_CAVE = create("ambient.lush_cave");
public static final SoundEvent AMBIENT_DRIPSTONE_CAVE = create("ambient.dripstone_cave");
public static final SoundEvent ANIMAL_BEES = create("ambient.animal.bees");
public static final SoundEvent ANIMAL_BIRDS = create("ambient.animal.birds");
public static final SoundEvent ANIMAL_CICADAS = create("ambient.animal.cicadas");
public static final SoundEvent ANIMAL_CRICKETS = create("ambient.animal.crickets");
public static final SoundEvent ANIMAL_FROGS_AND_CRICKETS = create("ambient.animal.frogs_and_crickets");
public static final SoundEvent ANIMAL_JUNGLE_DAY = create("ambient.animal.jungle_day");
public static final SoundEvent ANIMAL_JUNGLE_NIGHT = create("ambient.animal.jungle_night");
public static final SoundEvent ANIMAL_OWLS = create("ambient.animal.owls");
public static final SoundEvent FOLIAGE_LEAVES = create("ambient.foliage.leaves");
public static final SoundEvent WATER_DRIPSTONE_CAVES = create("ambient.water.dripstone_caves");
public static final SoundEvent WATER_LUSH_CAVES = create("ambient.water.lush_caves");
public static final SoundEvent WATER_RIVER = create("ambient.water.river");
public static final SoundEvent WATER_WAVES = create("ambient.water.waves");
public static final SoundEvent WIND_ARID = create("ambient.wind.arid");
public static final SoundEvent WIND_CAVE = create("ambient.wind.cave");
public static final SoundEvent WIND_COLD = create("ambient.wind.cold");
public static final SoundEvent WIND_DEEP_DARK = create("ambient.wind.deep_dark");
public static final SoundEvent WIND_END = create("ambient.wind.end");
public static final SoundEvent WIND_MOUNTAINS = create("ambient.wind.mountains");
public static final SoundEvent WIND_TEMPERATE = create("ambient.wind.temperate");

protected static SoundEvent create(String name) {
SoundEvent soundEvent = SoundEvent.of(Effective.id(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public record AmbientCondition(SoundEvent event, AmbiencePredicate predicate) {
public record AmbientCondition(SoundEvent event, Type type, AmbiencePredicate predicate) {
public interface AmbiencePredicate {
boolean shouldPlay(World world, BlockPos pos, PlayerEntity player);
}

public static enum Type {
WIND, ANIMAL, FOLIAGE, WATER;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class BiomeAmbientLoop extends MovingSoundInstance {
private static final int TRANSITION_TIME = 100;
private final ClientPlayerEntity player;
private int transitionTimer;
private AmbientCondition ambientConditions;
private final AmbientCondition ambientConditions;

public BiomeAmbientLoop(ClientPlayerEntity player, SoundEvent ambientSound, AmbientCondition ambientConditions) {
super(ambientSound, SoundCategory.AMBIENT, SoundInstance.createRandom());
Expand All @@ -28,7 +28,17 @@ public BiomeAmbientLoop(ClientPlayerEntity player, SoundEvent ambientSound, Ambi

@Override
public void tick() {
final float volumeAdjustor = EffectiveConfig.biomeAmbienceVolume / 100f;
final float windVolume = EffectiveConfig.windAmbienceVolume / 100f;
final float waterVolume = EffectiveConfig.waterAmbienceVolume / 100f;
final float foliageVolume = EffectiveConfig.foliageAmbienceVolume / 100f;
final float animalVolume = EffectiveConfig.animalAmbienceVolume / 100f;

final float volumeAdjustor = switch (this.ambientConditions.type()) {
case WIND -> windVolume;
case ANIMAL -> animalVolume;
case FOLIAGE -> foliageVolume;
case WATER -> waterVolume;
};

ClientWorld world = MinecraftClient.getInstance().world;
if (world != null && !this.player.isRemoved() && !this.player.isSubmergedInWater() && this.transitionTimer >= 0 && volumeAdjustor > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ public class EffectiveConfig extends MidnightConfig {
public static int cascadeSoundDistanceBlocks = 50;
@Comment(category = audio, centered = true) public static Comment biomeAmbience;
@Entry(category = audio, min = 0, max = 100, isSlider = true)
public static int biomeAmbienceVolume = 100;
public static int windAmbienceVolume = 100;
@Entry(category = audio, min = 0, max = 100, isSlider = true)
public static int waterAmbienceVolume = 100;
@Entry(category = audio, min = 0, max = 100, isSlider = true)
public static int foliageAmbienceVolume = 100;
@Entry(category = audio, min = 0, max = 100, isSlider = true)
public static int animalAmbienceVolume = 100;

public static boolean shouldGlowSquidsHypnotize() {
return glowSquidHypnotize == GlowSquidHypnoOptions.ATTRACT || glowSquidHypnotize == GlowSquidHypnoOptions.VISUAL;
Expand Down
7 changes: 5 additions & 2 deletions src/client/resources/assets/effective/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@
"effective.midnightconfig.cascadeAudio": "Cascade Audio",
"effective.midnightconfig.cascadeSoundsVolume": "Cascade Sound Volume",
"effective.midnightconfig.cascadeSoundDistanceBlocks": "Distance to Hear Cascades (in blocks)",
"effective.midnightconfig.biomeAmbience": "Biome Ambience",
"effective.midnightconfig.biomeAmbienceVolume": "Biome Ambience Volume",
"effective.midnightconfig.biomeAmbience": "Ambience",
"effective.midnightconfig.windAmbienceVolume": "Wind Volume",
"effective.midnightconfig.waterAmbienceVolume": "Water Volume",
"effective.midnightconfig.foliageAmbienceVolume": "Foliage Volume",
"effective.midnightconfig.animalAmbienceVolume": "Animal Volume",
"effective:modmenu.dashboard": "Dashboard"
}
Loading

0 comments on commit e8979b5

Please sign in to comment.