Jump to content

Sound Files


LurgyCoder

Recommended Posts

Heylo!

 

I'm am working on a mod, and everything has been going great till I got to the sounds. I tried tutorials, and checked other posts. Please HELP ME!!! It's probably something stupid, but please find and fix it!

 

Mob file:

package Lurgypais.ModMud;

import net.minecraft.block.Block;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIArrowAttack;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.passive.EntityVillager;
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.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class EntityMudChucker extends EntityMob implements IRangedAttackMob
{
    public EntityMudChucker(World par1World)
    {
        super(par1World);
        this.getNavigator().setAvoidsWater(true);
        this.tasks.addTask(1, new EntityAIArrowAttack(this, 1.25D, 20, 10.0F));
        this.tasks.addTask(2, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(4, new EntityAILookIdle(this));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, false));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMudBlobTest.class, 0, false));
    }

    /**
     * Returns true if the newer Entity AI code should be run
     */
    public boolean isAIEnabled()
    {
        return true;
    }

    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(13.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.20000000298023224D);
    }

    /**
     * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
     * use this to react to sunlight and start to burn.
     */
    public void onLivingUpdate()
    {
        super.onLivingUpdate();

        if (this.isWet())
        {
            this.attackEntityFrom(DamageSource.drown, 1.0F);
        }

        int i = MathHelper.floor_double(this.posX);
        int j = MathHelper.floor_double(this.posZ);

        for (i = 0; i < 4; ++i)
        {
            j = MathHelper.floor_double(this.posX + (double)((float)(i % 2 * 2 - 1) * 0.25F));
            int k = MathHelper.floor_double(this.posY);
            int l = MathHelper.floor_double(this.posZ + (double)((float)(i / 2 % 2 * 2 - 1) * 0.25F));
        }
    }

    /**
     * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param
     * par2 - Level of Looting used to kill this mob.
     */
    protected void dropRareDrop(int par1)
    {
        this.entityDropItem(new ItemStack(ModMud.mud_golden.itemID, 1, 1), 0.0F);
    }
    
    protected String getHurtSound()
    {
        return "modmud:mud_chucker.hurt";
    }

    /**
     * Attack the specified entity using a ranged attack.
     */
    public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
    {
        EntityMud entitymud = new EntityMud(this.worldObj, this);
        double d0 = par1EntityLivingBase.posX - this.posX;
        double d1 = par1EntityLivingBase.posY + (double)par1EntityLivingBase.getEyeHeight() - 1.100000023841858D - entitymud.posY;
        double d2 = par1EntityLivingBase.posZ - this.posZ;
        float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F;
        entitymud.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F);
        this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
        this.worldObj.spawnEntityInWorld(entitymud);
    }
}

 

Client Proxy:

 

package Lurgypais.ModMud;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.item.Item;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ClientProxyModMud extends CommonProxyModMud
{
@Override
public void registerRenderThings()
    {
	RenderingRegistry.registerEntityRenderingHandler(EntityMudBlobTest.class, new MudBlobRenderer(new ModelMudBlob(), 0.5F));
	RenderingRegistry.registerEntityRenderingHandler(EntityMudChucker.class, new MudChuckerRenderer(new ModelMudChucker(), 0.5F));
	RenderingRegistry.registerEntityRenderingHandler(EntityMudBoss.class, new MudBossRenderer(new ModelMudBoss(), 0.5F));
	RenderingRegistry.registerEntityRenderingHandler(EntityMole.class, new MoleRenderer(new ModelMole(), 0.5F));
	RenderingRegistry.registerEntityRenderingHandler(EntityMudBunny.class, new MudBunnyRenderer(new ModelMudBunny(), 0.5F));
    }

@Override
public int addArmor(String armor)
{
return RenderingRegistry.addNewArmourRendererPrefix(armor);
}

@Override
public void registerRenderers()
{
	RenderingRegistry.registerEntityRenderingHandler(EntityMud.class, new RenderSnowball(ModMud.mud));
	RenderingRegistry.registerEntityRenderingHandler(EntityMudWarp.class, new RenderSnowball(Item.netherStar));
	RenderingRegistry.registerEntityRenderingHandler(EntityMudBossProjectile.class, new RenderSnowball(Item.appleRed));
	RenderingRegistry.registerEntityRenderingHandler(EntityMudBossProjectile2.class, new RenderSnowball(Item.appleGold));
	RenderingRegistry.registerEntityRenderingHandler(EntityMudBossEgg.class, new RenderSnowball(ModMud.mud_bossEgg));
}
@Override
public void registerSound()
{
	MinecraftForge.EVENT_BUS.register(new SoundEvent());
}
}

 

