Skip to content

Commit

Permalink
Closes #357
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeryn99 committed Sep 6, 2024
1 parent 8ed2a53 commit 143d4bf
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package whocraft.tardis_refined.common.blockentity.shell;

import net.minecraft.client.resources.sounds.Sound;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -31,6 +32,7 @@
import whocraft.tardis_refined.constants.NbtConstants;
import whocraft.tardis_refined.patterns.ShellPattern;
import whocraft.tardis_refined.patterns.ShellPatterns;
import whocraft.tardis_refined.patterns.sound.TRShellSoundProfiles;
import whocraft.tardis_refined.registry.TRBlockEntityRegistry;

import java.util.Optional;
Expand Down Expand Up @@ -175,10 +177,15 @@ public void spawnCoralItems() {
@Override
public void playDoorCloseSound(boolean closeDoor) {
ShellPattern pattern = this.pattern();
if (pattern != null){
if (pattern != null) {
Level currentLevel = this.getLevel();
ConfiguredSound configuredSound = pattern.soundProfile().get().getDoorClose();
if (configuredSound != null){
ConfiguredSound configuredSound;
if (closeDoor) {
configuredSound = pattern.soundProfile().get() != null ? pattern.soundProfile().get().getDoorClose() : TRShellSoundProfiles.DEFAULT_SOUND_PROFILE.getDoorClose();
} else {
configuredSound = pattern.soundProfile().get() != null ? pattern.soundProfile().get().getDoorOpen() : TRShellSoundProfiles.DEFAULT_SOUND_PROFILE.getDoorOpen();
}
if (configuredSound != null) {
currentLevel.playSound(null, this.getBlockPos(), configuredSound.getSoundEvent(), SoundSource.BLOCKS, configuredSound.getPitch(), configuredSound.getVolume());
}
}
Expand All @@ -187,10 +194,15 @@ public void playDoorCloseSound(boolean closeDoor) {
@Override
public void playDoorLockedSound(boolean lockDoor) {
ShellPattern pattern = this.pattern();
if (pattern != null){
if (pattern != null) {
Level currentLevel = this.getLevel();
ConfiguredSound configuredSound = pattern.soundProfile().get().getDoorLocked();
if (configuredSound != null){
ConfiguredSound configuredSound;
if (lockDoor) {
configuredSound = pattern.soundProfile().get() != null ? pattern.soundProfile().get().getDoorLocked() : TRShellSoundProfiles.DEFAULT_SOUND_PROFILE.getDoorLocked();
} else {
configuredSound = pattern.soundProfile().get() != null ? pattern.soundProfile().get().getDoorUnlocked() : TRShellSoundProfiles.DEFAULT_SOUND_PROFILE.getDoorUnlocked();
}
if (configuredSound != null) {
currentLevel.playSound(null, this.getBlockPos(), configuredSound.getSoundEvent(), SoundSource.BLOCKS, configuredSound.getPitch(), configuredSound.getVolume());
}
}
Expand Down

0 comments on commit 143d4bf

Please sign in to comment.