Skip to content

Commit

Permalink
insert explosion gif here
Browse files Browse the repository at this point in the history
  • Loading branch information
TropheusJ committed Aug 25, 2023
1 parent cc47d64 commit 4e61c21
Showing 1 changed file with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4e61c21

Please sign in to comment.