Jump to content

Recommended Posts

Posted

I have made an item but when i do right click it doesn't play my sound.

 

The .ogg is in assets/azureusnation/sound/

 

Here is my code.

 

Main Class

 

 

package com.azureusnation.mod;

 

import com.azureusnation.mod.cards.main.Cards;

import com.azureusnation.mod.proxy.CommonProxy;

 

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

 

@Mod( modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION )

@NetworkMod( channels = {ModInfo.CHANNEL}, clientSideRequired = true, serverSideRequired = true )

public class Main {

 

@SidedProxy( clientSide = ModInfo.PROXY_LOCATION + ".ClientProxy", serverSide = ModInfo.PROXY_LOCATION + ".CommonProxy")

public static CommonProxy proxy;

 

@EventHandler

public static void preInit(FMLPreInitializationEvent event) {

proxy.initRenderers();

proxy.initSounds();

 

Cards.init();

}

 

@EventHandler

public static void init(FMLInitializationEvent event) {

Cards.addNames();

 

}

 

@EventHandler

public static void postInit(FMLPostInitializationEvent event) {

 

}

 

}

 

 

 

Proxy

 

 

package com.azureusnation.mod.proxy;

 

import com.azureusnation.mod.lib.SoundHandler;

 

import net.minecraftforge.common.MinecraftForge;

 

public class ClientProxy extends CommonProxy {

 

@Override

public void initRenderers() {

 

}

 

@Override

public void initSounds() {

MinecraftForge.EVENT_BUS.register(new SoundHandler());

}

 

}

 

 

 

Sound Handler

 

 

package com.azureusnation.mod.lib;

 

import com.azureusnation.mod.ModInfo;

 

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

import net.minecraftforge.event.ForgeSubscribe;

 

public class SoundHandler {

 

@ForgeSubscribe

public void onSound(SoundLoadEvent event) {

event.manager.addSound(ModInfo.ID.toLowerCase() + ":" + "cardeffect.ogg");

}

 

}

 

 

 

Item

 

 

package com.azureusnation.mod.cards;

 

import java.util.List;

 

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.EnumRarity;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.potion.Potion;

import net.minecraft.potion.PotionEffect;

import net.minecraft.world.World;

 

import com.azureusnation.mod.ModInfo;

import com.azureusnation.mod.lib.Names;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class DieHard extends Item {

 

public DieHard(int id) {

super(id);

this.setUnlocalizedName(Names.dieHard_unlocalizedName);

this.setMaxStackSize(1);

this.setCreativeTab(CreativeTabs.tabMisc);

}

 

public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {

 

par2World.playSoundAtEntity(par3EntityPlayer, ModInfo.ID.toLowerCase() + ":" + "cardeffect.ogg", 1.0f, 1.0f);

 

if (!par2World.isRemote)

{

if (!par3EntityPlayer.capabilities.isCreativeMode)

{

--par1ItemStack.stackSize;

}

 

par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.field_76434_w.id, 1200, 4));

}

return par1ItemStack;

}

 

@SideOnly(Side.CLIENT)

public boolean hasEffect(ItemStack par1ItemStack) {

return true;

}

 

public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4)

    {

par3List.add("Rarity: \u00A74EPIC");

par3List.add("Duration: 1:00");

par3List.add("מער הערצער ווי קען זייַן געוויינט");

    }

 

@Override

@SideOnly(Side.CLIENT)

public void registerIcons(IconRegister icon) {

itemIcon = icon.registerIcon(ModInfo.ID.toLowerCase() + ":" + "diehard");

}

 

}

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.