Music fix

This commit is contained in:
paulevsGitch 2020-10-05 19:53:16 +03:00
parent 3b3ac4ada4
commit 70e9813002
4 changed files with 55 additions and 4 deletions

View file

@ -0,0 +1,50 @@
package ru.betterend.mixin.client;
import org.spongepowered.asm.mixin.Final;
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 net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.gui.screen.CreditsScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.sound.MusicType;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.sound.MusicSound;
import net.minecraft.world.World;
@Mixin(MinecraftClient.class)
public class MinecraftClientMixin {
@Shadow
public ClientPlayerEntity player;
@Shadow
public Screen currentScreen;
@Shadow
@Final
public InGameHud inGameHud;
@Shadow
public ClientWorld world;
@Inject(method = "getMusicType", at = @At("HEAD"), cancellable = true)
private void getEndMusic(CallbackInfoReturnable<MusicSound> info) {
if (!(this.currentScreen instanceof CreditsScreen) && this.player != null) {
if (this.player.world.getRegistryKey() == World.END) {
if (this.inGameHud.getBossBarHud().shouldPlayDragonMusic()) {
info.setReturnValue(MusicType.DRAGON);
}
else {
MusicSound sound = (MusicSound) this.world.getBiomeAccess().method_27344(this.player.getBlockPos()).getMusic().orElse(MusicType.END);
info.setReturnValue(sound);
}
info.cancel();
}
}
}
}

View file

@ -14,7 +14,7 @@ import ru.betterend.BetterEnd;
import ru.betterend.entity.EntityDragonfly;
public class EntityRegistry {
public static final EntityType<EntityDragonfly> DRAGONFLY = register("dragonfly", SpawnGroup.CREATURE, 0.6F, 0.5F, EntityDragonfly::new, EntityDragonfly.createMobAttributes());
public static final EntityType<EntityDragonfly> DRAGONFLY = register("dragonfly", SpawnGroup.AMBIENT, 0.6F, 0.5F, EntityDragonfly::new, EntityDragonfly.createMobAttributes());
public static void register() {}

View file

@ -4,12 +4,12 @@
"sounds": [
{
"name": "betterend:music/dan_henig_eternal_garden",
"volume": 0.3,
"volume": 0.1,
"stream": false
},
{
"name": "betterend:music/dan_henig_nebular_focus",
"volume": 0.3,
"volume": 0.1,
"stream": false
}
]

View file

@ -7,7 +7,8 @@
"WorldRendererMixin",
"BackgroundRendererMixin",
"ClientRecipeBookMixin",
"ClientPlayNetworkHandlerMixin"
"ClientPlayNetworkHandlerMixin",
"MinecraftClientMixin"
],
"injectors": {
"defaultRequire": 1