Interface ISpiritSoundAPI

All Known Implementing Classes:
SpiritSoundAPI

public interface ISpiritSoundAPI
An API providing a means of registering custom sounds for when a spirit walks on your blocks or materials.
Author:
Eti
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    associateMaterialWith(net.minecraft.world.level.material.Material material, SpiritMaterial spiritMaterial)
    Associates the given custom material with a given SpiritMaterial.
    boolean
    MUST BE CHECKED BEFORE OTHER METHODS ARE USED. This validates that the mod is actually installed by the user.
    void
    registerSpiritStepSound(net.minecraft.world.level.block.Block entireBlockType, SpiritMaterial material)
    Associates all states of the given block with the given material's sound.
    void
    registerSpiritStepSound(net.minecraft.world.level.block.state.BlockState specificState, SpiritMaterial material)
    Associates the specific block state to the given material's sound.
    void
    setSpecialMaterialPredicate(net.minecraft.world.level.block.Block entireBlockType, ISpiritMaterialAcquisitionFunction getter)
    Associates the entire block type with the given ISpiritMaterialAcquisitionFunction which can be used to conditionally return a SpiritMaterial best suited for the block the entity is standing on and/or within.
    Note that this does not have a variant for a specific BlockState.
    void
    setSpecialMaterialPredicate(net.minecraft.world.level.material.Material material, ISpiritMaterialAcquisitionFunction getter)
    Associates the entire material with the given ISpiritMaterialAcquisitionFunction which can be used to conditionally return a SpiritMaterial best suited for the material of the block the entity is standing on and/or within.
    void
    setUseIfIn(net.minecraft.world.level.block.Block entireBlockType)
    If called, then all states of the given block will play their custom step sound if the player is walking in the same BlockPos rather than on top of it.
    void
    setUseIfIn(net.minecraft.world.level.block.state.BlockState specificState)
    If called, then the specific BlockState will play its custom step sound if the player is walking in the same BlockPos rather than on top of it.
  • Method Details

    • isInstalled

      boolean isInstalled()
      MUST BE CHECKED BEFORE OTHER METHODS ARE USED. This validates that the mod is actually installed by the user.
      Returns:
      Whether or not the API is installed.
    • registerSpiritStepSound

      void registerSpiritStepSound(net.minecraft.world.level.block.Block entireBlockType, SpiritMaterial material) throws ArgumentNullException, IllegalStateException
      Associates all states of the given block with the given material's sound. When a player walks on this block, and if they are currently a spirit, the sound associated with the given SpiritMaterial will play instead of the vanilla sound.

      Note that setting a block will not override definitions for any of its child states (if they have been defined). This means that setting the entire block to a given material with this method, and then calling registerSpiritStepSound(BlockState, SpiritMaterial) for a number of specific states of this block, is a perfectly valid method of providing a general default with deviations for special cases. The order in which these are called does not matter.
      Parameters:
      entireBlockType - The block that will have its sounds replaced for Spirits
      material - The material dictating the unique sound played.
      Throws:
      IllegalArgumentException - If the input block or material is null.
      IllegalStateException - If mod initialization has completed, or if isInstalled() returns false. This MUST be called before mod loading is complete.
      ArgumentNullException
    • registerSpiritStepSound

      void registerSpiritStepSound(net.minecraft.world.level.block.state.BlockState specificState, SpiritMaterial material) throws ArgumentNullException, IllegalStateException
      Associates the specific block state to the given material's sound. When a player walks on this block, and if they are currently a spirit, the sound associated with the given SpiritMaterial will play instead of the vanilla sound.
      Parameters:
      specificState - The block in a specific state that will have its sounds replaced for Spirits
      material - The material dictating the unique sound played.
      Throws:
      IllegalArgumentException - If the input state or material is null.
      IllegalStateException - If mod initialization has completed, or if isInstalled() returns false. This MUST be called before mod loading is complete.
      ArgumentNullException
    • setUseIfIn

      void setUseIfIn(net.minecraft.world.level.block.Block entireBlockType) throws ArgumentNullException, IllegalStateException
      If called, then all states of the given block will play their custom step sound if the player is walking in the same BlockPos rather than on top of it. This is useful for things like snow layer blocks, which should cause the player to sound like they are walking in snow.
      Parameters:
      entireBlockType - The block from which all states will be tested for occupancy rather than being stepped on.
      Throws:
      IllegalArgumentException - If the input block is null.
      IllegalStateException - If mod initialization has completed, or if isInstalled() returns false. This MUST be called before mod loading is complete.
      ArgumentNullException
    • setUseIfIn

      void setUseIfIn(net.minecraft.world.level.block.state.BlockState specificState) throws ArgumentNullException, IllegalStateException
      If called, then the specific BlockState will play its custom step sound if the player is walking in the same BlockPos rather than on top of it. This is useful for things like snow layer blocks, which should cause the player to sound like they are walking in snow.
      Parameters:
      specificState - The BlockState that will be tested for occupancy rather than being stepped on.
      Throws:
      IllegalArgumentException - If the input block is null.
      IllegalStateException - If mod initialization has completed, or if isInstalled() returns false. This MUST be called before mod loading is complete.
      ArgumentNullException
    • associateMaterialWith

      void associateMaterialWith(net.minecraft.world.level.material.Material material, SpiritMaterial spiritMaterial) throws ArgumentNullException, IllegalArgumentException, IllegalStateException
      Associates the given custom material with a given SpiritMaterial.
      Parameters:
      material - The material to associate.
      spiritMaterial - The SpiritMaterial that will be associated with this custom material.
      Throws:
      ArgumentNullException - If the input material is null.
      IllegalArgumentException - If the input material is vanilla or defined by EtiMod.
      IllegalStateException - If mod initialization has completed, or if isInstalled() returns false. This MUST be called before mod loading is complete.
    • setSpecialMaterialPredicate

      void setSpecialMaterialPredicate(net.minecraft.world.level.block.Block entireBlockType, ISpiritMaterialAcquisitionFunction getter) throws ArgumentNullException, IllegalStateException
      Associates the entire block type with the given ISpiritMaterialAcquisitionFunction which can be used to conditionally return a SpiritMaterial best suited for the block the entity is standing on and/or within.
      Note that this does not have a variant for a specific BlockState. Registering for an entire Block will cause it to only be run when that block is either under the player or occupying the same space as that player. This means it is possible to get its state from the world.
      Parameters:
      entireBlockType - The type of the block that this function will run on.
      getter - The ISpiritMaterialAcquisitionFunction used to determine the appropriate material.
      Throws:
      ArgumentNullException - If the input block type or getter is null.
      IllegalStateException - If mod initialization has completed, or if isInstalled() returns false. This MUST be called before mod loading is complete.
    • setSpecialMaterialPredicate

      void setSpecialMaterialPredicate(net.minecraft.world.level.material.Material material, ISpiritMaterialAcquisitionFunction getter) throws ArgumentNullException, IllegalArgumentException, IllegalStateException
      Associates the entire material with the given ISpiritMaterialAcquisitionFunction which can be used to conditionally return a SpiritMaterial best suited for the material of the block the entity is standing on and/or within.
      Parameters:
      material - The type of the material that this function will run on.
      getter - The ISpiritMaterialAcquisitionFunction used to determine the appropriate material.
      Throws:
      ArgumentNullException - If the input material or getter is null.
      IllegalArgumentException - If the input material is vanilla or defined by EtiMod.
      IllegalStateException - If mod initialization has completed, or if isInstalled() returns false. This MUST be called before mod loading is complete.