3 déc. 2013, 19:27

Bonjour,
J’ai suivi le tuto et créé un item pour jouer un son (une jukebox), mais quand je fais un clic droit, rien ne se passe.
Pouvez-vous m’aider ?

Classe principale :


if(event.getSide().isClient())
{
MinecraftForge.EVENT_BUS.register(new SoundEvent());
}

jukeBox1 = (new ItemJukebox1(jukeBox1ID)).setUnlocalizedName("JukeBox1").setTextureName("dragons:jukebox_1");
GameRegistry.registerItem(jukeBox1, "Jukebox 1", "Dragons");

ItemJukebox1 :


package fr.MrBlockTNT.Dragons.item;

import fr.MrBlockTNT.Dragons.core.Dragons;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class ItemJukebox1 extends Item
{
public ItemJukebox1(int id)
{
super(id);
this.setCreativeTab(Dragons.DragonsTab);
}

public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
{
world.playSoundAtEntity(player, "dragons:boss/fire_dragon", 1.0F, 1.0F);
return stack;
}
}

SoundEvent :


package fr.MrBlockTNT.Dragons.event;

import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;

public class SoundEvent
{
@ForgeSubscribe
public void onSound(SoundLoadEvent event)
{
try
{
event.manager.addMusic("dragons:boss/boss_end.ogg");
event.manager.addMusic("dragons:boss/fire_dragon.ogg");
event.manager.addMusic("dragons:boss/fire_dragon_second_half.ogg");
}
catch(Exception e)
{
System.out.println("Failed to registry sound");
}
}
}