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
FieldsModifier 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.world.level.block.SoundType
AMETHYST, AMETHYST_CLUSTER, ANCIENT_DEBRIS, ANVIL, AZALEA, AZALEA_LEAVES, BAMBOO, BAMBOO_SAPLING, BAMBOO_WOOD, BAMBOO_WOOD_HANGING_SIGN, BASALT, BIG_DRIPLEAF, BONE_BLOCK, CALCITE, CANDLE, CAVE_VINES, CHAIN, CHERRY_LEAVES, CHERRY_SAPLING, CHERRY_WOOD, CHERRY_WOOD_HANGING_SIGN, CHISELED_BOOKSHELF, COPPER, CORAL_BLOCK, CROP, DECORATED_POT, DECORATED_POT_CRACKED, DEEPSLATE, DEEPSLATE_BRICKS, DEEPSLATE_TILES, DRIPSTONE_BLOCK, EMPTY, FLOWERING_AZALEA, FROGLIGHT, FROGSPAWN, FUNGUS, GILDED_BLACKSTONE, GLASS, GLOW_LICHEN, GRASS, GRAVEL, HANGING_ROOTS, HANGING_SIGN, HARD_CROP, HONEY_BLOCK, LADDER, LANTERN, LARGE_AMETHYST_BUD, LILY_PAD, LODESTONE, MANGROVE_ROOTS, MEDIUM_AMETHYST_BUD, METAL, MOSS, MOSS_CARPET, MUD, MUD_BRICKS, MUDDY_MANGROVE_ROOTS, NETHER_BRICKS, NETHER_GOLD_ORE, NETHER_ORE, NETHER_SPROUTS, NETHER_WART, NETHER_WOOD, NETHER_WOOD_HANGING_SIGN, NETHERITE_BLOCK, NETHERRACK, NYLIUM, PACKED_MUD, PINK_PETALS, pitch, POINTED_DRIPSTONE, POLISHED_DEEPSLATE, POWDER_SNOW, ROOTED_DIRT, ROOTS, SAND, SCAFFOLDING, SCULK, SCULK_CATALYST, SCULK_SENSOR, SCULK_SHRIEKER, SCULK_VEIN, SHROOMLIGHT, SLIME_BLOCK, SMALL_AMETHYST_BUD, SMALL_DRIPLEAF, SNOW, SOUL_SAND, SOUL_SOIL, SPORE_BLOSSOM, STEM, STONE, SUSPICIOUS_GRAVEL, SUSPICIOUS_SAND, SWEET_BERRY_BUSH, TUFF, TWISTING_VINES, VINE, volume, WART_BLOCK, WEEPING_VINES, WET_GRASS, WOOD, WOOL
-
Constructor Summary
ConstructorsConstructorDescriptionForgeSoundType
(float volumeIn, float pitchIn, Supplier<SoundEvent> breakSoundIn, Supplier<SoundEvent> stepSoundIn, Supplier<SoundEvent> placeSoundIn, Supplier<SoundEvent> hitSoundIn, Supplier<SoundEvent> fallSoundIn) -
Method Summary
Modifier and TypeMethodDescription@NotNull SoundEvent
@NotNull SoundEvent
@NotNull SoundEvent
@NotNull SoundEvent
@NotNull SoundEvent
-
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
-