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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I have been following these exact tutorials for quite a while, I must agree that they are amazing and easy to follow. I have registered the item in the ModFoods class, I tried to do it in ModItems (Where all the items should be registered) but got errors, I think I may need to revert this and figure it out from there. Once again, thank you for your help! 👍 Just looking back, I have noticed in your code you added ITEMS.register, which I am guessing means that they are being registered in ModFoods, I shall go through the process of trial and error to figure this out.
    • ♈+2349027025197ஜ Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join a brotherhood for protection and wealth here’s is your opportunity, but you should know there’s no ritual without repercussions but with the right guidance and support from this great temple your destiny is certain to be changed for the better and equally protected depending if you’re destined for greatness Call now for enquiry +2349027025197☎+2349027025197₩™ I want to join ILLUMINATI occult without human sacrificeGREATORLDRADO BROTHERHOOD OCCULT , Is The Club of the Riches and Famous; is the world oldest and largest fraternity made up of 3 Millions Members. We are one Family under one father who is the Supreme Being. In Greatorldrado BROTHERHOOD we believe that we were born in paradise and no member should struggle in this world. Hence all our new members are given Money Rewards once they join in order to upgrade their lifestyle.; interested viewers should contact us; on. +2349027025197 ۝ஐℰ+2349027025197 ₩Greatorldrado BROTHERHOOD OCCULT IS A SACRED FRATERNITY WITH A GRAND LODGE TEMPLE SITUATED IN G.R.A PHASE 1 PORT HARCOURT NIGERIA, OUR NUMBER ONE OBLIGATION IS TO MAKE EVERY INITIATE MEMBER HERE RICH AND FAMOUS IN OTHER RISE THE POWERS OF GUARDIANS OF AGE+. +2349027025197   SEARCHING ON HOW TO JOIN THE Greatorldrado BROTHERHOOD MONEY RITUAL OCCULT IS NOT THE PROBLEM BUT MAKE SURE YOU'VE THOUGHT ABOUT IT VERY WELL BEFORE REACHING US HERE BECAUSE NOT EVERYONE HAS THE HEART TO DO WHAT IT TAKES TO BECOME ONE OF US HERE, BUT IF YOU THINK YOU'RE SERIOUS MINDED AND READY TO RUN THE SPIRITUAL RACE OF LIFE IN OTHER TO ACQUIRE ALL YOU NEED HERE ON EARTH CONTACT SPIRITUAL GRANDMASTER NOW FOR INQUIRY +2349027025197   +2349027025197 Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join
    • Hi, I'm trying to use datagen to create json files in my own mod. This is my ModRecipeProvider class. public class ModRecipeProvider extends RecipeProvider implements IConditionBuilder { public ModRecipeProvider(PackOutput pOutput) { super(pOutput); } @Override protected void buildRecipes(Consumer<FinishedRecipe> pWriter) { ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', ModItems.COMPRESSED_DIAMOND.get()) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get(),9) .requires(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()) .unlockedBy(getHasName(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get()), has(ModBlocks.COMPRESSED_DIAMOND_BLOCK.get())) .save(pWriter); ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.COMPRESSED_DIAMOND.get()) .pattern("SSS") .pattern("SSS") .pattern("SSS") .define('S', Blocks.DIAMOND_BLOCK) .unlockedBy(getHasName(ModItems.COMPRESSED_DIAMOND.get()), has(ModItems.COMPRESSED_DIAMOND.get())) .save(pWriter); } } When I try to run the runData client, it shows an error:  Caused by: java.lang.IllegalStateException: Duplicate recipe compressed:compressed_diamond I know that it's caused by the fact that there are two recipes for the ModItems.COMPRESSED_DIAMOND. But I need both of these recipes, because I need a way to craft ModItems.COMPRESSED_DIAMOND_BLOCK and restore 9 diamond blocks from ModItems.COMPRESSED_DIAMOND. Is there a way to solve this?
  • Topics

×
×
  • Create New...

Important Information

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