효과 — Sponge 7.1.0 documentation
효과¶
Now let's break this down. First, the SoundType specifies the sound that will be played. Next, we have a Vector3d position. This position can be constructed, or it can be retrieved from a Location using the Location#getPosition() method. In the example above, the sound will be played at the coordinates 1, 65, 1. Lastly, we have the volume that the sound will be played at. The volume is a double that ranges from zero to two.
Now that we can play basic sounds, we can go further in-depth with our sounds. Let's say we wanted to play our sound at a specified pitch. We can use the PitchModulation class to modulate the pitch to a specified note. We can also use a SoundCategory to specify what sound category we are playing. An example of these are shown below:
If a SoundCategory isn't specified when playing a sound, SoundCategories#MASTER will be used.
Now if we wanted to make a more specific particle, say the particle of a block, then we can use one of the several types found in the ParticleTypes class. For example, let's say we wanted to spawn particles of a cracking block of sand, ParticleTypes#BLOCK_CRACK. We would need to use the ParticleOptions#BLOCK_STATE option and specify that we would like to use a sand block. This can be done like so: