Jump to content

Recommended Posts

Posted

Hello guys.

 

I'm going to get straight to the point, basically Minecraft freezes when I spawn in a mob that has boss battle music  . It remains frozen for about 5 seconds then continues. It only does this once every time I load up Minecraft. After that it has no problem spawning in the boss and playing the music. Help?

 

Moving Sound Class:

 

package com.thecallunxz.realmsofascencia.audio;

import com.thecallunxz.realmsofascencia.Reference;
import com.thecallunxz.realmsofascencia.WorldDataRoa;
import com.thecallunxz.realmsofascencia.entities.mobs.bosses.EntityBossElgra;

import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.MovingSound;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class BossMusic extends MovingSound
{

    public Entity entityLiving;
    protected boolean repeat = true;
    protected boolean stopping = false;
    protected int repeatDelay = 0;
    protected WorldDataRoa data;
    

    protected float pitch;

    public BossMusic(String name)
    {
        super(new ResourceLocation(Reference.MOD_ID, name));
        this.repeat = true;
        this.volume = 0.8f;
        this.pitch = 1.0F;
    }

    public BossMusic(Entity e, String name)
    {
        super(new ResourceLocation(Reference.MOD_ID, name));
        volume = 5f;
        pitch = 1.0F;
        entityLiving = e;
        this.data = WorldDataRoa.get(e.getEntityWorld());
    }

    public void setDonePlaying()
    {
    	if(!this.stopping){
        this.repeat = false;
        this.stopping = true;
        this.volume = 1F;
        this.repeatDelay = 0;
        
    	}
    }

    @Override
    public boolean isDonePlaying()
    {
        return this.donePlaying;
    }

    @Override
    public void update()
    {
    	if(!data.inBossFight()){
    		setDonePlaying();
    	}
        xPosF = (float)entityLiving.posX;
        yPosF = (float)entityLiving.posY;
        zPosF = (float)entityLiving.posZ;
        
        if(stopping){
        	this.volume = this.volume-0.05F;
        }
        if(volume <= 0){
        	this.donePlaying = true;
        }
    }

    @Override
    public boolean canRepeat()
    {
        return this.repeat;
    }

    @Override
    public float getVolume()
    {
        return this.volume;
    }

    @Override
    public float getPitch()
    {
        return this.pitch;
    }

    @Override
    public int getRepeatDelay(){ return this.repeatDelay; }

    @Override
    public AttenuationType getAttenuationType()
    {
        return AttenuationType.NONE;
    }

 

 

Entity Class:

 

 public void onUpdate()
    {
        if (!this.worldObj.isRemote && this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL && this.getElgraSize() > 0)
        {
            this.isDead = true;
        }
        

        
        if (worldObj.isRemote){
        	BossCustomStatus.setBossStatus(this, true);
        if(!onSpawn){
     	   onSpawn = true;
     	   if(!data.inBossFight()){
     		  Main.proxy.playSoundAtEntity(this, "bossmusic");
     	   	}
     	   
        	}
        }
        
        data.setBossFight(true);
        
        this.setElgraSize((int) (this.getHealth()/50) + 1);
        
        this.squishFactor += (this.squishAmount - this.squishFactor) * 0.5F;
        this.prevSquishFactor = this.squishFactor;
        super.onUpdate();

        if(this.onGround && !this.field_175452_bi){
        	randVal--;
        	if(randVal <= 0 ){
        		this.jumpHigh();
        		randVal = 5;
        		
        		if(this.getElgraSize() > 2){
        		List<EntityElgraMinion> e = this.worldObj.getEntitiesWithinAABB(EntityElgraMinion.class, AxisAlignedBB.fromBounds(this.posX - 25, this.posY - 25, this.posZ - 25, this.posX + 25, this.posY + 25, this.posZ + 25));
        		
        		if(e.size() < 2){
        			
        			EntityElgraMinion minion = new EntityElgraMinion(worldObj);
        			minion.setLocationAndAngles(this.posX + this.rand.nextInt(10) - 5, this.posY + 3, this.posZ + this.rand.nextInt(10) - 5, this.rand.nextFloat() * 360.0F, 0.0F);
        			minion.setElgraSize(2);
        			worldObj.spawnEntityInWorld(minion);
        			
        			EntityElgraMinion minion2 = new EntityElgraMinion(worldObj);
        			minion2.setLocationAndAngles(this.posX + this.rand.nextInt(10) - 5, this.posY + 3, this.posZ + this.rand.nextInt(10) - 5, this.rand.nextFloat() * 360.0F, 0.0F);
        			minion2.setElgraSize(2);
        			worldObj.spawnEntityInWorld(minion2);
        			
        			
        			}
        		}
        	}
        }
        
        if (this.onGround && !this.field_175452_bi)
        {
            int i = this.getElgraSize();

            for (int j = 0; j < i * 8; ++j)
            {
                float f = this.rand.nextFloat() * (float)Math.PI * 2.0F;
                float f1 = this.rand.nextFloat() * 0.5F + 0.5F;
                float f2 = MathHelper.sin(f) * (float)i * 0.5F * f1;
                float f3 = MathHelper.cos(f) * (float)i * 0.5F * f1;
                World world = this.worldObj;
                EnumParticleTypes enumparticletypes = this.func_180487_n();
                double d0 = this.posX + (double)f2;
                double d1 = this.posZ + (double)f3;
                world.spawnParticle(enumparticletypes, d0, this.getEntityBoundingBox().minY, d1, 0.0D, 0.0D, 0.0D, new int[0]);
            }

            if (this.makesSoundOnLand())
            {
                this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) / 0.8F);
            }

            this.squishAmount = -0.5F;
        }
        else if (!this.onGround && this.field_175452_bi)
        {
            this.squishAmount = 1.0F;
        }

        this.field_175452_bi = this.onGround;
        this.alterSquishAmount();
    }

 

 

