From 4e61c21f71786fb0141f4abb5cb94fc2323023d8 Mon Sep 17 00:00:00 2001 From: TropheusJ Date: Fri, 25 Aug 2023 01:38:35 -0400 Subject: [PATCH] insert explosion gif here --- .../blockentities/LaserNodeBlockEntity.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/LaserNodeBlockEntity.java b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/LaserNodeBlockEntity.java index 60f58a3d..acdc1967 100644 --- a/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/LaserNodeBlockEntity.java +++ b/src/main/java/com/fusionflux/portalcubed/blocks/blockentities/LaserNodeBlockEntity.java @@ -122,21 +122,22 @@ protected void clientTick(BlockState state) { @Override public void tick() { - if ( - isRemoved() || - !LaserNodeBlockEntity.this.sound.equals(soundId) || - level == null || !level.getBlockState(worldPosition).getValue(BlockStateProperties.ENABLED) - ) { - musicInstance = null; - stop(); - } - if (!isCustomSound) return; - final Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); - final float newVolume = Mth.clampedLerp(0.01f, 1f, 1f - (float)cameraPos.subtract(x, y, z).length() / 16f); - if (newVolume != volume) { - volume = newVolume; - Minecraft.getInstance().getSoundManager().updateSourceVolume(null, 0); + if (level != null && !isRemoved() && LaserNodeBlockEntity.this.sound.equals(soundId)) { + BlockState state = level.getBlockState(worldPosition); + if (state.hasProperty(BlockStateProperties.ENABLED) && state.getValue(BlockStateProperties.ENABLED)) { + if (!isCustomSound) return; + final Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); + final float newVolume = Mth.clampedLerp(0.01f, 1f, 1f - (float)cameraPos.subtract(x, y, z).length() / 16f); + if (newVolume != volume) { + volume = newVolume; + Minecraft.getInstance().getSoundManager().updateSourceVolume(null, 0); + } + return; + } } + + musicInstance = null; + stop(); } }; Minecraft.getInstance().getSoundManager().play(musicInstance);