Class DeferredSoundType
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 DeferredHolders.
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:
-
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, CACTUS_FLOWER, CALCITE, CANDLE, CAVE_VINES, CHAIN, CHERRY_LEAVES, CHERRY_SAPLING, CHERRY_WOOD, CHERRY_WOOD_HANGING_SIGN, CHISELED_BOOKSHELF, COBWEB, COPPER, COPPER_BULB, COPPER_GRATE, CORAL_BLOCK, CREAKING_HEART, CROP, DECORATED_POT, DECORATED_POT_CRACKED, DEEPSLATE, DEEPSLATE_BRICKS, DEEPSLATE_TILES, DRIED_GHAST, DRIPSTONE_BLOCK, EMPTY, FLOWERING_AZALEA, FROGLIGHT, FROGSPAWN, FUNGUS, GILDED_BLACKSTONE, GLASS, GLOW_LICHEN, GRASS, GRAVEL, HANGING_ROOTS, HANGING_SIGN, HARD_CROP, HEAVY_CORE, HONEY_BLOCK, IRON, LADDER, LANTERN, LARGE_AMETHYST_BUD, LEAF_LITTER, 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, POLISHED_TUFF, POWDER_SNOW, RESIN, RESIN_BRICKS, 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, SPAWNER, SPONGE, SPORE_BLOSSOM, STEM, STONE, SUSPICIOUS_GRAVEL, SUSPICIOUS_SAND, SWEET_BERRY_BUSH, TRIAL_SPAWNER, TUFF, TUFF_BRICKS, TWISTING_VINES, VAULT, VINE, volume, WART_BLOCK, WEEPING_VINES, WET_GRASS, WET_SPONGE, WOOD, WOOL -
Constructor Summary
ConstructorsConstructorDescriptionDeferredSoundType(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
-
DeferredSoundType
public DeferredSoundType(float volumeIn, float pitchIn, Supplier<SoundEvent> breakSoundIn, Supplier<SoundEvent> stepSoundIn, Supplier<SoundEvent> placeSoundIn, Supplier<SoundEvent> hitSoundIn, Supplier<SoundEvent> fallSoundIn)
-
-
Method Details
-
getBreakSound
- Overrides:
getBreakSoundin classSoundType
-
getStepSound
- Overrides:
getStepSoundin classSoundType
-
getPlaceSound
- Overrides:
getPlaceSoundin classSoundType
-
getHitSound
- Overrides:
getHitSoundin classSoundType
-
getFallSound
- Overrides:
getFallSoundin classSoundType
-