提供: Minecraft Modding Wiki
この編集を取り消せます。
下記の差分を確認して、本当に取り消していいか検証してください。よろしければ変更を保存して取り消しを完了してください。
最新版 | 編集中の文章 | ||
1行目: | 1行目: | ||
{{前提MOD|reqmod="Fabric API 0.3.2 build 230~"}} | {{前提MOD|reqmod="Fabric API 0.3.2 build 230~"}} | ||
{{チュートリアル難易度|difficulty=0|clear=none}} | {{チュートリアル難易度|difficulty=0|clear=none}} | ||
− | |||
− | |||
− | |||
<p>再生できるサウンドの追加方法</p> | <p>再生できるサウンドの追加方法</p> | ||
==サウンドの追加== | ==サウンドの追加== | ||
20行目: | 17行目: | ||
public class SampleMod implements ModInitializer { | public class SampleMod implements ModInitializer { | ||
− | public static final Identifier SAMPLE_SOUND_ID = new Identifier(" | + | public static final Identifier SAMPLE_SOUND_ID = new Identifier(MOD_ID":sample_sound") |
public static SoundEvent SAMPLE_SOUND_EVENT = new SoundEvent(SAMPLE_SOUND_ID); | public static SoundEvent SAMPLE_SOUND_EVENT = new SoundEvent(SAMPLE_SOUND_ID); | ||
29行目: | 26行目: | ||
} | } | ||
</source> | </source> | ||
− | |||
==サウンドの再生== | ==サウンドの再生== | ||
− | |||
*SampleBlock.java | *SampleBlock.java | ||
<source lang = "java"> | <source lang = "java"> | ||
65行目: | 60行目: | ||
public class SampleItem extends Item | public class SampleItem extends Item | ||
{ | { | ||
− | public SampleItem(Settings | + | public SampleItem(Settings item$Settings_SampleItem) { |
− | super( | + | super(item$Settings_SampleItem); |
} | } | ||
@Override | @Override | ||
73行目: | 68行目: | ||
playerEntity.playSound(SampleMod.SAMPLE_SOUND_EVENT, 1.0F, 1.0F); | playerEntity.playSound(SampleMod.SAMPLE_SOUND_EVENT, 1.0F, 1.0F); | ||
return new TypedActionResult<>(ActionResult.SUCCESS, playerEntity.getStackInHand(hand)); | return new TypedActionResult<>(ActionResult.SUCCESS, playerEntity.getStackInHand(hand)); | ||
− | |||
− | |||
} | } | ||
} | } | ||
</source> | </source> | ||
− | |||
==解説== | ==解説== | ||
<source lang = "java"> | <source lang = "java"> |