Class ForgeSoundType

java.lang.Object
net.minecraft.block.SoundType
net.minecraftforge.common.util.ForgeSoundType

public class ForgeSoundType extends SoundType
A subclass of SoundType that uses Supplier<SoundEvent>s.

This class allows mod developers to safely create custom SoundTypes for use in their e.g. Block.

The problem with using SoundType directly is it requires SoundEvent instances directly, because SoundTypes are required to be present during Block creation and registration. However, SoundEvent must also be registered.

A possible solution of initializing SoundEvents first would require static initialization of the SoundEvent instances and later registration, which goes against the contract of the registry system and prevents the use of DeferredRegister and RegistryObjects.

This class offers an alternative and preferable solution, by allowing mods to create SoundTypes using Suppliers of SoundEvents instead, which do not require static initialization of SoundEvents and allow the direct use of RegistryObjects.

See Also: