Package etithespirit.orimod.apiimpl
Class SpiritSoundAPI
java.lang.Object
etithespirit.orimod.apiimpl.SpiritSoundAPI
- All Implemented Interfaces:
ISpiritSoundAPI
An implementation of the spirit sound API, which is used if the mod is installed.
- Author:
- Eti
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 givenISpiritMaterialAcquisitionFunction
which can be used to conditionally return aSpiritMaterial
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 givenISpiritMaterialAcquisitionFunction
which can be used to conditionally return aSpiritMaterial
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.
-
Constructor Details
-
SpiritSoundAPI
public SpiritSoundAPI()
-
-
Method Details
-
isInstalled
public boolean isInstalled()Description copied from interface:ISpiritSoundAPI
MUST BE CHECKED BEFORE OTHER METHODS ARE USED. This validates that the mod is actually installed by the user.- Specified by:
isInstalled
in interfaceISpiritSoundAPI
- Returns:
- Whether or not the API is installed.
-
registerSpiritStepSound
public void registerSpiritStepSound(net.minecraft.world.level.block.Block entireBlockType, SpiritMaterial material) throws ArgumentNullException, IllegalStateException Description copied from interface:ISpiritSoundAPI
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 callingISpiritSoundAPI.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.- Specified by:
registerSpiritStepSound
in interfaceISpiritSoundAPI
- Parameters:
entireBlockType
- The block that will have its sounds replaced for Spiritsmaterial
- The material dictating the unique sound played.- Throws:
IllegalStateException
- If mod initialization has completed, or ifISpiritSoundAPI.isInstalled()
returns false. This MUST be called before mod loading is complete.ArgumentNullException
-
registerSpiritStepSound
public void registerSpiritStepSound(net.minecraft.world.level.block.state.BlockState specificState, SpiritMaterial material) throws ArgumentNullException, IllegalStateException Description copied from interface:ISpiritSoundAPI
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.- Specified by:
registerSpiritStepSound
in interfaceISpiritSoundAPI
- Parameters:
specificState
- The block in a specific state that will have its sounds replaced for Spiritsmaterial
- The material dictating the unique sound played.- Throws:
IllegalStateException
- If mod initialization has completed, or ifISpiritSoundAPI.isInstalled()
returns false. This MUST be called before mod loading is complete.ArgumentNullException
-
setUseIfIn
public void setUseIfIn(net.minecraft.world.level.block.Block entireBlockType) throws ArgumentNullException, IllegalStateException Description copied from interface:ISpiritSoundAPI
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.- Specified by:
setUseIfIn
in interfaceISpiritSoundAPI
- Parameters:
entireBlockType
- The block from which all states will be tested for occupancy rather than being stepped on.- Throws:
IllegalStateException
- If mod initialization has completed, or ifISpiritSoundAPI.isInstalled()
returns false. This MUST be called before mod loading is complete.ArgumentNullException
-
setUseIfIn
public void setUseIfIn(net.minecraft.world.level.block.state.BlockState specificState) throws ArgumentNullException, IllegalStateException Description copied from interface:ISpiritSoundAPI
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.- Specified by:
setUseIfIn
in interfaceISpiritSoundAPI
- Parameters:
specificState
- The BlockState that will be tested for occupancy rather than being stepped on.- Throws:
IllegalStateException
- If mod initialization has completed, or ifISpiritSoundAPI.isInstalled()
returns false. This MUST be called before mod loading is complete.ArgumentNullException
-
associateMaterialWith
public void associateMaterialWith(net.minecraft.world.level.material.Material material, SpiritMaterial spiritMaterial) throws ArgumentNullException, IllegalArgumentException, IllegalStateException Description copied from interface:ISpiritSoundAPI
Associates the given custom material with a given SpiritMaterial.- Specified by:
associateMaterialWith
in interfaceISpiritSoundAPI
- Parameters:
material
- The material to associate.spiritMaterial
- TheSpiritMaterial
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 ifISpiritSoundAPI.isInstalled()
returns false. This MUST be called before mod loading is complete.
-
setSpecialMaterialPredicate
public void setSpecialMaterialPredicate(net.minecraft.world.level.block.Block entireBlockType, ISpiritMaterialAcquisitionFunction getter) throws ArgumentNullException, IllegalStateException Description copied from interface:ISpiritSoundAPI
Associates the entire block type with the givenISpiritMaterialAcquisitionFunction
which can be used to conditionally return aSpiritMaterial
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.- Specified by:
setSpecialMaterialPredicate
in interfaceISpiritSoundAPI
- Parameters:
entireBlockType
- The type of the block that this function will run on.getter
- TheISpiritMaterialAcquisitionFunction
used to determine the appropriate material.- Throws:
ArgumentNullException
- If the input block type or getter is null.IllegalStateException
- If mod initialization has completed, or ifISpiritSoundAPI.isInstalled()
returns false. This MUST be called before mod loading is complete.
-
setSpecialMaterialPredicate
public void setSpecialMaterialPredicate(net.minecraft.world.level.material.Material material, ISpiritMaterialAcquisitionFunction getter) throws ArgumentNullException, IllegalArgumentException, IllegalStateException Description copied from interface:ISpiritSoundAPI
Associates the entire material with the givenISpiritMaterialAcquisitionFunction
which can be used to conditionally return aSpiritMaterial
best suited for the material of the block the entity is standing on and/or within.- Specified by:
setSpecialMaterialPredicate
in interfaceISpiritSoundAPI
- Parameters:
material
- The type of the material that this function will run on.getter
- TheISpiritMaterialAcquisitionFunction
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 ifISpiritSoundAPI.isInstalled()
returns false. This MUST be called before mod loading is complete.
-