Skip to content

Commit

Permalink
Make in minecart sound respect anchors, fixes #70
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoBeliik committed Feb 27, 2024
1 parent b48f715 commit 133d947
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private float esm_setVolume(float volume) {
//don't care about forbidden sounds or from the psb
if (tempSound != null && !esm_isForbidden(tempSound) && !PlaySoundButton.isFromPSB()) {
ResourceLocation soundLocation = tempSound.getLocation();
float tempVolume = soundLocation.toString().contains("entity.lightning_bolt.thunder") ? 1F : tempSound.getVolume();
float tempVolume = soundLocation.getPath().contains("entity.lightning_bolt.thunder") ? 1F : tempSound.getVolume();

//remove sound to prevent repeated sounds and maintains the desired order
recentSoundsList.remove(soundLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,15 @@ public void editAnchor(String title, int Radius) {

public static Anchor getAnchor(SoundInstance sound) {
BlockPos soundPos = new BlockPos((int) sound.getX(), (int) sound.getY(), (int) sound.getZ());
Minecraft minecraft = Minecraft.getInstance();
LocalPlayer player = minecraft.player;
ClientLevel world = minecraft.level;

if (player != null && sound.getLocation().getPath().contains("entity.minecart.inside")) {
//give player coordinates if it's in the minecart, minecart.inside sound pos is always at 0
soundPos = player.getOnPos();
}
for (Anchor anchor : ISoundLists.anchorList) {
ClientLevel world = Minecraft.getInstance().level;
if (anchor.getAnchorPos() != null
&& world != null
&& world.dimension().location().equals(anchor.getDimension())
Expand Down

0 comments on commit 133d947

Please sign in to comment.