Skip to content

Commit

Permalink
Update music type detection code to automatically work with new types
Browse files Browse the repository at this point in the history
  • Loading branch information
AliahX committed Jun 20, 2023
1 parent 8cf572a commit b777a13
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
24 changes: 18 additions & 6 deletions src/main/java/com/aliahx/mixtape/mixin/MusicTrackerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ private int getMinDelayMixin(MusicSound musicSound) {
case "minecraft:music.creative" -> config.creativeConfig.minSongDelay;
case "minecraft:music.end" -> config.endConfig.minSongDelay;
case "minecraft:music.under_water" -> config.underwaterConfig.minSongDelay;
case "minecraft:music.game", "minecraft:music.overworld.deep_dark", "minecraft:music.overworld.dripstone_caves", "minecraft:music.overworld.grove", "minecraft:music.overworld.jagged_peaks", "minecraft:music.overworld.lush_caves", "minecraft:music.overworld.swamp", "minecraft:music.overworld.jungle_and_forest", "minecraft:music.overworld.old_growth_taiga", "minecraft:music.overworld.meadow", "minecraft:music.overworld.frozen_peaks", "minecraft:music.overworld.snowy_slopes", "minecraft:music.overworld.stony_peaks" -> config.gameConfig.minSongDelay;
case "minecraft:music.nether.nether_wastes", "minecraft:music.nether.warped_forest", "minecraft:music.nether.soul_sand_valley", "minecraft:music.nether.crimson_forest", "minecraft:music.nether.basalt_deltas" -> config.netherConfig.minSongDelay;
default -> musicSound.getMinDelay();
case "minecraft:music.game" -> config.gameConfig.minSongDelay;
default -> {
if(musicSound.getSound().value().getId().toString().contains("overworld")) {
yield config.gameConfig.minSongDelay;
} else if (musicSound.getSound().value().getId().toString().contains("nether")) {
yield config.netherConfig.minSongDelay;
}
yield musicSound.getMinDelay();
}
};
}

Expand All @@ -77,9 +83,15 @@ private int getMaxDelayMixin(MusicSound musicSound) {
case "minecraft:music.creative" -> config.creativeConfig.maxSongDelay;
case "minecraft:music.end" -> config.endConfig.maxSongDelay;
case "minecraft:music.under_water" -> config.underwaterConfig.maxSongDelay;
case "minecraft:music.game", "minecraft:music.overworld.deep_dark", "minecraft:music.overworld.dripstone_caves", "minecraft:music.overworld.grove", "minecraft:music.overworld.jagged_peaks", "minecraft:music.overworld.lush_caves", "minecraft:music.overworld.swamp", "minecraft:music.overworld.jungle_and_forest", "minecraft:music.overworld.old_growth_taiga", "minecraft:music.overworld.meadow", "minecraft:music.overworld.frozen_peaks", "minecraft:music.overworld.snowy_slopes", "minecraft:music.overworld.stony_peaks" -> config.gameConfig.maxSongDelay;
case "minecraft:music.nether.nether_wastes", "minecraft:music.nether.warped_forest", "minecraft:music.nether.soul_sand_valley", "minecraft:music.nether.crimson_forest", "minecraft:music.nether.basalt_deltas" -> config.netherConfig.maxSongDelay;
default -> musicSound.getMaxDelay();
case "minecraft:music.game" -> config.gameConfig.maxSongDelay;
default -> {
if(musicSound.getSound().value().getId().toString().contains("overworld")) {
yield config.gameConfig.maxSongDelay;
} else if (musicSound.getSound().value().getId().toString().contains("nether")) {
yield config.netherConfig.maxSongDelay;
}
yield musicSound.getMinDelay();
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,15 @@ private static void musicMixin(SoundEvent sound, CallbackInfoReturnable<Position
case "minecraft:music.end" -> config.endConfig.volume;
case "minecraft:music.under_water" -> config.underwaterConfig.volume;
case "minecraft:music.credits" -> config.creditsConfig.volume;
case "minecraft:music.game", "minecraft:music.overworld.deep_dark", "minecraft:music.overworld.dripstone_caves", "minecraft:music.overworld.grove", "minecraft:music.overworld.jagged_peaks", "minecraft:music.overworld.lush_caves", "minecraft:music.overworld.swamp", "minecraft:music.overworld.jungle_and_forest", "minecraft:music.overworld.old_growth_taiga", "minecraft:music.overworld.meadow", "minecraft:music.overworld.frozen_peaks", "minecraft:music.overworld.snowy_slopes", "minecraft:music.overworld.stony_peaks" -> config.gameConfig.volume;
case "minecraft:music.nether.nether_wastes", "minecraft:music.nether.warped_forest", "minecraft:music.nether.soul_sand_valley", "minecraft:music.nether.crimson_forest", "minecraft:music.nether.basalt_deltas" -> config.netherConfig.volume;
default -> 100f;
case "minecraft:music.game" -> config.gameConfig.volume;
default -> {
if(sound.getId().toString().contains("overworld")) {
yield config.gameConfig.volume;
} else if (sound.getId().toString().contains("nether")) {
yield config.netherConfig.volume;
}
yield 100f;
}
};
long note = config.mainConfig.varyPitch ? new Random().nextLong((config.mainConfig.maxNoteChange - config.mainConfig.minNoteChange) + 1) + config.mainConfig.minNoteChange : 0;
cir.setReturnValue(new PositionedSoundInstance(sound.getId(), SoundCategory.MUSIC, volume / 100, (float) Math.pow(2.0D, (double) (note) / 12.0D), SoundInstance.createRandom(), false, 0, SoundInstance.AttenuationType.NONE, 0.0D, 0.0D, 0.0D, false));
Expand Down

0 comments on commit b777a13

Please sign in to comment.