Client Proxy Class:

 

 @Override
    public void playSoundAtEntity(EntityLiving e, String name){
    	ISound music = new BossMusic(e, name);
    	Minecraft.getMinecraft().getSoundHandler().playSound(music);
    	
    }

 

 

Any help is greatly appreciated! Thanks

 

- TheCallunxz

Posted

Set the sound to streaming in your sounds.json.

 

How would I do this? sounds.json files are the bane of me.

 

Here is my file:

{
   "idlebones": {"category": "master", "sounds": ["idlebones1", "idlebones2", "idlebones3"]},
   "hitbones": {"category": "master", "sounds": ["hitbones"]},
   "deathbones": {"category": "master", "sounds": ["deathbones"]},
   "bossmusic": {"category": "master", "sounds": ["bossmusic"]}
   }

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

    • May this question can't be answered but is for a project. The question is more of how Forge load and manage mods, it's not required code or anything, just an explanation about how do it works on the load/manage of mods internally.
    • I myself am quite new to the modding scene, I started modding in February but have been in development hell a lot and have struggled to focus on one mod though I have been developing the current mod I've been working on since September and have made a lot of progress; during this time I have found a lot of helpful resources and have learnt a lot of things.    1. You can, I have had no Java experience previously and since modding have managed to be quite knowledgeable in Java.   2. Modding does not require massive teams, I and many others work alone, though having a team is certainly helpful in the modding process to get things done in a quicker and more organised way.   3. I absolutely have to recommend ModdingByKaupenjoe, he makes loads of tutorials for Minecraft from 1.16.5 and above with support for Forge, Fabric, and as of his 1.21 tutorials, Neoforge. These tutorials are really well made, covering almost every modding topic, (such as items, blocks, mobs, worldgen, etc.) and are pretty easy to follow, and Kaupenjoe always leaves the link to his GitHub repositories where you can view the code of that tutorial at your own pace as well as linking textures in the description of his videos for you to use. These forums are also quite good if you need help, though I have found that it sometimes takes a little while for a response but it is always worth the wait; from my experience the people on these forums have always been kind and helpful. There are also user-submitted tutorials that may be helpful as well.  Using GitHub to search up a certain class that you are wanting to use in your mod is also quite helpful, the video I have linked goes into more detail. I would also recommend planning out your mod before you make it to have a clearer idea of how you want your mod to be, including sketches and annotations are also a good idea for this. It has helped me make progress a lot quicker when programming as I already know how I want things to look/act.   I hope all this information helps!
    • I don't know what I did differently, but the error code changed to "Invalid signature for profile public key" so I set "enforce-secure-profile" to false since only my friend will be allowed to join anyway and then everything worked properly. Here's the logs anyway, but I hope the problem doesn't come back. https://paste.ee/p/Ri44L
  • Topics

×
×
  • Create New...

Important Information

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