Class ForgeSoundType
SoundType
that uses Supplier<SoundEvent>
s.
This class allows mod developers to safely create custom SoundType
s for use in their e.g. Block
.
The problem with using SoundType
directly is it requires SoundEvent
instances directly, because
SoundType
s are required to be present during Block
creation and registration. However,
SoundEvent
must also be registered.
A possible solution of initializing SoundEvent
s 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 RegistryObject
s.
This class offers an alternative and preferable solution, by allowing mods to create SoundType
s using
Supplier
s of SoundEvent
s instead, which do not require static initialization of SoundEvent
s
and allow the direct use of RegistryObject
s.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Supplier<SoundEvent>
private final Supplier<SoundEvent>
private final Supplier<SoundEvent>
private final Supplier<SoundEvent>
private final Supplier<SoundEvent>
Fields inherited from class net.minecraft.block.SoundType
ANCIENT_DEBRIS, ANVIL, BAMBOO, BAMBOO_SAPLING, BASALT, BONE_BLOCK, CHAIN, CORAL_BLOCK, CROP, FUNGUS, GILDED_BLACKSTONE, GLASS, GRASS, GRAVEL, HARD_CROP, HONEY_BLOCK, LADDER, LANTERN, LILY_PAD, LODESTONE, METAL, NETHER_BRICKS, NETHER_GOLD_ORE, NETHER_ORE, NETHER_SPROUTS, NETHER_WART, NETHERITE_BLOCK, NETHERRACK, NYLIUM, pitch, ROOTS, SAND, SCAFFOLDING, SHROOMLIGHT, SLIME_BLOCK, SNOW, SOUL_SAND, SOUL_SOIL, STEM, STONE, SWEET_BERRY_BUSH, TWISTING_VINES, VINE, volume, WART_BLOCK, WEEPING_VINES, WET_GRASS, WOOD, WOOL
-
Constructor Summary
ConstructorDescriptionForgeSoundType
(float volumeIn, float pitchIn, Supplier<SoundEvent> breakSoundIn, Supplier<SoundEvent> stepSoundIn, Supplier<SoundEvent> placeSoundIn, Supplier<SoundEvent> hitSoundIn, Supplier<SoundEvent> fallSoundIn) -
Method Summary
Modifier and TypeMethodDescription
-
Field Details
-
breakSound
-
stepSound
-
placeSound
-
hitSound
-
fallSound
-
-
Constructor Details
-
ForgeSoundType
public ForgeSoundType(float volumeIn, float pitchIn, Supplier<SoundEvent> breakSoundIn, Supplier<SoundEvent> stepSoundIn, Supplier<SoundEvent> placeSoundIn, Supplier<SoundEvent> hitSoundIn, Supplier<SoundEvent> fallSoundIn)
-
-
Method Details
-
getBreakSound
- Overrides:
getBreakSound
in classSoundType
-
getStepSound
- Overrides:
getStepSound
in classSoundType
-
getPlaceSound
- Overrides:
getPlaceSound
in classSoundType
-
getHitSound
- Overrides:
getHitSound
in classSoundType
-
getFallSound
- Overrides:
getFallSound
in classSoundType
-