Dunno what's wrong... As of now, I'm only using the "gunnshot.ogg" but here's what I got:
SoundEvents.class
package assets.cutiesmod.common;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;
public class SoundEvents
{
@ForgeSubscribe
public void onSound(SoundLoadEvent event) {
// You add them the same way as you add blocks.
event.manager.addSound("cutiesmod:robocutiesay1.ogg");
event.manager.addSound("cutiesmod:robocutiesay2.ogg");
event.manager.addSound("cutiesmod:robocutiehurt.ogg");
event.manager.addSound("cutiesmod:robocutiedeath.ogg");
event.manager.addSound("cutiesmod:gunshot.ogg");
}
}
ClientProxy:
public void registerSound()
{
if(FMLCommonHandler.instance().getSide().isClient())
{
MinecraftForge.EVENT_BUS.register(new SoundEvents());
}
}
Gun being used:
package assets.cutiesmod.common;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemLaserRifle extends Item
{
public ItemLaserRifle(int id)
{
super(id);
this.setMaxStackSize(64);
this.setCreativeTab(CreativeTabs.tabMaterials);
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister reg)
{
this.itemIcon = reg.registerIcon(CutiesMod.modid + ":" + this.getUnlocalizedName());
}
public ItemStack onItemRightClick(ItemStack par1ItemStack, World WorldObject, EntityPlayer EntityPlayerObject)
{
if (!EntityPlayerObject.capabilities.isCreativeMode)
{
--par1ItemStack.stackSize;
}
WorldObject.playSoundAtEntity(EntityPlayerObject, "cutiesmod:gunshot", 1.0F, 1.0F);
if (!WorldObject.isRemote)
{
WorldObject.spawnEntityInWorld(new EntitySnowball(WorldObject, EntityPlayerObject));
}
return par1ItemStack;
}
}
One thing I noticed was, that the sound system definitely has a problem with names that contain an underscore or a dot.
After fiddling for some time without any error message I got it working when removing these characters from my folder name.
Other than that, this thread helped me alot, thanks you very much!
wait i an confused on the fluids. are you saying that i need to make a 2 classes? one for
public class TutFluid extends Fluid {
public TutFluid() {
super("TutorialFluid");
setDensity(10); // How tick the fluid is, affects movement inside the liquid.
setViscosity(1000); // How fast the fluid flows.
FluidRegistry.registerFluid(this); // Registering inside it self, keeps things neat
}}
and one for?
public class BlockTutFluid extends BlockFluidClassic {
public BlockTutFluid(int Id) {
super(id, ModTutorial.tutFluid, Material.water);
ModTutorial.tutFluid.setBlockID(id); // Set the fluids block ID to this block.
}
// Use Register Icon as usual to get the block's icon.
// If you want you can reuse the water texture and change the color of it by doing as I have below:
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta) {
return Block.waterMoving.getIcon(side, meta);
}
@Override
public int colorMultiplier(IBlockAccess iblockaccess, int x, int y, int z)
{
return 0x66FF00; // HEX color code as indicated by the 0x infront. This is a greenish color.
}
if so did i do this right?
this is whats in my mods class
public static Fluid CheeseFluid;
this is whats in my fluids class
package course.usefulemeraldmod;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
public class CheeseFluid extends Fluid {
public CheeseFluid() {
super("CheeseFluid");
setDensity(10); // How tick the fluid is, affects movement inside the liquid.
setViscosity(1000); // How fast the fluid flows.
FluidRegistry.registerFluid(this); // Registering inside it self, keeps things neat
}}
and this is whats in my block class
package course.usefulemeraldmod;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.BlockFluidClassic;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCheeseFluid extends BlockFluidClassic {
public BlockCheeseFluid(int Id) {
super(Id, ExampleMod.CheeseFluid, Material.water);
ExampleMod.CheeseFluid.setBlockID(1220); // Set the fluids block ID to this block.
}
// Use Register Icon as usual to get the block's icon.
// If you want you can reuse the water texture and change the color of it by doing as I have below:
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta) {
return Block.waterMoving.getIcon(side, meta);
}
@Override
public int colorMultiplier(IBlockAccess iblockaccess, int x, int y, int z)
{
return 0xE9DC4A; // HEX color code as indicated by the 0x infront. This is a greenish color.
}
}
idk if im putting it the wrong place or... error (WorldObject cannot be resolved) and (EntityPlayerObject cannot be resolved to a variable) and [/code]world.playSoundAtEntity(player,"modid:hit",1F,1F);[/code] world and player cannot be resolved... sorry. Im probably putting it in the wrong place or something lol
world and player cannot be resolved... sorry. Im probably putting it in the wrong place or something lol
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) {
this.itemIcon = iconRegister.registerIcon("theviking:ironlongsword32X32");
MinecraftForge.EVENT_BUS.register(new vikingsound()); // Name of the class containing the ForgeSubscribe above
WorldObject.playSoundAtEntity(EntityPlayerObject, "mod_id:hit", 1.0F, 1.0F);
world.playSoundAtEntity(player, "modid:hit", 1F, 1F);
}
}
public class vikingsound {
@ForgeSubscribe
public void onSound(SoundLoadEvent event) {
// You add them the same way as you add blocks.
event.manager.addSound("theviking:hit1.wav");
}
}
you are doing these things inside the registerIcons method:
MinecraftForge.EVENT_BUS.register(new vikingsound()); // Name of the class containing the ForgeSubscribe above
WorldObject.playSoundAtEntity(EntityPlayerObject, "mod_id:hit", 1.0F, 1.0F);
world.playSoundAtEntity(player, "modid:hit", 1F, 1F);
The event buss should not be registering inside your item, it should be called by your base mod file (or well in the client proxy).
the world.playSoundAtEntity should be placed where you want the sound to play.
You can't play a sound at a player when you register an icon, since there's no player and no world at the time of registration
For the liquid code, could you post the code on something like github so I can see all of it, because im not getting a complete picture, when there are only segments of code in the tutorial.
For the liquid code, could you post the code on something like github so I can see all of it, because im not getting a complete picture, when there are only segments of code in the tutorial.
If you know what you are doing, then you should be fine with snippets.
The things which aren't shown are things you should be able to create on your own as a pre-req. for this tutorial
For the liquid code, first of all the fluids themselves work fine, except they don't create new source blocks.
Second: the bucket code doesn't work, correctly, you have to create a new method for, the tryPlacecontainedLiquid
and event then the bucket doesn't place the liquid, when extending the Fluidcontainer, but when it extends Item bucket it places stone instead of the liquid.
If you know what you are doing, then you should be fine with snippets.
The things which aren't shown are things you should be able to create on your own as a pre-req. for this tutorial
change to:
return "monsterhunter:kirin";
Remember what I said about numbers in the end? ^^
Ok it still dont work
could i ask will my ogg still works coz i played it in VLC and my ogg's length is 3 sec and i test other ogg like the chicken its length is 1 sec could this is the problem or not
by the way check my codes out if there are errors of mine
My SoundEvent.class
package MHF;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;
public class MHFSoundEvents
{
@ForgeSubscribe
public void onSound(SoundLoadEvent event) {
// You add them the same way as you add blocks.
event.manager.addSound("monsterhunter:kirin1.ogg");
}
}
My ClientProxy
package MHF.Core;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import MHF.MHFSoundEvents;
import MHF.MonsterHunterFrontier;
import MHF.Proxy;
import MHF.Entity.EntityKirin;
import MHF.Gui.GuiBBQ;
import MHF.Gui.GuiRegistry;
import MHF.Model.ModelKirin;
import MHF.Renderer.RenderKirin;
import MHF.Renderer.RenderingNewRegistry;
import MHF.TileEntity.TileEntityBBQSpit;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
public class FUCClientProxy extends Proxy
{
private Minecraft mc = Minecraft.getMinecraft();
private static String soundZipPath = "/resources/";
public void registerRenderers()
{
RenderingNewRegistry.init();
GuiRegistry.init();
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity != null)
{
switch(ID)
{
case 1: return new GuiBBQ(player.inventory, (TileEntityBBQSpit)tileEntity);
}
}
return null;
}
@ForgeSubscribe
public void registersounds()
{
MinecraftForge.EVENT_BUS.register(new MHFSoundEvents());
}
}
@ForgeSubscribe
public void registersounds()
{
MinecraftForge.EVENT_BUS.register(new MHFSoundEvents());
}
Maybe it's registerSounds(). With a capital S. And do you need the @ForgeSubscribe for that? You aren't using any events.
@ForgeSubscribe
public void registersounds()
{
MinecraftForge.EVENT_BUS.register(new MHFSoundEvents());
}
Maybe it's registerSounds(). With a capital S. And do you need the @ForgeSubscribe for that? You aren't using any events.
OH MY GOD IT WORKS !!! THANKS SO MUCH BRO THANK YOU THAT LITTLE THING HELPS ME A LOT STACKS OF DIAMONDS FOR YOU AND THANKS FOR THE CREATOR OF THIS TUT
The Meaning of Life, the Universe, and Everything.
Location:
Wyvernia
Join Date:
3/23/2013
Posts:
482
Location:
W420
Minecraft:
Heltrato
Member Details
Hey I need help again
how can i play my custom music / sound in my custom dimension ? is it possible
EDIT :
heres my code .
public void onSoundLoadEvent(SoundLoadEvent event, URL URL) {
music.add(new SoundPoolEntry("monsterhunter:MHFMainTheme1.ogg", URL)); // URL can be anything: point to a file, point to something in your classpath, etc.
}
public void onBackgroundMusic(PlayBackgroundMusicEvent event, Random rand)
{
if (mc.thePlayer.dimension == 3)
{
event.manager.addMusic("monsterhunter:MHFMainThem1.ogg");
event.manager.addMusic("monsterhunter:MHFMainTheme2.ogg");
event.manager.addMusic("monsterhunter:MHFMainTheme3.ogg");
}
}
Hello, I am trying to make a mod that has custom mob sounds. I followed your tutorial and got some errors.
Here is my code and my errors.
Here is my sound event class:
package partyMod;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;
public class PartySoundEvents
{
@ForgeSubscribe
public void onSound(SoundLoadEvent event)
{
// You add them the same way as you add blocks.
event.manager.addSound("partymod:partycreeper.ogg");
event.manager.addSound("partymod:partyzombie.ogg");
event.manager.addSound("partymod:partyskeleton.ogg");
}
}
Here is my ClientProxy. Ignore the entity registry:
package partyMod;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class ClientProxy extends CommonProxy
{
public void registerRenderInformation()
{
RenderingRegistry.registerEntityRenderingHandler(EntityPartySkeleton.class, new RenderPartySkeleton());
RenderingRegistry.registerEntityRenderingHandler(EntityPartyZombie.class, new RenderPartyZombie());
RenderingRegistry.registerEntityRenderingHandler(EntityPartyCreeper.class, new RenderPartyCreeper());
MinecraftForge.EVENT_BUS.register(new PartySoundEvents()); // Name of the class containing the ForgeSubscribe above
}
}
Here is where I call the sound in one of my mob entity classes:
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "partymod:partyzombie";
}
When I run the game and spawn the mob, the sound system crashes and I get this error.
2013-08-24 07:13:08 [INFO] [STDERR] Exception in thread "Thread-13" java.lang.NullPointerException
2013-08-24 07:13:08 [INFO] [STDERR] at paulscode.sound.codecs.CodecJOrbis.readHeader(CodecJOrbis.java:448)
2013-08-24 07:13:08 [INFO] [STDERR] at paulscode.sound.codecs.CodecJOrbis.initialize(CodecJOrbis.java:301)
2013-08-24 07:13:08 [INFO] [STDERR] at paulscode.sound.libraries.LibraryLWJGLOpenAL.loadSound(LibraryLWJGLOpenAL.java:392)
2013-08-24 07:13:08 [INFO] [STDERR] at paulscode.sound.libraries.LibraryLWJGLOpenAL.newSource(LibraryLWJGLOpenAL.java:640)
2013-08-24 07:13:08 [INFO] [STDERR] at paulscode.sound.SoundSystem.CommandNewSource(SoundSystem.java:1800)
2013-08-24 07:13:08 [INFO] [STDERR] at paulscode.sound.SoundSystem.CommandQueue(SoundSystem.java:2415)
2013-08-24 07:13:08 [INFO] [STDERR] at paulscode.sound.CommandThread.run(CommandThread.java:121)
When I close the game, it takes a few seconds longer than normal and this comes up.
SoundEvents.class
ClientProxy:
Gun being used:
After fiddling for some time without any error message I got it working when removing these characters from my folder name.
Other than that, this thread helped me alot, thanks you very much!
and one for?
if so did i do this right?
this is whats in my mods class
this is whats in my fluids class
and this is whats in my block class
if so how do i spawn them in to test?
world and player cannot be resolved... sorry. Im probably putting it in the wrong place or something lol
Sword Class
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.audio.SoundManager;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.world.World;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.common.MinecraftForge;
public class VikingSword extends ItemSword {
{setCreativeTab(CreativeTabs.tabCombat);
}public VikingSword(int ItemID, EnumToolMaterial material){
super(ItemID, material);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister iconRegister) {
this.itemIcon = iconRegister.registerIcon("theviking:ironlongsword32X32");
MinecraftForge.EVENT_BUS.register(new vikingsound()); // Name of the class containing the ForgeSubscribe above
WorldObject.playSoundAtEntity(EntityPlayerObject, "mod_id:hit", 1.0F, 1.0F);
world.playSoundAtEntity(player, "modid:hit", 1F, 1F);
}
}
Sound Class *has no errors
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
public class vikingsound {
@ForgeSubscribe
public void onSound(SoundLoadEvent event) {
// You add them the same way as you add blocks.
event.manager.addSound("theviking:hit1.wav");
}
}
The event buss should not be registering inside your item, it should be called by your base mod file (or well in the client proxy).
the world.playSoundAtEntity should be placed where you want the sound to play.
You can't play a sound at a player when you register an icon, since there's no player and no world at the time of registration
so the
and the go in my main mod file (class) and then the goes into my sword class and then I need to call it when I swing the sword. (I just wanna get the know how to register the sounds correctly)
Thanks so much for your time!
I dont know if this is correct
If you know what you are doing, then you should be fine with snippets.
The things which aren't shown are things you should be able to create on your own as a pre-req. for this tutorial
change to:
return "monsterhunter:kirin";
Remember what I said about numbers in the end? ^^
Second: the bucket code doesn't work, correctly, you have to create a new method for, the tryPlacecontainedLiquid
and event then the bucket doesn't place the liquid, when extending the Fluidcontainer, but when it extends Item bucket it places stone instead of the liquid.
Ok it still dont work
could i ask will my ogg still works coz i played it in VLC and my ogg's length is 3 sec and i test other ogg like the chicken its length is 1 sec could this is the problem or not
by the way check my codes out if there are errors of mine
My SoundEvent.class
My ClientProxy
public void registersounds()
{
MinecraftForge.EVENT_BUS.register(new MHFSoundEvents());
}
Maybe it's registerSounds(). With a capital S. And do you need the @ForgeSubscribe for that? You aren't using any events.
OH MY GOD IT WORKS !!! THANKS SO MUCH BRO THANK YOU THAT LITTLE THING HELPS ME A LOT STACKS OF DIAMONDS FOR YOU AND THANKS FOR THE CREATOR OF THIS TUT
how can i play my custom music / sound in my custom dimension ? is it possible
EDIT :
heres my code .
Here is my code and my errors.
Here is my sound event class:
Here is my ClientProxy. Ignore the entity registry:
Here is where I call the sound in one of my mob entity classes:
When I run the game and spawn the mob, the sound system crashes and I get this error.
When I close the game, it takes a few seconds longer than normal and this comes up.
I put my .ogg files in 1.6.2.jar\assets\partymod\sound.
Any ideas why it would crash? Any help is apreciated.
the assets/folder should be inside a SOURCE FOLDER of your project.