tutorial:sounds
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:sounds [2020/02/11 19:46] – Remove category from sounds.json. It was removed in Minecraft 1.10 earthcomputer | tutorial:sounds [2020/06/20 04:04] – add ; to code hydos | ||
---|---|---|---|
Line 7: | Line 7: | ||
if (!world.isClient) { | if (!world.isClient) { | ||
world.playSound( | world.playSound( | ||
- | null, // Player | + | null, // Player |
blockPos, // The position of where the sound will come from | blockPos, // The position of where the sound will come from | ||
SoundEvents.BLOCK_ANVIL_LAND, | SoundEvents.BLOCK_ANVIL_LAND, | ||
Line 17: | Line 17: | ||
</ | </ | ||
- | You can do this when the block is right clicked for example, by overriding '' | + | You can do this when the block is right clicked for example, by overriding '' |
<code java> | <code java> | ||
public class ExampleBlock extends Block { | public class ExampleBlock extends Block { | ||
Line 23: | Line 23: | ||
| | ||
@Override | @Override | ||
- | public | + | public |
if (!world.isClient) { | if (!world.isClient) { | ||
world.playSound(null, | world.playSound(null, | ||
Line 69: | Line 69: | ||
public class ExampleMod { | public class ExampleMod { | ||
[...] | [...] | ||
- | public static final Identifier MY_SOUND_ID = new Identifier(" | + | public static final Identifier MY_SOUND_ID = new Identifier(" |
public static SoundEvent MY_SOUND_EVENT = new SoundEvent(MY_SOUND_ID); | public static SoundEvent MY_SOUND_EVENT = new SoundEvent(MY_SOUND_ID); | ||
} | } | ||
Line 83: | Line 83: | ||
</ | </ | ||
==== Step 5: Use your sound event ==== | ==== Step 5: Use your sound event ==== | ||
- | Use the sound event just like we explained at the start ('' | + | Use the sound event just like we explained at the start ('' |
<code java> | <code java> | ||
public class ExampleBlock extends Block { | public class ExampleBlock extends Block { | ||
@Override | @Override | ||
- | public | + | public |
if (!world.isClient) { | if (!world.isClient) { | ||
world.playSound( | world.playSound( | ||
- | null, // Player | + | null, // Player |
blockPos, // The position of where the sound will come from | blockPos, // The position of where the sound will come from | ||
ExampleMod.MY_SOUND_EVENT, | ExampleMod.MY_SOUND_EVENT, |
tutorial/sounds.txt · Last modified: 2023/01/09 18:20 by slainlight