Sound Event:

 

package Lurgypais.ModMud;

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

public class SoundEvent
{
@ForgeSubscribe
    public void onSoundLoad(SoundLoadEvent event)
    {
	event.manager.addSound("modmud:mud_chucker/hurt.ogg");
    }
}

 

If you find the error, please explain why it's there. I wish to understand this. I am very new to modding, and use it to help me study Java.

 

If you find anything else to fix, and make better, tell me.

 

Thanks to all!!!

Heylo!

I am Lurgypai, but my coder name is LurgyCoder (I have an account under the same name on minecraft forums)

The name is not supposed to reference lurgy, I just came up with it.

Link to comment
Share on other sites

now it has an error:

 

Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )

 

I use Eclipse

Heylo!

I am Lurgypai, but my coder name is LurgyCoder (I have an account under the same name on minecraft forums)

The name is not supposed to reference lurgy, I just came up with it.

Link to comment
Share on other sites

now it has an error:

 

Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )

 

I use Eclipse

Er, heh, totally derped on that one, sorry. Yeah, the slash was in the right direction originally.

 

Well, I don't know how to register sub-foldered sounds in 1.6.4, but in 1.7.2, I use the sound names without specifying directory (note that 1.7.2 doesn't register sounds, but I was using the same format in 1.6.4 without subfolders):

event.manager.addSound("modmud:hurt.ogg");
// use the same string for playing the sound

Sorry if that's a bit confusing. If that doesn't work, I suggest trying to get your sound to work just in the base "assets/modid/sounds/" directory first, and then go from there. I never used subfolders for my sounds in 1.6.4, but they worked fine using the exact same format as I showed above when I ported to 1.7.2 and DID put them in subfolders.

Link to comment
Share on other sites

You see, I already had it just in the sound folder, but when it didn't work, tried putting it in a sub folder. I'll try what you said, than try without the subfolder again.

Heylo!

I am Lurgypai, but my coder name is LurgyCoder (I have an account under the same name on minecraft forums)

The name is not supposed to reference lurgy, I just came up with it.

Link to comment
Share on other sites

I am not sure the underscore is going to work...but the file path should be:

assets/modmud/sound/mud_chucker/hurt.ogg

 

iirc, i used

@ForgeSubscribe
    public void onSoundLoad(SoundLoadEvent event)
    {
	event.manager.soundPoolSound.addSound("stuff");
}

Back in 1.6 days.

Link to comment
Share on other sites

No luck...

I tried to install the latest forge 1.6to see if that would fix it, but after I finished, minecraft had errors...

Heylo!

I am Lurgypai, but my coder name is LurgyCoder (I have an account under the same name on minecraft forums)

The name is not supposed to reference lurgy, I just came up with it.

Link to comment
Share on other sites

We need more information to help you: what is your full file path to the sound? Do you get an error message in the console or a crash when you try to play the sound and it cannot be found, and what does that say? Are you using only one sound file, or are there multiple "hurt" sounds?

 

If you have multiple sound files named "hurt1.ogg", "hurt2.ogg", etc., you must add them all during the sound load event:

for (int i = 1; i <= number_of_sounds; ++i) {
event.manager.soundPoolSound.addSound("modmud:hurt" + i + ".ogg");
}

And play it normally, using "modmud.hurt" without any number on it.

Link to comment
Share on other sites

its just hurt.ogg. Thats the only file I have

The full path is:

forge/mcp/src/assets/modmud/mud_chucker/hurt.ogg

there is noerror or crash, It just doesn't play.

 

Heylo!

I am Lurgypai, but my coder name is LurgyCoder (I have an account under the same name on minecraft forums)

The name is not supposed to reference lurgy, I just came up with it.

Link to comment
Share on other sites

  • 3 weeks later...

Sry, I been gone a while

 

Anyway, I derped, I have one in forge/mcp/src/assets/modmud/sound/mud_chucker/hurt.ogg

 

I also put one in forge/mcp/src/assets/modmud/sound/hurt.ogg, just to double check

 

Heylo!

I am Lurgypai, but my coder name is LurgyCoder (I have an account under the same name on minecraft forums)

The name is not supposed to reference lurgy, I just came up with it.

Link to comment
Share on other sites

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.