Skip to content

Commit

Permalink
Remove attenuation from announcement sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
zbx1425 committed Sep 12, 2023
1 parent 973fceb commit ea4acd4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
import mtr.render.TrainRendererBase;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.client.resources.sounds.SoundInstance;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import vendor.cn.zbx1425.mtrsteamloco.org.mozilla.javascript.*;

import java.util.concurrent.Future;
Expand Down Expand Up @@ -108,14 +111,12 @@ public void playAnnSound(ResourceLocation sound, float volume, float pitch) {
Minecraft.getInstance().execute(() -> {
LocalPlayer player = Minecraft.getInstance().player;
if (player != null && train.isPlayerRiding(player)) {
player.playSound(
#if MC_VERSION >= "11903"
SoundEvent.createVariableRangeEvent(sound),
#else
new SoundEvent(sound),
#endif
volume, pitch
);
Minecraft.getInstance().getSoundManager().play(new SimpleSoundInstance(
sound, SoundSource.BLOCKS,
volume, pitch,
SoundInstance.createUnseededRandom(), false,
0, SoundInstance.Attenuation.NONE, 0.0, 0.0, 0.0, true
));
}
});
}
Expand Down
10 changes: 10 additions & 0 deletions forge/src/main/java/cn/zbx1425/mtrsteamloco/forge/MainForge.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.api.distmarker.Dist;
#if MC_VERSION >= "11900"
import net.minecraftforge.client.ConfigScreenHandler;
#else
import net.minecraftforge.client.ConfigGuiHandler;
#endif
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
Expand Down Expand Up @@ -59,9 +63,15 @@ public MainForge() {
MinecraftForge.EVENT_BUS.register(ClientProxy.ForgeEventBusListener.class);
});

#if MC_VERSION >= "11900"
ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class,
() -> new ConfigScreenHandler.ConfigScreenFactory(((minecraft, parent) ->
ConfigScreen.createScreen(parent))));
#else
ModLoadingContext.get().registerExtensionPoint(ConfigGuiHandler.ConfigGuiFactory.class,
() -> new ConfigGuiHandler.ConfigGuiFactory(((minecraft, parent) ->
ConfigScreen.createScreen(parent))));
#endif
}
private static void registerBlock(String path, RegistryObject<Block> block) {
BLOCKS.register(path, block::get);
Expand Down

0 comments on commit ea4acd4

Please sign in to comment.