Posted June 19, 20169 yr 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
June 19, 20169 yr Author 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"]} }
June 19, 20169 yr Author If only there was a complete description and explanation of the whole file structure... if only. Okay no need to rain on my parade! . It works thank you.
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.