Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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");

}

 

}

 

 

You should use:

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.