mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-10-20 22:26:24 -04:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddfc8194c8 | ||
|
|
22c5e55a6c |
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.api.tags.CobblemonBiomeTags;
|
||||
import com.cobblemon.mod.common.music.CustomMusic;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.sound.MusicSound;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
public class MinecraftClientMixin {
|
||||
|
||||
@Shadow
|
||||
public ClientPlayerEntity player;
|
||||
|
||||
@Inject(method = "getMusicType", at = @At("RETURN"), cancellable = true)
|
||||
private void cobblemon$getMusicType(CallbackInfoReturnable<MusicSound> cir) {
|
||||
|
||||
if (this.player != null) {
|
||||
RegistryEntry<Biome> playerBiome = this.player.getWorld().getBiome(this.player.getBlockPos());
|
||||
|
||||
List<MusicSound> possibleTracks = new ArrayList<>();
|
||||
|
||||
possibleTracks.add(cir.getReturnValue());
|
||||
|
||||
// Custom BiomeTag check to add music to certain biomes
|
||||
if (playerBiome.isIn(CobblemonBiomeTags.IS_ABYSS)) {
|
||||
possibleTracks.add(CustomMusic.DEEP_DARK);
|
||||
}
|
||||
|
||||
cir.setReturnValue(possibleTracks.get(new Random().nextInt(possibleTracks.size())));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,9 @@ object CobblemonSounds : PlatformRegistry<Registry<SoundEvent>, RegistryKey<Regi
|
||||
@JvmField
|
||||
val MULCH_REMOVE = this.create("mulch.remove")
|
||||
|
||||
@JvmField
|
||||
val MUSIC_DEEP_DARK = this.create("music.deep_dark")
|
||||
|
||||
|
||||
private fun create(name: String): SoundEvent = this.create(name, SoundEvent.of(cobblemonResource(name)))
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.music
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonSounds
|
||||
import net.minecraft.registry.entry.RegistryEntry
|
||||
import net.minecraft.sound.MusicSound
|
||||
import net.minecraft.sound.SoundEvent
|
||||
|
||||
|
||||
object CustomMusic {
|
||||
private fun createCustomIngameMusic(sound: RegistryEntry<SoundEvent?>?): MusicSound {
|
||||
return MusicSound(sound, 12000, 24000, false)
|
||||
}
|
||||
|
||||
@JvmField
|
||||
val DEEP_DARK = createCustomIngameMusic(RegistryEntry.of(CobblemonSounds.MUSIC_DEEP_DARK))
|
||||
}
|
||||
@@ -8,6 +8,9 @@
|
||||
"battle.pvw.default": {
|
||||
"sounds": []
|
||||
},
|
||||
"music.deep_dark": {
|
||||
"sounds": [ "cobblemon:music/cobblemon_taiga" ]
|
||||
},
|
||||
"healing_machine.active": {
|
||||
"sounds": [ "cobblemon:block/healing_machine_active" ]
|
||||
},
|
||||
|
||||
Binary file not shown.
@@ -7,6 +7,7 @@
|
||||
"BuiltinModelItemRendererMixin",
|
||||
"EntityRenderDispatcherMixin",
|
||||
"GameRendererMixin",
|
||||
"MinecraftClientMixin",
|
||||
"ModelPartMixin",
|
||||
"PartyScrollMixin",
|
||||
"PotionSlotMixin",
|
||||
@@ -26,6 +27,9 @@
|
||||
"PointedDripstoneBlockMixin",
|
||||
"ServerChunkManagerMixin",
|
||||
"ShearsDispenserBehaviorMixin",
|
||||
"StructurePoolAccessor",
|
||||
"StructurePoolGeneratorMixin",
|
||||
"StructureProcessorListMixin",
|
||||
"accessor.AccessorEntity",
|
||||
"accessor.StatusEffectInstanceAccessor",
|
||||
"entity.TameableEntityMixin",
|
||||
@@ -35,10 +39,7 @@
|
||||
"invoker.PressurePlateBlockInvoker",
|
||||
"invoker.StairsBlockInvoker",
|
||||
"invoker.TrapdoorBlockInvoker",
|
||||
"pokeball.ThrownEntityMixin",
|
||||
"StructurePoolGeneratorMixin",
|
||||
"StructurePoolAccessor",
|
||||
"StructureProcessorListMixin"
|
||||
"pokeball.ThrownEntityMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
Reference in New Issue
Block a user