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 [2019/08/01 20:28] – fudge | tutorial:sounds [2020/02/11 19:46] – Remove category from sounds.json. It was removed in Minecraft 1.10 earthcomputer | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Playing Sounds ====== | ====== Playing Sounds ====== | ||
- | Ready to replace those zombie sounds with your own cool sounds? You've come to the right place. | + | Ready to replace those zombie sounds with your own sounds? You've come to the right place. |
===== Playing a pre-existing sound ===== | ===== Playing a pre-existing sound ===== | ||
Line 20: | Line 20: | ||
<code java> | <code java> | ||
public class ExampleBlock extends Block { | public class ExampleBlock extends Block { | ||
- | ... | + | |
+ | | ||
@Override | @Override | ||
public boolean activate(BlockState blockState, World world, BlockPos blockPos, PlayerEntity placedBy, Hand hand, BlockHitResult blockHitResult) { | public boolean activate(BlockState blockState, World world, BlockPos blockPos, PlayerEntity placedBy, Hand hand, BlockHitResult blockHitResult) { | ||
Line 50: | Line 51: | ||
} | } | ||
</ | </ | ||
- | You can also add a category and subtitle to your sound: | + | You can also add a subtitle to your sound. The subtitle is a translation key, which should go in your language file. |
<code javascript resources/ | <code javascript resources/ | ||
{ | { | ||
" | " | ||
- | | + | " |
- | | + | |
" | " | ||
" | " | ||
Line 62: | Line 62: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | See the [[https:// | ||
==== Step 3: Create your sound event ==== | ==== Step 3: Create your sound event ==== | ||
Simply create a new instance of '' | Simply create a new instance of '' | ||
<code java> | <code java> | ||
public class ExampleMod { | public class ExampleMod { | ||
- | ... | + | |
- | public static | + | public static |
+ | public static SoundEvent MY_SOUND_EVENT = new SoundEvent(MY_SOUND_ID); | ||
} | } | ||
</ | </ | ||
Line 75: | Line 78: | ||
@Override | @Override | ||
public void onInitialize(){ | public void onInitialize(){ | ||
- | ... | + | [...] |
- | | + | |
} | } | ||
</ | </ |
tutorial/sounds.txt · Last modified: 2023/01/09 18:20 by slainlight