Jump to content

Recommended Posts

Posted

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.

Posted

Oh, its 1.6.4 forge!

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.

Posted

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.

Posted
  On 4/22/2014 at 1:00 AM, LurgyCoder said:

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.

Posted

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.

Posted

I tried and...

 

nothing. Well I gtg, back tomorrow

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.

Posted

Can someone help me?

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.

Posted

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.

Posted

Thanks, I'll try it.

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.

Posted

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.

Posted

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.

Posted

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.

Posted

Help...

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.

  • 3 weeks later...
Posted

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.

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

    • Cracked Launchers are not supported
    • After some time minecraft crashes with an error. Here is the log https://drive.google.com/file/d/1o-2R6KZaC8sxjtLaw5qj0A-GkG_SuoB5/view?usp=sharing
    • The specific issue is that items in my inventory wont stack properly. For instance, if I punch a tree down to collect wood, the first block I collected goes to my hand. So when I punch the second block of wood to collect it, it drops, but instead of stacking with the piece of wood already in my hand, it goes to the second slot in my hotbar instead. Another example is that I'll get some dirt, and then when I'm placing it down later I'll accidentally place a block where I don't want it. When I harvest it again, it doesn't go back to the stack that it came from on my hotbar, where it should have gone, but rather into my inventory. That means that if my inventory is full, then the dirt wont be picked up even though there should be space available in the stack I'm holding. The forge version I'm using is 40.3.0, for java 1.18.2. I'll leave the mods I'm using here, and I'd appreciate it if anybody can point me in the right direction in regards to figuring out how to fix this. I forgot to mention that I think it only happens on my server but I&#39;m not entirely sure. PLEASE HELP ME! LIST OF THE MODS. aaa_particles Adorn AdvancementPlaques AI-Improvements AkashicTome alexsdelight alexsmobs AmbientSounds amwplushies Animalistic another_furniture AppleSkin Aquaculture aquamirae architectury artifacts Atlas-Lib AutoLeveling AutoRegLib auudio balm betterfpsdist biggerstacks biomancy BiomesOPlenty blockui blueprint Bookshelf born_in_chaos Botania braincell BrassAmberBattleTowers brutalbosses camera CasinoCraft cfm (MrCrayfish’s Furniture Mod) chat_heads citadel cloth-config Clumps CMDCam CNB cobweb collective comforts convenientcurioscontainer cookingforblockheads coroutil CosmeticArmorReworked CozyHome CrabbersDelight crashexploitfixer crashutilities Create CreativeCore creeperoverhaul cristellib crittersandcompanions Croptopia CroptopiaAdditions CullLessLeaves curios curiouslanterns curiouslights Curses' Naturals CustomNPCs CyclopsCore dannys_expansion decocraft Decoration Mod DecorationDelightRefurbished Decorative Blocks Disenchanting DistantHorizons doubledoors DramaticDoors drippyloadingscreen durabilitytooltip dynamic-fps dynamiclights DynamicTrees DynamicTreesBOP DynamicTreesPlus Easy Dungeons EasyAnvils EasyMagic easy_npc eatinganimation ecologics effective_fg elevatorid embeddium emotecraft enchantlimiter EnchantmentDescriptions EnderMail engineersdecor entityculling entity_model_features entity_texture_features epicfight EvilCraft exlinefurniture expandability explosiveenhancement factory-blocks fairylights fancymenu FancyVideo FarmersDelight fast-ip-ping FastSuite ferritecore finsandtails FixMySpawnR Forge Middle Ages fossil FpsReducer2 furnish GamingDeco geckolib goblintraders goldenfood goodall H.e.b habitat harvest-with-ease hexerei hole_filler huge-structure-blocks HunterIllager iammusicplayer Iceberg illuminations immersive_paintings incubation infinitybuttons inventoryhud InventoryProfilesNext invocore ItemBorders itemzoom Jade jei (Just Enough Items) JetAndEliasArmors journeymap JRFTL justzoom kiwiboi Kobolds konkrete kotlinforforge lazydfu LegendaryTooltips libIPN lightspeed lmft lodestone LongNbtKiller LuckPerms Lucky77 MagmaMonsters malum ManyIdeasCore ManyIdeasDoors marbledsarsenal marg mcw-furniture mcw-lights mcw-paths mcw-stairs mcw-trapdoors mcw-windows meetyourfight melody memoryleakfix Mimic minecraft-comes-alive MineTraps minibosses MmmMmmMmmMmm MOAdecor (ART, BATH, COOKERY, GARDEN, HOLIDAYS, LIGHTS, SCIENCE) MobCatcher modonomicon mods_optimizer morehitboxes mowziesmobs MutantMonsters mysticalworld naturalist NaturesAura neapolitan NekosEnchantedBooks neoncraft2 nerb nifty NightConfigFixes nightlights nocube's_villagers_sell_animals NoSeeNoTick notenoughanimations obscure_api oculus oresabovediamonds otyacraftengine Paraglider Patchouli physics-mod Pillagers Gun PizzaCraft placeableitems Placebo player-animation-lib pneumaticcraft-repressurized polymorph PrettyPipes Prism projectbrazier Psychadelic-Chemistry PuzzlesLib realmrpg_imps_and_demons RecipesLibrary reeves-furniture RegionsUnexplored restrictedportals revive-me Scary_Mobs_And_Bosses selene shetiphiancore ShoulderSurfing smoothboot
    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
  • Topics

×
×
  • Create New...

Important Information

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