Class LoopingLightEnergyBlockSound

java.lang.Object
net.minecraft.client.resources.sounds.AbstractSoundInstance
net.minecraft.client.resources.sounds.AbstractTickableSoundInstance
etithespirit.orimod.client.audio.LoopingLightEnergyBlockSound
All Implemented Interfaces:
net.minecraft.client.resources.sounds.SoundInstance, net.minecraft.client.resources.sounds.TickableSoundInstance

public class LoopingLightEnergyBlockSound extends net.minecraft.client.resources.sounds.AbstractTickableSoundInstance
This class serves as the housing for a Light tech device's ambient loop sound. It is intended for use where there is a startup, loop, and shutdown sound.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.minecraft.client.resources.sounds.SoundInstance

    net.minecraft.client.resources.sounds.SoundInstance.Attenuation
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float
    The baseline volume that is used when playing any of the sounds involved.
    final net.minecraft.world.level.block.entity.BlockEntity
    The block this exists for.
    Identical to block with the exception that it is stored as an ILightEnergyStorage.
    double
    Because some devices may gain and spend energy at different intervals, it is possible for start/stop calls to be spammed.
    protected boolean
    Whether or not the startup sound has played.
    protected double
    The last tracked ratio of energy.
    This action executes when the sound ends due to energy going from nonzero to zero
    This action executes when the sound begins due to energy going from zero to nonzero
    This action executes when the sound ends due to its removal
    boolean
    If true, the startup action will be called when this instance is enqueued.
    protected float
    The "warmth" of the audio is used for a brief fade-in period to make the transition from the start sound to the loop sound less jarring.

    Fields inherited from class net.minecraft.client.resources.sounds.AbstractSoundInstance

    attenuation, delay, location, looping, pitch, random, relative, sound, source, volume, x, y, z
  • Constructor Summary

    Constructors
    Constructor
    Description
    LoopingLightEnergyBlockSound(net.minecraft.world.level.block.entity.BlockEntity blockEntity, net.minecraft.sounds.SoundEvent loop)
    Create a new looping energy sound for the given block entity.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    boolean
     
    protected double
    getVolumeForDistance(double maxDistance, double max)
    Returns the volume for the given distance via a linear falloff.
    void
    Resets the audio data associated with this sound, intended for use once it has stopped for whatever reason.
    void
     

    Methods inherited from class net.minecraft.client.resources.sounds.AbstractTickableSoundInstance

    isStopped, stop

    Methods inherited from class net.minecraft.client.resources.sounds.AbstractSoundInstance

    getAttenuation, getDelay, getLocation, getPitch, getSound, getSource, getVolume, getX, getY, getZ, isLooping, isRelative, resolve, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface net.minecraft.client.resources.sounds.SoundInstance

    getAttenuation, getDelay, getLocation, getPitch, getSound, getSource, getStream, getVolume, getX, getY, getZ, isLooping, isRelative, resolve
  • Field Details

    • block

      public final net.minecraft.world.level.block.entity.BlockEntity block
      The block this exists for.
    • energy

      public final ILightEnergyStorage energy
      Identical to block with the exception that it is stored as an ILightEnergyStorage.
    • onStartup

      public Runnable onStartup
      This action executes when the sound begins due to energy going from zero to nonzero
    • onShutdown

      public Runnable onShutdown
      This action executes when the sound ends due to energy going from nonzero to zero
    • onTermination

      public Runnable onTermination
      This action executes when the sound ends due to its removal
    • energyPercentThreshold

      public double energyPercentThreshold
      Because some devices may gain and spend energy at different intervals, it is possible for start/stop calls to be spammed. This value is a threshold for how full the energy device must be (as a percentage) to trigger a start/stop.
    • baseVolume

      public float baseVolume
      The baseline volume that is used when playing any of the sounds involved.
    • playStartupOnLoad

      public boolean playStartupOnLoad
      If true, the startup action will be called when this instance is enqueued.
    • lastRatio

      protected double lastRatio
      The last tracked ratio of energy.
    • hasPlayedStartup

      protected boolean hasPlayedStartup
      Whether or not the startup sound has played.
    • warmth

      protected float warmth
      The "warmth" of the audio is used for a brief fade-in period to make the transition from the start sound to the loop sound less jarring.
  • Constructor Details

    • LoopingLightEnergyBlockSound

      public LoopingLightEnergyBlockSound(net.minecraft.world.level.block.entity.BlockEntity blockEntity, net.minecraft.sounds.SoundEvent loop) throws IllegalArgumentException
      Create a new looping energy sound for the given block entity.
      Parameters:
      blockEntity - The block entity to play for.
      loop - The loop sound.
      Throws:
      IllegalArgumentException - If the given input block entity does not implement ILightEnergyStorage
  • Method Details

    • canPlaySound

      public boolean canPlaySound()
    • canStartSilent

      public boolean canStartSilent()
    • tick

      public void tick()
    • reset

      public void reset()
      Resets the audio data associated with this sound, intended for use once it has stopped for whatever reason.
    • getVolumeForDistance

      protected double getVolumeForDistance(double maxDistance, double max)
      Returns the volume for the given distance via a linear falloff.
      Parameters:
      maxDistance - The distance from which the volume will be 0.
      max - The maximum volume (at distance=0)
      Returns:
      A value between 0 and (max) based on the camera entity's distance.